Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

OSCAR::Matrix Class Reference
[Math]

This class is a 2D array of doubles that contains the appropriate functionality for managing robotics data. More...

#include <Matrix.h>

Inheritance diagram for OSCAR::Matrix:

Inheritance graph
[legend]
List of all members.

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
VectorIscratchIndxVectorI_M
VectorscratchColVector_M

Detailed Description

Author:
Chetan Kapoor and S. M. Orlow (NIH), Murat Cetin (MATLAB)
This class is a 2D array of doubles that contains the appropriate functionality for managing robotics data.


Constructor & Destructor Documentation

OSCAR::Matrix::Matrix unsigned int    nr,
unsigned int    nc,
const double *    f = 0,
const String   name = String(),
bool    initMtx = true
 

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.

Parameters:
nr Number of rows.
nc Number of columns.
f Pointer to an array of initialization values, default is no array.
name An String that is the name of the Matrix object.
initMtx If(f==0&&!initMtx) the matrix elements are not initialized
Exceptions:
There is an error if nr or nc is zero.

OSCAR::Matrix::Matrix unsigned int    nr,
unsigned int    nc,
const Vector   v,
OSCARError   err = DUMMY_ERROR(noError),
const String   name = String()
 

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.

Parameters:
nr Number of rows.
nc Number of columns.
v Pointer to a Vector of initialization values.
err Upon return, this will contain the error status of the constructor call.
name An String that is the name of the Matrix object.
Exceptions:
arraySizeMismatch arraySizeMismatch The number of Vector values does not equal the number of Matrix values.
There is also an error if nr or nc is zero.

OSCAR::Matrix::Matrix unsigned int    k,
double *    f,
const String   name = String()
 

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.

Parameters:
k Number of rows/columns.
f Pointer to an array of diagonal initialization values.
name An String that is the name of the Matrix object.
Exceptions:
There is an error if k is zero.

OSCAR::Matrix::Matrix const MatrixRow   rhs
 

Constructor.

Constructs a (1 x nrow) Matrix initialized by MatrixRow values.

Parameters:
rhs A MatrixRow object that is used to create a Matrix object.

OSCAR::Matrix::Matrix const MatrixCol   rhs
 

Constructor.

Constructs an (ncol x 1) Matrix object initialized by MatrixCol values.

Parameters:
rhs A MatrixCol object that is used to create a Matrix object.

OSCAR::Matrix::Matrix const Matrix &    rhs
 

Copy Constructor.

Constructs an Matrix from an existing Matrix.

Parameters:
rhs An Matrix object that is used to create the new object.

virtual OSCAR::Matrix::~Matrix   [virtual]
 

Virtual Destructor.

This is the Destructor for an object of type Matrix.

OSCAR::Matrix::Matrix const String   name = String() [protected]
 

Defaut Constructor for derived classes.

Call this constructor from the default constructor for derived classes to bypass the memory allocation in Matrix.

Parameters:
name A String which is the name of the Matrix. Default value is "".


Member Function Documentation

const double& OSCAR::Matrix::at unsigned int    irow,
unsigned int    icol
const
 

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.

Parameters:
irow The row position - 0 is the first row.
icol The column position - 0 is the first column.
Returns:
The Matrix element specified.
Exceptions:
outOfRange outOfRange

double& OSCAR::Matrix::at unsigned int    irow,
unsigned int    icol
 

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.

Parameters:
irow The row position - 0 is the first row.
icol The column position - 0 is the first column.
Returns:
The Matrix element specified.
Exceptions:
outOfRange outOfRange

bool OSCAR::Matrix::CholeskyDecomposition  
 

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.

Returns:
True if successful. False if the matrix is not positive definite.
Exceptions:
matrixSingularity matrixSingularity

void OSCAR::Matrix::CholeskyFowBackSubstitution double    b[],
double    x[]
const
 

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.

Parameters:
b Pointer to an array that holds the input as the right-hand side vector.
x Pointer to an array that holds the output as the solution vector.

bool OSCAR::Matrix::CholeskySolve const Vector   b,
Vector   x,
double &    determinant
const
 

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.

Parameters:
b Vector object representing the right-hand side vector. Must be of the same size as the number of columns of the matrix.
x Vector object containing the solution of the equations upon function return. Must be of the same size as the number of columns of the matrix.
determinant The determinant of the matrix.
Returns:
True if successful. False if the matrix is not positive definite.
Exceptions:
nonSquareMatrix nonSquareMatrix
vectorSizeMismatch vectorSizeMismatch

void OSCAR::Matrix::CombineRows unsigned int    i,
double    b,
unsigned int    j
 

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.

Parameters:
i The row to be replaced by the sum of row(i) + b*row(j)
b The multiplication factor by which row j is to be multiplied.
j The row multiplied by b and then added to row i.

bool OSCAR::Matrix::Copy const Matrix &    matrixToCopy
 

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.

Parameters:
matrixToCopy An Matrix object that is to be copied.
Returns:
True if copying was successful. Otherwise, False.
Exceptions:
MatrixSizeMismatch #MatrixSizeMismatch

bool OSCAR::Matrix::Determinant double &    det const
 

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.

Parameters:
det On return, this holds the value of the determinant.
Returns:
True if successful. Otherwise, False.
Exceptions:
nonSquareMatrix nonSquareMatrix

virtual void OSCAR::Matrix::dumpOn std::ostream &    out const [virtual]
 

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.

bool OSCAR::Matrix::EigenValues Vector   W const
 

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.

Parameters:
W If nrow >= ncol then must be of size ncol. If nrow < ncol then must be of size nrow.
Returns:
True if successful, False otherwise. Call GetError() for more details.
Exceptions:
matlabRelated matlabRelated If there is an error in MatlabInterface or in Matlab itself
VectorSizeMismatch #VectorSizeMismatch W must be of size ncol if nrow >= ncol W must be of size nrow if nrow < ncol
arraySizeMismatch arraySizeMismatch If there is an error in svdcmp (NonMatlab version)

double* OSCAR::Matrix::GetArray  
 

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())

Returns:
Pointer to first element in the array

const double* OSCAR::Matrix::GetArray   const
 

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())

Returns:
Pointer to first element in the array

const MatrixCol OSCAR::Matrix::GetCol unsigned int    col const
 

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.

Parameters:
col The col of the Matrix to be returned - 0 is the first column.
Returns:
An MatrixCol object that contains the col of the Matrix object.
Exceptions:
outOfRange outOfRange

MatrixCol OSCAR::Matrix::GetCol unsigned int    col
 

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.

Parameters:
col The col of the Matrix to be returned - 0 is the first column.
Returns:
An MatrixCol object that contains the col of the Matrix object.
Exceptions:
outOfRange outOfRange

const MatrixRow OSCAR::Matrix::GetRow unsigned int    row const
 

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.

Parameters:
row The row of the Matrix to be returned - 0 is the first row.
Returns:
An MatrixRow object that contains the row of the Matrix object.
Exceptions:
outOfRange outOfRange

MatrixRow OSCAR::Matrix::GetRow unsigned int    row
 

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.

Parameters:
row The row of the Matrix to be returned - 0 is the first row.
Returns:
An MatrixRow object that contains the row of the Matrix object.
Exceptions:
outOfRange outOfRange

bool OSCAR::Matrix::Identity  
 

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.

Returns:
True if successful. Otherwise False if the Matrix is non-square.
Exceptions:
nonSquareMatrix nonSquareMatrix

Reimplemented in OSCAR::Xform.

virtual bool OSCAR::Matrix::Inverse Matrix &    inverse,
double &    determinant
const [virtual]
 

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.

Parameters:
inverse On return, inverse holds the result of the inversion. This will remain unchanged if an error occurs.
determinant On return, determinant holds the value of the determinant of the Matrix.
Returns:
True if successful. False if non-square matrix, or if inverse is not the same size, or if LUDecomposition goes singular.
Exceptions:
nonSquareMatrix nonSquareMatrix
MatrixSizeMismatch #MatrixSizeMismatch
SingularMatrix #SingularMatrix
See also:
bool LUDecomposition(int* indx, double* d) const;

virtual bool OSCAR::Matrix::Inverse Matrix &    inverse const [virtual]
 

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.

Parameters:
inverse On return, this holds the result of the inversion. This will remain unchanged if an error occurs.
Returns:
True if successful. False if non-square matrix, or if LUDecomposition goes singular, or if inverse is not the same size as the original matrix.
Exceptions:
nonSquareMatrix nonSquareMatrix
MatrixSizeMismatch #MatrixSizeMismatch
SingularMatrix #SingularMatrix
See also:
bool LUDecomposition(int* indx, double* d) const;

bool OSCAR::Matrix::isSquare   const
 

Check if an Matrix is square.

This method is used to check if an Matrix is square or not.

Returns:
True if square(ncol==nrow). Otherwise, False.

bool OSCAR::Matrix::isUpperTriangle   const
 

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.

Returns:
True if bottom triangle is zeros. Otherwise, False.

bool OSCAR::Matrix::LUDecomposition int *    indx,
double *    d
 

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.

Parameters:
indx Pointer to the output vector which records the row (output) permutation effected by the partial pivoting indx[i...n]. The array it points to must be of size nrow.
d Outputs +-1 depending on whether the number of row (output) interchanges was even or odd, respectively. The calling matrix is replaced by its decomposed form.
Returns:
True if successful. Otherwise, False.
Exceptions:
matrixSingularity matrixSingularity

void OSCAR::Matrix::LUFowBackSubstitution const int *    indx,
double    b[]
const
 

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.

Parameters:
indx Pointer to an array that holds the input vector returned from LUDecomposition. Array pointed to must be of size nrow.
b Pointer to an array that holds the input/output of the LUForwardBackSubstitution. Array pointed to must be of size nrow.

bool OSCAR::Matrix::LUSolve const Vector   b,
Vector   x,
double &    determinant
const
 

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.

Parameters:
b Vector object representing the right-hand side vector. Must be of the same size as the number of columns of the matrix.
x Vector object containing the solution of the equations upon function return. Must be of the same size as the number of columns of the matrix.
determinant The determinant of the matrix.
Returns:
True if successful. False if the matrix is singular.
Exceptions:
nonSquareMatrix nonSquareMatrix
vectorSizeMismatch vectorSizeMismatch

virtual void OSCAR::Matrix::m_alloc unsigned int    rows,
unsigned int    cols
[protected, virtual]
 

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.

Parameters:
rows Number of rows in the Matrix object.
cols Number of columns in the Matrix object.

Reimplemented in OSCAR::FixedSizeMatrix< nRows, nCols >, OSCAR::FixedSizeMatrix< 6, 6 >, OSCAR::FixedSizeMatrix< 4, 4 >, and OSCAR::FixedSizeMatrix< 3, 3 >.

double OSCAR::Matrix::MatrixNorm double    P const
 

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.

Parameters:
P (P-norm). P can only take the following values: P=1, 2, 6(for infinity), 9(for frobenius)
Returns:
The norm if successful, -1 otherwise.
Exceptions:
matlabRelated matlabRelated if there is an error in MatlabInterface or in Matlab itself

double OSCAR::Matrix::Max   const
 

Get the Largest Value in the Matrix object.

This method is used to get the largest value in the Matrix.

Returns:
The largest value.

bool OSCAR::Matrix::Multiply const Vector   vec,
Vector   result
const
 

Matrix-vector multiplication.

Multiplies an Vector object with calling object and puts values in resulting Vector object.

Parameters:
vec vector of length (lhs.ncol) to post-multiply with calling object
result vector result of multiplication of length (lhs.ncol)
Returns:
True if vector sizes correct, if false call GetError
Exceptions:
MatrixSizeMismatch #MatrixSizeMismatch

Reimplemented in OSCAR::FixedSizeMatrix< nRows, nCols >, OSCAR::FixedSizeMatrix< 6, 6 >, OSCAR::FixedSizeMatrix< 4, 4 >, and OSCAR::FixedSizeMatrix< 3, 3 >.

bool OSCAR::Matrix::Multiply const Matrix &    rhs,
Matrix &    result
const
 

Matrix multiplication.

Multiplies an Matrix object with calling object and puts values in resulting Matrix object.

Parameters:
rhs (lhs.ncol X N ) matrix to post-multiply with calling object
result (lhs.nrow X rhs.ncol) result of multiplication
Returns:
True if matrix sizes correct, if false call GetError
Exceptions:
MatrixSizeMismatch #MatrixSizeMismatch

bool OSCAR::Matrix::MultiplyWithTranspose Matrix &    result const
 

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.

Parameters:
result On return, result will hold the resulting Matrix.
Returns:
True if successful. Otherwise, False.
Exceptions:
MatrixSizeMismatch #MatrixSizeMismatch:

unsigned int OSCAR::Matrix::nCol   const
 

Get the Number of columns in the Matrix object.

This method is used to get the number of columns in the Matrix object.

Returns:
The number of columns.

unsigned int OSCAR::Matrix::nRow   const
 

Get the Number of rows in the Matrix object.

This method is used to get the number of rows in the Matrix object.

Returns:
The number of rows.

Matrix OSCAR::Matrix::operator & const Matrix &    rhs const
 

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.

Parameters:
rhs An Matrix object.
Returns:
The resulting Matrix where the number of rows stays the same, but the number of columns increases to hold both RRMatrices.
Exceptions:
MatrixSizeMismatch #MatrixSizeMismatch

Matrix OSCAR::Matrix::operator * const Matrix &    rhs const
 

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.

Parameters:
rhs An Matrix object which is to be multiplied to the Matrix.
Returns:
The resulting Matrix object.
Exceptions:
MatrixSizeMismatch #MatrixSizeMismatch

Reimplemented in OSCAR::FixedSizeMatrix< nRows, nCols >, OSCAR::FixedSizeMatrix< 6, 6 >, OSCAR::FixedSizeMatrix< 4, 4 >, and OSCAR::FixedSizeMatrix< 3, 3 >.

Vector OSCAR::Matrix::operator * const Vector   rhs const
 

Overloaded operator*.

Multiplies an calling object by a vector and return the resulting Vector object.

Parameters:
rhs Vector of length ncol
Returns:
The resulting Vector object.

Reimplemented in OSCAR::FixedSizeMatrix< nRows, nCols >, OSCAR::FixedSizeMatrix< 6, 6 >, OSCAR::FixedSizeMatrix< 4, 4 >, and OSCAR::FixedSizeMatrix< 3, 3 >.

Matrix OSCAR::Matrix::operator * double    d const
 

Overloaded operator*.

Multiplies an Matrix object by a scalar and return the resulting Matrix object.

Parameters:
d A scalar quantity.
Returns:
The resulting Matrix object.

Reimplemented in OSCAR::FixedSizeMatrix< nRows, nCols >, OSCAR::FixedSizeMatrix< 6, 6 >, OSCAR::FixedSizeMatrix< 4, 4 >, and OSCAR::FixedSizeMatrix< 3, 3 >.

Matrix& OSCAR::Matrix::operator *= const Matrix &    m
 

Overloaded operator*=.

Multiply Matrix object with current matrix and assign result to current matrix.

Parameters:
m Matrix object.
Returns:
Reference to current matrix

Reimplemented in OSCAR::FixedSizeMatrix< nRows, nCols >, OSCAR::FixedSizeMatrix< 6, 6 >, OSCAR::FixedSizeMatrix< 4, 4 >, and OSCAR::FixedSizeMatrix< 3, 3 >.

Matrix& OSCAR::Matrix::operator *= double    d
 

Overloaded operator*=.

Multiply an elements of Matrix object by a scalar.

Parameters:
d A scalar quantity.
Returns:
Reference to current matrix

Reimplemented in OSCAR::FixedSizeMatrix< nRows, nCols >, OSCAR::FixedSizeMatrix< 6, 6 >, OSCAR::FixedSizeMatrix< 4, 4 >, and OSCAR::FixedSizeMatrix< 3, 3 >.

const double& OSCAR::Matrix::operator() unsigned int    irow,
unsigned int    icol
const
 

double& OSCAR::Matrix::operator() unsigned int    irow,
unsigned int    icol
 

Matrix OSCAR::Matrix::operator+ const Matrix &    rhs const
 

Overloaded operator+.

Add two RRMatrices together and return the resulting Matrix object. An error occurs if the two RRMatrices are of different sizes.

Parameters:
rhs An Matrix object which is to be added to the Matrix.
Returns:
The resulting Matrix object.
Exceptions:
MatrixSizeMismatch #MatrixSizeMismatch

Reimplemented in OSCAR::FixedSizeMatrix< nRows, nCols >, OSCAR::FixedSizeMatrix< 6, 6 >, OSCAR::FixedSizeMatrix< 4, 4 >, and OSCAR::FixedSizeMatrix< 3, 3 >.

Matrix& OSCAR::Matrix::operator+= const Matrix &    rhs
 

Overloaded operator+=.

Element-wise addition to an Matrix from the current matrix.

Parameters:
rhs An Matrix.
Returns:
Reference to current matrix

Reimplemented in OSCAR::FixedSizeMatrix< nRows, nCols >, OSCAR::FixedSizeMatrix< 6, 6 >, OSCAR::FixedSizeMatrix< 4, 4 >, and OSCAR::FixedSizeMatrix< 3, 3 >.

Matrix OSCAR::Matrix::operator-   const
 

Overloaded operator- (additive inverse).

Returns an Matrix object whose elements are the additive inverse (negative) of the current object.

Returns:
The resulting Matrix.

Reimplemented in OSCAR::Rot3by3, and OSCAR::SpatialXform.

Matrix OSCAR::Matrix::operator- const Matrix &    rhs const
 

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.

Parameters:
rhs An Matrix object which is to be subtracted from the Matrix.
Returns:
The resulting Matrix object.
Exceptions:
MatrixSizeMismatch #MatrixSizeMismatch

Reimplemented in OSCAR::FixedSizeMatrix< nRows, nCols >, OSCAR::FixedSizeMatrix< 6, 6 >, OSCAR::FixedSizeMatrix< 4, 4 >, and OSCAR::FixedSizeMatrix< 3, 3 >.

Matrix& OSCAR::Matrix::operator-= const Matrix &    rhs
 

Overloaded operator-=.

Element-wise subtraction of an Matrix from the current matrix.

Parameters:
rhs An Matrix.
Returns:
Reference to current matrix

Reimplemented in OSCAR::FixedSizeMatrix< nRows, nCols >, OSCAR::FixedSizeMatrix< 6, 6 >, OSCAR::FixedSizeMatrix< 4, 4 >, and OSCAR::FixedSizeMatrix< 3, 3 >.

Matrix OSCAR::Matrix::operator/ double    d const
 

Overloaded operator/.

Divides an Matrix object by a scalar and return the resulting Matrix object.

Parameters:
d A scalar quantity.
Returns:
The resulting Matrix object.

Reimplemented in OSCAR::FixedSizeMatrix< nRows, nCols >, OSCAR::FixedSizeMatrix< 6, 6 >, OSCAR::FixedSizeMatrix< 4, 4 >, and OSCAR::FixedSizeMatrix< 3, 3 >.

Matrix& OSCAR::Matrix::operator/= double    d
 

Overloaded operator/=.

Multiply an elements of Matrix object by a scalar.

Parameters:
d A scalar quantity.
Returns:
Reference to current matrix

Reimplemented in OSCAR::FixedSizeMatrix< nRows, nCols >, OSCAR::FixedSizeMatrix< 6, 6 >, OSCAR::FixedSizeMatrix< 4, 4 >, and OSCAR::FixedSizeMatrix< 3, 3 >.

Matrix& OSCAR::Matrix::operator= double    rhs
 

Assignment operator for doubles.

Assignment operator that resets all elements of the calling matrix to the rhs double value supplied

Parameters:
rhs A double that goes on the right hand side of the = operator.
Returns:
A reference to the object on the left hand side of the = operator.

Matrix& OSCAR::Matrix::operator= const Matrix &    rhs
 

Assignment operator.

Assignment operator for copies a specified Matrix object into current Matrix object. An error occurs if the matrices are of different sizes.

Parameters:
rhs An Matrix object that goes on the right hand side of the = operator.
Returns:
A reference to the object on the left hand side of the = operator.
Exceptions:
MatrixSizeMismatch #MatrixSizeMismatch

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 >.

bool OSCAR::Matrix::operator== const Matrix &    rhs const
 

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.

Parameters:
rhs An Matrix object.
Returns:
True if they are the same size and the elements are equal. Otherwise, False.

const MatrixRow OSCAR::Matrix::operator[] unsigned int    row const
 

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.

Parameters:
row The row of the Matrix to be returned - 0 is the first row.
Returns:
An MatrixRow object that contains the row of the Matrix object.

MatrixRow OSCAR::Matrix::operator[] unsigned int    row
 

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.

Parameters:
row The row of the Matrix to be returned - 0 is the first row.
Returns:
An MatrixRow object that contains the row of the Matrix object.

Matrix OSCAR::Matrix::operator~   const
 

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

Returns:
The inverse of the Matrix.
See also:
bool Inverse(Matrix& inverse)

virtual void OSCAR::Matrix::printOn std::ostream &    out const [virtual]
 

Output a Matrix object to an output stream.

This method is used to output a Matrix object to an output stream.

Parameters:
out An output stream to which the object is outputted.

bool OSCAR::Matrix::PseudoInvSVD Matrix &    inverse,
double    weight = .0001
const
 

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

Parameters:
inverse The output matrix containing inversion of Matrix - must be the transpose size of the Matrix.
weight The weight factor for divide by zero cases. Default 0.0001
Returns:
True if successful. False if Matrix inverse is not the transpose size of the Matrix, or if the SVD() fails.
Exceptions:
MatrixSizeMismatch #MatrixSizeMismatch

bool OSCAR::Matrix::SameSize const Matrix &    m const
 

Check if RRMatricies are of the same dimension.

Check if an Matrix has the same number of rows and columns as the argument.

Parameters:
m Matrix with which to compare sizes.
Returns:
True if same size. Otherwise, False.

bool OSCAR::Matrix::SetCol unsigned int    col,
const MatrixCol   colObject
 

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.

Parameters: