Om  1.0.0
A universal framework for multimedia simulation
Classes | Public Member Functions | Static Public Member Functions | List of all members
om::math::Matrix< T > Class Template Reference

A class that represents a matrix of an arbitrary number of rows and columns. More...

#include <omMatrix.h>

Classes

class  LeastSquares
 
class  QR
 

Public Member Functions

 Matrix ()
 Create an empty matrix with 0 row and 0 columns. More...
 
 Matrix (Size newNumRows)
 Create an uninitialized column vector with the specified number of rows. More...
 
 Matrix (Size newNumRows, Size newNumColumns)
 Create an uninitialized matrix with the specified number of rows and columns. More...
 
 Matrix (Size newNumRows, Size newNumColumns, const T &initializer)
 Create a matrix with the specified number of rows, columns, and scalar initilizer. More...
 
 Matrix (Size newNumRows, Size newNumColumns, const T *initializer)
 Create a matrix from a pointer to an array with elements specified in column-major order. More...
 
 Matrix (const MatrixND< T, 2, 2 > &matrix)
 Create a matrix copy of the specified 2x2 matrix. More...
 
 Matrix (const MatrixND< T, 3, 3 > &matrix)
 Create a matrix copy of the specified 3x3 matrix. More...
 
template<Size newNumRows, Size newNumColumns>
 Matrix (const MatrixND< T, newNumRows, newNumColumns > &matrix)
 Create a matrix copy of the specified MxN matrix. More...
 
template<Size newNumRows>
 Matrix (const VectorND< T, newNumRows > &vector)
 Create a matrix copy of the specified N-component column vector. More...
 
 Matrix (const Matrix &other)
 Create a copy of another matrix. More...
 
template<typename U >
 Matrix (const Matrix< U > &other)
 Create a copy of another matrix of a different scalar type. More...
 
 ~Matrix ()
 Destroy this matrix object, release its reference to the internal storage. More...
 
Matrixoperator= (const Matrix &other)
 Assign the contents of another matrix to this one. More...
 
VectorND< Size, 2 > getSize () const
 Return a 2D vector indicating the (row count, column count) in this matrix. More...
 
void setSize (Size newNumRows, Size newNumColumns)
 Change the size of this matrix without initializing the new matrix. More...
 
void setSize (Size newNumRows, Size newNumColumns, const T &initializer)
 Change the size of this matrix, filling the new entries with the specified value. More...
 
Size getSizeInBytes () const
 Return the approximate total size of this matrix's storage in bytes. More...
 
T * getScalars ()
 Return a pointer to the column-major storage for this matrix's elements. More...
 
const T * getScalars () const
 Return a const pointer to the column-major storage for this matrix's elements. More...
 
Size getScalarCount () const
 Return the total number of scalars that are stored in this matri. More...
 
T & get (Index rowIndex, Index columnIndex)
 Return the element at the specified (row, column) in the matrix. More...
 
const T & get (Index rowIndex, Index columnIndex) const
 Return the element at the specified (row, column) in the matrix. More...
 
void set (Index rowIndex, Index columnIndex, const T &value)
 Set the element at the specified (row, column) in the matrix. More...
 
void setAll (const T &scalar)
 Set all of the elements in the matrix to the specified scalar value. More...
 
void zero ()
 Set all of the elements in the matrix to zero. More...
 
T & operator() (Index rowIndex, Index columnIndex)
 Return the element at the specified (row, column) in the matrix. More...
 
const T & operator() (Index rowIndex, Index columnIndex) const
 Return the element at the specified (row, column) in the matrix. More...
 
Bool isNull () const
 Return whether or not this matrix's internal storage is not allocated. More...
 
Bool isSet () const
 Return whether or not this matrix's internal storage is allocated. More...
 
Size getColumnCount () const
 Return the number of columns that this matrix has. More...
 
Matrix getColumn (Index columnIndex)
 Return a reference to the column at the specified index in the matrix. More...
 
Bool setColumn (Index columnIndex, const Matrix &newColumn)
 Set the column vector at the specified index in the matrix. More...
 
Size getRowCount () const
 Return the number of rows that this matrix has. More...
 
Matrix getRow (Index rowIndex) const
 Return the row at the specified index in the matrix. More...
 
Bool setRow (Index rowIndex, const Matrix &newRow)
 Set the row vector at the specified index in the matrix. More...
 
Matrix transpose () const
 Return the inverse of the matrix if it has one. More...
 
void transpose (Matrix &result) const
 Write the transpose of this matrix to the output parameter. More...
 
Bool operator== (const Matrix &other) const
 Return whether or not every element in this matrix is equal to that in another matrix. More...
 
Bool operator!= (const Matrix< T > &other) const
 Return whether or not some element in this matrix is not equal to that in another matrix. More...
 
Matrix operator- () const
 Negate every element of this matrix and return the resulting matrix. More...
 
const Matrixoperator+ () const
 'Positivate' every element of this matrix, returning a copy of the original matrix. More...
 
Matrix operator+ (const Matrix &matrix) const
 Add this matrix to another and return the resulting matrix. More...
 
Matrix operator+ (const T &scalar) const
 Add a scalar to the elements of this matrix and return the resulting matrix. More...
 
Matrix operator- (const Matrix &matrix) const
 Add this matrix to another and return the resulting matrix. More...
 
Matrix operator- (const T &scalar) const
 Subtract a scalar from the elements of this matrix and return the resulting matrix. More...
 
Matrix operator* (const Matrix &matrix) const
 Multiply a matrix by this matrix and return the result. More...
 
Matrix operator* (const T &scalar) const
 Multiply the elements of this matrix by a scalar and return the resulting matrix. More...
 
Matrix operator/ (const T &scalar) const
 Divide the elements of this matrix by a scalar and return the resulting matrix. More...
 
Matrixoperator+= (const Matrix &matrix)
 Add the elements of another matrix to this matrix. More...
 
Matrixoperator+= (const T &scalar)
 Add a scalar value to the elements of this matrix. More...
 
Matrixoperator-= (const Matrix &matrix)
 Subtract the elements of another matrix from this matrix. More...
 
Matrixoperator-= (const T &scalar)
 Subtract a scalar value from the elements of this matrix. More...
 
Matrixoperator*= (const T &scalar)
 Multiply the elements of this matrix by a scalar value. More...
 
Matrixoperator/= (const T &scalar)
 Divide the elements of this matrix by a scalar value. More...
 
data::String toString () const
 Convert this matrix into a human-readable string representation. More...
 
 operator data::String () const
 Convert this matrix into a human-readable string representation. More...
 

Static Public Member Functions

static void getIdentity (Size size, Matrix &matrix)
 Get the square identity matrix for the specified matrix size in the output parameter. More...
 

Detailed Description

template<typename T>
class om::math::Matrix< T >

A class that represents a matrix of an arbitrary number of rows and columns.

Constructor & Destructor Documentation

template<typename T>
om::math::Matrix< T >::Matrix ( )
inline

Create an empty matrix with 0 row and 0 columns.

template<typename T>
om::math::Matrix< T >::Matrix ( Size  newNumRows)
inlineexplicit

Create an uninitialized column vector with the specified number of rows.

template<typename T>
om::math::Matrix< T >::Matrix ( Size  newNumRows,
Size  newNumColumns 
)
inlineexplicit

Create an uninitialized matrix with the specified number of rows and columns.

template<typename T>
om::math::Matrix< T >::Matrix ( Size  newNumRows,
Size  newNumColumns,
const T &  initializer 
)
inlineexplicit

Create a matrix with the specified number of rows, columns, and scalar initilizer.

template<typename T>
om::math::Matrix< T >::Matrix ( Size  newNumRows,
Size  newNumColumns,
const T *  initializer 
)
inlineexplicit

Create a matrix from a pointer to an array with elements specified in column-major order.

template<typename T>
om::math::Matrix< T >::Matrix ( const MatrixND< T, 2, 2 > &  matrix)
inline

Create a matrix copy of the specified 2x2 matrix.

template<typename T>
om::math::Matrix< T >::Matrix ( const MatrixND< T, 3, 3 > &  matrix)
inline

Create a matrix copy of the specified 3x3 matrix.

template<typename T>
template<Size newNumRows, Size newNumColumns>
om::math::Matrix< T >::Matrix ( const MatrixND< T, newNumRows, newNumColumns > &  matrix)
inline

Create a matrix copy of the specified MxN matrix.

template<typename T>
template<Size newNumRows>
om::math::Matrix< T >::Matrix ( const VectorND< T, newNumRows > &  vector)
inline

Create a matrix copy of the specified N-component column vector.

template<typename T>
om::math::Matrix< T >::Matrix ( const Matrix< T > &  other)
inline

Create a copy of another matrix.

template<typename T>
template<typename U >
om::math::Matrix< T >::Matrix ( const Matrix< U > &  other)
inline

Create a copy of another matrix of a different scalar type.

template<typename T>
om::math::Matrix< T >::~Matrix ( )
inline

Destroy this matrix object, release its reference to the internal storage.

Member Function Documentation

template<typename T>
Matrix& om::math::Matrix< T >::operator= ( const Matrix< T > &  other)
inline

Assign the contents of another matrix to this one.

template<typename T>
VectorND<Size,2> om::math::Matrix< T >::getSize ( ) const
inline

Return a 2D vector indicating the (row count, column count) in this matrix.

template<typename T>
void om::math::Matrix< T >::setSize ( Size  newNumRows,
Size  newNumColumns 
)
inline

Change the size of this matrix without initializing the new matrix.

Use this method to change the size of a matrix without having to initialize its elements. This can be faster if you know that valid entries will later be written to the matrix.

template<typename T>
void om::math::Matrix< T >::setSize ( Size  newNumRows,
Size  newNumColumns,
const T &  initializer 
)
inline

Change the size of this matrix, filling the new entries with the specified value.

If the matrix size shrinks along a dimension, the matrix is truncated in that dimension.

template<typename T>
Size om::math::Matrix< T >::getSizeInBytes ( ) const
inline

Return the approximate total size of this matrix's storage in bytes.

template<typename T>
T* om::math::Matrix< T >::getScalars ( )
inline

Return a pointer to the column-major storage for this matrix's elements.

template<typename T>
const T* om::math::Matrix< T >::getScalars ( ) const
inline

Return a const pointer to the column-major storage for this matrix's elements.

template<typename T>
Size om::math::Matrix< T >::getScalarCount ( ) const
inline

Return the total number of scalars that are stored in this matri.

template<typename T>
T& om::math::Matrix< T >::get ( Index  rowIndex,
Index  columnIndex 
)
inline

Return the element at the specified (row, column) in the matrix.

template<typename T>
const T& om::math::Matrix< T >::get ( Index  rowIndex,
Index  columnIndex 
) const
inline

Return the element at the specified (row, column) in the matrix.

template<typename T>
void om::math::Matrix< T >::set ( Index  rowIndex,
Index  columnIndex,
const T &  value 
)
inline

Set the element at the specified (row, column) in the matrix.

template<typename T>
void om::math::Matrix< T >::setAll ( const T &  scalar)
inline

Set all of the elements in the matrix to the specified scalar value.

template<typename T>
void om::math::Matrix< T >::zero ( )
inline

Set all of the elements in the matrix to zero.

template<typename T>
T& om::math::Matrix< T >::operator() ( Index  rowIndex,
Index  columnIndex 
)
inline

Return the element at the specified (row, column) in the matrix.

template<typename T>
const T& om::math::Matrix< T >::operator() ( Index  rowIndex,
Index  columnIndex 
) const
inline

Return the element at the specified (row, column) in the matrix.

template<typename T>
Bool om::math::Matrix< T >::isNull ( ) const
inline

Return whether or not this matrix's internal storage is not allocated.

template<typename T>
Bool om::math::Matrix< T >::isSet ( ) const
inline

Return whether or not this matrix's internal storage is allocated.

template<typename T>
Size om::math::Matrix< T >::getColumnCount ( ) const
inline

Return the number of columns that this matrix has.

template<typename T>
Matrix om::math::Matrix< T >::getColumn ( Index  columnIndex)
inline

Return a reference to the column at the specified index in the matrix.

template<typename T>
Bool om::math::Matrix< T >::setColumn ( Index  columnIndex,
const Matrix< T > &  newColumn 
)
inline

Set the column vector at the specified index in the matrix.

template<typename T>
Size om::math::Matrix< T >::getRowCount ( ) const
inline

Return the number of rows that this matrix has.

template<typename T>
Matrix om::math::Matrix< T >::getRow ( Index  rowIndex) const
inline

Return the row at the specified index in the matrix.

template<typename T>
Bool om::math::Matrix< T >::setRow ( Index  rowIndex,
const Matrix< T > &  newRow 
)
inline

Set the row vector at the specified index in the matrix.

template<typename T>
Matrix om::math::Matrix< T >::transpose ( ) const
inline

Return the inverse of the matrix if it has one.

If there is no inverse, or the matrix is not square, a 0 by 0 matrix is returned.Return the transpose of this matrix.

template<typename T>
void om::math::Matrix< T >::transpose ( Matrix< T > &  result) const
inline

Write the transpose of this matrix to the output parameter.

template<typename T>
Bool om::math::Matrix< T >::operator== ( const Matrix< T > &  other) const
inline

Return whether or not every element in this matrix is equal to that in another matrix.

template<typename T>
Bool om::math::Matrix< T >::operator!= ( const Matrix< T > &  other) const
inline

Return whether or not some element in this matrix is not equal to that in another matrix.

template<typename T>
Matrix om::math::Matrix< T >::operator- ( ) const
inline

Negate every element of this matrix and return the resulting matrix.

template<typename T>
const Matrix& om::math::Matrix< T >::operator+ ( ) const
inline

'Positivate' every element of this matrix, returning a copy of the original matrix.

template<typename T>
Matrix om::math::Matrix< T >::operator+ ( const Matrix< T > &  matrix) const
inline

Add this matrix to another and return the resulting matrix.

template<typename T>
Matrix om::math::Matrix< T >::operator+ ( const T &  scalar) const
inline

Add a scalar to the elements of this matrix and return the resulting matrix.

template<typename T>
Matrix om::math::Matrix< T >::operator- ( const Matrix< T > &  matrix) const
inline

Add this matrix to another and return the resulting matrix.

template<typename T>
Matrix om::math::Matrix< T >::operator- ( const T &  scalar) const
inline

Subtract a scalar from the elements of this matrix and return the resulting matrix.

template<typename T>
Matrix om::math::Matrix< T >::operator* ( const Matrix< T > &  matrix) const
inline

Multiply a matrix by this matrix and return the result.

template<typename T>
Matrix om::math::Matrix< T >::operator* ( const T &  scalar) const
inline

Multiply the elements of this matrix by a scalar and return the resulting matrix.

template<typename T>
Matrix om::math::Matrix< T >::operator/ ( const T &  scalar) const
inline

Divide the elements of this matrix by a scalar and return the resulting matrix.

template<typename T>
Matrix& om::math::Matrix< T >::operator+= ( const Matrix< T > &  matrix)
inline

Add the elements of another matrix to this matrix.

template<typename T>
Matrix& om::math::Matrix< T >::operator+= ( const T &  scalar)
inline

Add a scalar value to the elements of this matrix.

template<typename T>
Matrix& om::math::Matrix< T >::operator-= ( const Matrix< T > &  matrix)
inline

Subtract the elements of another matrix from this matrix.

template<typename T>
Matrix& om::math::Matrix< T >::operator-= ( const T &  scalar)
inline

Subtract a scalar value from the elements of this matrix.

template<typename T>
Matrix& om::math::Matrix< T >::operator*= ( const T &  scalar)
inline

Multiply the elements of this matrix by a scalar value.

template<typename T>
Matrix& om::math::Matrix< T >::operator/= ( const T &  scalar)
inline

Divide the elements of this matrix by a scalar value.

template<typename T>
data::String om::math::Matrix< T >::toString ( ) const
inline

Convert this matrix into a human-readable string representation.

template<typename T>
om::math::Matrix< T >::operator data::String ( ) const
inline

Convert this matrix into a human-readable string representation.

template<typename T>
static void om::math::Matrix< T >::getIdentity ( Size  size,
Matrix< T > &  matrix 
)
inlinestatic

Get the square identity matrix for the specified matrix size in the output parameter.


The documentation for this class was generated from the following file: