v2DM-DOCI  1.0
doci2DM::Matrix Class Reference

#include <Matrix.h>

+ Collaboration diagram for doci2DM::Matrix:

Public Member Functions

 Matrix (int n)
 
 Matrix (const Matrix &)
 
 Matrix (Matrix &&)
 
virtual ~Matrix ()
 
Matrixoperator= (const Matrix &)
 
Matrixoperator= (Matrix &&)
 
Matrixoperator= (double)
 
Matrixoperator+= (const Matrix &)
 
Matrixoperator-= (const Matrix &)
 
Matrixdaxpy (double alpha, const Matrix &)
 
Matrixoperator*= (double)
 
Matrixoperator/= (double)
 
Matrixmprod (const Matrix &, const Matrix &)
 
double & operator() (int i, int j)
 
double operator() (int i, int j) const
 
double * gMatrix ()
 
const double * gMatrix () const
 
int gn () const
 
double trace () const
 
Vector diagonalize ()
 
Vector diagonalize_2x2 ()
 
double ddot (const Matrix &) const
 
void invert ()
 
void invert_2x2 ()
 
void dscal (double alpha)
 
void fill_Random ()
 
void fill_Random (int seed)
 
void sqrt (int option)
 
void sqrt_2x2 (int option)
 
void mdiag (const Vector &)
 
void L_map (const Matrix &, const Matrix &)
 
void L_map_2x2 (const Matrix &, const Matrix &)
 
void symmetrize ()
 
void SaveRawToFile (const std::string) const
 
void sep_pm (Matrix &, Matrix &)
 
void sep_pm_2x2 (Matrix &, Matrix &)
 
void unit ()
 

Private Attributes

std::unique_ptr< double[]> matrix
 pointer of doubles, contains the numbers, the matrix More...
 
int n
 dimension of the matrix More...
 

Friends

std::ostream & operator<< (std::ostream &, const doci2DM::Matrix &)
 

Detailed Description

Definition at line 43 of file Matrix.h.

Constructor & Destructor Documentation

Matrix::Matrix ( int  n)

constructor

Parameters
ndimension of the matrix

Definition at line 54 of file Matrix.cpp.

Matrix::Matrix ( const Matrix orig)

copy constructor

Parameters
origThe matrix you want to be copied into the object you are constructing

Definition at line 66 of file Matrix.cpp.

Matrix::Matrix ( Matrix &&  orig)

Definition at line 75 of file Matrix.cpp.

Matrix::~Matrix ( )
virtual

Destructor

Definition at line 84 of file Matrix.cpp.

Member Function Documentation

Matrix & Matrix::daxpy ( double  alpha,
const Matrix matrix_pl 
)

add the matrix matrix_pl times the constant alpha to this

Parameters
alphathe constant to multiply the matrix_pl with
matrix_plthe Matrix to be multiplied by alpha and added to this

Definition at line 157 of file Matrix.cpp.

+ Here is the call graph for this function:

double Matrix::ddot ( const Matrix matrix_i) const
Returns
inproduct of (*this) matrix with matrix_i, defined as Tr (A B)
Parameters
matrix_iinput matrix

Definition at line 324 of file Matrix.cpp.

+ Here is the call graph for this function:

Vector Matrix::diagonalize ( )

Diagonalizes symmetric matrices. Watch out! The current matrix (*this) is destroyed, in it the eigenvectors will be stored (one in every column).

Returns
eigenvalues Vector with the eigenvalues

Definition at line 259 of file Matrix.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Vector Matrix::diagonalize_2x2 ( )

Diagonalize 2x2 matrix Overwrite matrix with the (normed) eigenvectors

Returns
Vector with the eigenvalues

Definition at line 285 of file Matrix.cpp.

void Matrix::dscal ( double  alpha)

Scale the matrix (*this) with parameter alpha

Parameters
alphascalefactor

Definition at line 381 of file Matrix.cpp.

+ Here is the call graph for this function:

void Matrix::fill_Random ( )

Fill the matrix with random numbers. The seed is the current time.

Definition at line 392 of file Matrix.cpp.

void Matrix::fill_Random ( int  seed)

Fill the matrix with random numbers.

Parameters
seedthe seed for the random number generator

Definition at line 401 of file Matrix.cpp.

double * Matrix::gMatrix ( )
Returns
the underlying pointer to matrix, useful for mkl applications

Definition at line 223 of file Matrix.cpp.

+ Here is the caller graph for this function:

const double * Matrix::gMatrix ( ) const

Definition at line 228 of file Matrix.cpp.

int Matrix::gn ( ) const
Returns
the dimension of the matrix

Definition at line 236 of file Matrix.cpp.

+ Here is the caller graph for this function:

void Matrix::invert ( )

Invert positive semidefinite symmetric matrix is stored in (*this), original matrix (*this) is destroyed

Definition at line 335 of file Matrix.cpp.

+ Here is the call graph for this function:

void Matrix::invert_2x2 ( )

Invert 2x2 matrix

Definition at line 358 of file Matrix.cpp.

void Matrix::L_map ( const Matrix map,
const Matrix object 
)

Multiply symmetric matrix object left en right with symmetric matrix map to form another symmetric matrix and put it in (*this): this = map*object*map

Parameters
mapmatrix that will be multiplied to the left en to the right of matrix object
objectcentral matrix

Definition at line 508 of file Matrix.cpp.

+ Here is the call graph for this function:

void Matrix::L_map_2x2 ( const Matrix map,
const Matrix object 
)

L_map for 2x2 matrices. Will store map*object*map in this

Parameters
mapmatrix that will be multiplied to the left en to the right of matrix object
objectcentral matrix

Definition at line 533 of file Matrix.cpp.

void Matrix::mdiag ( const Vector diag)

Multiply this matrix with diagonal matrix

Parameters
diagDiagonal matrix to multiply with this, has to be allocated on matrix dimension.

Definition at line 494 of file Matrix.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Matrix & Matrix::mprod ( const Matrix A,
const Matrix B 
)

Matrix product of two general matrices A en B, put result in this

Parameters
Aleft matrix
Bright matrix

Definition at line 558 of file Matrix.cpp.

+ Here is the call graph for this function:

double & Matrix::operator() ( int  i,
int  j 
)

write access to your matrix, change the number on row i and column j remark that for the conversion to lapack functions the double pointer is transposed!

Parameters
irow number
jcolumn number
Returns
the entry on place i,j

Definition at line 199 of file Matrix.cpp.

double Matrix::operator() ( int  i,
int  j 
) const

read access to your matrix, view the number on row i and column j remark that for the conversion to lapack functions the double pointer is transposed!

Parameters
irow number
jcolumn number
Returns
the entry on place i,j

Definition at line 213 of file Matrix.cpp.

Matrix & Matrix::operator*= ( double  c)

*= operator overloaded: multiply by a constant

Parameters
cthe number to multiply your matrix with

Definition at line 171 of file Matrix.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Matrix & Matrix::operator+= ( const Matrix matrix_pl)

overload the += operator for matrices

Parameters
matrix_plThe matrix you want to add to this

Definition at line 126 of file Matrix.cpp.

+ Here is the call graph for this function:

Matrix & Matrix::operator-= ( const Matrix matrix_pl)

overload the -= operator for matrices

Parameters
matrix_plThe matrix you want to deduct from this

Definition at line 141 of file Matrix.cpp.

+ Here is the call graph for this function:

Matrix & Matrix::operator/= ( double  c)

/= operator overloaded: divide by a constant

Parameters
cthe number to divide your matrix through

Definition at line 185 of file Matrix.cpp.

+ Here is the call graph for this function:

Matrix & Matrix::operator= ( const Matrix matrix_copy)

overload the equality operator

Parameters
matrix_copyThe matrix you want to be copied into this

Definition at line 92 of file Matrix.cpp.

Matrix & Matrix::operator= ( Matrix &&  matrix_copy)

Definition at line 101 of file Matrix.cpp.

Matrix & Matrix::operator= ( double  a)

Make all the number in your matrix equal to the number a, e.g. usefull for initialization (Matrix M = 0)

Parameters
athe number

Definition at line 114 of file Matrix.cpp.

void Matrix::SaveRawToFile ( const std::string  filename) const

Definition at line 606 of file Matrix.cpp.

void Matrix::sep_pm ( Matrix p,
Matrix m 
)

Seperate matrix into two matrices, a positive and negative semidefinite part.

Parameters
ppositive (plus) output part
mnegative (minus) output part

Definition at line 649 of file Matrix.cpp.

+ Here is the call graph for this function:

void Matrix::sep_pm_2x2 ( Matrix pos,
Matrix neg 
)

Special version of sep_pm that only works for 2x2 matrices

Parameters
posthe positive part of the matrix
negthe negative part of the matrix

Definition at line 758 of file Matrix.cpp.

void Matrix::sqrt ( int  option)

Take the square root out of the positive semidefinite matrix, destroys original matrix, square root will be put in (*this)

Parameters
option= 1, positive square root, = -1, negative square root.

Definition at line 414 of file Matrix.cpp.

+ Here is the call graph for this function:

void Matrix::sqrt_2x2 ( int  option)

Take the square root out of the positive semidefinite matrix, destroys original matrix, square root will be put in (*this) Only works for 2x2 matrices

Parameters
option= 1, positive square root, = -1, negative square root.

Definition at line 448 of file Matrix.cpp.

void Matrix::symmetrize ( )

Copy upper triangle into lower triangle.

Definition at line 573 of file Matrix.cpp.

+ Here is the caller graph for this function:

double Matrix::trace ( ) const
Returns
the trace of the matrix:

Definition at line 244 of file Matrix.cpp.

+ Here is the caller graph for this function:

void Matrix::unit ( )

Set this matrix to a unit matrix

Definition at line 812 of file Matrix.cpp.

+ Here is the caller graph for this function:

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  output,
const doci2DM::Matrix matrix_p 
)
friend

Output stream operator overloaded, the usage is simple, if you want to print to a file, make an ifstream object and type:

object << matrix << endl;

For output onto the screen type:

cout << matrix << endl;

Parameters
outputThe stream to which you are writing (e.g. cout)
matrix_pde Matrix you want to print

Definition at line 581 of file Matrix.cpp.

Member Data Documentation

std::unique_ptr<double []> doci2DM::Matrix::matrix
private

pointer of doubles, contains the numbers, the matrix

Definition at line 145 of file Matrix.h.

int doci2DM::Matrix::n
private

dimension of the matrix

Definition at line 148 of file Matrix.h.


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