SMatrix Class Reference

SMatrix, square matrix class definition. More...

#include <SMatrix.h>

Inheritance diagram for SMatrix:
QOperator QAnnihilation QCreation QDisplacement QParity TensorQOperator

List of all members.

Public Member Functions

 SMatrix (int dim_i=1)
 Default initialisation, matrix dimension is dim_i, all elements are zero.
 SMatrix (int dim_i, complex< double > diag)
 Creates a diagonal matrix with dimension dim_i.
 SMatrix (int dim_i, const complex< double > *Mtab_i)
 Creates a matrix from array, read order from left to right.
 SMatrix (int dim_i, double *real, double *imag)
 Creates a matrix from real and imaginary arrays.
 SMatrix (const SMatrix &m)
 Constructor by copy.
 ~SMatrix ()
 Destructor.
int getdim () const
 Send matrix dimension (dim).
void redim (int ndim)
 Modify the matrix dimension.
void setdiag (complex< double > diag)
 Creates a diagonal matrix, which all elements = diag.
void setdiag (complex< double > *tab_diag)
 Transform the matrix in a diagonal matrix one, which all elements = array tab_diag.
void print (const char *option="") const
 Output matrix as C code, ONLY for matlab mexPrintf(), cout<<SMatrix instead.
void decompositionLU (SMatrix &L, SMatrix &U)
 LU decomposition.
void decompositionCholesky (SMatrix &L, SMatrix &U)
 Cholesky decomposition.
void SolveCrout (Ket b, Ket &x, SMatrix Lm, SMatrix Um)
 Solve linear system using Crout Method.
void SolveSOR (Ket b, Ket &x)
 Solve linear system using SOR Method.
void SolveGaussSeidel (Ket b, Ket &x)
 Solve linear system using Gauss Seidel Method.
complex< double > getdetformal () const
 Calculate the determinant (formal mode).
complex< double > getdet () const
 Calculate the determinant with LU decomposition.
complex< double > gettrace () const
 Calculate the matrix trace.
double getnorm () const
 Calculate the matrix norm.
double getmax (double a[], int n) const
 Get the maximum value.
SMatrix gettransposed () const
 Calculate the matrix transposed.
SMatrix gethermitiantransposed () const
 Calculate the conjugate transposed.
SMatrix getreducedmatrix (int row, int col) const
 Return a matrix without row i and column j.
SMatrix getinversedformal () const
 Calculate the inversed matrix (formal mode).
SMatrix getinversed () const
 Calculate the inversed matrix.
SMatrix getabsmatrix () const
 Return matrix with the abs of all elements.
SMatrix getexpm () const
 Calculate the matrix exponential using Pade algoritm (see Matlab for documentation).
complex< double > & operator() (int i, int j)
 Acces to matrix elements.
complex< double > operator() (int i, int j) const
 Read/Write matrix elements.
const SMatrixoperator= (const SMatrix &m)
 Affectation operator.
SMatrix operator+ (const SMatrix &m) const
 Addition operator.
SMatrix operator- (const SMatrix &m) const
 Soustraction operator.
SMatrix operator* (const SMatrix &m) const
 Multiplication operator.
SMatrix operator/ (const SMatrix &m) const
 Division operator.

Friends

EXPORTED_FUNCTION SMatrix operator* (complex< double > a, const SMatrix &m)
 Scalar complex - matrix multiplication.
EXPORTED_FUNCTION SMatrix operator* (double a, const SMatrix &m)
 Scalar double - matrix multiplication.
EXPORTED_FUNCTION SMatrix operator* (const SMatrix &m, complex< double > a)
 Matrix - scalar complex multiplication.
EXPORTED_FUNCTION SMatrix operator* (const SMatrix &m, double a)
 Matrix - scalar double multiplication.
EXPORTED_FUNCTION SMatrix operator* (complex< double > a, const SMatrix *m)
 Scalar complex - matrix pointer multiplication.
EXPORTED_FUNCTION SMatrix operator/ (const SMatrix &m, double a)
 Matrix - scalar double division.
EXPORTED_FUNCTION SMatrix operator/ (const SMatrix &m, complex< double > a)
 Matrix - scalar complex division.
EXPORTED_FUNCTION std::ostream & operator<< (std::ostream &out, const SMatrix &m)
 Write to a flux, allow cout<<matrix; .

Detailed Description

SMatrix, square matrix class definition.

SMatrix is the square matrix base class for linear algebra operations. This class is composed by basical matrix operations, like trace, determinant, etc... You can also find numerical methods like LU decomposition, direct and interactives methods to solve linear systems. This class provides a user friend interface for load, create and get information from matrices, this is the mother class of Quantum Operators (QOperator).


Constructor & Destructor Documentation

SMatrix::SMatrix ( int  dim_i = 1  ) 

Default initialisation, matrix dimension is dim_i, all elements are zero.

To create a matrix with all elements 0, you need to pass a valid dimension (dim_i > 0).

Parameters:
dim_i Matrix row = column dimension.
SMatrix::SMatrix ( int  dim_i,
complex< double >  diag 
)

Creates a diagonal matrix with dimension dim_i.

To create a diagonal matrix, you pass the matrix dimension and the non zero element that will be put in the diagonal.

Parameters:
dim_i Matrix row = column dimension.
diag Complex number with double precision that will be put in the diagonal.
SMatrix::SMatrix ( int  dim_i,
const complex< double > *  Mtab_i 
)

Creates a matrix from array, read order from left to right.

To create a matrix from a complex<double> array that contains matrix data, you pass the matrix dimension and the data array.

Parameters:
dim_i Matrix row = column dimension.
Mtab_i Complex double precision array with all data. The data is put from left to right, in other words we fix the row and change columns.
SMatrix::SMatrix ( int  dim_i,
double *  real,
double *  imag 
)

Creates a matrix from real and imaginary arrays.

SMatrix::SMatrix ( const SMatrix m  ) 

Constructor by copy.

Allow you to do that: SMatrix A(B), where B is a SMatrix.

Parameters:
m Matrix to be copied.
SMatrix::~SMatrix (  ) 

Destructor.

Destroy all matrix array elements.


Member Function Documentation

void SMatrix::decompositionCholesky ( SMatrix L,
SMatrix U 
)

Cholesky decomposition.

To elaborate a Cholesky decomposition, you need to pass the lower and upper matrices to be elaborated.

Parameters:
L Lower matrix
U Upper matrix
Returns:
Returns L and U with the correct data.
void SMatrix::decompositionLU ( SMatrix L,
SMatrix U 
)

LU decomposition.

To decompose your matrix into a lower and upper triangular matrix product, you pass to SMatrix L (lower), SMatrix U (upper).

Parameters:
L Lower matrix to be passed.
U Upper matrix to be passed.
Returns:
Returns L and U with the correct data.
SMatrix SMatrix::getabsmatrix (  )  const

Return matrix with the abs of all elements.

Returns:
Returns the matrix with all abs elements.
complex< double > SMatrix::getdet (  )  const

Calculate the determinant with LU decomposition.

Returns:
Returns the matrix determinant, using LU decomposition.
complex< double > SMatrix::getdetformal (  )  const

Calculate the determinant (formal mode).

Returns:
Returns the matrix determinant.
int SMatrix::getdim (  )  const [inline]

Send matrix dimension (dim).

SMatrix SMatrix::getexpm (  )  const

Calculate the matrix exponential using Pade algoritm (see Matlab for documentation).

Returns:
Returns the matrix exponential using Pade algorithm.
SMatrix SMatrix::gethermitiantransposed (  )  const

Calculate the conjugate transposed.

Returns:
Returns the transposed conjugate matrix.
SMatrix SMatrix::getinversed (  )  const

Calculate the inversed matrix.

Returns:
Returns the matrix inversed using LAPACK++ libraries if avaiable.
SMatrix SMatrix::getinversedformal (  )  const

Calculate the inversed matrix (formal mode).

Returns:
Returns the matrix inversed.
double SMatrix::getmax ( double  a[],
int  n 
) const

Get the maximum value.

Returns:
Returns the maximum from an array.
Parameters:
a Your array.
n Array dimension.
double SMatrix::getnorm (  )  const

Calculate the matrix norm.

Returns:
Returns the matrix norm = bigger row abs sum (Matlab norm('A',inf)).
SMatrix SMatrix::getreducedmatrix ( int  row,
int  col 
) const

Return a matrix without row i and column j.

Parameters:
row Row to be removed.
col Column to be removed.
Returns:
Returns the reduced matrix.
complex< double > SMatrix::gettrace (  )  const

Calculate the matrix trace.

Returns:
Returns the matrix trace.
SMatrix SMatrix::gettransposed (  )  const

Calculate the matrix transposed.

Returns:
Returns the transposed matrix.
complex<double> SMatrix::operator() ( int  i,
int  j 
) const [inline]

Read/Write matrix elements.

complex<double>& SMatrix::operator() ( int  i,
int  j 
) [inline]

Acces to matrix elements.

SMatrix SMatrix::operator* ( const SMatrix m  )  const

Multiplication operator.

Allow you to multiply 2 or more operators, i.e: A = A*B*...*C;

Returns:
Returns the matrix multiplication.
SMatrix SMatrix::operator+ ( const SMatrix m  )  const

Addition operator.

Allow you to sum 2 or more operators, i.e: A = A + B + ... + C;

Returns:
Returns the matrix sum.
SMatrix SMatrix::operator- ( const SMatrix m  )  const

Soustraction operator.

Allow you to subtracte 2 or more operators, i.e: A = A - B - ... - C;

Returns:
Returns the matrix subtraction.
SMatrix SMatrix::operator/ ( const SMatrix m  )  const

Division operator.

Allow you to divide 2 or more operators, i.e: A = A/B/.../C;

Returns:
Returns the matrix division.
const SMatrix & SMatrix::operator= ( const SMatrix m  ) 

Affectation operator.

Allow you to use the = operator, i.e: SMatrix A(2); SMatrix B(2); A = B;

void SMatrix::print ( const char *  option = ""  )  const

Output matrix as C code, ONLY for matlab mexPrintf(), cout<<SMatrix instead.

You can output matrix using this command i.e.: SMatrix A(...); A.print(); or A.print("expo");

Parameters:
option If you pass the option "expo" all matrix elements will be showed with the exponential notation, else data will be showed as doubles.
Returns:
Return the matrix output.
void SMatrix::redim ( int  ndim  ) 

Modify the matrix dimension.

To modify the dimension of a matrix, you pass the new dimension.

Parameters:
ndim New matrix dimension.
void SMatrix::setdiag ( complex< double > *  tab_diag  ) 

Transform the matrix in a diagonal matrix one, which all elements = array tab_diag.

To create a diagonal matrix, you need to pass a complex array that will be put in the diagonal.

Parameters:
tab_diag Complex array that contains the elements to be put in the diagonal.
Returns:
Modify you matrix data.
void SMatrix::setdiag ( complex< double >  diag  ) 

Creates a diagonal matrix, which all elements = diag.

To create a diagonal matrix, you need to pass a complex number to be put in the diagonal.

Parameters:
diag Complex number to be put in the diagonal.
Returns:
Modify your matrix data.
void SMatrix::SolveCrout ( Ket  b,
Ket x,
SMatrix  Lm,
SMatrix  Um 
)

Solve linear system using Crout Method.

To solve a linear system A*x=b, you pass b and an empty x, you also need to pass the LU matrix from A.

Parameters:
b The know vector.
x The solution vector.
Lm The lower triangular matrix.
Um The upper triangular matrix.
Returns:
Return x with the solution.
void SMatrix::SolveGaussSeidel ( Ket  b,
Ket x 
)

Solve linear system using Gauss Seidel Method.

To solve a linear system A*x=b, you pass b and an empty x.

Parameters:
b The know vector.
x The solution vector.
Returns:
Return x with the solution.
void SMatrix::SolveSOR ( Ket  b,
Ket x 
)

Solve linear system using SOR Method.

To solve a linear system A*x=b, you pass b and an empty x.

Parameters:
b The know vector.
x The solution vector.
Returns:
Return x with the solution.

Friends And Related Function Documentation

EXPORTED_FUNCTION SMatrix operator* ( complex< double >  a,
const SMatrix m 
) [friend]

Scalar complex - matrix pointer multiplication.

EXPORTED_FUNCTION SMatrix operator* ( const SMatrix m,
double  a 
) [friend]

Matrix - scalar double multiplication.

EXPORTED_FUNCTION SMatrix operator* ( const SMatrix m,
complex< double >  a 
) [friend]

Matrix - scalar complex multiplication.

EXPORTED_FUNCTION SMatrix operator* ( double  a,
const SMatrix m 
) [friend]

Scalar double - matrix multiplication.

EXPORTED_FUNCTION SMatrix operator* ( complex< double >  a,
const SMatrix m 
) [friend]

Scalar complex - matrix multiplication.

EXPORTED_FUNCTION SMatrix operator/ ( const SMatrix m,
complex< double >  a 
) [friend]

Matrix - scalar complex division.

EXPORTED_FUNCTION SMatrix operator/ ( const SMatrix m,
double  a 
) [friend]

Matrix - scalar double division.

EXPORTED_FUNCTION std::ostream& operator<< ( std::ostream &  out,
const SMatrix m 
) [friend]

Write to a flux, allow cout<<matrix; .


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

Generated on Sun Sep 6 20:54:35 2009 for CQEDSimulator by  doxygen 1.6.1