SynAPSE  0.6.0
Synergistic Analysis of Phase Space Evolution
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
Public Member Functions | Private Attributes
Matrix< T > Class Template Reference

Object that can host any type of data in an matrix arrangement. More...

#include <Matrix.hh>

Public Member Functions

 Matrix ()
 Default constructor, initilizes an empty matrix of dimension 0x0. More...
 
 Matrix (const size_t n)
 Square constructor, initializes an empty nxn square matrix. More...
 
 Matrix (const size_t m, const size_t n)
 Size constructor, initializes an empty mxn matrix. More...
 
 Matrix (const size_t m, const size_t n, const T &value)
 Constant constructor, initializes an mxn matrix filled with value. More...
 
 Matrix (const std::vector< T > &v)
 Column vector constructor, initializes an nx1 matrix filled with v. More...
 
 Matrix (const std::vector< std::vector< T >> &mat)
 Std constructor, sets the underlying std matrix. More...
 
 Matrix (const Matrix &mat)
 Copy constructor. More...
 
 ~Matrix ()
 Destructor. More...
 
Matrix & operator= (const Matrix &mat)
 Equality operator. More...
 
 operator bool () const
 Boolean operator. More...
 
bool operator! () const
 Boolean not operator. More...
 
Matrix operator- () const
 Overload the unary minus for matrix algebra. More...
 
Matrix operator+ (const Matrix &mat) const
 Overload the matrix sum. More...
 
void operator+= (const Matrix &mat)
 Overload the matrix sum. More...
 
Matrix operator- (const Matrix &mat) const
 Overload the matrix substraction. More...
 
void operator-= (const Matrix &mat)
 Overload the matrix substraction. More...
 
Matrix operator* (const Matrix &mat) const
 Overload the matrix product. More...
 
void operator*= (const Matrix &mat)
 Overload the matrix product equality. More...
 
Matrix operator* (const T &factor) const
 Overload the matrix product with a scalar. More...
 
void operator*= (const T &factor)
 Overload the matrix product with a scalar. More...
 
Vector< T > operator* (const Vector< T > &vec) const
 Overload the matrix product with a vector, returns a vector. More...
 
Matrix operator/ (const T &factor) const
 Overload the matrix ratio with a scalar. More...
 
void operator/= (const T &factor)
 Overload the matrix ratio with a scalar. More...
 
const std::vector< T > & operator[] (const size_t i) const
 Overload the subscript operator, return an std::vector row. More...
 
std::vector< T > & operator[] (const size_t i)
 Overload the subscript operator, return an std::vector row, allows mods. More...
 
T Cofactor (const size_t i, const size_t j) const
 Returns the ith-jth cofactor of the matrix. More...
 
Matrix< T > CofactorMatrix () const
 Returns the inverse of the matrix. More...
 
T Determinant () const
 Returns the deterimant of the matrix. More...
 
std::vector< T > Column (const size_t i) const
 Returns the i^th column of the matrix as a vector. More...
 
Matrix< T > EigenVectors (std::vector< T > &lambdas, const double eps=1e-6) const
 Returns the matrix of which the columns are the eigenvectors of the matrix. More...
 
void Fill (const T &value)
 Fills the matrix with a certain value. More...
 
void Identity ()
 Sets the matrix to an identity matrix. More...
 
Matrix< T > Inverse () const
 Returns the inverse of the matrix. More...
 
void Invert ()
 Inverts the matrix in place. More...
 
bool IsSymmetric () const
 Checks whether the matrix is symmetric or not. More...
 
const size_t Nrows () const
 Returns the number of rows. More...
 
const size_t Ncols () const
 Returns the number of columns. More...
 
void Print () const
 Print the matrix. More...
 
void RemoveColumn (const size_t i)
 Removes the i^th column of the matrix. More...
 
void RemoveRow (const size_t i)
 Removes the i^th row of the matrix. More...
 
void Resize (const size_t m, const size_t n)
 Resizes the matrix to chosen dimension. More...
 
const std::vector< T > & Row (const size_t i) const
 Returns the i^th row of the matrix as a vector. More...
 
std::vector< T > & Row (const size_t i)
 Returns the i^th row of the matrix as a vector, allows mods. More...
 
std::vector< T > Solve (const std::vector< T > &b) const
 Solves A*x=b, provided with b. More...
 
const std::vector< std::vector
< T > > & 
std () const
 Returns the underlying std vector. More...
 
Matrix< T > Transpose () const
 Returns the matrix transpose. More...
 

Private Attributes

std::vector< std::vector< T > > _mat
 Underlying std::vector<std::vector>> More...
 

Detailed Description

template<typename T>
class Matrix< T >

Object that can host any type of data in an matrix arrangement.

The class definition also contains a multitude of linear algrebra methods that are useful to work with matrices.

Constructor & Destructor Documentation

template<typename T >
Matrix< T >::Matrix ( )

Default constructor, initilizes an empty matrix of dimension 0x0.

template<typename T >
Matrix< T >::Matrix ( const size_t  n)

Square constructor, initializes an empty nxn square matrix.

template<typename T >
Matrix< T >::Matrix ( const size_t  m,
const size_t  n 
)

Size constructor, initializes an empty mxn matrix.

template<typename T>
Matrix< T >::Matrix ( const size_t  m,
const size_t  n,
const T &  value 
)

Constant constructor, initializes an mxn matrix filled with value.

template<typename T>
Matrix< T >::Matrix ( const std::vector< T > &  v)

Column vector constructor, initializes an nx1 matrix filled with v.

template<typename T>
Matrix< T >::Matrix ( const std::vector< std::vector< T >> &  mat)

Std constructor, sets the underlying std matrix.

template<typename T>
Matrix< T >::Matrix ( const Matrix< T > &  mat)

Copy constructor.

template<typename T >
Matrix< T >::~Matrix ( )

Destructor.

Member Function Documentation

template<typename T >
T Matrix< T >::Cofactor ( const size_t  i,
const size_t  j 
) const

Returns the ith-jth cofactor of the matrix.

Parameters
iRow index
jColumn index
Returns
Cofactor
template<typename T >
Matrix< T > Matrix< T >::CofactorMatrix ( ) const

Returns the inverse of the matrix.

Returns
Inverse matrix
template<typename T >
std::vector< T > Matrix< T >::Column ( const size_t  i) const

Returns the i^th column of the matrix as a vector.

Returns
i^th column as a vector
template<typename T >
T Matrix< T >::Determinant ( ) const

Returns the deterimant of the matrix.

Returns
Value of the determinant
template<typename T>
Matrix< T > Matrix< T >::EigenVectors ( std::vector< T > &  lambdas,
const double  eps = 1e-6 
) const

Returns the matrix of which the columns are the eigenvectors of the matrix.

Parameters
lambdasEigenvalues
epsPrecision criterion to stop the iteration
Returns
Matrix of eigenvectors
template<typename T>
void Matrix< T >::Fill ( const T &  value)

Fills the matrix with a certain value.

Parameters
valueValue to fill the matrix with
template<typename T >
void Matrix< T >::Identity ( )

Sets the matrix to an identity matrix.

template<typename T >
Matrix< T > Matrix< T >::Inverse ( ) const

Returns the inverse of the matrix.

Returns
Inverse matrix
template<typename T >
void Matrix< T >::Invert ( )

Inverts the matrix in place.

template<typename T >
bool Matrix< T >::IsSymmetric ( ) const

Checks whether the matrix is symmetric or not.

Returns
True is symmetric
template<typename T >
const size_t Matrix< T >::Ncols ( ) const

Returns the number of columns.

Returns
Number of columns
template<typename T >
const size_t Matrix< T >::Nrows ( ) const

Returns the number of rows.

Returns
Number of rows
template<typename T >
Matrix< T >::operator bool ( ) const
explicit

Boolean operator.

template<typename T >
bool Matrix< T >::operator! ( ) const

Boolean not operator.

template<typename T >
Matrix< T > Matrix< T >::operator* ( const Matrix< T > &  mat) const

Overload the matrix product.

template<typename T>
Matrix< T > Matrix< T >::operator* ( const T &  factor) const

Overload the matrix product with a scalar.

template<typename T>
Vector< T > Matrix< T >::operator* ( const Vector< T > &  vec) const

Overload the matrix product with a vector, returns a vector.

template<typename T >
void Matrix< T >::operator*= ( const Matrix< T > &  mat)

Overload the matrix product equality.

template<typename T>
void Matrix< T >::operator*= ( const T &  factor)

Overload the matrix product with a scalar.

template<typename T >
Matrix< T > Matrix< T >::operator+ ( const Matrix< T > &  mat) const

Overload the matrix sum.

template<typename T >
void Matrix< T >::operator+= ( const Matrix< T > &  mat)

Overload the matrix sum.

template<typename T >
Matrix< T > Matrix< T >::operator- ( ) const

Overload the unary minus for matrix algebra.

template<typename T >
Matrix< T > Matrix< T >::operator- ( const Matrix< T > &  mat) const

Overload the matrix substraction.

template<typename T >
void Matrix< T >::operator-= ( const Matrix< T > &  mat)

Overload the matrix substraction.

template<typename T>
Matrix< T > Matrix< T >::operator/ ( const T &  factor) const

Overload the matrix ratio with a scalar.

template<typename T>
void Matrix< T >::operator/= ( const T &  factor)

Overload the matrix ratio with a scalar.

template<typename T >
Matrix< T > & Matrix< T >::operator= ( const Matrix< T > &  mat)

Equality operator.

template<typename T >
const std::vector< T > & Matrix< T >::operator[] ( const size_t  i) const

Overload the subscript operator, return an std::vector row.

template<typename T >
std::vector< T > & Matrix< T >::operator[] ( const size_t  i)

Overload the subscript operator, return an std::vector row, allows mods.

template<typename T >
void Matrix< T >::Print ( ) const

Print the matrix.

template<typename T >
void Matrix< T >::RemoveColumn ( const size_t  i)

Removes the i^th column of the matrix.

template<typename T >
void Matrix< T >::RemoveRow ( const size_t  i)

Removes the i^th row of the matrix.

template<typename T >
void Matrix< T >::Resize ( const size_t  m,
const size_t  n 
)

Resizes the matrix to chosen dimension.

Parameters
mNumber of rows
nNumber of columns
template<typename T >
const std::vector< T > & Matrix< T >::Row ( const size_t  i) const

Returns the i^th row of the matrix as a vector.

Returns
i^th row as a vector
template<typename T >
std::vector< T > & Matrix< T >::Row ( const size_t  i)

Returns the i^th row of the matrix as a vector, allows mods.

Returns
i^th row as a vector
template<typename T>
std::vector< T > Matrix< T >::Solve ( const std::vector< T > &  b) const

Solves A*x=b, provided with b.

Returns
Vector solution x, optimized
template<typename T >
const std::vector< std::vector< T > > & Matrix< T >::std ( ) const

Returns the underlying std vector.

Returns
underlying std vector
template<typename T >
Matrix< T > Matrix< T >::Transpose ( ) const

Returns the matrix transpose.

Returns
The transpose of the matrix

Field Documentation

template<typename T>
std::vector<std::vector<T> > Matrix< T >::_mat
private

Underlying std::vector<std::vector>>


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