In file matrix.h:generic matrix class.
Public Fields
-
Friend functions and operators
Public Methods
-
matrix(void)
- constructs an uninitialized matrix
-
matrix(int N)
- constructs an NxN matrix but does not initialize its elements
-
matrix(int Nr, int Nc, int clear = 1)
- constructs an Nr x Nc matrix and sets the elements to 0 if clear is 1
-
matrix(int Nr, int Nc, const double* data)
- constructs an Nr x Nc matrix and sets its elements to the values pointed to by data.
-
matrix(const matrix &other)
- copy constructor
-
matrix(const tmatrix &tm)
- copy constructor
-
matrix(const quaternion &q)
- constructor for a 3x3 matrix corresponding to the rotation represented by q
-
~matrix(void)
- destructor
-
static matrix identity(int N)
- returns an N x N identity matrix
-
inline int nrows(void) const
- returns the number of rows in the matrix
-
inline int ncols(void) const
- returns the number of columns in the matrix
-
inline double& operator()(int r, int c)
- returns a reference to element (r, c)
-
inline double& elem(int r, int c)
- returns a reference to element (r, c)
-
inline double* elem(void)
- returns a pointer to the matrix's storage space.
-
inline double* addr(int r, int c)
- returns a pointer to the element at (r, c)
-
inline double* rowAddr(int row)
- returns a pointer to the first element in the indicated row
-
inline int isSquare(void) const
- returns non-zero if the matrix is square, 0 if not
-
void resize(int newRows, int newCols)
- resizes a matrix.
-
matrix& makeIdentity(void)
- sets the matrix to the identity matrix, maintaining current dimensions and assuming the matrix is square
-
void print(FILE* fp) const
- prints the matrix to a file
-
Row, column, and block operations
-
int compose(double rx, double ry, double rz)
- composes a 3x3 rotation matrix.
-
int decompose(double &rx, double &ry, double &rz)
- decomposes a 3x3 rotation matrix into the rotation angles as specified by matrix::compose.
-
void transpose(void)
- transposes the matrix.
-
void negate(void)
- negates all elements in the matrix
-
matrix& operator=(int zeroOrOne)
- sets a matrix to either the zero matrix or the identity matrix.
-
matrix& operator=(const matrix &src)
- assignment operator
-
matrix& operator=(const tmatrix &src)
- assignment operator.
-
matrix& operator=(const quaternion &q)
- assignment operator.
-
matrix& operator*=(double d)
- scalar multiplication operator
-
matrix& operator*=(const matrix &src)
- matrix multiplication operator; computes (*this)*src
-
matrix& operator+=(const matrix &src)
- addition operator
-
matrix& operator-=(const matrix &src)
- subtraction operator
Documentation
generic matrix class. Matrix elements are stored in row-major form
(i.e. the first element in a matrix's array is for (row=0, col=0), the
second element in the array is for (row=0, col=1), and so on. Each
matrix has a small amount of storage (determined by the constant
MATRIX_SPACE) so that small matrices do not require calls to new and
delete. Larger matrices allocate and deallocate dynamic memory.
- matrix(void)
- constructs an uninitialized matrix
- matrix(int N)
- constructs an NxN matrix but does not initialize its elements
- matrix(int Nr, int Nc, int clear = 1)
- constructs an Nr x Nc matrix and sets the elements to 0 if clear is 1
- matrix(int Nr, int Nc, const double* data)
- constructs an Nr x Nc matrix and sets its elements to the values
pointed to by data. Data must hold Nr x Nc elements in row-major
form.
- matrix(const matrix &other)
- copy constructor
- matrix(const tmatrix &tm)
- copy constructor
- matrix(const quaternion &q)
- constructor for a 3x3 matrix corresponding to the rotation represented
by q
- ~matrix(void)
- destructor
- static matrix identity(int N)
- returns an N x N identity matrix
- inline int nrows(void) const
- returns the number of rows in the matrix
- inline int ncols(void) const
- returns the number of columns in the matrix
- inline double& operator()(int r, int c)
- returns a reference to element (r, c)
- inline double& elem(int r, int c)
- returns a reference to element (r, c)
- inline double* elem(void)
- returns a pointer to the matrix's storage space. Note that this
space may either be part of the matrix's internal space, or may
be dynamically allocated.
- inline double* addr(int r, int c)
- returns a pointer to the element at (r, c)
- inline double* rowAddr(int row)
- returns a pointer to the first element in the indicated row
- inline int isSquare(void) const
- returns non-zero if the matrix is square, 0 if not
- void resize(int newRows, int newCols)
- resizes a matrix. if the current size is not equal to the new
size, then the contents of the matrix will likely be lost.
- matrix& makeIdentity(void)
- sets the matrix to the identity matrix, maintaining current dimensions
and assuming the matrix is square
- void print(FILE* fp) const
- prints the matrix to a file
- Row, column, and block operations
- inline void getRow(int r, double* data) const
- copies the r'th row into data
- inline void getRow(int r, vector &v) const
- copies the r'th row into v; assumes v has sufficient space
- inline void getCol(int c, double* data) const
- copies the c'th col into data
- inline void getCol(int c, vector &v) const
- copies the c'th col into v; assumes v has sufficient space
- inline void setRow(int r, const double* data)
- sets the r'th row to the elements pointed to by data
- inline void clearRow(int r)
- sets the r'th row to zero
- inline void clearColumn(int c)
- sets the c'th column to zero
- inline void setSubRow(int r, int c0, int size, const double* data)
- Sets part of a row to the supplied values. 'size' entries starting
at column 'c0' in row 'r' are set to the values pointed to by 'data'.
- inline void setColumn(int c, const double* data)
- sets the c'th column to the elements pointed to by data
- inline void setSubColumn(int c, int r0, int size, const double* data)
- Sets part of a column to the supplied values. 'size' entries starting
at row 'r0' in column 'c' are set to the values pointed to by 'data'.
- void setBlock(const matrix &subM, int r, int c)
- sets the sub-block starting at (r, c) to subM
- void copyBlock(const matrix &M, int destr, int destc, int mr0, int mc0, int mr1, int mc1)
- copies the block ([mr0mr1], [mc0mc1]) into M starting at
(destr, destc)
- void clearBlock(int r, int c, int nr, int nc)
- sets an nr by nc block (starting at (r, c)) to zero
- int compose(double rx, double ry, double rz)
- composes a 3x3 rotation matrix. The matrix is equivalent to
the product of three rotation matrices: rotZ(rz)*rotX(rx)*rotY(ry)
where rotZ(rz) indicates a rotation about z by rz.
- int decompose(double &rx, double &ry, double &rz)
- decomposes a 3x3 rotation matrix into the rotation angles
as specified by matrix::compose. The matrix must be 3x3.
- void transpose(void)
- transposes the matrix. Note that if the matrix is not square,
some dynamic is temporarily allocated to use as a workspace.
If you are concerned about performance, use the two-argument
friend function transpose().
- void negate(void)
- negates all elements in the matrix
- matrix& operator=(int zeroOrOne)
- sets a matrix to either the zero matrix or the identity matrix.
If zeroOrOne is 0, then the matrix will be zeroed; otherwise, it
will be set to the identity matrix assuming the matrix is
square.
- matrix& operator=(const matrix &src)
- assignment operator
- matrix& operator=(const tmatrix &src)
- assignment operator. Creates a 4x4 matrix with elements equal to those
of src
- matrix& operator=(const quaternion &q)
- assignment operator. Creates a 3x3 matrix corresponding to the
rotation represented by q.
- matrix& operator*=(double d)
- scalar multiplication operator
- matrix& operator*=(const matrix &src)
- matrix multiplication operator; computes (*this)*src
- matrix& operator+=(const matrix &src)
- addition operator
- matrix& operator-=(const matrix &src)
- subtraction operator
- Friend functions and operators
- Friends:
- matrix &transpose(matrix &dest, const matrix &src)
matrix transpose(const matrix &src)
int eliminateUnusedDims(matrix &dest, const matrix &src,
int restoreUnusedDims(matrix &dest, const matrix &src,
matrix operator+(matrix &m1, matrix &m2)
matrix operator-(matrix &m1, matrix &m2)
matrix operator*(const matrix &m, double d)
matrix operator*(double d, const matrix &m)
vector operator*(const matrix &m, const vector &v)
vector operator*(const vector &v, const matrix &m)
triple operator*(const matrix &m, const triple &t)
triple operator*(const triple &t, const matrix &m)
int operator==(const matrix &a, const matrix &b)
matrix operator *(const matrix &m1, const matrix &m2)
int mmult(matrix &result, const matrix &a, const matrix &b)
int mmult(matrix &result, const matrix &a, const matrix &b,
int mmultTranspose(matrix &result, const matrix &A, const matrix &B)
int diagMatrixMult(matrix &M, const vector &D)
int outerProduct(matrix &result, const vector &v1, const vector &v2)
int outerProduct(matrix &result, const triple &v1, const triple &v2)
int inverse(matrix &result, const matrix &m,
- int* ignoredR
- const int* unused
- This class has no child classes.
- Friends:
- tmatrix
triple
vector
quaternion
Alphabetic index HTML hierarchy of classes or Java
This page was generated with the help of DOC++.