Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

Matrix Class Reference

A class for 2-dimensional matrices. More...

#include <Matrix.h>

List of all members.

Public Member Functions

 Matrix (int m, int n)
 Create a matrix Note that the elements of the matrix will be random, they have NOT been initialized to zero or any other value.

 Matrix (Matrix &M)
 Copy constructor.

 Matrix (Matrix *M)
 Similar to the copy constructor.

virtual ~Matrix ()
virtual void print ()
 Prints the matrix on the screen.

virtual realelementAt (int i, int j)
 Value of a given cell in the matrix.

virtual Matrixmultiply (Matrix &other)
 Multiplies the matrix with the given matrix and returns a new matrix.

virtual Matrixmultiply (Matrix *other)
 Multiplies the matrix with the given matrix and returns a new matrix.

virtual void multiply (real f)
 Multiplies the matrix with the scalar quantity provided.

virtual void swapRows (int i, int j)
 Swaps the ith and jth row of the matrix.

virtual Matrixtranspose ()
 Finds the transpose of the matrix You will have to deallocate the tranpose matrix with delete.

virtual Matrixinverse ()
 Finds the inverse of the matrix You will have to deallocate the inverse matrix with delete.


Static Public Member Functions

MatrixIdentity (int n)
 Returns the identity matrix of size nxn.


Friends

std::ostream & operator<< (std::ostream &s, Matrix &M)
 Prints matrix to the provided output stream.


Detailed Description

A class for 2-dimensional matrices.

This probably isn't the most efficient way to do matrix operations, use of optimized matrix libraries would be preferable, but this should suffice for most applications


Constructor & Destructor Documentation

Matrix int  m,
int  n
 

Create a matrix Note that the elements of the matrix will be random, they have NOT been initialized to zero or any other value.

Parameters:
m Number of rows
n Number of columns

Matrix Matrix M  ) 
 

Copy constructor.

Matrix Matrix M  ) 
 

Similar to the copy constructor.

virtual ~Matrix  )  [virtual]
 


Member Function Documentation

virtual real& elementAt int  i,
int  j
[virtual]
 

Value of a given cell in the matrix.

Parameters:
i The row in the matrix
j The column in the matrix
Returns:
Value of the element at the ith row and jth column

Matrix* Identity int  n  )  [static]
 

Returns the identity matrix of size nxn.

You will have to deallocate the identity matrix with delete

Parameters:
n The number of rows/columns in the matrix
Returns:
The square identity matrix of nxn

virtual Matrix* inverse  )  [virtual]
 

Finds the inverse of the matrix You will have to deallocate the inverse matrix with delete.

Uses the gaussian elmination technique to calculate the inverse

Returns:
A new matrix which is the inverse of this matrix
Exceptions:
Exception if the matrix is not invertible.

virtual void multiply real  f  )  [virtual]
 

Multiplies the matrix with the scalar quantity provided.

virtual Matrix* multiply Matrix other  )  [virtual]
 

Multiplies the matrix with the given matrix and returns a new matrix.

You will have to deallocate the product matrix with delete.

Parameters:
other The matrix to multiply with
Returns:
The product matrix
Exceptions:
Exception if the matrices cannot be multiplied

virtual Matrix* multiply Matrix other  )  [virtual]
 

Multiplies the matrix with the given matrix and returns a new matrix.

You will have to deallocate the product matrix with delete.

Parameters:
other The matrix to multiply with
Returns:
The product matrix
Exceptions:
Exception if the matrices cannot be multiplied

virtual void print  )  [virtual]
 

Prints the matrix on the screen.

virtual void swapRows int  i,
int  j
[virtual]
 

Swaps the ith and jth row of the matrix.

virtual Matrix* transpose  )  [virtual]
 

Finds the transpose of the matrix You will have to deallocate the tranpose matrix with delete.

Returns:
A new matrix which is the transpose of the current matrix


Friends And Related Function Documentation

std::ostream& operator<< std::ostream &  s,
Matrix M
[friend]
 

Prints matrix to the provided output stream.


The documentation for this class was generated from the following file:
Generated on Fri Jun 18 13:19:08 2004 for Annie by doxygen 1.3.5