| Bsoft 2.0.5 Bernard's software package

Classes | Public Member Functions | List of all members
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)
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)
void | fill (double v)
int | check_for_singularity ()
void | normalize ()
void | randomize ()
int | multiply_in_place (vector< double > &vec)
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)
| Computes all eigenvalues and eigenvectors of a real symmetric matrix. More...

## Detailed Description

Definition at line 21 of file Matrix.h.

## Constructor & Destructor Documentation

## ◆ Matrix() [1/4]

Matrix::Matrix | ( |  | ) |
| inline

Definition at line 40 of file Matrix.h.

## ◆ Matrix() [2/4]

Matrix::Matrix | ( | const Matrix & | mat | ) |
| inline

Definition at line 41 of file Matrix.h.

## ◆ Matrix() [3/4]

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

Definition at line 45 of file Matrix.h.

## ◆ Matrix() [4/4]

Matrix::Matrix | ( | Bstring & | filename | ) |
| inline

Definition at line 48 of file Matrix.h.

## ◆ ~Matrix()

Matrix::~Matrix | ( |  | ) |
| inline

Definition at line 93 of file Matrix.h.

## Member Function Documentation

## ◆ check_for_singularity()

int Matrix::check_for_singularity | ( |  | ) |
| inline

Definition at line 188 of file Matrix.h.

## ◆ columns()

long Matrix::columns | ( |  | ) |
| inline

Definition at line 154 of file Matrix.h.

## ◆ data()

double* Matrix::data | ( |  | ) |
| inline

Definition at line 111 of file Matrix.h.

## ◆ delete_row_column()

Matrix Matrix::delete_row_column | ( | long | rc | ) |
| inline

Definition at line 173 of file Matrix.h.

## ◆ determinant()

double Matrix::determinant | ( |  | ) |
| inline

Definition at line 247 of file Matrix.h.

## ◆ eigen_sort()

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

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.Sorts eigenvalues into descending order and rearranges matrix columns accordingly.

Parameters

  val | eigenvalues.

Returns
  void .

      The eigenvectors are in the columns.
      This method uses straight insertion.

  Reference: Press W.H. et al (1992) Numerical Recipes in C.

Definition at line 677 of file matrix.cpp.

## ◆ fill()

void Matrix::fill | ( | double | v | ) |
| inline

Definition at line 186 of file Matrix.h.

## ◆ 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.

Definition at line 421 of file matrix.cpp.

## ◆ jrotate()

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

Definition at line 394 of file matrix.cpp.

## ◆ 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.

Definition at line 78 of file matrix.cpp.

## ◆ LU_decomposition() [2/2]

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

Definition at line 254 of file Matrix.h.

## ◆ multiply_in_place()

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

Definition at line 49 of file matrix.cpp.

## ◆ normalize()

void Matrix::normalize | ( |  | ) |
| inline

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

Definition at line 202 of file Matrix.h.

## ◆ operator *()

Matrix Matrix::operator * | ( | Matrix & | mat | ) |
| inline

Definition at line 143 of file Matrix.h.

## ◆ operator-()

Matrix Matrix::operator- | ( |  | ) |
| inline

Definition at line 138 of file Matrix.h.

## ◆ operator=()

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

Definition at line 131 of file Matrix.h.

## ◆ operator[]()

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

Definition at line 126 of file Matrix.h.

## ◆ randomize()

void Matrix::randomize | ( |  | ) |
| inline

Definition at line 237 of file Matrix.h.

## ◆ rows()

long Matrix::rows | ( |  | ) |
| inline

Definition at line 153 of file Matrix.h.

## ◆ show_below_cutoff()

void Matrix::show_below_cutoff | ( | double | d | ) |
| inline

Definition at line 157 of file Matrix.h.

## ◆ 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.

Definition at line 177 of file matrix.cpp.

## ◆ singular_value_decomposition() [2/2]

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

Definition at line 265 of file Matrix.h.

## ◆ size()

long Matrix::size | ( |  | ) |
| inline

Definition at line 155 of file Matrix.h.

## ◆ swap_rows_columns()

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

Definition at line 167 of file Matrix.h.

## ◆ write()

void Matrix::write | ( | Bstring & | filename | ) |
| inline

Definition at line 95 of file Matrix.h.

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

- /Users/bernard/b20/bsoft/include/Matrix.h
- /Users/bernard/b20/bsoft/src/util/matrix.cpp