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

A wrapper around Eigen::Matrix. More...

#include <EigenMatrix.h>

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

Public Member Functions

map_type copy_view () const
 Get a copy of the Eigen matrix. More...
 
EigenVector copyColumn (size_t i) const
 Copy a column into an EigenVector. More...
 
EigenVector copyRow (size_t i) const
 Copy a row into an EigenVector. More...
 
double det () const
 Calculate the determinant. More...
 
void diag (const EigenVector &d)
 Set the matrix to be diagonal. More...
 
 EigenMatrix ()=default
 Constructor. More...
 
 EigenMatrix (const EigenMatrix &M)
 Copy constructor. More...
 
 EigenMatrix (const Kernel::Matrix< double > &M)
 Constructor. More...
 
 EigenMatrix (const Kernel::Matrix< double > &M, size_t row, size_t col, size_t nRows, size_t nCols)
 Constructor. More...
 
 EigenMatrix (const size_t nx, const size_t ny)
 Constructor. More...
 
 EigenMatrix (EigenMatrix &M, size_t row, size_t col, size_t nRows, size_t nCols)
 Create a submatrix. More...
 
 EigenMatrix (std::initializer_list< std::initializer_list< double > > ilist)
 Construct from an initialisation list. More...
 
void eigenSystem (EigenVector &eigenValues, EigenMatrix &eigenVectors)
 Calculate the eigensystem of a symmetric matrix. More...
 
double get (size_t i, size_t j) const
 Get an element. More...
 
void identity ()
 Set this matrix to identity matrix. More...
 
const map_type inspector () const
 Get a const copy of the Eigen matrix. More...
 
void invert ()
 Invert this matrix. More...
 
bool isEmpty () const
 Is matrix empty. More...
 
map_typemutator ()
 Get the map to Eigen matrix. More...
 
double & operator() (size_t i, size_t j)
 Get the reference to the data element. More...
 
double operator() (size_t i, size_t j) const
 The "index" operator. More...
 
EigenMatrix operator* (const EigenMatrix &m) const
 Matrix by Matrix multiplication. More...
 
EigenVector operator* (const EigenVector &v) const
 Matrix by vector multiplication. More...
 
EigenMatrixoperator*= (const double &d)
 Multiply this matrix by a number. More...
 
EigenMatrixoperator+= (const double &d)
 Add a constant to this matrix. More...
 
EigenMatrixoperator+= (const EigenMatrix &M)
 Add a matrix to this. More...
 
EigenMatrixoperator-= (const double &d)
 subtract a constant from this More...
 
EigenMatrixoperator-= (const EigenMatrix &M)
 Subtract a matrix from this. More...
 
EigenMatrixoperator= (const Eigen::MatrixXd v)
 Assignment operator - Eigen::MatrixXd. More...
 
EigenMatrixoperator= (const EigenMatrix &M)
 Copy assignment operator. More...
 
void resize (const size_t nx, const size_t ny)
 Resize the matrix. More...
 
void set (size_t i, size_t j, double 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 EigenVector &rhs, EigenVector &x)
 Solve system of linear equations M*x == rhs, M is this matrix This matrix is destroyed. More...
 
EigenMatrix tr () const
 Calculate the eigensystem of a symmetric matrix. More...
 
void zero ()
 Set all elements to zero. More...
 

Protected Member Functions

EigenMatrix move ()
 Create a new matrix and move the data to it. More...
 

Private Member Functions

 EigenMatrix (std::vector< double > &&data, size_t nx, size_t ny)
 "Move" constructor More...
 
EigenVector multiplyByVector (const EigenVector &v) const
 

Private Attributes

std::vector< double > m_data
 Default element storage. More...
 
EigenMatrix_View m_view
 The pointer to the vector. More...
 

Detailed Description

A wrapper around Eigen::Matrix.

Author
Roman Tolchenov, Tessella plc
Date
24/02/2012

Definition at line 33 of file EigenMatrix.h.

Constructor & Destructor Documentation

◆ EigenMatrix() [1/8]

Mantid::CurveFitting::EigenMatrix::EigenMatrix ( )
default

Constructor.

Referenced by move().

◆ EigenMatrix() [2/8]

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

Constructor.

Parameters
nx:: First dimension
ny:: Second dimension

Definition at line 18 of file EigenMatrix.cpp.

◆ EigenMatrix() [3/8]

Mantid::CurveFitting::EigenMatrix::EigenMatrix ( std::initializer_list< std::initializer_list< double > >  ilist)

Construct from an initialisation list.

Parameters
ilist:: Initialisation list as a list of rows: {{M00, M01, M02, ...}, {M10, M11, M12, ...}, ... {Mn0, Mn1, Mn2, ...}}

Definition at line 27 of file EigenMatrix.cpp.

References set(), and size2().

◆ EigenMatrix() [4/8]

Mantid::CurveFitting::EigenMatrix::EigenMatrix ( const EigenMatrix M)

Copy constructor.

Parameters
M:: The other matrix.

Definition at line 43 of file EigenMatrix.cpp.

◆ EigenMatrix() [5/8]

Mantid::CurveFitting::EigenMatrix::EigenMatrix ( EigenMatrix M,
size_t  row,
size_t  col,
size_t  nRows,
size_t  nCols 
)

Create a submatrix.

A submatrix is a reference to part of the parent matrix.

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 52 of file EigenMatrix.cpp.

References m_data, m_view, mutator(), size1(), and size2().

◆ EigenMatrix() [6/8]

Mantid::CurveFitting::EigenMatrix::EigenMatrix ( const Kernel::Matrix< double > &  M)

◆ EigenMatrix() [7/8]

Mantid::CurveFitting::EigenMatrix::EigenMatrix ( const Kernel::Matrix< double > &  M,
size_t  row,
size_t  col,
size_t  nRows,
size_t  nCols 
)

Constructor.

Create a submatrix.

A submatrix is a reference to part of the parent matrix.

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 81 of file EigenMatrix.cpp.

References Mantid::Kernel::Matrix< T >::getVector(), m_data, Mantid::CurveFitting::EigenMatrix_View::matrix_mutator(), Mantid::Kernel::Matrix< T >::numCols(), Mantid::Kernel::Matrix< T >::numRows(), and resize().

◆ EigenMatrix() [8/8]

Mantid::CurveFitting::EigenMatrix::EigenMatrix ( std::vector< double > &&  data,
size_t  nx,
size_t  ny 
)
private

"Move" constructor

Definition at line 98 of file EigenMatrix.cpp.

Member Function Documentation

◆ copy_view()

map_type Mantid::CurveFitting::EigenMatrix::copy_view ( ) const
inline

Get a copy of the Eigen matrix.

Definition at line 60 of file EigenMatrix.h.

Referenced by copyColumn(), and copyRow().

◆ copyColumn()

EigenVector Mantid::CurveFitting::EigenMatrix::copyColumn ( size_t  i) const

◆ copyRow()

EigenVector Mantid::CurveFitting::EigenMatrix::copyRow ( size_t  i) const

◆ det()

double Mantid::CurveFitting::EigenMatrix::det ( ) const

Calculate the determinant.

Definition at line 286 of file EigenMatrix.cpp.

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

Referenced by solve().

◆ diag()

void Mantid::CurveFitting::EigenMatrix::diag ( const EigenVector d)

Set the matrix to be diagonal.

Parameters
d:: Values on the diagonal.

Definition at line 179 of file EigenMatrix.cpp.

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

◆ eigenSystem()

void Mantid::CurveFitting::EigenMatrix::eigenSystem ( EigenVector eigenValues,
EigenMatrix eigenVectors 
)

Calculate the eigensystem of a symmetric 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 299 of file EigenMatrix.cpp.

References inspector(), n, size1(), and size2().

Referenced by Mantid::CurveFitting::NLLS::allEigSymm().

◆ get()

double Mantid::CurveFitting::EigenMatrix::get ( size_t  i,
size_t  j 
) const

◆ identity()

void Mantid::CurveFitting::EigenMatrix::identity ( )

Set this matrix to identity matrix.

Definition at line 172 of file EigenMatrix.cpp.

References m_view, and Mantid::CurveFitting::EigenMatrix_View::matrix_mutator().

◆ inspector()

const map_type Mantid::CurveFitting::EigenMatrix::inspector ( ) const
inline

◆ invert()

void Mantid::CurveFitting::EigenMatrix::invert ( )

◆ isEmpty()

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

◆ move()

EigenMatrix Mantid::CurveFitting::EigenMatrix::move ( )
protected

Create a new matrix and move the data to it.

Definition at line 347 of file EigenMatrix.cpp.

References EigenMatrix(), m_data, size1(), and size2().

◆ multiplyByVector()

EigenVector Mantid::CurveFitting::EigenMatrix::multiplyByVector ( const EigenVector v) const
private

◆ mutator()

map_type & Mantid::CurveFitting::EigenMatrix::mutator ( )
inline

◆ operator()() [1/2]

double & Mantid::CurveFitting::EigenMatrix::operator() ( size_t  i,
size_t  j 
)
inline

Get the reference to the data element.

Definition at line 152 of file EigenMatrix.h.

References m_data, m_view, and Mantid::CurveFitting::EigenMatrix_View::rows().

◆ operator()() [2/2]

double Mantid::CurveFitting::EigenMatrix::operator() ( size_t  i,
size_t  j 
) const
inline

The "index" operator.

Definition at line 149 of file EigenMatrix.h.

◆ operator*() [1/2]

EigenMatrix Mantid::CurveFitting::EigenMatrix::operator* ( const EigenMatrix m) const

Matrix by Matrix multiplication.

Parameters
m:: A matrix to multiply by. Must have the same size1() as size2() of this matrix.
Returns
A Matrix - the result of the multiplication. Size of the returned vector equals size2() of first matrix by size1*() of second.
Exceptions
std::invalid_argumentif the input matrix has a wrong size.

Definition at line 239 of file EigenMatrix.cpp.

References inspector(), Mantid::Geometry::m, and size2().

◆ operator*() [2/2]

EigenVector Mantid::CurveFitting::EigenMatrix::operator* ( const EigenVector v) const

Matrix by vector multiplication.

Parameters
v:: A vector to multiply by. Must have the same size as size2().
Returns
A vector - the result of the multiplication. Size of the returned vector equals size1().
Exceptions
std::invalid_argumentif the input vector has a wrong size.

Definition at line 224 of file EigenMatrix.cpp.

References inspector(), Mantid::CurveFitting::EigenVector::inspector(), Mantid::CurveFitting::EigenVector::size(), and size2().

◆ operator*=()

EigenMatrix & Mantid::CurveFitting::EigenMatrix::operator*= ( const double &  d)

Multiply this matrix by a number.

multiply this matrix by a number

Parameters
d:: A number

Definition at line 214 of file EigenMatrix.cpp.

References Mantid::Geometry::d, m_view, and Mantid::CurveFitting::EigenMatrix_View::matrix_mutator().

◆ operator+=() [1/2]

EigenMatrix & Mantid::CurveFitting::EigenMatrix::operator+= ( const double &  d)

Add a constant to this matrix.

add a constant to this matrix

Parameters
d:: A number

Definition at line 196 of file EigenMatrix.cpp.

References Mantid::Geometry::d, m_view, and Mantid::CurveFitting::EigenMatrix_View::matrix_mutator().

◆ operator+=() [2/2]

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

Add a matrix to this.

add a matrix to this

Parameters
M:: A matrix

Definition at line 190 of file EigenMatrix.cpp.

References inspector(), m_view, and Mantid::CurveFitting::EigenMatrix_View::matrix_mutator().

◆ operator-=() [1/2]

EigenMatrix & Mantid::CurveFitting::EigenMatrix::operator-= ( const double &  d)

subtract a constant from this

Parameters
d:: A number

Definition at line 208 of file EigenMatrix.cpp.

References Mantid::Geometry::d, m_view, and Mantid::CurveFitting::EigenMatrix_View::matrix_mutator().

◆ operator-=() [2/2]

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

Subtract a matrix from this.

subtract a matrix from this

Parameters
M:: A matrix

Definition at line 202 of file EigenMatrix.cpp.

References inspector(), m_view, and Mantid::CurveFitting::EigenMatrix_View::matrix_mutator().

◆ operator=() [1/2]

EigenMatrix & Mantid::CurveFitting::EigenMatrix::operator= ( const Eigen::MatrixXd  v)

Assignment operator - Eigen::MatrixXd.

Definition at line 109 of file EigenMatrix.cpp.

References Mantid::Geometry::m, m_data, and m_view.

◆ operator=() [2/2]

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

Copy assignment operator.

Definition at line 102 of file EigenMatrix.cpp.

References m_data, m_view, size1(), and size2().

◆ resize()

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

◆ set()

void Mantid::CurveFitting::EigenMatrix::set ( size_t  i,
size_t  j,
double  value 
)

◆ size1()

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

◆ size2()

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

◆ solve()

void Mantid::CurveFitting::EigenMatrix::solve ( const EigenVector rhs,
EigenVector x 
)

Solve system of linear equations M*x == rhs, M is this matrix This matrix is destroyed.

Solve system of linear equations M*x == rhs, M is this matrix.

Parameters
rhs:: The right-hand-side vector
x:: The solution vector
rhs:: The right-hand-side vector
x:: The solution vector
Exceptions
std::invalid_argumentif the input vectors have wrong sizes.
std::runtime_errorif Eigen cannot produce a valid solution.

Definition at line 254 of file EigenMatrix.cpp.

References det(), inspector(), n, rhs, size1(), size2(), and Mantid::Geometry::x.

◆ tr()

EigenMatrix Mantid::CurveFitting::EigenMatrix::tr ( ) const

Calculate the eigensystem of a symmetric matrix.

Copy matrix, transpose, then return transposed copy.

Definition at line 360 of file EigenMatrix.cpp.

References inspector().

Referenced by Mantid::CurveFitting::CostFunctions::CostFuncFitting::calActiveCovarianceMatrix(), Mantid::CurveFitting::CostFunctions::CostFuncFitting::calCovarianceMatrix(), and Mantid::CurveFitting::Functions::ChebfunBase::roots().

◆ zero()

void Mantid::CurveFitting::EigenMatrix::zero ( )

Member Data Documentation

◆ m_data

std::vector<double> Mantid::CurveFitting::EigenMatrix::m_data
private

Default element storage.

Definition at line 128 of file EigenMatrix.h.

Referenced by EigenMatrix(), isEmpty(), move(), operator()(), operator=(), and resize().

◆ m_view

EigenMatrix_View Mantid::CurveFitting::EigenMatrix::m_view
private

The pointer to the vector.

Definition at line 130 of file EigenMatrix.h.

Referenced by EigenMatrix(), get(), identity(), operator()(), operator*=(), operator+=(), operator-=(), operator=(), resize(), set(), size1(), size2(), and zero().


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