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

LA::Matrix Class Reference

Represents a nxm Matrix with entries of type double. More...

#include <LA_Matrix.h>

Collaboration diagram for LA::Matrix:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Matrix ()
 Standard constructor.

 Matrix (int rows, int columns)
 Constructs a nxm matrix and initializes all entries to 0.0.

 Matrix (int rows, int columns, const double *M)
 Constructs a nxm matrix and initializes the entries to the values in the passed array (row major).

 Matrix (const Matrix &M)
 Copy contructor.

 Matrix (const Matrix3x3< double > &M)
 Copy contructor.

virtual ~Matrix ()
 Destructor.

Matrixoperator= (const Matrix &M)
 Copy operator.

Matrixoperator= (const Matrix3x3< double > &M)
 Copy operator.

void create (int rows, int columns)
 Recreates this matrix as nxm matrix and initializes all values to 0.0.

void create (int rows, int columns, const double *M)
 Recreates this matrix as nxm matrix and initializes the entries to the values in the passed array (row major).

const Vectoroperator[] (int row) const
 Constant element access operator.

Vectoroperator[] (int row)
 Element access operator.

const Vectoroperator() (int row) const
 Constant element access operator.

Vectoroperator() (int row)
 Element access operator.

const double & operator() (int row, int column) const
 Constant element access operator.

double & operator() (int row, int column)
 Element access operator.

int rows () const
 Returns the number of rows (n).

int columns () const
 Returns the number of columns (m).

Vector get_row (int index) const
 Returns a row vector.

void set_row (int index, const Vector &v)
 Sets a row vector.

Vector get_column (int index) const
 Returns a column vector.

void set_column (int index, const Vector &v)
 Sets a column vector.

Matrix get_sub (int rowstart, int rowlength, int columnstart, int columnlength) const
 Retrieves a submatrix.

void set_sub (int rowstart, int columnstart, const Matrix &M)
 Sets a submatrix.

Matrixoperator+= (const Matrix &M)
 Adds a matrix to this matrix.

Matrixoperator-= (const Matrix &M)
 Subtracts a matrix from this matrix.

Matrixoperator *= (const Matrix &M)
 Multiplies this matrix with another matrix.

Matrixoperator *= (const double &s)
 Multiplies all entries of this matrix with the passed scalar.

Matrixoperator/= (const Matrix &M)
 Divides this matrix by the passed matrix (multiplies this matrix with the inverse of the passed matrix).

Matrixoperator/= (const double &s)
 Divides all entries of this matrix by the passed scalar.

void transpose ()
 Transposes the matrix.

Matrix transposition () const
 Returns the transposition of this matrix.

Matrix T () const
 Returns the transposition of this matrix.

void invert ()
 Inverts this matrix.

Matrix inverse () const
 Returns the inverse of this matrix.

Vector solve (const Vector &b)
 Solves the linear equation Ax=b where A is this matrix.

double det () const
 Returns the determinant of this matrix.

std::string asString () const
 Returns a human-readable representation of the matrix.


Static Public Member Functions

Matrix identity (int dim)
 Returns a nxn identity matrix.


Private Member Functions

void destroy ()

Private Attributes

int r
int c
Vectorcontent

Friends

Matrix operator+ (const Matrix &M1, const Matrix &M2)
 Adds to matrices.

Matrix operator- (const Matrix &M1, const Matrix &M2)
 Subtracts to matrices.

Matrix operator * (const Matrix &M1, const Matrix &M2)
 Multiplies to matrices.

Vector operator * (const Matrix &M, const Vector &v)
 Multiplies a matrix with a vector.

Matrix operator * (const Matrix &M, const double &s)
 Multiplies a matrix with a scalar.

Matrix operator * (const double &s, const Matrix &M)
 Multiplies a matrix with a scalar.

Matrix operator/ (const Matrix &M, const double &s)
 Divides a matrix by a scalar.

Matrix operator/ (const Matrix &M1, const Matrix &M2)
 Divides a matrix by another matrix (same as multiplying with the inverse).

Matrix transpose (const Matrix &M)
 Returns the transposition of a matrix.

Matrix invert (const Matrix &M)
 Returns the inverse of a matrix.

Matrix inv (const Matrix &M)
 Returns the inverse of a matrix.

double det (const Matrix &M)
 Returns the determinant of a matrix.

Outoperator<< (Out &stream, const Matrix &M)
 Out operator for GT-streams.

Inoperator>> (In &stream, Matrix &M)
 In operator for GT-streams.


Detailed Description

Represents a nxm Matrix with entries of type double.

Author:
Stefan Uhrig

Definition at line 28 of file LA_Matrix.h.


Constructor & Destructor Documentation

LA::Matrix::Matrix  ) 
 

Standard constructor.

Contructs an empty matrix.

Definition at line 14 of file LA_Matrix.cpp.

LA::Matrix::Matrix int  rows,
int  columns
 

Constructs a nxm matrix and initializes all entries to 0.0.

Parameters:
rows Number of rows (n)
columns Number of columns (m)

Definition at line 18 of file LA_Matrix.cpp.

References create().

Here is the call graph for this function:

LA::Matrix::Matrix int  rows,
int  columns,
const double *  M
 

Constructs a nxm matrix and initializes the entries to the values in the passed array (row major).

Parameters:
rows Number of rows (n)
columns Number of columns (m)
M Array with values that are used to initialize the matrix.

Definition at line 23 of file LA_Matrix.cpp.

References create().

Here is the call graph for this function:

LA::Matrix::Matrix const Matrix M  ) 
 

Copy contructor.

Parameters:
M Matrix to copy.
Returns:
Reference to this matrix.

Definition at line 29 of file LA_Matrix.cpp.

LA::Matrix::Matrix const Matrix3x3< double > &  M  ) 
 

Copy contructor.

Parameters:
M Matrix to copy.
Returns:
Reference to this matrix.

Definition at line 35 of file LA_Matrix.cpp.

LA::Matrix::~Matrix  )  [virtual]
 

Destructor.

Definition at line 49 of file LA_Matrix.cpp.

References destroy().

Here is the call graph for this function:


Member Function Documentation

Matrix LA::Matrix::identity int  dim  )  [static]
 

Returns a nxn identity matrix.

Parameters:
dim Dimension of matrix (n).
Returns:
Identity matrix.

Definition at line 41 of file LA_Matrix.cpp.

Matrix & LA::Matrix::operator= const Matrix M  ) 
 

Copy operator.

Parameters:
M Matrix to copy.
Returns:
Reference to this matrix.

Definition at line 54 of file LA_Matrix.cpp.

References c, content, create(), and r.

Here is the call graph for this function:

Matrix & LA::Matrix::operator= const Matrix3x3< double > &  M  ) 
 

Copy operator.

Parameters:
M Matrix3x3 to copy.
Returns:
Reference to this matrix.

Definition at line 62 of file LA_Matrix.cpp.

References Matrix3x3< V >::c, content, and create().

Here is the call graph for this function:

void LA::Matrix::create int  rows,
int  columns
 

Recreates this matrix as nxm matrix and initializes all values to 0.0.

Parameters:
rows Number of rows (n).
columns Number of columns (m).

Definition at line 74 of file LA_Matrix.cpp.

References content, and destroy().

Referenced by LA::Eigenvalues::Eigenvalues(), Matrix(), operator=(), and LA::operator>>().

Here is the call graph for this function:

void LA::Matrix::create int  rows,
int  columns,
const double *  M
 

Recreates this matrix as nxm matrix and initializes the entries to the values in the passed array (row major).

Parameters:
rows Number of rows (n).
columns Number of columns (m).
M Array with values that are used to initialize the matrix.

Definition at line 87 of file LA_Matrix.cpp.

References content, and destroy().

Here is the call graph for this function:

const Vector & LA::Matrix::operator[] int  row  )  const
 

Constant element access operator.

Parameters:
row Index of row (zero-based).
Returns:
Constant reference to appropriate row vector.

Definition at line 104 of file LA_Matrix.cpp.

References content.

Vector & LA::Matrix::operator[] int  row  ) 
 

Element access operator.

Parameters:
row Index of row (zero-based).
Returns:
Reference to appropriate row vector.

Definition at line 110 of file LA_Matrix.cpp.

References content.

const Vector & LA::Matrix::operator() int  row  )  const
 

Constant element access operator.

Parameters:
row Index of row (one-based).
Returns:
Constant reference to appropriate row vector.

Definition at line 116 of file LA_Matrix.cpp.

References content.

Vector & LA::Matrix::operator() int  row  ) 
 

Element access operator.

Parameters:
row Index of row (one-based).
Returns:
Reference to appropriate row vector.

Definition at line 122 of file LA_Matrix.cpp.

References content.

const double & LA::Matrix::operator() int  row,
int  column
const
 

Constant element access operator.

Parameters:
row Index of row (one-based).
column Index of column (one-based).
Returns:
Constant reference to appropriate entry.

Definition at line 128 of file LA_Matrix.cpp.

References LA::Vector::content, and content.

double & LA::Matrix::operator() int  row,
int  column
 

Element access operator.

Parameters:
row Index of row (one-based).
column Index of column (one-based).
Returns:
Reference to appropriate entry.

Definition at line 135 of file LA_Matrix.cpp.

References LA::Vector::content, and content.

int LA::Matrix::rows  )  const
 

Returns the number of rows (n).

Returns:
Number of rows (n).

Definition at line 142 of file LA_Matrix.cpp.

Referenced by LA::operator<<().

int LA::Matrix::columns  )  const
 

Returns the number of columns (m).

Returns:
Number of columns (m).

Definition at line 147 of file LA_Matrix.cpp.

Referenced by LA::Eigenvalues::Eigenvalues(), and LA::operator<<().

Vector LA::Matrix::get_row int  index  )  const
 

Returns a row vector.

Parameters:
index Index of row (one-based).
Returns:
Row vector with specified index.

Definition at line 152 of file LA_Matrix.cpp.

References content.

void LA::Matrix::set_row int  index,
const Vector v
 

Sets a row vector.

Parameters:
index Index of row (one-based).
v Vector the row is set to.

Definition at line 158 of file LA_Matrix.cpp.

References content, and LA::Vector::n.

Vector LA::Matrix::get_column int  index  )  const
 

Returns a column vector.

Parameters:
index Index of column (one-based).
Returns:
Column vector with specified index.

Definition at line 165 of file LA_Matrix.cpp.

References content.

void LA::Matrix::set_column int  index,
const Vector v
 

Sets a column vector.

Parameters:
index Index of column (one-based).
v Vector the column is set to.

Definition at line 175 of file LA_Matrix.cpp.

References LA::Vector::content, content, and LA::Vector::n.

Referenced by LA::LU::inverse().

Matrix LA::Matrix::get_sub int  rowstart,
int  rowlength,
int  columnstart,
int  columnlength
const
 

Retrieves a submatrix.

Parameters:
rowstart The index of the row where to start (one-based).
rowlength The number of rows to extract.
columnstart The index of the column where to start (one-based).
columnlength The number of columns to extract.
Returns:
The appropriate submatrix.

Definition at line 184 of file LA_Matrix.cpp.

References content, and LA::Vector::sub().

Here is the call graph for this function:

void LA::Matrix::set_sub int  rowstart,
int  columnstart,
const Matrix M
 

Sets a submatrix.

Parameters:
rowstart The row where to start
columnstart The column where to start
M The submatrix to set.

Definition at line 197 of file LA_Matrix.cpp.

References c, content, r, and LA::Vector::set_sub().

Here is the call graph for this function:

Matrix & LA::Matrix::operator+= const Matrix M  ) 
 

Adds a matrix to this matrix.

Parameters:
M Matrix to add.
Returns:
Reference to this matrix.

Definition at line 206 of file LA_Matrix.cpp.

References c, content, and r.

Matrix & LA::Matrix::operator-= const Matrix M  ) 
 

Subtracts a matrix from this matrix.

Parameters:
M Matrix to subtract.
Returns:
Reference to this matrix.

Definition at line 214 of file LA_Matrix.cpp.

References c, content, and r.

Matrix & LA::Matrix::operator *= const Matrix M  ) 
 

Multiplies this matrix with another matrix.

Parameters:
M Matrix to multiply this matrix with.
Returns:
Reference to this matrix.

Definition at line 222 of file LA_Matrix.cpp.

Matrix & LA::Matrix::operator *= const double &  s  ) 
 

Multiplies all entries of this matrix with the passed scalar.

Parameters:
s Scalar to multiply this matrix with.
Returns:
Reference to this matrix.

Definition at line 228 of file LA_Matrix.cpp.

References content.

Matrix & LA::Matrix::operator/= const Matrix M  ) 
 

Divides this matrix by the passed matrix (multiplies this matrix with the inverse of the passed matrix).

Parameters:
M Matrix to divide this matrix by.
Returns:
Reference to this matrix.

Definition at line 235 of file LA_Matrix.cpp.

References LA::invert().

Here is the call graph for this function:

Matrix & LA::Matrix::operator/= const double &  s  ) 
 

Divides all entries of this matrix by the passed scalar.

Parameters:
s Scalar to divide this matrix by.
Returns:
Reference to this matrix.

Definition at line 241 of file LA_Matrix.cpp.

References content.

void LA::Matrix::transpose  ) 
 

Transposes the matrix.

Definition at line 248 of file LA_Matrix.cpp.

References LA::Vector::content, and content.

Referenced by LA::transpose(), and transposition().

Matrix LA::Matrix::transposition  )  const
 

Returns the transposition of this matrix.

Returns:
Transposition of this matrix.

Definition at line 261 of file LA_Matrix.cpp.

References transpose().

Referenced by T().

Here is the call graph for this function:

Matrix LA::Matrix::T  )  const
 

Returns the transposition of this matrix.

Returns:
Transposition of this matrix.

Definition at line 268 of file LA_Matrix.cpp.

References transposition().

Here is the call graph for this function:

void LA::Matrix::invert  ) 
 

Inverts this matrix.

Definition at line 273 of file LA_Matrix.cpp.

References LA::LU::inverse().

Referenced by LA::inv(), and LA::invert().

Here is the call graph for this function:

Matrix LA::Matrix::inverse  )  const
 

Returns the inverse of this matrix.

Returns:
Inverse of this matrix.

Definition at line 281 of file LA_Matrix.cpp.

References LA::invert().

Here is the call graph for this function:

Vector LA::Matrix::solve const Vector b  ) 
 

Solves the linear equation Ax=b where A is this matrix.

Parameters:
b A vector.
Returns:
The solution vector x.

Definition at line 286 of file LA_Matrix.cpp.

References LA::Vector::n, and LA::LU::solve().

Referenced by interpol::SplineInterpolation::CalcSplines().

Here is the call graph for this function:

double LA::Matrix::det  )  const
 

Returns the determinant of this matrix.

Returns:
The determinant of this matrix.

Definition at line 295 of file LA_Matrix.cpp.

References LA::LU::det().

Referenced by LA::det().

Here is the call graph for this function:

std::string LA::Matrix::asString  )  const
 

Returns a human-readable representation of the matrix.

Returns:
Human-readable representation of the matrix.

Definition at line 303 of file LA_Matrix.cpp.

void LA::Matrix::destroy  )  [private]
 

Definition at line 310 of file LA_Matrix.cpp.

References content.

Referenced by create(), and ~Matrix().


Friends And Related Function Documentation

Matrix operator+ const Matrix M1,
const Matrix M2
[friend]
 

Adds to matrices.

Parameters:
M1 First matrix.
M2 Second matrix.
Returns:
M1 + M2.

Definition at line 319 of file LA_Matrix.cpp.

Matrix operator- const Matrix M1,
const Matrix M2
[friend]
 

Subtracts to matrices.

Parameters:
M1 First matrix.
M2 Second matrix.
Returns:
M1 - M2.

Definition at line 326 of file LA_Matrix.cpp.

Matrix operator * const Matrix M1,
const Matrix M2
[friend]
 

Multiplies to matrices.

Parameters:
M1 First matrix.
M2 Second matrix.
Returns:
M1*M2.

Definition at line 333 of file LA_Matrix.cpp.

Vector operator * const Matrix M,
const Vector v
[friend]
 

Multiplies a matrix with a vector.

Parameters:
M A matrix.
v A vector.
Returns:
M*v.

Definition at line 353 of file LA_Matrix.cpp.

Matrix operator * const Matrix M,
const double &  s
[friend]
 

Multiplies a matrix with a scalar.

Parameters:
M Matrix.
s Scalar.
Returns:
M*s.

Definition at line 369 of file LA_Matrix.cpp.

Matrix operator * const double &  s,
const Matrix M
[friend]
 

Multiplies a matrix with a scalar.

Parameters:
s Scalar.
M Matrix.
Returns:
s*M.

Definition at line 376 of file LA_Matrix.cpp.

Matrix operator/ const Matrix M,
const double &  s
[friend]
 

Divides a matrix by a scalar.

Parameters:
M Matrix.
s Scalar.
Returns:
M/s.

Definition at line 383 of file LA_Matrix.cpp.

Matrix operator/ const Matrix M1,
const Matrix M2
[friend]
 

Divides a matrix by another matrix (same as multiplying with the inverse).

Parameters:
M1 First matrix.
M2 Second matrix.
Returns:
M1/M2 (M1*inv(M2))

Definition at line 390 of file LA_Matrix.cpp.

Matrix transpose const Matrix M  )  [friend]
 

Returns the transposition of a matrix.

Parameters:
M Matrix.
Returns:
Transposition of matrix.

Definition at line 395 of file LA_Matrix.cpp.

Matrix invert const Matrix M  )  [friend]
 

Returns the inverse of a matrix.

Parameters:
M Matrix.
Returns:
Inverse of matrix.

Definition at line 402 of file LA_Matrix.cpp.

Matrix inv const Matrix M  )  [friend]
 

Returns the inverse of a matrix.

Parameters:
M Matrix.
Returns:
Inverse of matrix.

Definition at line 409 of file LA_Matrix.cpp.

double det const Matrix M  )  [friend]
 

Returns the determinant of a matrix.

Parameters:
M Matrix.
Returns:
Determinant of matrix.

Definition at line 416 of file LA_Matrix.cpp.

Out& operator<< Out stream,
const Matrix M
[friend]
 

Out operator for GT-streams.

Parameters:
stream Out-stream.
v Vector to output.
Returns:
Reference to passed Out-stream.

Definition at line 435 of file LA_Matrix.cpp.

In& operator>> In stream,
Matrix M
[friend]
 

In operator for GT-streams.

Parameters:
stream In-stream.
v Vector to read to.
Returns:
Reference to passed In-stream.

Definition at line 445 of file LA_Matrix.cpp.


Member Data Documentation

int LA::Matrix::r [private]
 

Definition at line 306 of file LA_Matrix.h.

Referenced by LA::operator *(), operator+=(), operator-=(), LA::operator<<(), operator=(), and set_sub().

int LA::Matrix::c [private]
 

Definition at line 307 of file LA_Matrix.h.

Referenced by LA::operator *(), operator+=(), operator-=(), LA::operator<<(), operator=(), and set_sub().

Vector* LA::Matrix::content [private]
 

Definition at line 308 of file LA_Matrix.h.

Referenced by create(), destroy(), get_column(), get_row(), get_sub(), LA::operator *(), operator *=(), operator()(), operator+=(), operator-=(), operator/=(), LA::operator<<(), operator=(), LA::operator>>(), operator[](), set_column(), set_row(), set_sub(), and transpose().


The documentation for this class was generated from the following files:
Generated on Mon Mar 20 22:24:12 2006 for GT2005 by doxygen 1.3.6