kao.math.matvec.Matrix Class Reference

A Matrix class. More...

List of all members.

Classes

class  Bounds
 Calculates the row and column ranges to use for multi-threaded processing.

Public Member Functions

 Matrix (int rows, int cols, boolean sparse)
 Matrix (int firstRow, int rows, int firstCol, int cols, boolean sparse)
void init ()
void set (int i, int j, double e)
void set (Matrix M)
double get (int i, int j)
int getCols ()
int getRows ()
int getFirstCol ()
int getLastCol ()
int getFirstRow ()
int getLastRow ()
boolean isSparse ()
void print (String s)
void write (String file)
Vector getCol (int j)
Vector getRow (int i)
void setCol (int j, Vector col)
void setRow (int i, Vector row)
boolean isEmpty ()
Matrix add (Matrix M)
Matrix add (double s)
Matrix sub (Matrix M)
Matrix sub (double s)
Matrix multElem (Matrix M)
Matrix mult (Matrix M)
Vector mult (Vector x, boolean transpose)
Vector mult (Vector x)
Matrix mult (double s)
Matrix div (Matrix M)
Matrix div (double s)
Matrix copy ()
Matrix inverse ()
Matrix transpose ()
Matrix resize (int rows, int cols, boolean preserve)
double sum ()
boolean isSameDimension (Matrix A)
boolean isSameRowDimension (Matrix A)
boolean isSameColDimension (Matrix A)

Static Public Member Functions

static Matrix identity (int firstRow, int rows, int firstCol, int cols, boolean sparse)
static Matrix identity (Matrix A)
static Matrix zeros (int firstRow, int rows, int firstCol, int cols, boolean sparse)
static Matrix zeros (Matrix A)
static Matrix empty (int firstRow, int firstCol, boolean sparse)
static Matrix empty (Matrix A)

Detailed Description

A Matrix class.

A flexible Matrix class which can use dense or sparse storage with arbitrary row and column indices. Operations on the matrices are automatically multi-threaded.

Author:
David Kao

Constructor & Destructor Documentation

kao.math.matvec.Matrix.Matrix ( int  rows,
int  cols,
boolean  sparse 
)

Create a 0 index based Matrix with the specified number of rows and column.

Parameters:
[in] rows Number of rows
[in] cols Number of columns
[in] sparse Is the matrix sparse
kao.math.matvec.Matrix.Matrix ( int  firstRow,
int  rows,
int  firstCol,
int  cols,
boolean  sparse 
)

Create a Matrix with the specified number of rows and column with a specified start row and column indices.

Parameters:
[in] firstRow First row of matrix
[in] rows Number of rows
[in] firstCol First column of matrix
[in] cols Number of columns
[in] sparse Is the matrix sparse

Member Function Documentation

Matrix kao.math.matvec.Matrix.add ( double  s  ) 

Scalar addition

Parameters:
[in] s Scalar to add to this
Returns:
Scalar addition
Matrix kao.math.matvec.Matrix.add ( Matrix  M  ) 

Matrix addition

Parameters:
[in] M Matrix to add to this
Returns:
Matrix addition
Matrix kao.math.matvec.Matrix.copy (  ) 

Copy Matrix

Returns:
Copy of this Matrix
Matrix kao.math.matvec.Matrix.div ( double  s  ) 

Scalar division

Parameters:
[in] s Scalar to divide from this
Returns:
Scalar division
Matrix kao.math.matvec.Matrix.div ( Matrix  M  ) 

Matrix element division

Parameters:
[in] M Matrix to divide from this
Returns:
Matrix element division
static Matrix kao.math.matvec.Matrix.empty ( Matrix  A  )  [static]

Create an empty Matrix with same row and column indices as A

Parameters:
[in] A Matrix A
Returns:
Empty Matrix
static Matrix kao.math.matvec.Matrix.empty ( int  firstRow,
int  firstCol,
boolean  sparse 
) [static]

Create an empty Matrix

Parameters:
[in] firstRow First row
[in] firstCol First column
[in] sparse Is Matrix sparse
Returns:
Identity Matrix
double kao.math.matvec.Matrix.get ( int  i,
int  j 
)

Get element M(i,j)

Parameters:
[in] i Row i
[in] j Row j
Returns:
Element i,j
Vector kao.math.matvec.Matrix.getCol ( int  j  ) 

Get column j

Parameters:
[in] j Column index j
Returns:
Vector of column j
int kao.math.matvec.Matrix.getCols (  ) 

Get number of columns in Matrix

Returns:
Number of columns
int kao.math.matvec.Matrix.getFirstCol (  ) 

Get first column index of Matrix

Returns:
Index of first column
int kao.math.matvec.Matrix.getFirstRow (  ) 

Get first row index of Matrix

Returns:
Index of first row
int kao.math.matvec.Matrix.getLastCol (  ) 

Get last column index of Matrix

Returns:
Index of last column
int kao.math.matvec.Matrix.getLastRow (  ) 

Get last row index of Matrix

Returns:
Index of last row
Vector kao.math.matvec.Matrix.getRow ( int  i  ) 

Get row i

Parameters:
[in] i Row index i
Returns:
Vector of row i
int kao.math.matvec.Matrix.getRows (  ) 

Get number of rows in Matrix

Returns:
Number of rows
static Matrix kao.math.matvec.Matrix.identity ( Matrix  A  )  [static]

Create an identity Matrix with same dimensions as A

Parameters:
[in] A Matrix A
Returns:
Identity Matrix
static Matrix kao.math.matvec.Matrix.identity ( int  firstRow,
int  rows,
int  firstCol,
int  cols,
boolean  sparse 
) [static]

Create an identity Matrix

Parameters:
[in] firstRow First row
[in] rows Number of rows
[in] firstCol First column
[in] cols Number of columns
[in] sparse Is Matrix sparse
Returns:
Identity Matrix
void kao.math.matvec.Matrix.init (  ) 

Initialise the Matrix to zeros

Matrix kao.math.matvec.Matrix.inverse (  ) 

Calculate inverse of Matrix

Returns:
Inverse of this Matrix
boolean kao.math.matvec.Matrix.isEmpty (  ) 

Does the Matrix have zero rows and zero columns

Returns:
true/false
boolean kao.math.matvec.Matrix.isSameColDimension ( Matrix  A  ) 

Does this Matrix have the same column dimensions as A

Parameters:
[in] A Matrix A
Returns:
true/false
boolean kao.math.matvec.Matrix.isSameDimension ( Matrix  A  ) 

Does this Matrix have the same dimensions as A

Parameters:
[in] A Matrix A
Returns:
true/false
boolean kao.math.matvec.Matrix.isSameRowDimension ( Matrix  A  ) 

Does this Matrix have the same row dimensions as A

Parameters:
[in] A Matrix A
Returns:
true/false
boolean kao.math.matvec.Matrix.isSparse (  ) 

Is Matrix sparse

Returns:
true/false
Matrix kao.math.matvec.Matrix.mult ( double  s  ) 

Scalar multiplication

Parameters:
[in] s Scalar to multiply to this
Returns:
Scalar multiplication
Vector kao.math.matvec.Matrix.mult ( Vector  x  ) 

Vector multiplication

Parameters:
[in] x Vector to multiply to this
Returns:
Vector multiplication
Vector kao.math.matvec.Matrix.mult ( Vector  x,
boolean  transpose 
)

Vector multiplication

Parameters:
[in] x Vector to multiply to this
[in] transpose Use transpose of this Matrix
Returns:
Vector multiplication
Matrix kao.math.matvec.Matrix.mult ( Matrix  M  ) 

Matrix multiplication

Parameters:
[in] M Matrix to multiply to this
Returns:
Matrix multiplication
Matrix kao.math.matvec.Matrix.multElem ( Matrix  M  ) 

Matrix element multiplication

Parameters:
[in] M Matrix to multiply to this
Returns:
Matrix element multiplication
void kao.math.matvec.Matrix.print ( String  s  ) 

Print the Matrix prefixed with identifier s

Parameters:
[in] s String identifier
Matrix kao.math.matvec.Matrix.resize ( int  rows,
int  cols,
boolean  preserve 
)

Resize Matrix to the specified number of rows and columns. There is a flag to determine whether the data is preserved.

Parameters:
[in] rows Number of rows
[in] cols Number of columns
[in] preserve Preserve the matrix data
Returns:
Resized Matrix
void kao.math.matvec.Matrix.set ( Matrix  M  ) 

Set this Matrix to M

Parameters:
[in] M Matrix M
void kao.math.matvec.Matrix.set ( int  i,
int  j,
double  e 
)

Set element M(i,j) with the value of e.

Parameters:
[in] i Row i
[in] j Column j
[in] e Element value
void kao.math.matvec.Matrix.setCol ( int  j,
Vector  col 
)

Set column j with Vector col

Parameters:
[in] j Column index j
[in] col Vector of column values
void kao.math.matvec.Matrix.setRow ( int  i,
Vector  row 
)

Set row i with Vector row

Parameters:
[in] i Row index i
[in] row Vector of row values
Matrix kao.math.matvec.Matrix.sub ( double  s  ) 

Scalar subtraction

Parameters:
[in] s Scalar to subtract from this
Returns:
Matrix subtraction
Matrix kao.math.matvec.Matrix.sub ( Matrix  M  ) 

Matrix subtraction

Parameters:
[in] M Matrix to subtract from this
Returns:
Matrix subtraction
double kao.math.matvec.Matrix.sum (  ) 

Calculate the sum of all elements

Returns:
Sum of all elements
Matrix kao.math.matvec.Matrix.transpose (  ) 

Calculate transpose of this Matrix

Returns:
Transpose of this Matrix
void kao.math.matvec.Matrix.write ( String  file  ) 

Write Matrix to file

Parameters:
[in] file File to write to
static Matrix kao.math.matvec.Matrix.zeros ( Matrix  A  )  [static]

Create a Matrix of zeros with same dimensions as A

Parameters:
[in] A Matrix A
Returns:
Zero Matrix
static Matrix kao.math.matvec.Matrix.zeros ( int  firstRow,
int  rows,
int  firstCol,
int  cols,
boolean  sparse 
) [static]

Create a Matrix of zeros

Parameters:
[in] firstRow First row
[in] rows Number of rows
[in] firstCol First column
[in] cols Number of columns
[in] sparse Is Matrix sparse
Returns:
Identity Matrix

Generated on Wed Apr 21 22:01:41 2010 for kao-math by  doxygen 1.6.1