Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Examples

Matrix< Z > Class Template Reference

#include <matrix.h>

List of all members.

Public Member Functions

 Matrix (void)
 Matrix (unsigned int Rows, unsigned int Cols)
 Empty Constructor.
 Matrix (Z *elements, unsigned int Rows, unsigned int Cols)
 Initilizing constructor.
 Matrix (const Matrix &A)
 Assignment Constructor.
Matrixoperator= (const Matrix &C)
 Copy Constructor.
 ~Matrix ()
Z & operator() (unsigned int i, unsigned int j)
 Elementwise Access.
const Z & operator() (unsigned i, unsigned j) const
Matrixoperator+= (const Matrix &M)
 In place addition.
Matrixoperator-= (const Matrix &M)
 In place subtraction (see above).
Matrixoperator *= (Matrix M)
 In place multiplication.
template<typename S>
Matrixoperator *= (const S &s)
 In place scalar multiplication.
void dump (const char *filename)
 Dump matrix to filename.
void read (const char *filename)
 Read matrix from file created by dump(const char*).

Public Attributes

Z * A
 Pointer to the matrix elements.
unsigned int M
 Number of Rows.
unsigned int N
 Number of Columns.
Z * scratch
 Scratch space for working.

Friends

std::ostream & operator<< (std::ostream &, const Matrix &)
 Output operator.


Detailed Description

template<typename Z>
class Matrix< Z >

Matrix Class Takes any built in type or standard library types such as std::complex<double> as its template argument.
Examples:

example.cpp.


Constructor & Destructor Documentation

template<typename Z>
Matrix< Z >::Matrix void   )  [inline]
 

template<typename Z>
Matrix< Z >::Matrix unsigned int  Rows,
unsigned int  Cols
 

Empty Constructor.

Takes two arguments specifying the rows and columns

template<typename Z>
Matrix< Z >::Matrix Z *  elements,
unsigned int  Rows,
unsigned int  Cols
 

Initilizing constructor.

This takes an additional pointer to an initilizing array containing the matrix elements. For example

 int a[] = {1,2,3,4}; 
 Matrix<int> A(a,2,2); 

template<typename Z>
Matrix< Z >::Matrix const Matrix< Z > &  A  ) 
 

Assignment Constructor.

template<typename Z>
Matrix< Z >::~Matrix  ) 
 


Member Function Documentation

template<typename Z>
void Matrix< Z >::dump const char *  filename  ) 
 

Dump matrix to filename.

template<typename Z>
template<typename S>
Matrix< Z > & Matrix< Z >::operator *= const S &  s  ) 
 

In place scalar multiplication.

template<typename Z>
Matrix< Z > & Matrix< Z >::operator *= Matrix< Z >  M  ) 
 

In place multiplication.

template<typename Z>
const Z& Matrix< Z >::operator() unsigned  i,
unsigned  j
const [inline]
 

template<typename Z>
Z & Matrix< Z >::operator() unsigned int  i,
unsigned int  j
[inline]
 

Elementwise Access.

template<typename Z>
Matrix< Z > & Matrix< Z >::operator+= const Matrix< Z > &  M  ) 
 

In place addition.

This performs A = A+B. It is usually preferably to do addition like this when you're worried about performance as it doesn't require any temporary variables or copying of return values

template<typename Z>
Matrix< Z > & Matrix< Z >::operator-= const Matrix< Z > &  M  ) 
 

In place subtraction (see above).

template<typename Z>
Matrix< Z > & Matrix< Z >::operator= const Matrix< Z > &  C  ) 
 

Copy Constructor.

template<typename Z>
void Matrix< Z >::read const char *  filename  ) 
 

Read matrix from file created by dump(const char*).


Friends And Related Function Documentation

template<typename Z>
std::ostream& operator<< std::ostream &  output,
const Matrix< Z > &  A
[friend]
 

Output operator.


Member Data Documentation

template<typename Z>
Z* Matrix< Z >::A
 

Pointer to the matrix elements.

template<typename Z>
unsigned int Matrix< Z >::M
 

Number of Rows.

template<typename Z>
unsigned int Matrix< Z >::N
 

Number of Columns.

template<typename Z>
Z* Matrix< Z >::scratch
 

Scratch space for working.


The documentation for this class was generated from the following file:
Generated on Sun Jul 10 21:57:14 2005 by  doxygen 1.4.1