Mantid
|
A complex-valued matrix for linear algebra computations. More...
#include <EigenComplexMatrix.h>
Public Member Functions | |
ComplexMatrix () | |
Constructor. More... | |
ComplexMatrix (ComplexMatrix &&m) noexcept | |
Move constructor. More... | |
ComplexMatrix (const ComplexMatrix &M) | |
Copy constructor. More... | |
ComplexMatrix (const ComplexMatrix &M, const size_t row, const size_t col, const size_t nRows, const size_t nCols) | |
Create a submatrix. More... | |
ComplexMatrix (const size_t nx, const size_t ny) | |
Constructor. More... | |
ComplexMatrix (Eigen::MatrixXcd &&m) noexcept | |
Move constructor with EigenMatrix. More... | |
ComplexVector | copyColumn (const size_t i) const |
Copy a column into a GSLVector. More... | |
ComplexVector | copyRow (const size_t i) const |
Copy a row into a GSLVector. More... | |
ComplexMatrix | ctr () const |
Get "conjugate transposed" matrix to be used in multiplications. More... | |
ComplexType | det () |
Calculate the determinant. More... | |
void | diag (const ComplexVector &d) |
Set the matrix to be diagonal. More... | |
Eigen::MatrixXcd & | eigen () |
Get the reference to the eigen matrix. More... | |
const Eigen::MatrixXcd | eigen () const |
Get the const pointer to the GSL matrix. More... | |
void | eigenSystemHermitian (EigenVector &eigenValues, ComplexMatrix &eigenVectors) |
Calculate the eigensystem of a Hermitian matrix. More... | |
ComplexType | get (const size_t i, const size_t j) const |
Get an element. More... | |
void | identity () |
Set this matrix to identity matrix. More... | |
void | invert () |
Invert this matrix. More... | |
bool | isEmpty () const |
Is matrix empty. More... | |
ComplexType & | operator() (const size_t i, const size_t j) |
Get the reference to the data element. More... | |
ComplexType | operator() (const size_t i, const size_t j) const |
The "index" operator. More... | |
ComplexMatrix | operator* (const ComplexMatrix &m) const |
Multiply this matrix by a complex matrix. More... | |
ComplexMatrix | operator* (const EigenMatrix &m) const |
Multiply this matrix by a matrix. More... | |
ComplexMatrix & | operator*= (const ComplexType &d) |
Multiply this matrix by a number. More... | |
ComplexMatrix & | operator+= (const ComplexMatrix &M) |
Add a matrix to this. More... | |
ComplexMatrix & | operator+= (const ComplexType &d) |
Add a constant to this matrix. More... | |
ComplexMatrix & | operator-= (const ComplexMatrix &M) |
Subtract a matrix from this. More... | |
ComplexMatrix & | operator= (ComplexMatrix &&M) |
Move assignment operator. More... | |
ComplexMatrix & | operator= (const ComplexMatrix &M) |
Copy assignment operator. More... | |
ComplexMatrix & | operator= (const Eigen::MatrixXcd M) |
Copy assignment operator. More... | |
std::vector< double > | packToStdVector () const |
Pack the matrix into a single std vector of doubles (for passing in and out of algorithms) More... | |
void | resize (const size_t nx, const size_t ny) |
Resize the matrix. More... | |
void | set (const size_t i, const size_t j, const ComplexType value) |
Set an element. More... | |
size_t | size1 () const |
First size of the matrix. More... | |
size_t | size2 () const |
Second size of the matrix. More... | |
void | solve (const ComplexVector &rhs, ComplexVector &x) |
Solve system of linear equations M*x == rhs, M is this matrix This matrix is destroyed. More... | |
void | sortColumns (const std::vector< size_t > &indices) |
Sort columns in order defined by an index array. More... | |
ComplexMatrix | tr () const |
Get "transposed" matrix to be used in multiplications. More... | |
void | unpackFromStdVector (const std::vector< double > &v) |
Unpack an std vector into this matrix. More... | |
void | zero () |
Set all elements to zero. More... | |
Private Attributes | |
Eigen::MatrixXcd | m_matrix |
The pointer to the complex Eigen matrix. More... | |
A complex-valued matrix for linear algebra computations.
Definition at line 31 of file EigenComplexMatrix.h.
Mantid::CurveFitting::ComplexMatrix::ComplexMatrix | ( | ) |
Constructor.
Definition at line 15 of file EigenComplexMatrix.cpp.
Mantid::CurveFitting::ComplexMatrix::ComplexMatrix | ( | const size_t | nx, |
const size_t | ny | ||
) |
Constructor.
nx | :: First dimension |
ny | :: Second dimension |
Definition at line 19 of file EigenComplexMatrix.cpp.
References zero().
Mantid::CurveFitting::ComplexMatrix::ComplexMatrix | ( | const ComplexMatrix & | M | ) |
Copy constructor.
M | :: The other matrix. |
Definition at line 23 of file EigenComplexMatrix.cpp.
Mantid::CurveFitting::ComplexMatrix::ComplexMatrix | ( | const ComplexMatrix & | M, |
const size_t | row, | ||
const size_t | col, | ||
const size_t | nRows, | ||
const size_t | nCols | ||
) |
Create a submatrix.
A submatrix is a view into the parent matrix. Lifetime of a submatrix cannot exceed the lifetime of the parent.
M | :: The parent matrix. |
row | :: The first row in the submatrix. |
col | :: The first column in the submatrix. |
nRows | :: The number of rows in the submatrix. |
nCols | :: The number of columns in the submatrix. |
Definition at line 32 of file EigenComplexMatrix.cpp.
|
explicitnoexcept |
Move constructor.
Definition at line 43 of file EigenComplexMatrix.cpp.
|
explicitnoexcept |
Move constructor with EigenMatrix.
Move constructor with Eigen::Matrix.
Definition at line 46 of file EigenComplexMatrix.cpp.
ComplexVector Mantid::CurveFitting::ComplexMatrix::copyColumn | ( | const size_t | i | ) | const |
Copy a column into a GSLVector.
Copy a column into a Complex EigenVector.
i | :: A column index. |
Definition at line 255 of file EigenComplexMatrix.cpp.
ComplexVector Mantid::CurveFitting::ComplexMatrix::copyRow | ( | const size_t | i | ) | const |
Copy a row into a GSLVector.
Copy a row into a EigenVector.
i | :: A row index. |
Definition at line 244 of file EigenComplexMatrix.cpp.
ComplexMatrix Mantid::CurveFitting::ComplexMatrix::ctr | ( | ) | const |
Get "conjugate transposed" matrix to be used in multiplications.
Copy matrix, conjugate, then return transposed copy.
Definition at line 323 of file EigenComplexMatrix.cpp.
ComplexType Mantid::CurveFitting::ComplexMatrix::det | ( | ) |
void Mantid::CurveFitting::ComplexMatrix::diag | ( | const ComplexVector & | d | ) |
Set the matrix to be diagonal.
d | :: Values on the diagonal. |
Definition at line 124 of file EigenComplexMatrix.cpp.
References Mantid::Geometry::d, n, resize(), set(), and zero().
|
inline |
Get the reference to the eigen matrix.
Definition at line 54 of file EigenComplexMatrix.h.
Referenced by ComplexMatrix(), copyColumn(), copyRow(), ctr(), operator*(), operator+=(), operator-=(), operator=(), solve(), and tr().
|
inline |
Get the const pointer to the GSL matrix.
Definition at line 56 of file EigenComplexMatrix.h.
void Mantid::CurveFitting::ComplexMatrix::eigenSystemHermitian | ( | EigenVector & | eigenValues, |
ComplexMatrix & | eigenVectors | ||
) |
Calculate the eigensystem of a Hermitian matrix.
eigenValues | :: Output variable that receives the eigenvalues of this matrix. |
eigenVectors | :: Output variable that receives the eigenvectors of this matrix. |
Definition at line 228 of file EigenComplexMatrix.cpp.
References m_matrix, n, Mantid::CurveFitting::EigenVector::resize(), size1(), and size2().
ComplexType Mantid::CurveFitting::ComplexMatrix::get | ( | const size_t | i, |
const size_t | j | ||
) | const |
Get an element.
get an element
i | :: The row |
j | :: The column |
Definition at line 101 of file EigenComplexMatrix.cpp.
References m_matrix, size1(), and size2().
Referenced by packToStdVector().
void Mantid::CurveFitting::ComplexMatrix::identity | ( | ) |
Set this matrix to identity matrix.
Definition at line 117 of file EigenComplexMatrix.cpp.
References m_matrix.
void Mantid::CurveFitting::ComplexMatrix::invert | ( | ) |
Invert this matrix.
Definition at line 207 of file EigenComplexMatrix.cpp.
bool Mantid::CurveFitting::ComplexMatrix::isEmpty | ( | ) | const |
ComplexType & Mantid::CurveFitting::ComplexMatrix::operator() | ( | const size_t | i, |
const size_t | j | ||
) |
Get the reference to the data element.
Definition at line 114 of file EigenComplexMatrix.cpp.
References m_matrix.
ComplexType Mantid::CurveFitting::ComplexMatrix::operator() | ( | const size_t | i, |
const size_t | j | ||
) | const |
The "index" operator.
Definition at line 109 of file EigenComplexMatrix.cpp.
ComplexMatrix Mantid::CurveFitting::ComplexMatrix::operator* | ( | const ComplexMatrix & | m | ) | const |
Multiply this matrix by a complex matrix.
Definition at line 170 of file EigenComplexMatrix.cpp.
References eigen(), Mantid::Geometry::m, and size2().
ComplexMatrix Mantid::CurveFitting::ComplexMatrix::operator* | ( | const EigenMatrix & | m | ) | const |
Multiply this matrix by a matrix.
Definition at line 159 of file EigenComplexMatrix.cpp.
References eigen(), Mantid::Geometry::m, and size2().
ComplexMatrix & Mantid::CurveFitting::ComplexMatrix::operator*= | ( | const ComplexType & | d | ) |
Multiply this matrix by a number.
multiply this matrix by a number
d | :: A number |
Definition at line 153 of file EigenComplexMatrix.cpp.
References Mantid::Geometry::d, and m_matrix.
ComplexMatrix & Mantid::CurveFitting::ComplexMatrix::operator+= | ( | const ComplexMatrix & | M | ) |
Add a matrix to this.
add a matrix to this
M | :: A matrix |
Definition at line 135 of file EigenComplexMatrix.cpp.
ComplexMatrix & Mantid::CurveFitting::ComplexMatrix::operator+= | ( | const ComplexType & | d | ) |
Add a constant to this matrix.
add a constant to this matrix
d | :: A number |
Definition at line 141 of file EigenComplexMatrix.cpp.
References Mantid::Geometry::d, and m_matrix.
ComplexMatrix & Mantid::CurveFitting::ComplexMatrix::operator-= | ( | const ComplexMatrix & | M | ) |
Subtract a matrix from this.
subtract a matrix from this
M | :: A matrix |
Definition at line 147 of file EigenComplexMatrix.cpp.
ComplexMatrix & Mantid::CurveFitting::ComplexMatrix::operator= | ( | ComplexMatrix && | M | ) |
Move assignment operator.
Move assignment operator - check this still works now m_matrix is no longer a pointer.
Definition at line 55 of file EigenComplexMatrix.cpp.
References m_matrix.
ComplexMatrix & Mantid::CurveFitting::ComplexMatrix::operator= | ( | const ComplexMatrix & | M | ) |
Copy assignment operator.
Definition at line 49 of file EigenComplexMatrix.cpp.
ComplexMatrix & Mantid::CurveFitting::ComplexMatrix::operator= | ( | const Eigen::MatrixXcd | M | ) |
Copy assignment operator.
Copy assignment operator - check we don't need a non-const assignment operator.
Definition at line 61 of file EigenComplexMatrix.cpp.
References m_matrix.
std::vector< double > Mantid::CurveFitting::ComplexMatrix::packToStdVector | ( | ) | const |
Pack the matrix into a single std vector of doubles (for passing in and out of algorithms)
Definition at line 280 of file EigenComplexMatrix.cpp.
References get(), size1(), size2(), and value.
Referenced by Mantid::CurveFitting::CrystalFieldEnergies::exec().
void Mantid::CurveFitting::ComplexMatrix::resize | ( | const size_t | nx, |
const size_t | ny | ||
) |
void Mantid::CurveFitting::ComplexMatrix::set | ( | const size_t | i, |
const size_t | j, | ||
const ComplexType | value | ||
) |
Set an element.
set an element
i | :: The row |
j | :: The column |
value | :: The new vaule |
Definition at line 90 of file EigenComplexMatrix.cpp.
References m_matrix, size1(), size2(), and value.
Referenced by diag(), and unpackFromStdVector().
size_t Mantid::CurveFitting::ComplexMatrix::size1 | ( | ) | const |
First size of the matrix.
Definition at line 81 of file EigenComplexMatrix.cpp.
References m_matrix.
Referenced by ComplexMatrix(), copyColumn(), copyRow(), det(), eigenSystemHermitian(), get(), invert(), packToStdVector(), resize(), set(), solve(), sortColumns(), and unpackFromStdVector().
size_t Mantid::CurveFitting::ComplexMatrix::size2 | ( | ) | const |
Second size of the matrix.
Definition at line 84 of file EigenComplexMatrix.cpp.
References m_matrix.
Referenced by ComplexMatrix(), copyColumn(), copyRow(), det(), eigenSystemHermitian(), get(), invert(), operator*(), packToStdVector(), resize(), set(), solve(), sortColumns(), and unpackFromStdVector().
void Mantid::CurveFitting::ComplexMatrix::solve | ( | const ComplexVector & | rhs, |
ComplexVector & | x | ||
) |
Solve system of linear equations M*x == rhs, M is this matrix This matrix is destroyed.
rhs | :: The right-hand-side vector |
x | :: The solution vector |
Definition at line 184 of file EigenComplexMatrix.cpp.
References det(), eigen(), n, rhs, size1(), size2(), and Mantid::Geometry::x.
void Mantid::CurveFitting::ComplexMatrix::sortColumns | ( | const std::vector< size_t > & | indices | ) |
Sort columns in order defined by an index array.
indices | :: Indices defining the order of columns in sorted matrix. |
Definition at line 267 of file EigenComplexMatrix.cpp.
ComplexMatrix Mantid::CurveFitting::ComplexMatrix::tr | ( | ) | const |
Get "transposed" matrix to be used in multiplications.
Copy matrix, transpose, then return transposed copy.
Definition at line 316 of file EigenComplexMatrix.cpp.
void Mantid::CurveFitting::ComplexMatrix::unpackFromStdVector | ( | const std::vector< double > & | packed | ) |
Unpack an std vector into this matrix.
Matrix size must match the size of the vector
Matrix size must match the size of the vector
packed | :: A vector with complex data packed with ComplexMatrix::packToStdVector(). |
Definition at line 300 of file EigenComplexMatrix.cpp.
void Mantid::CurveFitting::ComplexMatrix::zero | ( | ) |
Set all elements to zero.
Definition at line 120 of file EigenComplexMatrix.cpp.
References m_matrix.
Referenced by Mantid::CurveFitting::Functions::calculateEigensystem(), ComplexMatrix(), diag(), and resize().
|
private |
The pointer to the complex Eigen matrix.
Definition at line 126 of file EigenComplexMatrix.h.
Referenced by ComplexMatrix(), ctr(), det(), eigenSystemHermitian(), get(), identity(), invert(), isEmpty(), operator()(), operator*=(), operator+=(), operator-=(), operator=(), resize(), set(), size1(), size2(), sortColumns(), tr(), and zero().