Mantid
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
Mantid::CurveFitting::ComplexMatrix Class Reference

A complex-valued matrix for linear algebra computations. More...

#include <EigenComplexMatrix.h>

Inheritance diagram for Mantid::CurveFitting::ComplexMatrix:
Mantid::CurveFitting::FortranMatrix< ComplexMatrix >

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...
 
ComplexTypeoperator() (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...
 
ComplexMatrixoperator*= (const ComplexType &d)
 Multiply this matrix by a number. More...
 
ComplexMatrixoperator+= (const ComplexMatrix &M)
 Add a matrix to this. More...
 
ComplexMatrixoperator+= (const ComplexType &d)
 Add a constant to this matrix. More...
 
ComplexMatrixoperator-= (const ComplexMatrix &M)
 Subtract a matrix from this. More...
 
ComplexMatrixoperator= (ComplexMatrix &&M)
 Move assignment operator. More...
 
ComplexMatrixoperator= (const ComplexMatrix &M)
 Copy assignment operator. More...
 
ComplexMatrixoperator= (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...
 

Detailed Description

A complex-valued matrix for linear algebra computations.

Definition at line 31 of file EigenComplexMatrix.h.

Constructor & Destructor Documentation

◆ ComplexMatrix() [1/6]

Mantid::CurveFitting::ComplexMatrix::ComplexMatrix ( )

Constructor.

Definition at line 15 of file EigenComplexMatrix.cpp.

◆ ComplexMatrix() [2/6]

Mantid::CurveFitting::ComplexMatrix::ComplexMatrix ( const size_t  nx,
const size_t  ny 
)

Constructor.

Parameters
nx:: First dimension
ny:: Second dimension

Definition at line 19 of file EigenComplexMatrix.cpp.

References zero().

◆ ComplexMatrix() [3/6]

Mantid::CurveFitting::ComplexMatrix::ComplexMatrix ( const ComplexMatrix M)

Copy constructor.

Parameters
M:: The other matrix.

Definition at line 23 of file EigenComplexMatrix.cpp.

◆ ComplexMatrix() [4/6]

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.

Parameters
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.

References eigen(), m_matrix, size1(), and size2().

◆ ComplexMatrix() [5/6]

Mantid::CurveFitting::ComplexMatrix::ComplexMatrix ( ComplexMatrix &&  m)
explicitnoexcept

Move constructor.

Definition at line 43 of file EigenComplexMatrix.cpp.

◆ ComplexMatrix() [6/6]

Mantid::CurveFitting::ComplexMatrix::ComplexMatrix ( Eigen::MatrixXcd &&  m)
explicitnoexcept

Move constructor with EigenMatrix.

Move constructor with Eigen::Matrix.

Definition at line 46 of file EigenComplexMatrix.cpp.

Member Function Documentation

◆ copyColumn()

ComplexVector Mantid::CurveFitting::ComplexMatrix::copyColumn ( const size_t  i) const

Copy a column into a GSLVector.

Copy a column into a Complex EigenVector.

Parameters
i:: A column index.

Definition at line 255 of file EigenComplexMatrix.cpp.

References eigen(), size1(), and size2().

◆ copyRow()

ComplexVector Mantid::CurveFitting::ComplexMatrix::copyRow ( const size_t  i) const

Copy a row into a GSLVector.

Copy a row into a EigenVector.

Parameters
i:: A row index.

Definition at line 244 of file EigenComplexMatrix.cpp.

References eigen(), size1(), and size2().

◆ ctr()

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.

References eigen(), and m_matrix.

◆ det()

ComplexType Mantid::CurveFitting::ComplexMatrix::det ( )

Calculate the determinant.

Definition at line 215 of file EigenComplexMatrix.cpp.

References m_matrix, size1(), and size2().

Referenced by solve().

◆ diag()

void Mantid::CurveFitting::ComplexMatrix::diag ( const ComplexVector d)

Set the matrix to be diagonal.

Parameters
d:: Values on the diagonal.

Definition at line 124 of file EigenComplexMatrix.cpp.

References Mantid::Geometry::d, n, resize(), set(), and zero().

◆ eigen() [1/2]

Eigen::MatrixXcd & Mantid::CurveFitting::ComplexMatrix::eigen ( )
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().

◆ eigen() [2/2]

const Eigen::MatrixXcd Mantid::CurveFitting::ComplexMatrix::eigen ( ) const
inline

Get the const pointer to the GSL matrix.

Definition at line 56 of file EigenComplexMatrix.h.

◆ eigenSystemHermitian()

void Mantid::CurveFitting::ComplexMatrix::eigenSystemHermitian ( EigenVector eigenValues,
ComplexMatrix eigenVectors 
)

Calculate the eigensystem of a Hermitian matrix.

Parameters
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().

◆ get()

ComplexType Mantid::CurveFitting::ComplexMatrix::get ( const size_t  i,
const size_t  j 
) const

Get an element.

get an element

Parameters
i:: The row
j:: The column

Definition at line 101 of file EigenComplexMatrix.cpp.

References m_matrix, size1(), and size2().

Referenced by packToStdVector().

◆ identity()

void Mantid::CurveFitting::ComplexMatrix::identity ( )

Set this matrix to identity matrix.

Definition at line 117 of file EigenComplexMatrix.cpp.

References m_matrix.

◆ invert()

void Mantid::CurveFitting::ComplexMatrix::invert ( )

Invert this matrix.

Definition at line 207 of file EigenComplexMatrix.cpp.

References m_matrix, size1(), and size2().

◆ isEmpty()

bool Mantid::CurveFitting::ComplexMatrix::isEmpty ( ) const

Is matrix empty.

Definition at line 67 of file EigenComplexMatrix.cpp.

References m_matrix.

◆ operator()() [1/2]

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.

◆ operator()() [2/2]

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.

◆ operator*() [1/2]

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().

◆ operator*() [2/2]

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().

◆ operator*=()

ComplexMatrix & Mantid::CurveFitting::ComplexMatrix::operator*= ( const ComplexType d)

Multiply this matrix by a number.

multiply this matrix by a number

Parameters
d:: A number

Definition at line 153 of file EigenComplexMatrix.cpp.

References Mantid::Geometry::d, and m_matrix.

◆ operator+=() [1/2]

ComplexMatrix & Mantid::CurveFitting::ComplexMatrix::operator+= ( const ComplexMatrix M)

Add a matrix to this.

add a matrix to this

Parameters
M:: A matrix

Definition at line 135 of file EigenComplexMatrix.cpp.

References eigen(), and m_matrix.

◆ operator+=() [2/2]

ComplexMatrix & Mantid::CurveFitting::ComplexMatrix::operator+= ( const ComplexType d)

Add a constant to this matrix.

add a constant to this matrix

Parameters
d:: A number

Definition at line 141 of file EigenComplexMatrix.cpp.

References Mantid::Geometry::d, and m_matrix.

◆ operator-=()

ComplexMatrix & Mantid::CurveFitting::ComplexMatrix::operator-= ( const ComplexMatrix M)

Subtract a matrix from this.

subtract a matrix from this

Parameters
M:: A matrix

Definition at line 147 of file EigenComplexMatrix.cpp.

References eigen(), and m_matrix.

◆ operator=() [1/3]

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.

◆ operator=() [2/3]

ComplexMatrix & Mantid::CurveFitting::ComplexMatrix::operator= ( const ComplexMatrix M)

Copy assignment operator.

Definition at line 49 of file EigenComplexMatrix.cpp.

References eigen(), and m_matrix.

◆ operator=() [3/3]

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.

◆ packToStdVector()

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().

◆ resize()

void Mantid::CurveFitting::ComplexMatrix::resize ( const size_t  nx,
const size_t  ny 
)

Resize the matrix.

Parameters
nx:: New first dimension
ny:: New second dimension

Definition at line 72 of file EigenComplexMatrix.cpp.

References m_matrix, size1(), size2(), and zero().

Referenced by diag().

◆ set()

void Mantid::CurveFitting::ComplexMatrix::set ( const size_t  i,
const size_t  j,
const ComplexType  value 
)

Set an element.

set an element

Parameters
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().

◆ size1()

size_t Mantid::CurveFitting::ComplexMatrix::size1 ( ) const

◆ size2()

size_t Mantid::CurveFitting::ComplexMatrix::size2 ( ) const

◆ solve()

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.

Parameters
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.

◆ sortColumns()

void Mantid::CurveFitting::ComplexMatrix::sortColumns ( const std::vector< size_t > &  indices)

Sort columns in order defined by an index array.

Parameters
indices:: Indices defining the order of columns in sorted matrix.

Definition at line 267 of file EigenComplexMatrix.cpp.

References m_matrix, size1(), and size2().

◆ tr()

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.

References eigen(), and m_matrix.

◆ unpackFromStdVector()

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

Parameters
packed:: A vector with complex data packed with ComplexMatrix::packToStdVector().

Definition at line 300 of file EigenComplexMatrix.cpp.

References set(), size1(), size2(), and value.

◆ zero()

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().

Member Data Documentation

◆ m_matrix

Eigen::MatrixXcd Mantid::CurveFitting::ComplexMatrix::m_matrix
private

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