Public Member Functions | Protected Attributes | Friends

gridripper::math::Matrix< T > Class Template Reference

Matrix class. More...

#include <Matrix.h>

List of all members.

Public Member Functions

 Matrix ()
 Creates a 0x0 empty matrix.
 Matrix (int rows, int columns)
 Creates a matrix with the specified number of rows and columns.
 Matrix (const Matrix< T > &)
 Copy constructor.
void setZero ()
 Sets all the values in this matrix to zero.
void setIdentity ()
 Sets the diagonal elements to 1, all other elements to zero.
virtual void setSize (int rows, int columns)
 Changes the size dynamically.
int getNumRows () const
 Returns the number of rows.
int getNumColumns () const
 Returns the number of columns.
T & operator() (int i, int j)
 Gets a reference to the element at row i, column j.
operator() (int i, int j) const
 Gets the element at row i, column j.
T & operator[] (int i)
 Gets a reference to an element.
operator[] (int i) const
 Gets an element.
Matrix< T > & operator= (const Matrix< T > &)
 Copies another matrix onto this matrix.
bool operator== (const Matrix< T > &) const
 Tests whether two matrices are equal.
int operator!= (const Matrix< T > &B) const
 Tests whether two matrices are not equal.
Matrix< T > operator+ () const
 Unary plus operation.
Matrix< T > operator- () const
 Unary minus operation.
Matrix< T > operator+ (const Matrix< T > &) const
 Adds two matrices.
Matrix< T > operator- (const Matrix< T > &) const
 Subtracts a matrix.
MVector< T > operator* (const MVector< T > &) const
 Multiples the matrix by another matrix.
Matrix< T > operator* (T) const
 Multiples the matrix by a scalar.
Matrix< T > operator/ (T) const
 Divides the matrix by a scalar.
Matrix< T > operator^ (int) const
 Calculates an integer power of the matrix.
Matrix< T > operator* (const Matrix< T > &) const
 Multiplies the matrix by another matrix.
Matrix< T > & operator+= (const Matrix< T > &)
 Adds a matrix.
Matrix< T > & operator-= (const Matrix< T > &)
 Subtracts a matrix.
Matrix< T > & operator*= (T)
 Multiplies by a scalar.
Matrix< T > & operator/= (T)
 Divides by a scalar.
Matrix< T > & operator*= (const Matrix< T > &B)
 Multiplies the matrix by another matrix.
Matrix< T > & operator^= (int)
 Calculates an integer power.
Matrix< T > operator~ () const
 Returns the transpose of this matrix.
Matrix< T > minorMatrix (int row, int column) const
 Returns a matrix constructed by the removal of the specified row and column of this matrix.
trace () const
 Returns the trace.
det () const
 Returns the determinant.
void invert ()
 Inverts this matrix.
void invert (const Matrix< T > &)
 Inverts the specified matrix and places new values into this matrix.
void swapRows (int i, int j)
 Swaps two rows.

Protected Attributes

T * x
 Array of matrix components.
int numRows
 Number of rows.
int numColumns
 Number of columns.

Friends

template<class T2 >
Matrix< T2 > operator* (T2 s, const Matrix< T2 > &A)
 Multiplies a scalar by a matrix.
template<class T2 >
MVector< T2 > operator* (const MVector< T2 > &, const Matrix< T2 > &)
 Multiplies the matrix by a scalar.
template<class T2 >
MVector< T2 > operator/ (const MVector< T2 > &, const Matrix< T2 > &)
 Solve linear system of equations.
template<class T2 >
std::istream & operator>> (std::istream &, Matrix< T2 > &)
 Reads a matrix from a stream.
template<class T2 >
std::ostream & operator<< (std::ostream &, const Matrix< T2 > &)
 Writes a matrix into a stream.

Detailed Description

template<class T>
class gridripper::math::Matrix< T >

Matrix class.

Version:
GridRipper 12/21/2008
Author:
Peter Csizmadia
Since:
1991

Constructor & Destructor Documentation

template<class T>
gridripper::math::Matrix< T >::Matrix (  )  [inline]

Creates a 0x0 empty matrix.

template<class T>
gridripper::math::Matrix< T >::Matrix ( int  rows,
int  columns 
)

Creates a matrix with the specified number of rows and columns.

template<class T>
gridripper::math::Matrix< T >::Matrix ( const Matrix< T > &   ) 

Copy constructor.


Member Function Documentation

template<class T>
T gridripper::math::Matrix< T >::det (  )  const

Returns the determinant.

template<class T>
int gridripper::math::Matrix< T >::getNumColumns (  )  const [inline]

Returns the number of columns.

template<class T>
int gridripper::math::Matrix< T >::getNumRows (  )  const [inline]

Returns the number of rows.

template<class T>
void gridripper::math::Matrix< T >::invert (  )  [inline]

Inverts this matrix.

template<class T>
void gridripper::math::Matrix< T >::invert ( const Matrix< T > &   ) 

Inverts the specified matrix and places new values into this matrix.

template<class T>
int gridripper::math::Matrix< T >::operator!= ( const Matrix< T > &  B  )  const [inline]

Tests whether two matrices are not equal.

template<class T>
MVector<T> gridripper::math::Matrix< T >::operator* ( const MVector< T > &   )  const

Multiples the matrix by another matrix.

template<class T>
Matrix<T> gridripper::math::Matrix< T >::operator* (  )  const

Multiples the matrix by a scalar.

template<class T>
Matrix<T> gridripper::math::Matrix< T >::operator* ( const Matrix< T > &   )  const

Multiplies the matrix by another matrix.

template<class T>
Matrix<T>& gridripper::math::Matrix< T >::operator*= (  ) 

Multiplies by a scalar.

template<class T>
Matrix<T>& gridripper::math::Matrix< T >::operator*= ( const Matrix< T > &  B  )  [inline]

Multiplies the matrix by another matrix.

template<class T>
Matrix<T> gridripper::math::Matrix< T >::operator+ (  )  const [inline]

Unary plus operation.

template<class T>
Matrix<T> gridripper::math::Matrix< T >::operator+ ( const Matrix< T > &   )  const

Adds two matrices.

template<class T>
Matrix<T>& gridripper::math::Matrix< T >::operator+= ( const Matrix< T > &   ) 

Adds a matrix.

template<class T>
Matrix<T> gridripper::math::Matrix< T >::operator- ( const Matrix< T > &   )  const

Subtracts a matrix.

template<class T>
Matrix<T> gridripper::math::Matrix< T >::operator- (  )  const

Unary minus operation.

template<class T>
Matrix<T>& gridripper::math::Matrix< T >::operator-= ( const Matrix< T > &   ) 

Subtracts a matrix.

template<class T>
Matrix<T> gridripper::math::Matrix< T >::operator/ (  )  const

Divides the matrix by a scalar.

template<class T>
Matrix<T>& gridripper::math::Matrix< T >::operator/= (  ) 

Divides by a scalar.

template<class T>
Matrix<T>& gridripper::math::Matrix< T >::operator= ( const Matrix< T > &   ) 

Copies another matrix onto this matrix.

template<class T>
bool gridripper::math::Matrix< T >::operator== ( const Matrix< T > &   )  const

Tests whether two matrices are equal.

template<class T>
T& gridripper::math::Matrix< T >::operator[] ( int  i  )  [inline]

Gets a reference to an element.

Parameters:
i element index, it must be less than the total number of elements (numRows*numColumns)
template<class T>
T gridripper::math::Matrix< T >::operator[] ( int  i  )  const [inline]

Gets an element.

Parameters:
i element index, it must be less than the total number of elements (numRows*numColumns)
template<class T>
Matrix<T> gridripper::math::Matrix< T >::operator^ ( int   )  const

Calculates an integer power of the matrix.

template<class T>
Matrix<T>& gridripper::math::Matrix< T >::operator^= ( int   ) 

Calculates an integer power.

template<class T>
Matrix<T> gridripper::math::Matrix< T >::operator~ (  )  const

Returns the transpose of this matrix.

template<class T>
void gridripper::math::Matrix< T >::setIdentity (  ) 

Sets the diagonal elements to 1, all other elements to zero.

template<class T>
virtual void gridripper::math::Matrix< T >::setSize ( int  rows,
int  columns 
) [virtual]

Changes the size dynamically.

template<class T>
void gridripper::math::Matrix< T >::setZero (  ) 

Sets all the values in this matrix to zero.

template<class T>
void gridripper::math::Matrix< T >::swapRows ( int  i,
int  j 
)

Swaps two rows.

template<class T>
T gridripper::math::Matrix< T >::trace (  )  const

Returns the trace.


Friends And Related Function Documentation

template<class T>
template<class T2 >
Matrix<T2> operator* ( T2  s,
const Matrix< T2 > &  A 
) [friend]

Multiplies a scalar by a matrix.

template<class T>
template<class T2 >
MVector<T2> operator* ( const MVector< T2 > &  ,
const Matrix< T2 > &   
) [friend]

Multiplies the matrix by a scalar.

template<class T>
template<class T2 >
MVector<T2> operator/ ( const MVector< T2 > &  ,
const Matrix< T2 > &   
) [friend]

Solve linear system of equations.

template<class T>
template<class T2 >
std::ostream& operator<< ( std::ostream &  ,
const Matrix< T2 > &   
) [friend]

Writes a matrix into a stream.

template<class T>
template<class T2 >
std::istream& operator>> ( std::istream &  ,
Matrix< T2 > &   
) [friend]

Reads a matrix from a stream.


Member Data Documentation

template<class T>
int gridripper::math::Matrix< T >::numColumns [protected]

Number of columns.

template<class T>
int gridripper::math::Matrix< T >::numRows [protected]

Number of rows.

template<class T>
T* gridripper::math::Matrix< T >::x [protected]

Array of matrix components.


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