CMatrix Class Reference
[Linear algebra library]

#include <matrix.h>

List of all members.

Public Member Functions

 CMatrix (const size_t &nrow=0, const size_t &ncol=0)
 CMatrix (const CMatrix &m)
 CMatrix (const CVector &v)
 ~CMatrix ()
CVector col (const size_t &) const
CMatrix crop (const size_t &nr, const size_t &nc, const size_t &nrz=0, const size_t &ncz=0) const
real det (void) const
CMatrix dev (const size_t &, const size_t &) const
CMatrix diag () const
size_t columns () const
size_t rows () const
CMatrix img (void) const
CMatrix inv (void) const
bool empty () const
CMatrix kern (const size_t &vsize) const
CVector row (size_t) const
CSubSpace solve (const CVector &) const
void swap_row (const size_t &, const size_t &)
void swap_col (const size_t &, const size_t &)
CMatrix transp (void) const
real & operator() (const size_t &row, const size_t &col)
real operator() (const size_t &row, const size_t &col) const
CMatrixoperator= (const CMatrix &)
bool operator== (const CMatrix &) const
bool operator!= (const CMatrix &) const
CMatrix operator- () const
CMatrix operator* (const CMatrix &) const
CVector operator* (const CVector &) const

Static Public Member Functions

static CMatrix id (const size_t &)
static CMatrix rnd (const size_t &, const size_t &)
static CMatrix rot3d (const size_t &, const real &)

Protected Member Functions

CMatrix gaussjordan (bool *is_inv=NULL, CMatrix *inv=NULL, soltype_t *soltype=NULL, CVector *bb=NULL, CMatrix *tkern=NULL) const

Protected Attributes

real * m_data
size_t m_nrow
size_t m_ncol


Detailed Description

Class for describing matrices.

Definition at line 35 of file matrix.h.


Constructor & Destructor Documentation

CMatrix::CMatrix ( const size_t &  nrow = 0,
const size_t &  ncol = 0 
) [inline]

Constructs a CMatrix with the given number of rows and columns.

Definition at line 49 of file matrix.h.

References empty(), m_data, m_ncol, and m_nrow.

Referenced by dev(), gaussjordan(), id(), inv(), and solve().

CMatrix::CMatrix ( const CMatrix m  )  [inline]

Copy constructor.

Definition at line 66 of file matrix.h.

References empty(), m_data, m_ncol, and m_nrow.

CMatrix::CMatrix ( const CVector v  )  [inline]

Returns the matrix corresponding to a vector

Definition at line 82 of file matrix.h.

References m_data, and m_nrow.

CMatrix::~CMatrix (  )  [inline]

The destructor.

Definition at line 99 of file matrix.h.

References empty(), and m_data.


Member Function Documentation

CMatrix CMatrix::id ( const size_t &  n  )  [static]

Returns the (square) identity matrix for a given dimension.

Parameters:
n the dimension of the identity matrix.

Definition at line 36 of file matrix.cpp.

References CMatrix().

Referenced by CSailDisp::CSailDisp(), gaussjordan(), kern(), and solve().

CMatrix CMatrix::rnd ( const size_t &  nrow,
const size_t &  ncol 
) [static]

Returns a random matrix of specified dimension.

Parameters:
nrow number of rows for the matrix
ncol number of columns for the matrix

Definition at line 50 of file matrix.cpp.

CMatrix CMatrix::rot3d ( const size_t &  axis,
const real &  angle 
) [static]

CVector CMatrix::col ( const size_t &  index  )  const

Extracts the vector for the specified column.

Parameters:
index the index of the column to return

Definition at line 94 of file matrix.cpp.

References m_data, m_ncol, and m_nrow.

Referenced by gaussjordan().

CMatrix CMatrix::crop ( const size_t &  nr,
const size_t &  nc,
const size_t &  nrz = 0,
const size_t &  ncz = 0 
) const

Extracts part of a CMatrix.

Parameters:
nr row to start at
nc column to start at
nrz number of rows to extract
ncz number of columns to extract

Definition at line 113 of file matrix.cpp.

References m_ncol, and m_nrow.

Referenced by gaussjordan().

real CMatrix::det ( void   )  const

Returns the determinant of a CMatrix. The matrix must be square!

Definition at line 139 of file matrix.cpp.

References det(), dev(), m_ncol, and m_nrow.

Referenced by det().

CMatrix CMatrix::dev ( const size_t &  i,
const size_t &  j 
) const

Returns a square Matrix with the specified rows and lines removed. The matrix must be square!

Parameters:
i the index of the row to remove
j the index of the column to remove

Definition at line 167 of file matrix.cpp.

References CMatrix(), empty(), m_ncol, and m_nrow.

Referenced by det().

CMatrix CMatrix::diag (  )  const [inline]

Diagonalises matrix. Currently this is implemented as a full pivot Gauss-Jordan diagonalisation.

Definition at line 119 of file matrix.h.

References gaussjordan().

Referenced by img().

size_t CMatrix::columns (  )  const [inline]

Accessor for the number of columns.

Definition at line 124 of file matrix.h.

References m_ncol.

Referenced by CSubSpace::CSubSpace().

size_t CMatrix::rows (  )  const [inline]

Accessor for the number of rows.

Definition at line 129 of file matrix.h.

References m_nrow.

Referenced by CSubSpace::CSubSpace(), CSubSpace::getdim(), and CSubSpace::intersect().

CMatrix CMatrix::img ( void   )  const

Returns the image space of the linear application associated with the matrix.

Definition at line 390 of file matrix.cpp.

References diag(), and transp().

CMatrix CMatrix::inv ( void   )  const

Inverts matrix by Gauss-Jordan method with full pivoting.

Definition at line 398 of file matrix.cpp.

References CMatrix(), empty(), gaussjordan(), m_ncol, and m_nrow.

bool CMatrix::empty (  )  const [inline]

Is the matrixan empty (0x0) matrix?

Definition at line 136 of file matrix.h.

References m_ncol, and m_nrow.

Referenced by CMatrix(), dev(), inv(), kern(), and ~CMatrix().

CMatrix CMatrix::kern ( const size_t &  vsize  )  const

Returns the kernel of the linear application. associated with the matrix.

Definition at line 420 of file matrix.cpp.

References empty(), gaussjordan(), and id().

Referenced by CSubSpace::CSubSpace().

CVector CMatrix::row ( size_t  index  )  const

Retrieves a row of the matrix in vector form.

Definition at line 436 of file matrix.cpp.

References m_data, m_ncol, and m_nrow.

CSubSpace CMatrix::solve ( const CVector b  )  const

Solves the linear equations system formed by the current matrix and a given right-hand side vector.

Parameters:
b the right-hand side values in the equation

Definition at line 453 of file matrix.cpp.

References CMatrix(), gaussjordan(), id(), and m_nrow.

void CMatrix::swap_row ( const size_t &  i1,
const size_t &  i2 
)

Swaps two rows of a matrix.

Definition at line 488 of file matrix.cpp.

References m_data, m_ncol, and m_nrow.

Referenced by gaussjordan().

void CMatrix::swap_col ( const size_t &  j1,
const size_t &  j2 
)

Swap two columns of a matrix.

Definition at line 510 of file matrix.cpp.

References m_data, m_ncol, and m_nrow.

Referenced by gaussjordan().

CMatrix CMatrix::transp ( void   )  const

Transposes ('tilts') matrix

Definition at line 532 of file matrix.cpp.

References m_data, m_ncol, and m_nrow.

Referenced by CSubSpace::CSubSpace(), and img().

real & CMatrix::operator() ( const size_t &  row,
const size_t &  col 
) [inline]

Returns the selected element of the matrix.

Definition at line 170 of file matrix.h.

References m_data, m_ncol, and m_nrow.

real CMatrix::operator() ( const size_t &  row,
const size_t &  col 
) const [inline]

Returns the selected element of the matrix.

Definition at line 183 of file matrix.h.

References m_data, m_ncol, and m_nrow.

CMatrix & CMatrix::operator= ( const CMatrix m  ) 

Performs an assignment.

Definition at line 552 of file matrix.cpp.

References m_data, m_ncol, and m_nrow.

bool CMatrix::operator== ( const CMatrix m  )  const

Tests two matrices for equality.

Definition at line 580 of file matrix.cpp.

References m_ncol, and m_nrow.

bool CMatrix::operator!= ( const CMatrix m  )  const

Tests two matrices for non-equality.

Definition at line 596 of file matrix.cpp.

CMatrix CMatrix::operator- (  )  const

Return the opposite of a matrix.

Definition at line 604 of file matrix.cpp.

References m_data, m_ncol, and m_nrow.

CMatrix CMatrix::operator* ( const CMatrix m2  )  const

Matrix product

Definition at line 615 of file matrix.cpp.

References m_data, m_ncol, and m_nrow.

CVector CMatrix::operator* ( const CVector v  )  const

Multiplies a matrix by a vector.

Definition at line 637 of file matrix.cpp.

References m_data, m_ncol, and m_nrow.

CMatrix CMatrix::gaussjordan ( bool *  is_inv = NULL,
CMatrix inv = NULL,
soltype_t *  soltype = NULL,
CVector bb = NULL,
CMatrix tkern = NULL 
) const [protected]

Diagonalises matrix by Gauss-Jordan method with full pivoting optionally returns the inverse matrix.

Definition at line 204 of file matrix.cpp.

References CMatrix(), col(), crop(), id(), m_ncol, m_nrow, swap_col(), and swap_row().

Referenced by diag(), inv(), kern(), and solve().


Member Data Documentation

real* CMatrix::m_data [protected]

the matrix's data

Definition at line 39 of file matrix.h.

Referenced by CMatrix(), col(), operator()(), operator*(), operator-(), operator=(), row(), swap_col(), swap_row(), transp(), and ~CMatrix().

size_t CMatrix::m_nrow [protected]

size_t CMatrix::m_ncol [protected]


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

Generated on Sun Mar 22 21:38:32 2009 for Sailcut CAD by  doxygen 1.5.6