#include <Matrix.h>
Inheritance diagram for OSCAR::Matrix:

Public Methods | |
| Matrix (unsigned int nr, unsigned int nc, const double *f=0, const String &name=String(), bool initMtx=true) | |
| Matrix (unsigned int nr, unsigned int nc, const Vector &v, OSCARError &err=DUMMY_ERROR(noError), const String &name=String()) | |
| Matrix (unsigned int k, double *f, const String &name=String()) | |
| Matrix (const MatrixRow &rhs) | |
| Matrix (const MatrixCol &rhs) | |
| Matrix (const Matrix &rhs) | |
| virtual | ~Matrix () |
| double & | at (unsigned int irow, unsigned int icol) |
| const double & | at (unsigned int irow, unsigned int icol) const |
| double & | operator() (unsigned int irow, unsigned int icol) |
| const double & | operator() (unsigned int irow, unsigned int icol) const |
| MatrixRow | GetRow (unsigned int row) |
| const MatrixRow | GetRow (unsigned int row) const |
| MatrixRow | operator[] (unsigned int row) |
| const MatrixRow | operator[] (unsigned int row) const |
| bool | SetRow (unsigned int row, const MatrixRow &rowObject) |
| MatrixCol | GetCol (unsigned int col) |
| const MatrixCol | GetCol (unsigned int col) const |
| bool | SetCol (unsigned int col, const MatrixCol &colObject) |
| unsigned int | nRow () const |
| unsigned int | nCol () const |
| bool | isSquare () const |
| bool | SameSize (const Matrix &m) const |
| Matrix & | operator= (const Matrix &rhs) |
| Matrix & | operator= (double rhs) |
| bool | Copy (const Matrix &matrixToCopy) |
| bool | operator== (const Matrix &rhs) const |
| Matrix & | operator *= (double d) |
| Matrix & | operator/= (double d) |
| Matrix & | operator+= (const Matrix &rhs) |
| Matrix & | operator-= (const Matrix &rhs) |
| Matrix & | operator *= (const Matrix &m) |
| Matrix | operator+ (const Matrix &rhs) const |
| Matrix | operator- (const Matrix &rhs) const |
| Matrix | operator- () const |
| Matrix | operator * (double d) const |
| bool | Multiply (const Matrix &rhs, Matrix &result) const |
| bool | Multiply (const Vector &vec, Vector &result) const |
| Vector | operator * (const Vector &rhs) const |
| Matrix | operator * (const Matrix &rhs) const |
| Matrix | operator/ (double d) const |
| Matrix | operator & (const Matrix &rhs) const |
| bool | SwitchRows (unsigned int r1, unsigned int r2) |
| bool | SwitchCols (unsigned int c1, unsigned int c2) |
| void | CombineRows (unsigned int i, double b, unsigned int j) |
| double | Max () const |
| bool | Identity () |
| Matrix | t () const |
| bool | t (Matrix &rhs) const |
| bool | MultiplyWithTranspose (Matrix &result) const |
| bool | isUpperTriangle () const |
| Matrix | UpperTriangle () |
| bool | LUDecomposition (int *indx, double *d) |
| void | LUFowBackSubstitution (const int *indx, double b[]) const |
| bool | LUSolve (const Vector &b, Vector &x, double &determinant) const |
| bool | CholeskyDecomposition () |
| void | CholeskyFowBackSubstitution (double b[], double x[]) const |
| bool | CholeskySolve (const Vector &b, Vector &x, double &determinant) const |
| bool | Determinant (double &det) const |
| virtual bool | Inverse (Matrix &inverse) const |
| virtual bool | Inverse (Matrix &inverse, double &determinant) const |
| virtual bool | SpeedInverse (Matrix &inverse, double &determinant) const |
| Matrix | operator~ () const |
| bool | PseudoInvSVD (Matrix &inverse, double weight=.0001) const |
| bool | SVD (Matrix &U, Vector &W, Matrix &V) const |
| bool | EigenValues (Vector &W) const |
| double | MatrixNorm (double P) const |
| String | ToFlatString () const |
| virtual void | printOn (std::ostream &out) const |
| virtual void | dumpOn (std::ostream &out) const |
| void | sizeError (char *where, unsigned int a, unsigned int b) const |
| const double * | GetArray () const |
| double * | GetArray () |
Protected Methods | |
| Matrix (const String &name=String()) | |
| virtual void | m_alloc (unsigned int rows, unsigned int cols) |
Protected Attributes | |
| unsigned int | nrow |
| unsigned int | ncol |
| DoubleP * | _row |
| double * | _m |
| Matrix * | scratchMatrix_NbyM |
| VectorI * | scratchIndxVectorI_M |
| Vector * | scratchColVector_M |
|
||||||||||||||||||||||||
|
Constructor. Default behavior: Constructs an (nr x nc) Matrix and initialized to zero matrix Second behavior: (f specified) Constructs an (nr x nc) Matrix and initialized by the first (nr x nc) elements in array of doubles specified by *f. To use this constructor with a 2-D array, pass the array as Arr[0] or &Arr[0][0]. It initializes Matrix by using a row pattern, e.g. in an Nx4 matrix the first row is initialized with the first 4 values in the array *f. Behavior is undefined for array with less than (nr x nc) elements. Third behavior: (initMtx specified) If (initMtx == false), elements of the matrix are not initialized. This behavior is efficient for creating temporaries that will be initialized later.
|
|
||||||||||||||||||||||||
|
Constructor. Constructs an (nr x nc) Matrix of size initialized by an Vector. It initializes Matrix by using a row pattern, e.g. in an Nx4 matrix the first row is initialized with the first 4 values in the Vector. The size of Vector must be of size nr*nc or an error will occur.
|
|
||||||||||||||||
|
Constructor. Constructs an diagonal (k x k) Matrix from the first k elemants of an array of doubles. this->at(i,j) = {f[i], i=j; 0, i!=j} Behavior is not defined if k is greater than the number of elements in f.
|
|
|
Constructor. Constructs a (1 x nrow) Matrix initialized by MatrixRow values. |
|
|
Constructor. Constructs an (ncol x 1) Matrix object initialized by MatrixCol values. |
|
|
Copy Constructor. Constructs an Matrix from an existing Matrix.
|
|
|
Virtual Destructor. This is the Destructor for an object of type Matrix. |
|
|
Defaut Constructor for derived classes. Call this constructor from the default constructor for derived classes to bypass the memory allocation in Matrix.
|
|
||||||||||||
|
Read element of a const Matrix object. This method allows read access an element of a const Matrix object. This method is similar to operator() except range checking is only done in Debug mode. In release mode this function can return garbage if the cell specified is out of range. Use this method if speed is critical. An Error is returned if the matrix does not contain the cell specified.
|
|
||||||||||||
|
Get an element of a non-const Matrix object. This method allows read/write access of an element of a non-const Matrix object. This method is similar to operator() except range checking is only done in Debug mode. In release mode this function can return garbage if the cell specified is out of range. Use this method if speed is critical. An Error is returned if the matrix does not contain the cell specified.
|
|
|
Cholesky Decomposition of an Matrix object. This method is used to perform a Cholesky decomposition of an Matrix object. The calling matrix (*this) is replaced by its Cholesky form. The array pointed to by indx* must be of size nrow. The matrix must be symmetric and positive definite. This method can be used as an efficient way to check the positive definiteness of a matrix. However, it will not check whether or not the matrix is symmetric. It will assume that the matrix is symmetric.
|
|
||||||||||||
|
Cholesky forward and backward substitution of an Matrix object. This method is used to perform a Cholesky forward and backward substitution, i.e. it solves the set of linear equations Ax = b. The array pointed to by b* and x* must be of size nrow. This method must be called only after a call to CholeskyDecomposition() or it will give errorneous results.
|
|
||||||||||||||||
|
Solve the set of linear equation Ax = b using Cholesky decomposition. This method solves the set of linear equation Ax = b using Cholesky decomposition. In order to use this method, the matrix must be symmetric and positive definite.
|
|
||||||||||||||||
|
Combine Two rows in an Matrix object. This method is used to combine two rows in an Matrix object. It performs the row operation defined by row(i) = row(i) + b*row(j). If i or j are out of range then GetRow() will have an error.
|
|
|
Copy a Matrix object into current Matrix object. Copies a specified Matrix object into current Matrix object. An error occurs if the matrices are of different sizes.
|
|
|
Get the Determinant of an Matrix object. This method is used to compute the determinant of an Matrix via LUDecomposition. The matrix must be square otherwise an error will occur.
|
|
|
Output a Matrix object to an output stream. This method is used to output an entire Matrix object to an output stream, along with its number of rows and of columns. |
|
|
EigenValues Method - Matlab and Non-Matlab versions. The Non-matlab version of EigenValues is not working. This method is used to compute the eigenvalues or singular values of a matrix and places them in descending order. If MATLAB is defined, then Matlab libraries are used for computing this, otherwise Numerical receipes for 'C' is used. This however produces erroneous results in certain cases. The Matlab version uses several different techniques to compute the eigenvalues: if nrow==ncol then it uses the eig() method in Matlab, if nrow < ncol it multiplies the Matrix by its transpose and then uses the eig() method in Matlab, if nrow > ncol then the svd() method is used and eigenvalues are taken from that. For more info. see the MatlabInterface class. The Non-Matlab version uses only the svdcmp() method to get eigenvalues. For more info see the svdcmp class. When the matrix is nrow < ncol the extra zeros in the Eigenvalue vector resulting from the svdcmp method are removed. The two versions gave the same results when the matrix was non-square. When the matrix is square there were sign and small magnitude differences because different methods are used depending on whether Matlab is being used.
|
|
|
Get a pointer to the first element in the matrix. Returns a pointer to the data in this matrix, to be used where the size of the matrix is already known, or to pass the data to another function that does not know about Matrix. OPERATIONS ON THIS POINTER MUST DO THEIR OWN RANGE CHEKING. Valid range: zero<=i<(nRow() X nCol())
|
|
|
Get a const pointer to first element in the matrix. Returns a const pointer to the data in this matrix, to be used where the size of the matrix is already known, or to pass the data to another function that does not know about Matrix. A single element can then be referenced by GetArray()[whichElement] OPERATIONS ON THIS POINTER MUST DO THEIR OWN RANGE CHEKING. Valid range: zero<=i<(nRow() X nCol())
|
|
|
Get a Column of an Matrix object. This method is used to get a column of an Matrix object, and return it as an MatrixCol object. An error occurs if the col to be returned is out of range.
|
|
|
Get a Column of an Matrix object. This method is used to get a column of an Matrix object, and return it as an MatrixCol object. An error occurs if the col to be returned is out of range.
|
|
|
Get a Row of an Matrix object. This method is used to get a row of an Matrix object, and return it as an MatrixRow object. An error occurs if the row to be returned is out of range.
|
|
|
Get a Row of an Matrix object. This method is used to get a row of an Matrix object, and return it as an MatrixRow object. An error occurs if the row to be returned is out of range.
|
|
|
Modify an Matrix object to an identity Matrix. This method is used to fill the Matrix up with 1's on the diagonal and 0's everywhere else, thus creating an Identity Matrix.
Reimplemented in OSCAR::Xform. |
|
||||||||||||
|
Get the Inverse of an Matrix object. This method is used to get the inverse of an RRMmatrix via LUDecomp. and LUFowBackSubs. This is similar to Inverse(Matrix& inverse) except it also stores the determinant. The Matrix must be square, otherwise an error will occur, but the program will not terminate. The inverse Matrix must be the same size or an error will occur, but the program will not terminate and the inverse Matrix will remain unchanged. These errors will return a boolean false.
|
|
|
Get the Inverse of an Matrix object. This method is used to get the inverse of an Matrix via LUDecomposition and LUFowBackSubstitution. The Matrix must be square otherwise an error will occur, but the program will not terminate. The inverse Matrix must be the same size or an error will occur, but the program will not terminate and the inverse matrix will remain unchanged. These errors will return a bool false.
|
|
|
Check if an Matrix is square. This method is used to check if an Matrix is square or not.
|
|
|
Check if an Matrix object is composed of zeros below the diagonal. This method is used to check if the Matrix object is composed of zeros below the diagonal.
|
|
||||||||||||
|
Lower, Upper Triangular Decomposition of an Matrix object. This method is used to perform a Lower, Upper triangular decomposition of an Matrix object. The calling matrix (*this) is replaced by its LU form. The array pointed to by indx* must be of size nrow. The Determinant() and Inverse() methods that use LUD do this internally.
|
|
||||||||||||
|
Lower, Upper, forward and backward substitution of an Matrix object. This method is used to perform a Lower, Upper forward and backward substitution. The input/output array pointed to by b* is all that is modified by this method. The array pointed to by b* must be of size nrow. The Inverse() methods set this size internally. |
|
||||||||||||||||
|
Solve the set of linear equation Ax = b using LU decomposition. This method solves the set of linear equation Ax = b using LU decomposition. It is basically a wrapper of LUDecomposition and LUFowBackSubstitution method in order to make it easier to use. It is a more efficient way to calculate inv(A)*b than using SpeedInverse(A)*b. However, if only inv(A) is needed, SpeedInverse must still be used.
|
|
||||||||||||
|
Allocate Memory for a Matrix object. This method is used to allocate memory for a new Matrix object. This method is called by the constructors. Reimplemented in OSCAR::FixedSizeMatrix< nRows, nCols >, OSCAR::FixedSizeMatrix< 6, 6 >, OSCAR::FixedSizeMatrix< 4, 4 >, and OSCAR::FixedSizeMatrix< 3, 3 >. |
|
|
MatrixNorm Method - Matlab and Non-Matlab versions. This method computes the norm of a matrix with respect to a given norm. There is a Matlab, and a Non-Matlab version. Both versions give the same results even for the 2-norm(largest singular value) because Matlab uses svd to calculate eigenvalues for norms even if it is a square matrix. This removes the differences that occur in the EigenValues() method above which has differences between versions. For more info. on Matlab version see MatlabInterface Some definitions are: 1-norm is the largest column sum, 2-norm is the largest singular value, infinity norm is the largest row sum, and the Frobenius norm is the overall size of the Matrix.
|
|
|
Get the Largest Value in the Matrix object. This method is used to get the largest value in the Matrix.
|
|
||||||||||||
|
Matrix-vector multiplication. Multiplies an Vector object with calling object and puts values in resulting Vector object.
Reimplemented in OSCAR::FixedSizeMatrix< nRows, nCols >, OSCAR::FixedSizeMatrix< 6, 6 >, OSCAR::FixedSizeMatrix< 4, 4 >, and OSCAR::FixedSizeMatrix< 3, 3 >. |
|
||||||||||||
|
Matrix multiplication. Multiplies an Matrix object with calling object and puts values in resulting Matrix object.
|
|
|
Multiply an Matrix with its Transpose. This method is used to Multiply an Matrix with its transpose, and store the resulting Matrix in the Matrix parameter. The resulting Matrix is a square symmetric Matrix. An error occurs if the result is not of size nrow x nrow where nrow is the number of rows in the current Matrix.
|
|
|
Get the Number of columns in the Matrix object. This method is used to get the number of columns in the Matrix object.
|
|
|
Get the Number of rows in the Matrix object. This method is used to get the number of rows in the Matrix object.
|
|
|
Overloaded concatenation operator&. Performs column-wize concatenation of two RRMatrices s.t. result = [current|argument] The number of rows must be the same in both RRMatrices, otherwise an error will occur.
|
|
|
Overloaded operator*. Multiplies two RRMatrices together and returns the resulting Matrix object. An error occurs if the number of columns of the first matrix is not the same as the number of rows in the second matrix.
Reimplemented in OSCAR::FixedSizeMatrix< nRows, nCols >, OSCAR::FixedSizeMatrix< 6, 6 >, OSCAR::FixedSizeMatrix< 4, 4 >, and OSCAR::FixedSizeMatrix< 3, 3 >. |
|
|
Overloaded operator*. Multiplies an calling object by a vector and return the resulting Vector object.
Reimplemented in OSCAR::FixedSizeMatrix< nRows, nCols >, OSCAR::FixedSizeMatrix< 6, 6 >, OSCAR::FixedSizeMatrix< 4, 4 >, and OSCAR::FixedSizeMatrix< 3, 3 >. |
|
|
Overloaded operator*. Multiplies an Matrix object by a scalar and return the resulting Matrix object.
Reimplemented in OSCAR::FixedSizeMatrix< nRows, nCols >, OSCAR::FixedSizeMatrix< 6, 6 >, OSCAR::FixedSizeMatrix< 4, 4 >, and OSCAR::FixedSizeMatrix< 3, 3 >. |
|
|
Overloaded operator*=. Multiply Matrix object with current matrix and assign result to current matrix.
Reimplemented in OSCAR::FixedSizeMatrix< nRows, nCols >, OSCAR::FixedSizeMatrix< 6, 6 >, OSCAR::FixedSizeMatrix< 4, 4 >, and OSCAR::FixedSizeMatrix< 3, 3 >. |
|
|
Overloaded operator*=. Multiply an elements of Matrix object by a scalar.
Reimplemented in OSCAR::FixedSizeMatrix< nRows, nCols >, OSCAR::FixedSizeMatrix< 6, 6 >, OSCAR::FixedSizeMatrix< 4, 4 >, and OSCAR::FixedSizeMatrix< 3, 3 >. |
|
||||||||||||
|
|
|
||||||||||||
|
|
|
|
Overloaded operator+. Add two RRMatrices together and return the resulting Matrix object. An error occurs if the two RRMatrices are of different sizes.
Reimplemented in OSCAR::FixedSizeMatrix< nRows, nCols >, OSCAR::FixedSizeMatrix< 6, 6 >, OSCAR::FixedSizeMatrix< 4, 4 >, and OSCAR::FixedSizeMatrix< 3, 3 >. |
|
|
Overloaded operator+=. Element-wise addition to an Matrix from the current matrix.
Reimplemented in OSCAR::FixedSizeMatrix< nRows, nCols >, OSCAR::FixedSizeMatrix< 6, 6 >, OSCAR::FixedSizeMatrix< 4, 4 >, and OSCAR::FixedSizeMatrix< 3, 3 >. |
|
|
Overloaded operator- (additive inverse). Returns an Matrix object whose elements are the additive inverse (negative) of the current object.
Reimplemented in OSCAR::Rot3by3, and OSCAR::SpatialXform. |
|
|
Overloaded operator-. Subtracts an Matrix from the current Matrix object and returns the resulting Matrix object. An error occurs if the two RRMatrices are of different sizes.
Reimplemented in OSCAR::FixedSizeMatrix< nRows, nCols >, OSCAR::FixedSizeMatrix< 6, 6 >, OSCAR::FixedSizeMatrix< 4, 4 >, and OSCAR::FixedSizeMatrix< 3, 3 >. |
|
|
Overloaded operator-=. Element-wise subtraction of an Matrix from the current matrix.
Reimplemented in OSCAR::FixedSizeMatrix< nRows, nCols >, OSCAR::FixedSizeMatrix< 6, 6 >, OSCAR::FixedSizeMatrix< 4, 4 >, and OSCAR::FixedSizeMatrix< 3, 3 >. |
|
|
Overloaded operator/. Divides an Matrix object by a scalar and return the resulting Matrix object.
Reimplemented in OSCAR::FixedSizeMatrix< nRows, nCols >, OSCAR::FixedSizeMatrix< 6, 6 >, OSCAR::FixedSizeMatrix< 4, 4 >, and OSCAR::FixedSizeMatrix< 3, 3 >. |
|
|
Overloaded operator/=. Multiply an elements of Matrix object by a scalar.
Reimplemented in OSCAR::FixedSizeMatrix< nRows, nCols >, OSCAR::FixedSizeMatrix< 6, 6 >, OSCAR::FixedSizeMatrix< 4, 4 >, and OSCAR::FixedSizeMatrix< 3, 3 >. |
|
|
Assignment operator for doubles. Assignment operator that resets all elements of the calling matrix to the rhs double value supplied
|
|
|
Assignment operator. Assignment operator for copies a specified Matrix object into current Matrix object. An error occurs if the matrices are of different sizes.
Reimplemented in OSCAR::FixedSizeMatrix< nRows, nCols >, OSCAR::Rot3by3, OSCAR::SpatialXform, OSCAR::Xform, OSCAR::FixedSizeMatrix< 6, 6 >, OSCAR::FixedSizeMatrix< 4, 4 >, and OSCAR::FixedSizeMatrix< 3, 3 >. |
|
|
Overloaded Operator==. This overloaded operator== is used to check if two RRMatrices are equal - First it tests to see if they are the same size, and then performs element-wise comparison.
|
|
|
Overloaded operator[]. Returns const MatrixRow object and, combined with MatrixRow::operator[] const, allows read access of an element in the matrix at with the same syntax as a built-in 2-dimensional array.
|
|
|
Overloaded Operator[]. Returns MatrixRow object and, combined with MatrixRow::operator[], allows read/write access of an element in the matrix at with the same syntax as a built-in 2-dimensional array.
|
|
|
Get the Inverse of an Matrix object. This method is used to get the Inverse of an Matrix object. It internally creates an Matrix to hold the inverse so no argument is needed. See Inverse(Matrix& inverse) for more information
|
|
|
Output a Matrix object to an output stream. This method is used to output a Matrix object to an output stream.
|
|
||||||||||||
|
Invert a non-square Matrix object. This method is used to Invert a non-square Matrix object, and uses the pseudo inverse singular value decomposition algorithm that inverts a non-square matrix. The parameter inverse must be the transpose size of the Matrix, otherwise an error will occur. Part of the calculation involves dividing by a computed weighting factor. If the computed weight is zero, then the weight value is added in to stop errors. If an error occurs Matrix inverse is left unchanged. An error occurs if the size of the inverse is not the transpose size of the Matrix
|
|
|
Check if RRMatricies are of the same dimension. Check if an Matrix has the same number of rows and columns as the argument.
|
|
||||||||||||
|
Set a Column of an Matrix object. This method is used to set a column of an Matrix object using an MatrixCol object. An error occurs if the column size of the Matrix and MatrixCol objects is different.
|