Mantid
|
A wrapper around Eigen::Matrix. More...
#include <EigenMatrix.h>
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_type & | mutator () |
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... | |
EigenMatrix & | operator*= (const double &d) |
Multiply this matrix by a number. More... | |
EigenMatrix & | operator+= (const double &d) |
Add a constant to this matrix. More... | |
EigenMatrix & | operator+= (const EigenMatrix &M) |
Add a matrix to this. More... | |
EigenMatrix & | operator-= (const double &d) |
subtract a constant from this More... | |
EigenMatrix & | operator-= (const EigenMatrix &M) |
Subtract a matrix from this. More... | |
EigenMatrix & | operator= (const Eigen::MatrixXd v) |
Assignment operator - Eigen::MatrixXd. More... | |
EigenMatrix & | operator= (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... | |
|
default |
Constructor.
Referenced by move().
Mantid::CurveFitting::EigenMatrix::EigenMatrix | ( | const size_t | nx, |
const size_t | ny | ||
) |
Constructor.
nx | :: First dimension |
ny | :: Second dimension |
Definition at line 18 of file EigenMatrix.cpp.
Mantid::CurveFitting::EigenMatrix::EigenMatrix | ( | std::initializer_list< std::initializer_list< double > > | ilist | ) |
Construct from an initialisation list.
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.
Mantid::CurveFitting::EigenMatrix::EigenMatrix | ( | const EigenMatrix & | M | ) |
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.
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.
Mantid::CurveFitting::EigenMatrix::EigenMatrix | ( | const Kernel::Matrix< double > & | M | ) |
Constructor.
M | :: A matrix to copy. |
Definition at line 64 of file EigenMatrix.cpp.
References Mantid::Kernel::Matrix< T >::getVector(), m_data, Mantid::CurveFitting::EigenMatrix_View::matrix_mutator(), Mantid::Kernel::Matrix< T >::numCols(), and Mantid::Kernel::Matrix< T >::numRows().
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.
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().
|
private |
"Move" constructor
Definition at line 98 of file EigenMatrix.cpp.
|
inline |
Get a copy of the Eigen matrix.
Definition at line 60 of file EigenMatrix.h.
Referenced by copyColumn(), and copyRow().
EigenVector Mantid::CurveFitting::EigenMatrix::copyColumn | ( | size_t | i | ) | const |
Copy a column into an EigenVector.
Copy a column into a EigenVector.
i | :: A column index. |
Definition at line 335 of file EigenMatrix.cpp.
References copy_view(), Mantid::CurveFitting::EigenMatrix_View::innerStride(), Mantid::CurveFitting::EigenMatrix_View::matrix_mutator(), Mantid::CurveFitting::EigenMatrix_View::rows(), size1(), and size2().
EigenVector Mantid::CurveFitting::EigenMatrix::copyRow | ( | size_t | i | ) | const |
Copy a row into an EigenVector.
Copy a row into a EigenVector.
i | :: A row index. |
Definition at line 322 of file EigenMatrix.cpp.
References Mantid::CurveFitting::EigenMatrix_View::cols(), copy_view(), Mantid::CurveFitting::EigenMatrix_View::matrix_mutator(), Mantid::CurveFitting::EigenMatrix_View::outerStride(), size1(), and size2().
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().
void Mantid::CurveFitting::EigenMatrix::diag | ( | const EigenVector & | d | ) |
Set the matrix to be diagonal.
d | :: Values on the diagonal. |
Definition at line 179 of file EigenMatrix.cpp.
References Mantid::Geometry::d, n, resize(), set(), and zero().
void Mantid::CurveFitting::EigenMatrix::eigenSystem | ( | EigenVector & | eigenValues, |
EigenMatrix & | eigenVectors | ||
) |
Calculate the eigensystem of a symmetric matrix.
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().
double Mantid::CurveFitting::EigenMatrix::get | ( | size_t | i, |
size_t | j | ||
) | const |
Get an element.
get an element
i | :: The row |
j | :: The column |
Definition at line 160 of file EigenMatrix.cpp.
References Mantid::CurveFitting::EigenMatrix_View::cols(), isEmpty(), m_view, Mantid::CurveFitting::EigenMatrix_View::matrix_inspector(), and Mantid::CurveFitting::EigenMatrix_View::rows().
Referenced by Mantid::CurveFitting::CostFunctions::CostFuncLeastSquares::addValDerivHessian(), Mantid::CurveFitting::CostFunctions::CostFuncUnweightedLeastSquares::calActiveCovarianceMatrix(), Mantid::CurveFitting::CostFunctions::CostFuncLeastSquares::calActiveCovarianceMatrix(), Mantid::CurveFitting::CostFunctions::CostFuncPoisson::calculateHessian(), Mantid::CurveFitting::CostFunctions::CostFuncFitting::calFittingErrors(), Mantid::CurveFitting::Algorithms::Fit::createOutput(), Mantid::CurveFitting::Algorithms::ProfileChiSquared1D::execConcrete(), Mantid::CurveFitting::EigenJacobian::get(), and Mantid::CurveFitting::CostFunctions::CostFuncFitting::valDerivHessian().
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().
|
inline |
Get a const copy of the Eigen matrix.
Definition at line 58 of file EigenMatrix.h.
Referenced by Mantid::CurveFitting::CostFunctions::CostFuncFitting::calActiveCovarianceMatrix(), Mantid::CurveFitting::Algorithms::Fit::createOutput(), det(), eigenSystem(), Mantid::CurveFitting::NLLS::getSvdJ(), invert(), Mantid::CurveFitting::FuncMinimisers::LevenbergMarquardtMDMinimizer::iterate(), Mantid::CurveFitting::NLLS::matmultInner(), multiplyByVector(), Mantid::CurveFitting::NLLS::multJ(), Mantid::CurveFitting::NLLS::multJt(), operator*(), operator+=(), operator-=(), solve(), and tr().
void Mantid::CurveFitting::EigenMatrix::invert | ( | ) |
Invert this matrix.
Definition at line 278 of file EigenMatrix.cpp.
References inspector(), mutator(), size1(), and size2().
Referenced by Mantid::CurveFitting::CostFunctions::CostFuncLeastSquares::calActiveCovarianceMatrix(), and Mantid::CurveFitting::Algorithms::ProfileChiSquared1D::getCovarianceMatrix().
bool Mantid::CurveFitting::EigenMatrix::isEmpty | ( | ) | const |
Is matrix empty.
Definition at line 119 of file EigenMatrix.cpp.
References m_data.
Referenced by Mantid::CurveFitting::CostFunctions::CostFuncLeastSquares::calActiveCovarianceMatrix(), get(), set(), and Mantid::CurveFitting::CostFunctions::CostFuncFitting::valDerivHessian().
|
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().
|
private |
Definition at line 349 of file EigenMatrix.cpp.
References inspector(), Mantid::CurveFitting::EigenVector::inspector(), Mantid::CurveFitting::EigenVector::size(), and size2().
|
inline |
Get the map to Eigen matrix.
Definition at line 56 of file EigenMatrix.h.
Referenced by Mantid::CurveFitting::EigenJacobian::addNumberToColumn(), Mantid::CurveFitting::CostFunctions::CostFuncFitting::calActiveCovarianceMatrix(), EigenMatrix(), Mantid::CurveFitting::Functions::BSpline::evaluateBasisFnDerivatives(), Mantid::CurveFitting::EigenJacobian::getJ(), Mantid::CurveFitting::gsl_df(), invert(), Mantid::CurveFitting::NLLS::matmultInner(), Mantid::CurveFitting::NLLS::rankOneUpdate(), and Mantid::CurveFitting::Functions::ChebfunBase::roots().
|
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().
|
inline |
The "index" operator.
Definition at line 149 of file EigenMatrix.h.
EigenMatrix Mantid::CurveFitting::EigenMatrix::operator* | ( | const EigenMatrix & | m | ) | const |
Matrix by Matrix multiplication.
std::invalid_argument | if the input matrix has a wrong size. |
Definition at line 239 of file EigenMatrix.cpp.
References inspector(), Mantid::Geometry::m, and size2().
EigenVector Mantid::CurveFitting::EigenMatrix::operator* | ( | const EigenVector & | v | ) | const |
Matrix by vector multiplication.
v | :: A vector to multiply by. Must have the same size as size2(). |
std::invalid_argument | if 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().
EigenMatrix & Mantid::CurveFitting::EigenMatrix::operator*= | ( | const double & | d | ) |
Multiply this matrix by a number.
multiply this matrix by a number
d | :: A number |
Definition at line 214 of file EigenMatrix.cpp.
References Mantid::Geometry::d, m_view, and Mantid::CurveFitting::EigenMatrix_View::matrix_mutator().
EigenMatrix & Mantid::CurveFitting::EigenMatrix::operator+= | ( | const double & | d | ) |
Add a constant to this matrix.
add a constant to this matrix
d | :: A number |
Definition at line 196 of file EigenMatrix.cpp.
References Mantid::Geometry::d, m_view, and Mantid::CurveFitting::EigenMatrix_View::matrix_mutator().
EigenMatrix & Mantid::CurveFitting::EigenMatrix::operator+= | ( | const EigenMatrix & | M | ) |
Add a matrix to this.
add a matrix to this
M | :: A matrix |
Definition at line 190 of file EigenMatrix.cpp.
References inspector(), m_view, and Mantid::CurveFitting::EigenMatrix_View::matrix_mutator().
EigenMatrix & Mantid::CurveFitting::EigenMatrix::operator-= | ( | const double & | d | ) |
subtract a constant from this
d | :: A number |
Definition at line 208 of file EigenMatrix.cpp.
References Mantid::Geometry::d, m_view, and Mantid::CurveFitting::EigenMatrix_View::matrix_mutator().
EigenMatrix & Mantid::CurveFitting::EigenMatrix::operator-= | ( | const EigenMatrix & | M | ) |
Subtract a matrix from this.
subtract a matrix from this
M | :: A matrix |
Definition at line 202 of file EigenMatrix.cpp.
References inspector(), m_view, and Mantid::CurveFitting::EigenMatrix_View::matrix_mutator().
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.
EigenMatrix & Mantid::CurveFitting::EigenMatrix::operator= | ( | const EigenMatrix & | M | ) |
void Mantid::CurveFitting::EigenMatrix::resize | ( | const size_t | nx, |
const size_t | ny | ||
) |
Resize the matrix.
nx | :: New first dimension |
ny | :: New second dimension |
Definition at line 124 of file EigenMatrix.cpp.
References m_data, and m_view.
Referenced by Mantid::CurveFitting::CostFunctions::CostFuncPoisson::addValDerivHessian(), Mantid::CurveFitting::CostFunctions::CostFuncFitting::calActiveCovarianceMatrix(), Mantid::CurveFitting::CostFunctions::CostFuncFitting::calTransformationMatrixNumerically(), diag(), Mantid::CurveFitting::EigenJacobian::EigenJacobian(), EigenMatrix(), and Mantid::CurveFitting::CostFunctions::CostFuncFitting::valDerivHessian().
void Mantid::CurveFitting::EigenMatrix::set | ( | size_t | i, |
size_t | j, | ||
double | value | ||
) |
Set an element.
set an element
i | :: The row |
j | :: The column |
value | :: The new vaule |
Definition at line 146 of file EigenMatrix.cpp.
References Mantid::CurveFitting::EigenMatrix_View::cols(), isEmpty(), m_view, Mantid::CurveFitting::EigenMatrix_View::matrix_mutator(), Mantid::CurveFitting::EigenMatrix_View::rows(), and value.
Referenced by Mantid::CurveFitting::CostFunctions::CostFuncLeastSquares::addValDerivHessian(), Mantid::CurveFitting::CostFunctions::CostFuncPoisson::calculateHessian(), Mantid::CurveFitting::CostFunctions::CostFuncFitting::calTransformationMatrixNumerically(), diag(), EigenMatrix(), Mantid::CurveFitting::Functions::ChebfunBase::roots(), Mantid::CurveFitting::EigenJacobian::set(), and Mantid::CurveFitting::CostFunctions::CostFuncFitting::valDerivHessian().
size_t Mantid::CurveFitting::EigenMatrix::size1 | ( | ) | const |
First size of the matrix.
Definition at line 137 of file EigenMatrix.cpp.
References m_view, and Mantid::CurveFitting::EigenMatrix_View::rows().
Referenced by Mantid::CurveFitting::EigenJacobian::addNumberToColumn(), Mantid::CurveFitting::CostFunctions::CostFuncLeastSquares::addValDerivHessian(), Mantid::CurveFitting::CostFunctions::CostFuncUnweightedLeastSquares::calActiveCovarianceMatrix(), Mantid::CurveFitting::CostFunctions::CostFuncLeastSquares::calActiveCovarianceMatrix(), Mantid::CurveFitting::CostFunctions::CostFuncFitting::calFittingErrors(), copyColumn(), copyRow(), Mantid::CurveFitting::Algorithms::Fit::createOutput(), det(), EigenMatrix(), eigenSystem(), invert(), move(), operator=(), and solve().
size_t Mantid::CurveFitting::EigenMatrix::size2 | ( | ) | const |
Second size of the matrix.
Definition at line 140 of file EigenMatrix.cpp.
References Mantid::CurveFitting::EigenMatrix_View::cols(), and m_view.
Referenced by Mantid::CurveFitting::EigenJacobian::addNumberToColumn(), Mantid::CurveFitting::CostFunctions::CostFuncLeastSquares::addValDerivHessian(), Mantid::CurveFitting::CostFunctions::CostFuncUnweightedLeastSquares::calActiveCovarianceMatrix(), Mantid::CurveFitting::CostFunctions::CostFuncLeastSquares::calActiveCovarianceMatrix(), Mantid::CurveFitting::CostFunctions::CostFuncFitting::calFittingErrors(), copyColumn(), copyRow(), Mantid::CurveFitting::Algorithms::Fit::createOutput(), det(), EigenMatrix(), eigenSystem(), invert(), move(), multiplyByVector(), operator*(), operator=(), and 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.
rhs | :: The right-hand-side vector |
x | :: The solution vector |
rhs | :: The right-hand-side vector |
x | :: The solution vector |
std::invalid_argument | if the input vectors have wrong sizes. |
std::runtime_error | if 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.
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().
void Mantid::CurveFitting::EigenMatrix::zero | ( | ) |
Set all elements to zero.
Definition at line 175 of file EigenMatrix.cpp.
References m_view, and Mantid::CurveFitting::EigenMatrix_View::matrix_mutator().
Referenced by Mantid::CurveFitting::CostFunctions::CostFuncPoisson::addValDerivHessian(), Mantid::CurveFitting::Functions::deg_on(), diag(), Mantid::CurveFitting::FuncMinimisers::TrustRegionMinimizer::evalHF(), Mantid::CurveFitting::Functions::ChebfunBase::roots(), Mantid::CurveFitting::CostFunctions::CostFuncFitting::valDerivHessian(), and Mantid::CurveFitting::EigenJacobian::zero().
|
private |
Default element storage.
Definition at line 128 of file EigenMatrix.h.
Referenced by EigenMatrix(), isEmpty(), move(), operator()(), operator=(), and resize().
|
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().