All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | Private Attributes | Friends | List of all members
PLMD::Matrix< T > Class Template Reference

This class stores a full matrix and allows one to do some simple matrix operations. More...

#include <Matrix.h>

Inheritance diagram for PLMD::Matrix< T >:
Inheritance graph
[legend]

Public Member Functions

 Matrix (const unsigned nr=0, const unsigned nc=0)
 
 Matrix (const Matrix< T > &t)
 
void resize (const unsigned nr, const unsigned nc)
 Resize the matrix. More...
 
unsigned nrows () const
 Return the number of rows. More...
 
unsigned ncols () const
 Return the number of columns. More...
 
operator() (const unsigned &i, const unsigned &j) const
 Return element i,j of the matrix. More...
 
T & operator() (const unsigned &i, const unsigned &j)
 Return a referenre to element i,j of the matrix. More...
 
Matrix< T > & operator= (const T &v)
 Set all elements of the matrix equal to the value of v. More...
 
Matrix< T > & operator= (const Matrix< T > &m)
 Set the Matrix equal to another Matrix. More...
 
Matrix< T > & operator= (const std::vector< T > &v)
 Set the Matrix equal to the value of a standard vector - used for readin. More...
 
Matrix< T > operator+= (const T &v)
 Add v to all elements of the Matrix. More...
 
Matrix< T > & operator+= (const Matrix< T > &m)
 Matrix addition. More...
 
Matrix< T > operator-= (const T &v)
 Subtract v from all elements of the Matrix. More...
 
Matrix< T > & operator-= (const Matrix< T > &m)
 Matrix subtraction. More...
 
unsigned isSymmetric () const
 Test if the matrix is symmetric or not. More...
 
Row operator[] (I i)
 access element (with [][] syntax) More...
 
Const_row operator[] (I i) const
 access element (with [][] syntax) More...
 

Private Attributes

unsigned sz
 Number of elements in matrix (nrows*ncols) More...
 
unsigned rw
 Number of rows in matrix. More...
 
unsigned cl
 Number of columns in matrix. More...
 
std::vector< T > data
 The data in the matrix. More...
 

Friends

template<typename U >
void mult (const Matrix< U > &, const Matrix< U > &, Matrix< U > &)
 Matrix matrix multiply. More...
 
template<typename U >
void mult (const Matrix< U > &, const std::vector< U > &, std::vector< U > &)
 Matrix times a std::vector. More...
 
template<typename U >
void mult (const std::vector< U > &, const Matrix< U > &, std::vector< U > &)
 std::vector times a Matrix More...
 
template<typename U >
void transpose (const Matrix< U > &, Matrix< U > &)
 Matrix transpose. More...
 
template<typename U >
Logoperator<< (Log &, const Matrix< U > &)
 Output the entire matrix on a single line. More...
 
template<typename U >
void matrixOut (Log &, const Matrix< U > &)
 Output the Matrix in matrix form. More...
 
template<typename U >
int diagMat (const Matrix< U > &, std::vector< double > &, Matrix< double > &)
 Diagonalize a symmetric matrix - returns zero if diagonalization worked. More...
 
template<typename U >
int logdet (const Matrix< U > &, double &)
 Calculate the logarithm of the determinant of a symmetric matrix - returns zero if succesfull. More...
 
template<typename U >
int Invert (const Matrix< U > &, Matrix< double > &)
 Invert a matrix (works for both symmetric and assymetric matrices) - returns zero if sucesfull. More...
 
template<typename U >
void cholesky (const Matrix< U > &, Matrix< U > &)
 Do a cholesky decomposition of a matrix. More...
 
template<typename U >
void chol_elsolve (const Matrix< U > &, const std::vector< U > &, std::vector< U > &)
 Solve a system of equations using the cholesky decomposition. More...
 

Detailed Description

template<typename T>
class PLMD::Matrix< T >

This class stores a full matrix and allows one to do some simple matrix operations.

Definition at line 68 of file Matrix.h.

Constructor & Destructor Documentation

template<typename T>
PLMD::Matrix< T >::Matrix ( const unsigned  nr = 0,
const unsigned  nc = 0 
)
inline

Definition at line 103 of file Matrix.h.

template<typename T>
PLMD::Matrix< T >::Matrix ( const Matrix< T > &  t)
inline

Definition at line 104 of file Matrix.h.

Member Function Documentation

template<typename T>
unsigned PLMD::Matrix< T >::isSymmetric ( ) const
inline

Test if the matrix is symmetric or not.

Definition at line 157 of file Matrix.h.

template<typename T>
unsigned PLMD::Matrix< T >::ncols ( ) const
inline

Return the number of columns.

Definition at line 110 of file Matrix.h.

template<typename T>
unsigned PLMD::Matrix< T >::nrows ( ) const
inline

Return the number of rows.

Definition at line 108 of file Matrix.h.

template<typename T>
T PLMD::Matrix< T >::operator() ( const unsigned &  i,
const unsigned &  j 
) const
inline

Return element i,j of the matrix.

Definition at line 112 of file Matrix.h.

template<typename T>
T& PLMD::Matrix< T >::operator() ( const unsigned &  i,
const unsigned &  j 
)
inline

Return a referenre to element i,j of the matrix.

Definition at line 114 of file Matrix.h.

template<typename T>
Matrix<T> PLMD::Matrix< T >::operator+= ( const T &  v)
inline

Add v to all elements of the Matrix.

Definition at line 135 of file Matrix.h.

template<typename T>
Matrix<T>& PLMD::Matrix< T >::operator+= ( const Matrix< T > &  m)
inline

Matrix addition.

Definition at line 140 of file Matrix.h.

template<typename T>
Matrix<T> PLMD::Matrix< T >::operator-= ( const T &  v)
inline

Subtract v from all elements of the Matrix.

Definition at line 146 of file Matrix.h.

template<typename T>
Matrix<T>& PLMD::Matrix< T >::operator-= ( const Matrix< T > &  m)
inline

Matrix subtraction.

Definition at line 151 of file Matrix.h.

template<typename T>
Matrix<T>& PLMD::Matrix< T >::operator= ( const T &  v)
inline

Set all elements of the matrix equal to the value of v.

Definition at line 116 of file Matrix.h.

template<typename T>
Matrix<T>& PLMD::Matrix< T >::operator= ( const Matrix< T > &  m)
inline

Set the Matrix equal to another Matrix.

Definition at line 121 of file Matrix.h.

template<typename T>
Matrix<T>& PLMD::Matrix< T >::operator= ( const std::vector< T > &  v)
inline

Set the Matrix equal to the value of a standard vector - used for readin.

Definition at line 129 of file Matrix.h.

Row PLMD::MatrixSquareBracketsAccess< Matrix< T > , T , I, J >::operator[] ( i)
inherited

access element (with [][] syntax)

Const_row PLMD::MatrixSquareBracketsAccess< Matrix< T > , T , I, J >::operator[] ( i) const
inherited

access element (with [][] syntax)

template<typename T>
void PLMD::Matrix< T >::resize ( const unsigned  nr,
const unsigned  nc 
)
inline

Resize the matrix.

Definition at line 106 of file Matrix.h.

Friends And Related Function Documentation

template<typename T>
template<typename U >
void chol_elsolve ( const Matrix< U > &  ,
const std::vector< U > &  ,
std::vector< U > &   
)
friend

Solve a system of equations using the cholesky decomposition.

template<typename T>
template<typename U >
void cholesky ( const Matrix< U > &  ,
Matrix< U > &   
)
friend

Do a cholesky decomposition of a matrix.

template<typename T>
template<typename U >
int diagMat ( const Matrix< U > &  ,
std::vector< double > &  ,
Matrix< double > &   
)
friend

Diagonalize a symmetric matrix - returns zero if diagonalization worked.

template<typename T>
template<typename U >
int Invert ( const Matrix< U > &  ,
Matrix< double > &   
)
friend

Invert a matrix (works for both symmetric and assymetric matrices) - returns zero if sucesfull.

template<typename T>
template<typename U >
int logdet ( const Matrix< U > &  ,
double &   
)
friend

Calculate the logarithm of the determinant of a symmetric matrix - returns zero if succesfull.

template<typename T>
template<typename U >
void matrixOut ( Log ,
const Matrix< U > &   
)
friend

Output the Matrix in matrix form.

template<typename T>
template<typename U >
void mult ( const Matrix< U > &  ,
const Matrix< U > &  ,
Matrix< U > &   
)
friend

Matrix matrix multiply.

template<typename T>
template<typename U >
void mult ( const Matrix< U > &  ,
const std::vector< U > &  ,
std::vector< U > &   
)
friend

Matrix times a std::vector.

template<typename T>
template<typename U >
void mult ( const std::vector< U > &  ,
const Matrix< U > &  ,
std::vector< U > &   
)
friend

std::vector times a Matrix

template<typename T>
template<typename U >
Log& operator<< ( Log ,
const Matrix< U > &   
)
friend

Output the entire matrix on a single line.

template<typename T>
template<typename U >
void transpose ( const Matrix< U > &  ,
Matrix< U > &   
)
friend

Matrix transpose.

Member Data Documentation

template<typename T>
unsigned PLMD::Matrix< T >::cl
private

Number of columns in matrix.

Definition at line 99 of file Matrix.h.

template<typename T>
std::vector<T> PLMD::Matrix< T >::data
private

The data in the matrix.

Definition at line 101 of file Matrix.h.

template<typename T>
unsigned PLMD::Matrix< T >::rw
private

Number of rows in matrix.

Definition at line 97 of file Matrix.h.

template<typename T>
unsigned PLMD::Matrix< T >::sz
private

Number of elements in matrix (nrows*ncols)

Definition at line 95 of file Matrix.h.


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