Loading [MathJax]/extensions/tex2jax.js
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 >:

Public Member Functions

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

Private Attributes

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

Friends

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.
 
template<typename U>
void cholesky (const Matrix< U > &, Matrix< U > &)
 Do a cholesky decomposition of a matrix.
 
template<typename U>
int diagMat (const Matrix< U > &, std::vector< double > &, Matrix< double > &)
 Diagonalize a symmetric matrix - returns zero if diagonalization worked.
 
template<typename U>
int Invert (const Matrix< U > &, Matrix< double > &)
 Invert a matrix (works for both symmetric and asymmetric matrices) - returns zero if sucesfull.
 
template<typename U>
int logdet (const Matrix< U > &, double &)
 Calculate the logarithm of the determinant of a symmetric matrix - returns zero if succesfull.
 
template<typename U>
void matrixOut (Log &, const Matrix< U > &)
 Output the Matrix in matrix form.
 
template<typename U>
void mult (const Matrix< U > &, const Matrix< U > &, Matrix< U > &)
 Matrix matrix multiply.
 
template<typename U>
void mult (const Matrix< U > &, const std::vector< U > &, std::vector< U > &)
 Matrix times a std::vector.
 
template<typename U>
void mult (const std::vector< U > &, const Matrix< U > &, std::vector< U > &)
 std::vector times a Matrix
 
template<typename U>
Matrix< U > operator* (U &, const Matrix< U > &)
 Multiply matrix by scalar.
 
template<typename U>
Logoperator<< (Log &, const Matrix< U > &)
 Output the entire matrix on a single line.
 
template<typename U>
int pseudoInvert (const Matrix< U > &, Matrix< double > &)
 Calculate the Moore-Penrose Pseudoinverse of a matrix.
 
template<typename U>
void transpose (const Matrix< U > &, Matrix< U > &)
 Matrix transpose.
 

Detailed Description

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

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

Constructor & Destructor Documentation

◆ Matrix() [1/2]

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

◆ Matrix() [2/2]

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

Member Function Documentation

◆ getVector()

template<typename T>
std::vector< T > & PLMD::Matrix< T >::getVector ( )
inline

Return the contents of the matrix as a vector of length rw*cl.

◆ isSymmetric()

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

Test if the matrix is symmetric or not.

◆ ncols()

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

Return the number of columns.

◆ nrows()

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

Return the number of rows.

◆ operator()() [1/2]

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.

◆ operator()() [2/2]

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

Return element i,j of the matrix.

◆ operator*=()

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

Multiply all elements by v.

◆ operator+=() [1/2]

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

Matrix addition.

◆ operator+=() [2/2]

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

Add v to all elements of the Matrix.

◆ operator-=() [1/2]

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

Matrix subtraction.

◆ operator-=() [2/2]

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

Subtract v from all elements of the Matrix.

◆ operator=() [1/3]

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

Set the Matrix equal to another Matrix.

◆ operator=() [2/3]

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.

◆ operator=() [3/3]

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.

◆ operator[]() [1/2]

MatrixSquareBracketsAccess< T, T, unsigned, unsigned >::Row PLMD::MatrixSquareBracketsAccess< T, T, unsigned, unsigned >::operator[] ( unsigned i)
inherited

access element (with [][] syntax)

◆ operator[]() [2/2]

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

access element (with [][] syntax)

◆ resize()

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

Resize the matrix.

◆ setFromVector()

template<typename T>
void PLMD::Matrix< T >::setFromVector ( const std::vector< T > & vecin)
inline

Set the matrix from a vector input.

Friends And Related Symbol Documentation

◆ chol_elsolve

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.

◆ cholesky

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

Do a cholesky decomposition of a matrix.

◆ diagMat

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.

◆ Invert

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

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

◆ logdet

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.

◆ matrixOut

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

Output the Matrix in matrix form.

◆ mult [1/3]

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

Matrix matrix multiply.

◆ mult [2/3]

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

Matrix times a std::vector.

◆ mult [3/3]

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

std::vector times a Matrix

◆ operator*

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

Multiply matrix by scalar.

◆ operator<<

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

Output the entire matrix on a single line.

◆ pseudoInvert

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

Calculate the Moore-Penrose Pseudoinverse of a matrix.

◆ transpose

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

Matrix transpose.

Member Data Documentation

◆ cl

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

Number of columns in matrix.

◆ data

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

The data in the matrix.

◆ rw

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

Number of rows in matrix.

◆ sz

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

Number of elements in matrix (nrows*ncols)


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