Bsoft 2.1.4
Bernard's software package
Matrix Class Reference

#include <Matrix.h>

Classes

class  Row
 

Public Member Functions

 Matrix ()
 
 Matrix (const Matrix &mat)
 
 Matrix (long rows, long cols)
 
 Matrix (Bstring &filename)
 
 ~Matrix ()
 
void write (Bstring &filename)
 
double * data ()
 
Row operator[] (long i)
 
Matrix operator= (const Matrix mat)
 
Matrix operator- ()
 
Matrix operator+= (Matrix mat)
 
Matrix operator+ (Matrix mat)
 
Matrix operator-= (Matrix mat)
 
Matrix operator- (Matrix mat)
 
Matrix operator*= (Matrix mat)
 
Matrix operator* (Matrix &mat)
 
vector< double > operator* (vector< double > &vec)
 
long rows ()
 
long columns ()
 
long size ()
 
void show_below_cutoff (double d)
 
void swap_rows_columns (long rc1, long rc2)
 
Matrix delete_row_column (long rc)
 
Matrix transpose () const
 
void fill (double v)
 
int check_for_singularity ()
 
void normalize ()
 
void randomize ()
 
int multiply_in_place (vector< double > &vec)
 Multiplies a matrix by a vector, modifiying the vector. More...
 
double determinant ()
 
double LU_decomposition ()
 Matrix inversion by LU decomposition. More...
 
double LU_decomposition (vector< double > &b)
 
double singular_value_decomposition ()
 Singular value decomposition of a matrix . More...
 
double singular_value_decomposition (vector< double > &b)
 
int jrotate (double s, double tau, long i, long j, long k, long l)
 
vector< double > jacobi_rotation ()
 Computes all eigenvalues and eigenvectors of a real symmetric matrix. More...
 
void eigen_sort (vector< double > &val)
 Sorts eigenvalues into descending order and rearranges matrix columns accordingly. More...
 

Constructor & Destructor Documentation

◆ Matrix() [1/4]

Matrix::Matrix ( )
inline

◆ Matrix() [2/4]

Matrix::Matrix ( const Matrix mat)
inline

◆ Matrix() [3/4]

Matrix::Matrix ( long  rows,
long  cols 
)
inline

◆ Matrix() [4/4]

Matrix::Matrix ( Bstring filename)
inline

◆ ~Matrix()

Matrix::~Matrix ( )
inline

Member Function Documentation

◆ check_for_singularity()

int Matrix::check_for_singularity ( )
inline

◆ columns()

long Matrix::columns ( )
inline

◆ data()

double * Matrix::data ( )
inline

◆ delete_row_column()

Matrix Matrix::delete_row_column ( long  rc)
inline

◆ determinant()

double Matrix::determinant ( )
inline

◆ eigen_sort()

void Matrix::eigen_sort ( vector< double > &  val)

Sorts eigenvalues into descending order and rearranges matrix columns accordingly.

Parameters
valeigenvalues.
The eigenvectors are in the columns.
This method uses straight insertion.
Reference: Press W.H. et al (1992) Numerical Recipes in C.

◆ fill()

void Matrix::fill ( double  v)
inline

◆ jacobi_rotation()

vector< double > Matrix::jacobi_rotation ( )

Computes all eigenvalues and eigenvectors of a real symmetric matrix.

Returns
double* val eigenvalues.

The eigenvectors are returned in the columns of the input matrix. Reference: Press W.H. et al (1992) Numerical Recipes in C.

◆ jrotate()

int Matrix::jrotate ( double  s,
double  tau,
long  i,
long  j,
long  k,
long  l 
)

◆ LU_decomposition() [1/2]

double Matrix::LU_decomposition ( )

Matrix inversion by LU decomposition.

Returns
double determinant.
This inverts matrix A by LU decomposition.
The matrix A must be square and is converted to and replaced by its inverse.
Note: The matrix is modified.
Reference: Press W.H. et al (1992) Numerical Recipes in C.

◆ LU_decomposition() [2/2]

double Matrix::LU_decomposition ( vector< double > &  b)
inline

◆ multiply_in_place()

int Matrix::multiply_in_place ( vector< double > &  vec)

Multiplies a matrix by a vector, modifiying the vector.

Parameters
&vecvector.
Returns
double determinant.

◆ normalize()

void Matrix::normalize ( )
inline

The rows and columns are alternatively iteratively normalized until the error is small enough.

◆ operator*() [1/2]

Matrix Matrix::operator* ( Matrix mat)
inline

◆ operator*() [2/2]

vector< double > Matrix::operator* ( vector< double > &  vec)
inline

◆ operator*=()

Matrix Matrix::operator*= ( Matrix  mat)
inline

◆ operator+()

Matrix Matrix::operator+ ( Matrix  mat)
inline

◆ operator+=()

Matrix Matrix::operator+= ( Matrix  mat)
inline

◆ operator-() [1/2]

Matrix Matrix::operator- ( )
inline

◆ operator-() [2/2]

Matrix Matrix::operator- ( Matrix  mat)
inline

◆ operator-=()

Matrix Matrix::operator-= ( Matrix  mat)
inline

◆ operator=()

Matrix Matrix::operator= ( const Matrix  mat)
inline

◆ operator[]()

Row Matrix::operator[] ( long  i)
inline

◆ randomize()

void Matrix::randomize ( )
inline

◆ rows()

long Matrix::rows ( )
inline

◆ show_below_cutoff()

void Matrix::show_below_cutoff ( double  d)
inline

◆ singular_value_decomposition() [1/2]

double Matrix::singular_value_decomposition ( )

Singular value decomposition of a matrix .

Returns
double* 0.

The matrix A is replaced by the matrix U. Reference: Press W.H. et al (1992) Numerical Recipes in C.

◆ singular_value_decomposition() [2/2]

double Matrix::singular_value_decomposition ( vector< double > &  b)
inline

◆ size()

long Matrix::size ( )
inline

◆ swap_rows_columns()

void Matrix::swap_rows_columns ( long  rc1,
long  rc2 
)
inline

◆ transpose()

Matrix Matrix::transpose ( ) const
inline

◆ write()

void Matrix::write ( Bstring filename)
inline

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