v2DM-DOCI
1.0
|
#include <Matrix.h>
Public Member Functions | |
Matrix (int n) | |
Matrix (const Matrix &) | |
Matrix (Matrix &&) | |
virtual | ~Matrix () |
Matrix & | operator= (const Matrix &) |
Matrix & | operator= (Matrix &&) |
Matrix & | operator= (double) |
Matrix & | operator+= (const Matrix &) |
Matrix & | operator-= (const Matrix &) |
Matrix & | daxpy (double alpha, const Matrix &) |
Matrix & | operator*= (double) |
Matrix & | operator/= (double) |
Matrix & | mprod (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 &) |
Matrix::Matrix | ( | int | n | ) |
Matrix::Matrix | ( | const Matrix & | orig | ) |
copy constructor
orig | The 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.
|
virtual |
Destructor
Definition at line 84 of file Matrix.cpp.
add the matrix matrix_pl times the constant alpha to this
alpha | the constant to multiply the matrix_pl with |
matrix_pl | the Matrix to be multiplied by alpha and added to this |
Definition at line 157 of file Matrix.cpp.
double Matrix::ddot | ( | const Matrix & | matrix_i | ) | const |
matrix_i | input matrix |
Definition at line 324 of file Matrix.cpp.
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).
Definition at line 259 of file Matrix.cpp.
Vector Matrix::diagonalize_2x2 | ( | ) |
Diagonalize 2x2 matrix Overwrite matrix with the (normed) eigenvectors
Definition at line 285 of file Matrix.cpp.
void Matrix::dscal | ( | double | alpha | ) |
Scale the matrix (*this) with parameter alpha
alpha | scalefactor |
Definition at line 381 of file Matrix.cpp.
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.
seed | the seed for the random number generator |
Definition at line 401 of file Matrix.cpp.
double * Matrix::gMatrix | ( | ) |
Definition at line 223 of file Matrix.cpp.
const double * Matrix::gMatrix | ( | ) | const |
Definition at line 228 of file Matrix.cpp.
int Matrix::gn | ( | ) | const |
Definition at line 236 of file Matrix.cpp.
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.
void Matrix::invert_2x2 | ( | ) |
Invert 2x2 matrix
Definition at line 358 of file Matrix.cpp.
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
map | matrix that will be multiplied to the left en to the right of matrix object |
object | central matrix |
Definition at line 508 of file Matrix.cpp.
L_map for 2x2 matrices. Will store map*object*map in this
map | matrix that will be multiplied to the left en to the right of matrix object |
object | central matrix |
Definition at line 533 of file Matrix.cpp.
void Matrix::mdiag | ( | const Vector & | diag | ) |
Multiply this matrix with diagonal matrix
diag | Diagonal matrix to multiply with this, has to be allocated on matrix dimension. |
Definition at line 494 of file Matrix.cpp.
Matrix product of two general matrices A en B, put result in this
A | left matrix |
B | right matrix |
Definition at line 558 of file Matrix.cpp.
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!
i | row number |
j | column number |
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!
i | row number |
j | column number |
Definition at line 213 of file Matrix.cpp.
Matrix & Matrix::operator*= | ( | double | c | ) |
*= operator overloaded: multiply by a constant
c | the number to multiply your matrix with |
Definition at line 171 of file Matrix.cpp.
overload the += operator for matrices
matrix_pl | The matrix you want to add to this |
Definition at line 126 of file Matrix.cpp.
overload the -= operator for matrices
matrix_pl | The matrix you want to deduct from this |
Definition at line 141 of file Matrix.cpp.
Matrix & Matrix::operator/= | ( | double | c | ) |
/= operator overloaded: divide by a constant
c | the number to divide your matrix through |
Definition at line 185 of file Matrix.cpp.
overload the equality operator
matrix_copy | The matrix you want to be copied into this |
Definition at line 92 of file Matrix.cpp.
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)
a | the 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.
Seperate matrix into two matrices, a positive and negative semidefinite part.
p | positive (plus) output part |
m | negative (minus) output part |
Definition at line 649 of file Matrix.cpp.
Special version of sep_pm that only works for 2x2 matrices
pos | the positive part of the matrix |
neg | the 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)
option | = 1, positive square root, = -1, negative square root. |
Definition at line 414 of file Matrix.cpp.
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
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.
double Matrix::trace | ( | ) | const |
Definition at line 244 of file Matrix.cpp.
void Matrix::unit | ( | ) |
Set this matrix to a unit matrix
Definition at line 812 of file Matrix.cpp.
|
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;
output | The stream to which you are writing (e.g. cout) |
matrix_p | de Matrix you want to print |
Definition at line 581 of file Matrix.cpp.
|
private |