Mantid
|
Numerical Matrix class. More...
#include <Matrix.h>
Public Types | |
using | value_type = T |
Enable users to retrieve the element type. More... | |
Public Member Functions | |
void | averSymmetric () |
make Matrix symmetric More... | |
T | compSum () const |
Add up each component sums for the matrix. More... | |
T | determinant () const |
Calculate the determinant. More... | |
std::vector< T > | Diagonal () const |
Returns a vector of the diagonal. More... | |
int | Diagonalise (Matrix< T > &, Matrix< T > &) const |
(only Symmetric matrix) More... | |
bool | equals (const Matrix< T > &A, const double Tolerance=FLT_EPSILON) const |
Element by element comparison within tolerance. More... | |
T | factor () |
Calculate the factor. More... | |
void | GaussJordan (Kernel::Matrix< int > &) |
Not valid for Integer. More... | |
void | GaussJordan (Matrix< T > &) |
Create a Gauss-Jordan Inversion. More... | |
std::vector< T > | getVector () const |
void | identityMatrix () |
Makes the matrix an idenity matrix. More... | |
T | Invert () |
LU inversion routine. More... | |
void | invertTridiagonal () |
Check it's a square tridiagonal matrix with all diagonal elements equal and if yes invert the matrix using analytic formula. More... | |
bool | isOrthogonal () const |
Check if a matrix is orthogonal. More... | |
bool | isRotation () const |
Check if a matrix represents a proper rotation @ return :: true/false. More... | |
T | item (size_t row, size_t col) const |
Matrix (const Matrix< T > &) | |
Simple copy constructor. More... | |
Matrix (const Matrix< T > &, const size_t nrow, const size_t ncol) | |
Constructor with for a missing row/column. More... | |
Matrix (const size_t nrow=0, const size_t ncol=0, bool const makeIdentity=false) | |
Constructor with pre-set sizes. More... | |
Matrix (const std::vector< T > &) | |
Build square matrix from a linear vector. More... | |
Matrix (const std::vector< T > &, const size_t nrow, const size_t ncol) | |
Build a non-square matrix from vector and dimensions. More... | |
Matrix (const std::vector< T > &, const std::vector< T > &) | |
Constructor to take two vectors and multiply them to construct a matrix. More... | |
Matrix (Matrix< T > &&) noexcept | |
void | multiplyPoint (const std::vector< T > &in, std::vector< T > &out) const |
Multiply M*Vec. More... | |
void | normVert () |
Vertical normalisation. More... | |
size_t | numCols () const |
Return the number of columns in the matrix. More... | |
size_t | numRows () const |
Return the number of rows in the matrix. More... | |
operator std::vector< T > () const | |
bool | operator!= (const Matrix< T > &) const |
Element by Element comparison. More... | |
Matrix< T > | operator* (const Matrix< T > &) const |
Basic matrix multiply. More... | |
std::vector< T > | operator* (const std::vector< T > &) const |
Multiply M*Vec. More... | |
Matrix< T > | operator* (const T &) const |
Multiply by constant. More... | |
V3D | operator* (const V3D &) const |
Multiply M*Vec. More... | |
Matrix< T > & | operator*= (const Matrix< T > &) |
Basic matrix multipy. More... | |
Matrix< T > & | operator*= (const T &) |
Multiply by constant. More... | |
Matrix< T > | operator+ (const Matrix< T > &) const |
Basic addition operator. More... | |
Matrix< T > & | operator+= (const Matrix< T > &) |
Basic addition operator. More... | |
Matrix< T > | operator- (const Matrix< T > &) const |
Basic subtraction operator. More... | |
Matrix< T > & | operator-= (const Matrix< T > &) |
Basic subtraction operator. More... | |
Matrix< T > & | operator/= (const T &) |
Divide by constant. More... | |
bool | operator< (const Matrix< T > &) const |
Element by element comparison of < Always returns false if the Matrix have different sizes. More... | |
Matrix< T > & | operator= (const Matrix< T > &) |
Simple assignment operator. More... | |
Matrix< T > & | operator= (Matrix< T > &&) noexcept |
bool | operator== (const Matrix< T > &) const |
Element by element comparison within tolerance. More... | |
bool | operator>= (const Matrix< T > &) const |
Element by element comparison of >= Always returns false if the Matrix have different sizes. More... | |
T * | operator[] (const size_t row) |
Array accessor. Use, e.g. Matrix[row][col]. More... | |
const T * | operator[] (const size_t row) const |
const Array accessor. Use, e.g. Matrix[row][col] More... | |
Matrix< T > | postMultiplyByDiagonal (const std::vector< T > &) const |
post-multiply this*D More... | |
Matrix< T > | preMultiplyByDiagonal (const std::vector< T > &) const |
pre-multiply D*this More... | |
void | print () const |
Simple print out routine. More... | |
void | setColumn (const size_t nCol, const std::vector< T > &newCol) |
void | setMem (const size_t, const size_t) |
Sets the memory held in matrix. More... | |
void | setRandom (size_t seed=0, double rMin=-1, double rMax=1) |
initialize random matrix; More... | |
void | setRow (const size_t nRow, const std::vector< T > &newRow) |
std::pair< size_t, size_t > | size () const |
Access matrix sizes. More... | |
void | sortEigen (Matrix< T > &) |
Sort eigenvectors. More... | |
size_t | Ssize () const |
Return the smallest matrix size. More... | |
std::string | str () const |
Convert the matrix into a simple linear string expression. More... | |
void | swapCols (const size_t, const size_t) |
Swap cols (second V index) More... | |
void | swapRows (const size_t, const size_t) |
Swap rows (first V index) More... | |
std::vector< T > | toRotation () |
Transform the matrix to a rotation matrix, by normalizing each column to 1. More... | |
Matrix< T > | Tprime () const |
Transpose the matrix. More... | |
T | Trace () const |
Trace of the matrix. More... | |
Matrix< T > & | Transpose () |
Transpose the matrix. More... | |
void | write (std::ostream &, int const =0) const |
Write out function for blocks of 10 Columns. More... | |
void | zeroMatrix () |
Set the matrix to zero. More... | |
Private Types | |
template<class U > | |
using | CMemoryArray = std::unique_ptr< U[]> |
1D memory allocation to be wrapped with pointers to the rows More... | |
template<typename U > | |
using | MatrixMemoryPtrs = std::unique_ptr< U *[]> |
Pointers to rows in the raw data array to make it appear 2D. More... | |
Private Member Functions | |
void | lubcmp (int *, int &) |
starts inversion process More... | |
void | lubksb (int const *, double *) |
Implements a separation of the Matrix into a triangular matrix. More... | |
void | rotate (double const, double const, int const, int const, int const, int const) |
Applies a rotation to a particular point of tan(theta)=tau. More... | |
Private Attributes | |
size_t | m_numColumns |
Number of columns (y coordinate) More... | |
size_t | m_numRows |
Number of rows (x coordinate) More... | |
MatrixMemoryPtrs< T > | m_rawData |
Representation of 2D data. More... | |
CMemoryArray< T > | m_rawDataAlloc |
Pointer to allocated memory. More... | |
Friends | |
template<typename TYPE > | |
void | dumpToStream (std::ostream &, const Kernel::Matrix< TYPE > &, const char) |
template<typename TYPE > | |
void | fillFromStream (std::istream &, Kernel::Matrix< TYPE > &, const char) |
Numerical Matrix class.
Holds a matrix of variable type and size. Should work for real and complex objects. Carries out eigenvalue and inversion if the matrix is square
|
private |
|
private |
using Mantid::Kernel::Matrix< T >::value_type = T |
Mantid::Kernel::Matrix< T >::Matrix | ( | const size_t | nrow = 0 , |
const size_t | ncol = 0 , |
||
bool const | makeIdentity = false |
||
) |
Constructor with pre-set sizes.
Matrix is zeroed
nrow | :: number of rows |
ncol | :: number of columns |
makeIdentity | :: flag for the constructor to return an identity matrix |
Definition at line 90 of file Matrix.cpp.
Mantid::Kernel::Matrix< T >::Matrix | ( | const std::vector< T > & | A, |
const std::vector< T > & | B | ||
) |
Constructor to take two vectors and multiply them to construct a matrix.
(assuming that we have columns x row vector.
(assuming that we have columns x row vector.
A | :: Column vector to multiply |
B | :: Row vector to multiply |
Definition at line 107 of file Matrix.cpp.
Mantid::Kernel::Matrix< T >::Matrix | ( | const std::vector< T > & | data | ) |
Build square matrix from a linear vector.
Throw if the vector.size() != m_numRows * m_numRows;
Definition at line 126 of file Matrix.cpp.
Mantid::Kernel::Matrix< T >::Matrix | ( | const std::vector< T > & | data, |
const size_t | nrow, | ||
const size_t | ncol | ||
) |
Build a non-square matrix from vector and dimensions.
Definition at line 146 of file Matrix.cpp.
Mantid::Kernel::Matrix< T >::Matrix | ( | const Matrix< T > & | A, |
const size_t | nrow, | ||
const size_t | ncol | ||
) |
Constructor with for a missing row/column.
A | :: The input matrix |
nrow | :: number of row to miss |
ncol | :: number of column to miss |
Definition at line 167 of file Matrix.cpp.
Mantid::Kernel::Matrix< T >::Matrix | ( | const Matrix< T > & | A | ) |
Simple copy constructor.
A | :: Object to copy |
Definition at line 197 of file Matrix.cpp.
References Mantid::Kernel::Matrix< T >::m_numColumns, Mantid::Kernel::Matrix< T >::m_numRows, Mantid::Kernel::Matrix< T >::m_rawData, and Mantid::Kernel::Matrix< T >::setMem().
|
noexcept |
Definition at line 237 of file Matrix.cpp.
void Mantid::Kernel::Matrix< T >::averSymmetric |
make Matrix symmetric
Simple function to create an average symmetric matrix out of the Matrix.
Definition at line 1249 of file Matrix.cpp.
T Mantid::Kernel::Matrix< T >::compSum |
Add up each component sums for the matrix.
Definition at line 1131 of file Matrix.cpp.
T Mantid::Kernel::Matrix< T >::determinant |
Calculate the determinant.
Calculate the derminant of the matrix.
Definition at line 1048 of file Matrix.cpp.
References Mantid::Kernel::Matrix< T >::factor().
Referenced by Mantid::MDAlgorithms::IntegratePeaksMD2::calcCovar(), Mantid::Geometry::UnitCell::calculateGstar(), Mantid::Geometry::SymmetryElementRotationGenerator::canProcess(), Mantid::Geometry::SymmetryElementMirrorGenerator::canProcess(), Mantid::Geometry::IndexingUtils::CheckUB(), Mantid::Geometry::SymmetryElementWithAxisGenerator::determineAxis(), Mantid::Geometry::SymmetryElementRotationGenerator::determineRotationSense(), Mantid::Geometry::SymmetryElementRotationGenerator::determineSymbol(), Mantid::MDAlgorithms::CalculateCoverageDGS::exec(), Mantid::Kernel::VMDBase< TYPE >::getNormalVector(), Mantid::Geometry::SymmetryOperation::getOrderFromMatrix(), Mantid::Geometry::UnitCell::recVolume(), Mantid::Geometry::OrientedLattice::setUB(), Mantid::MDAlgorithms::MDNorm::validateInputs(), and Mantid::Geometry::UnitCell::volume().
std::vector< T > Mantid::Kernel::Matrix< T >::Diagonal |
Returns a vector of the diagonal.
Returns the diagonal form as a vector.
Definition at line 1265 of file Matrix.cpp.
Referenced by Mantid::MDAlgorithms::IntegratePeaksMD2::calcCovar(), and Mantid::Kernel::Matrix< T >::sortEigen().
int Mantid::Kernel::Matrix< T >::Diagonalise | ( | Matrix< T > & | EigenVec, |
Matrix< T > & | DiagMatrix | ||
) | const |
(only Symmetric matrix)
Attempt to diagonalise the matrix IF symmetric.
EigenVec | :: (output) the Eigenvectors matrix |
DiagMatrix | :: the diagonal matrix of eigenvalues |
Definition at line 1319 of file Matrix.cpp.
References fabs, Mantid::Kernel::Matrix< T >::m_rawData, and Mantid::Kernel::Matrix< T >::rotate().
Referenced by Mantid::MDAlgorithms::IntegratePeaksMD2::calcCovar(), Mantid::Geometry::Quadratic::distance(), and Mantid::Crystal::CalculateUMatrix::exec().
bool Mantid::Kernel::Matrix< T >::equals | ( | const Matrix< T > & | A, |
const double | Tolerance = FLT_EPSILON |
||
) | const |
Element by element comparison within tolerance.
Tolerance means that the value must be > tolerance and less than (diff/max)>tolerance Always returns 0 if the Matrix have different sizes
A | :: matrix to check. |
Tolerance | :: tolerance in comparing elements |
Definition at line 499 of file Matrix.cpp.
References fabs, and Mantid::Kernel::Tolerance.
T Mantid::Kernel::Matrix< T >::factor |
Calculate the factor.
Gauss jordan diagonal factorisation The diagonal is left as the values, the lower part is zero.
Definition at line 1063 of file Matrix.cpp.
References fabs.
Referenced by Mantid::Kernel::Matrix< T >::determinant().
|
inline |
void Mantid::Kernel::Matrix< T >::GaussJordan | ( | Matrix< T > & | B | ) |
Create a Gauss-Jordan Inversion.
Invert this matrix in place using Gauss-Jordan elimination.
Matrix will be replaced by its inverse.
B | :: [input, output] Must have same dimensions as A. Returned as identity matrix. (?) |
std::invalid_argument | on input error |
std::runtime_error | if singular |
Definition at line 838 of file Matrix.cpp.
References fabs, Mantid::Kernel::Matrix< T >::m_numColumns, Mantid::Kernel::Matrix< T >::m_numRows, Mantid::Kernel::Matrix< T >::m_rawData, and Mantid::Kernel::Matrix< T >::swapRows().
std::vector< T > Mantid::Kernel::Matrix< T >::getVector |
Definition at line 77 of file Matrix.cpp.
Referenced by Mantid::MDAlgorithms::ConvertToMD::addExperimentInfo(), Mantid::DataObjects::FakeMD::addFakeEllipsoid(), Mantid::MDAlgorithms::MDWSTransform::buildQTrahsf(), Mantid::CurveFitting::EigenMatrix::EigenMatrix(), Mantid::Crystal::SelectCellOfType::exec(), Mantid::Crystal::SelectCellWithForm::exec(), Mantid::MDAlgorithms::CutMD::exec(), Mantid::MDAlgorithms::MDWSTransform::getTransfMatrix(), Mantid::Geometry::OrientedLattice::saveNexus(), Mantid::MDAlgorithms::MDNorm::setQUnit(), and Mantid::DataObjects::AffineMatrixParameter::toXMLString().
void Mantid::Kernel::Matrix< T >::identityMatrix |
Makes the matrix an idenity matrix.
Zeros all the terms outside of the square
Definition at line 661 of file Matrix.cpp.
Referenced by Mantid::DataObjects::CoordTransformAffine::addTranslation(), Mantid::DataObjects::AffineMatrixParameter::AffineMatrixParameter(), Mantid::DataObjects::CoordTransformAffine::buildNonOrthogonal(), Mantid::DataObjects::CoordTransformAffine::buildOrthogonal(), Mantid::MDAlgorithms::IntegratePeaksMD2::calcCovar(), Mantid::DataObjects::CoordTransformAffine::CoordTransformAffine(), Mantid::Geometry::ShapeFactory::createShape(), Mantid::Crystal::PredictSatellitePeaks::exec(), and Mantid::Geometry::Goniometer::Goniometer().
T Mantid::Kernel::Matrix< T >::Invert |
LU inversion routine.
If the Matrix is square then invert the matrix using LU decomposition.
Definition at line 924 of file Matrix.cpp.
References Mantid::Kernel::Matrix< T >::lubcmp(), Mantid::Kernel::Matrix< T >::lubksb(), and Mantid::Kernel::Matrix< T >::m_rawData.
Referenced by Mantid::DataObjects::FakeMD::addFakeEllipsoid(), Mantid::Crystal::SelectCellWithForm::ApplyTransform(), Mantid::DataObjects::BasePeak::BasePeak(), Mantid::DataObjects::CoordTransformAffine::buildNonOrthogonal(), Mantid::MDAlgorithms::IntegratePeaksMD2::calcCovar(), Mantid::Geometry::Goniometer::calcFromQSampleAndWavelength(), Mantid::Geometry::UnitCell::calculateB(), Mantid::Geometry::UnitCell::calculateGstar(), Mantid::Geometry::IndexingUtils::CalculateMillerIndices(), Mantid::MDAlgorithms::MDNormDirectSC::calculateNormalization(), Mantid::MDAlgorithms::MDNormSCD::calculateNormalization(), Mantid::MDAlgorithms::MDNorm::calQTransform(), Mantid::MDAlgorithms::SlicingAlgorithm::createAlignedTransform(), Mantid::MDAlgorithms::SlicingAlgorithm::createTransform(), Mantid::Crystal::CalculatePeaksHKL::exec(), Mantid::Crystal::GoniometerAnglesFromPhiRotation::exec(), Mantid::Crystal::OptimizeCrystalPlacement::exec(), Mantid::Crystal::ShowPeakHKLOffsets::exec(), Mantid::Crystal::TransformHKL::exec(), Mantid::MDAlgorithms::CalculateCoverageDGS::exec(), Mantid::MDAlgorithms::ConvertToDiffractionMDWorkspace::exec(), Mantid::MDAlgorithms::IntegrateEllipsoidsTwoStep::exec(), Mantid::MDAlgorithms::IntegrateEllipsoidsV1::exec(), Mantid::MDAlgorithms::LoadDNSSCD::fillOutputWorkspace(), Mantid::Crystal::PeakHKLErrors::function1D(), Mantid::Crystal::PeakHKLErrors::functionDeriv1D(), Mantid::Geometry::OrientedLattice::GetABC(), Mantid::Geometry::IndexingUtils::GetIndexedPeaks(), Mantid::Geometry::MatrixVectorPair< MatrixNumericType, VectorType >::getInverse(), Mantid::MDAlgorithms::MDWSTransform::getTransfMatrix(), Mantid::Geometry::OrientedLattice::GetUB(), Mantid::Geometry::OrientedLattice::getuVector(), Mantid::Geometry::OrientedLattice::getvVector(), Mantid::Geometry::OrientedLattice::hklFromQ(), Mantid::Geometry::IndexingUtils::IndexingError(), Mantid::Crystal::GoniometerAnglesFromPhiRotation::IndexRaw(), Mantid::Geometry::ConventionalCell::init(), Mantid::Geometry::SymmetryOperation::init(), Mantid::Geometry::IndexingUtils::NumberIndexed(), Mantid::Geometry::IndexingUtils::Optimize_6dUB(), Mantid::Geometry::IndexingUtils::Optimize_UB(), Mantid::DataObjects::PeaksWorkspace::peakInfo(), Mantid::Kernel::V3D::reBase(), Mantid::Geometry::UnitCell::recalculateFromGstar(), Mantid::Geometry::Quadratic::rotate(), Mantid::DataObjects::BasePeak::setGoniometerMatrix(), Mantid::Geometry::OrientedLattice::setModUB(), Mantid::Geometry::OrientedLattice::setUB(), Mantid::MDAlgorithms::ConvertCWSDExpToMomentum::setupTransferMatrix(), Mantid::Geometry::GridDetector::testIntersectionWithChildren(), and Mantid::Geometry::RectangularDetector::testIntersectionWithChildren().
void Mantid::Kernel::Matrix< T >::invertTridiagonal |
Check it's a square tridiagonal matrix with all diagonal elements equal and if yes invert the matrix using analytic formula.
If not then use standard Invert
Definition at line 963 of file Matrix.cpp.
bool Mantid::Kernel::Matrix< T >::isOrthogonal |
Check if a matrix is orthogonal.
Same as isRotation, but allows determinant to be -1 @ return :: true/false
Definition at line 1444 of file Matrix.cpp.
References fabs, and Mantid::API::operator*().
Referenced by Mantid::Geometry::OrientedLattice::setU().
bool Mantid::Kernel::Matrix< T >::isRotation |
Check if a matrix represents a proper rotation @ return :: true/false.
Definition at line 1424 of file Matrix.cpp.
References fabs, and Mantid::API::operator*().
Referenced by Mantid::Geometry::NiggliCell::NiggliCell(), Mantid::Geometry::OrientedLattice::OrientedLattice(), and Mantid::Geometry::OrientedLattice::setU().
|
inline |
|
private |
starts inversion process
Find biggest pivot and move to top row.
Then divide by pivot.
interchange | :: odd/even nterchange (+/-1) |
rowperm | :: row permutations [m_numRows values] |
Definition at line 1147 of file Matrix.cpp.
References fabs.
Referenced by Mantid::Kernel::Matrix< T >::Invert().
|
private |
Implements a separation of the Matrix into a triangular matrix.
Definition at line 1220 of file Matrix.cpp.
Referenced by Mantid::Kernel::Matrix< T >::Invert().
void Mantid::Kernel::Matrix< T >::multiplyPoint | ( | const std::vector< T > & | in, |
std::vector< T > & | out | ||
) | const |
Multiply M*Vec.
Matrix multiplication THIS * Vec to produce a vec.
in | :: size of vector > this->nrows |
out | :: result of Matrix(This * Vec) |
MisMatch<size_t> | if there is a size mismatch. |
Definition at line 375 of file Matrix.cpp.
Referenced by Mantid::MDAlgorithms::MDNorm::calcSingleDetectorNorm(), Mantid::MDAlgorithms::MDNormDirectSC::calculateNormalization(), Mantid::MDAlgorithms::MDNormSCD::calculateNormalization(), and Mantid::Geometry::MeshObject::multiply().
void Mantid::Kernel::Matrix< T >::normVert |
Vertical normalisation.
Normalise EigenVectors Assumes that they have already been calculated.
Definition at line 1112 of file Matrix.cpp.
|
inline |
Return the number of columns in the matrix.
Definition at line 147 of file Matrix.h.
Referenced by Mantid::Geometry::ShapeFactory::addGoniometerTag(), Mantid::DataObjects::AffineMatrixParameter::AffineMatrixParameter(), Mantid::CurveFitting::AugmentedLagrangianOptimizer::checkConstraints(), Mantid::Geometry::IndexingUtils::CheckUB(), Mantid::DataObjects::AffineMatrixParameter::clone(), Mantid::Geometry::convertMatrix(), Mantid::DataObjects::CoordTransformAffine::CoordTransformAffine(), Mantid::DataObjects::AffineMatrixParameter::copyRawMatrix(), Mantid::DataObjects::CoordTransformAffine::copyRawMatrix(), Mantid::CurveFitting::Functions::ComptonScatteringCountRate::createConstraintMatrices(), Mantid::CurveFitting::Functions::ComptonScatteringCountRate::createEqualityCM(), WorkspaceCreationHelper::createPeaksWorkspace(), Mantid::Geometry::SymmetryElementWithAxisGenerator::determineAxis(), Mantid::Kernel::dumpToStream(), Mantid::CurveFitting::EigenMatrix::EigenMatrix(), Mantid::Crystal::TransformHKL::exec(), Mantid::Geometry::IndexingUtils::Find_UB(), Mantid::MDAlgorithms::MDNormDirectSC::findIntergratedDimensions(), Mantid::MDAlgorithms::MDNormSCD::findIntergratedDimensions(), Mantid::Geometry::IndexingUtils::FormUB_From_abc_Vectors(), Mantid::Geometry::OrientedLattice::GetABC(), Mantid::DataObjects::PeakShapeEllipsoid::getDirectionInSpecificFrame(), Mantid::Geometry::getGSLMatrix(), Mantid::Geometry::SymmetryOperationSymbolParser::getNormalizedIdentifier(), Mantid::Geometry::OrientedLattice::GetUB(), Mantid::Kernel::Math::SLSQPMinimizer::initializeConstraints(), Mantid::CurveFitting::Functions::ComptonScatteringCountRate::iterationStarting(), Mantid::Geometry::MeshObject::multiply(), Mantid::Geometry::operator*(), Mantid::Geometry::IndexingUtils::Optimize_6dUB(), Mantid::Geometry::IndexingUtils::Optimize_UB(), Mantid::Geometry::UnitCell::recalculateFromGstar(), Mantid::Geometry::IndexingUtils::ScanFor_UB(), Mantid::DataObjects::BasePeak::setGoniometerMatrix(), Mantid::DataObjects::AffineMatrixParameter::setMatrix(), Mantid::DataObjects::CoordTransformAffine::setMatrix(), Mantid::DataObjects::AffineMatrixParameter::toXMLString(), MantidQt::API::transformFromDoubleToCoordT(), Mantid::CurveFitting::Functions::ComptonScatteringCountRate::updateCMatrixValues(), and Mantid::Geometry::SymmetryOperationSymbolParser::verifyMatrix().
|
inline |
Return the number of rows in the matrix.
Definition at line 144 of file Matrix.h.
Referenced by Mantid::Geometry::ShapeFactory::addGoniometerTag(), Mantid::DataObjects::AffineMatrixParameter::AffineMatrixParameter(), Mantid::MDAlgorithms::IntegratePeaksMD2::calcCovar(), Mantid::Geometry::IndexingUtils::CheckUB(), Mantid::DataObjects::AffineMatrixParameter::clone(), Mantid::Geometry::convertMatrix(), Mantid::DataObjects::CoordTransformAffine::CoordTransformAffine(), Mantid::DataObjects::AffineMatrixParameter::copyRawMatrix(), Mantid::DataObjects::CoordTransformAffine::copyRawMatrix(), Mantid::CurveFitting::Functions::ComptonScatteringCountRate::createConstraintMatrices(), Mantid::CurveFitting::Functions::ComptonScatteringCountRate::createEqualityCM(), WorkspaceCreationHelper::createPeaksWorkspace(), Mantid::Geometry::SymmetryElementWithAxisGenerator::determineAxis(), Mantid::Kernel::dumpToStream(), Mantid::CurveFitting::EigenMatrix::EigenMatrix(), Mantid::Crystal::TransformHKL::exec(), Mantid::Geometry::IndexingUtils::Find_UB(), Mantid::MDAlgorithms::MDNormDirectSC::findIntergratedDimensions(), Mantid::MDAlgorithms::MDNormSCD::findIntergratedDimensions(), Mantid::Geometry::IndexingUtils::FormUB_From_abc_Vectors(), Mantid::Geometry::OrientedLattice::GetABC(), Mantid::DataObjects::PeakShapeEllipsoid::getDirectionInSpecificFrame(), Mantid::Geometry::getGSLMatrix(), Mantid::Geometry::SymmetryOperationSymbolParser::getNormalizedIdentifier(), Mantid::Geometry::OrientedLattice::GetUB(), Mantid::MDAlgorithms::MDNorm::getValuesFromOtherDimensions(), Mantid::Kernel::Math::SLSQPMinimizer::initializeConstraints(), Mantid::Geometry::MeshObject::multiply(), Mantid::Geometry::operator*(), Mantid::Geometry::IndexingUtils::Optimize_6dUB(), Mantid::Geometry::IndexingUtils::Optimize_UB(), Mantid::Geometry::UnitCell::recalculateFromGstar(), Mantid::Geometry::IndexingUtils::ScanFor_UB(), Mantid::DataObjects::BasePeak::setGoniometerMatrix(), Mantid::DataObjects::AffineMatrixParameter::setMatrix(), Mantid::DataObjects::CoordTransformAffine::setMatrix(), MantidQt::API::transformFromDoubleToCoordT(), Mantid::CurveFitting::Functions::ComptonScatteringCountRate::updateCMatrixValues(), and Mantid::Geometry::SymmetryOperationSymbolParser::verifyMatrix().
|
inline |
bool Mantid::Kernel::Matrix< T >::operator!= | ( | const Matrix< T > & | A | ) | const |
Element by Element comparison.
A | :: Matrix to check |
Definition at line 472 of file Matrix.cpp.
References Mantid::Kernel::operator==().
Matrix< T > Mantid::Kernel::Matrix< T >::operator* | ( | const Matrix< T > & | A | ) | const |
Basic matrix multiply.
Matrix multiplication THIS * A.
A | :: Matrix to multiply by (this->row must == A->columns) |
MisMatch<size_t> | if there is a size mismatch. |
Definition at line 327 of file Matrix.cpp.
References Mantid::Geometry::X.
std::vector< T > Mantid::Kernel::Matrix< T >::operator* | ( | const std::vector< T > & | Vec | ) | const |
Multiply M*Vec.
Matrix multiplication THIS * Vec to produce a vec.
Vec | :: size of vector > this->nrows |
MisMatch<size_t> | if there is a size mismatch. |
Definition at line 349 of file Matrix.cpp.
Matrix< T > Mantid::Kernel::Matrix< T >::operator* | ( | const T & | Value | ) | const |
Multiply by constant.
Matrix multiplication THIS * Value.
Value | :: Scalar to multiply by |
Definition at line 408 of file Matrix.cpp.
References Mantid::Geometry::X.
V3D Mantid::Kernel::Matrix< T >::operator* | ( | const V3D & | Vx | ) | const |
Multiply M*Vec.
Matrix multiplication THIS * V.
Vx | :: Colunm vector to multiply by |
MisMatch<size_t> | if there is a size mismatch. |
Definition at line 388 of file Matrix.cpp.
References Mantid::Kernel::V3D::X().
Matrix< T > & Mantid::Kernel::Matrix< T >::operator*= | ( | const Matrix< T > & | A | ) |
Basic matrix multipy.
Matrix multiplication THIS *= A Note that we call operator* to avoid the problem of changing matrix size.
A | :: Matrix to multiply by (this->row must == A->columns) |
Definition at line 431 of file Matrix.cpp.
References Mantid::Kernel::Matrix< T >::m_numRows, and Mantid::API::operator*().
Matrix< T > & Mantid::Kernel::Matrix< T >::operator*= | ( | const T & | Value | ) |
Multiply by constant.
Matrix multiplication THIS * Value.
Value | :: Scalar to multiply matrix by |
Definition at line 440 of file Matrix.cpp.
Matrix< T > Mantid::Kernel::Matrix< T >::operator+ | ( | const Matrix< T > & | A | ) | const |
Basic addition operator.
Matrix addition THIS + A If the size is different then 0 is added where appropiate Matrix A is not expanded.
A | :: Matrix to add |
Definition at line 299 of file Matrix.cpp.
References Mantid::Geometry::X.
Matrix< T > & Mantid::Kernel::Matrix< T >::operator+= | ( | const Matrix< T > & | A | ) |
Basic addition operator.
Matrix addition THIS + A If the size is different then 0 is added where appropiate Matrix A is not expanded.
A | :: Matrix to add |
Definition at line 257 of file Matrix.cpp.
References Mantid::Kernel::Matrix< T >::m_numColumns, Mantid::Kernel::Matrix< T >::m_numRows, and Mantid::Kernel::Matrix< T >::m_rawData.
Matrix< T > Mantid::Kernel::Matrix< T >::operator- | ( | const Matrix< T > & | A | ) | const |
Basic subtraction operator.
Matrix subtraction THIS - A If the size is different then 0 is subtracted where appropiate.
This matrix determines the size
A | :: Matrix to add |
Definition at line 313 of file Matrix.cpp.
References Mantid::Geometry::X.
Matrix< T > & Mantid::Kernel::Matrix< T >::operator-= | ( | const Matrix< T > & | A | ) |
Basic subtraction operator.
Matrix subtractoin THIS - A If the size is different then 0 is added where appropiate Matrix A is not expanded.
A | :: Matrix to add |
Definition at line 278 of file Matrix.cpp.
References Mantid::Kernel::Matrix< T >::m_numColumns, Mantid::Kernel::Matrix< T >::m_numRows, and Mantid::Kernel::Matrix< T >::m_rawData.
Matrix< T > & Mantid::Kernel::Matrix< T >::operator/= | ( | const T & | Value | ) |
Divide by constant.
Matrix divishio THIS / Value.
Value | :: Scalar to multiply matrix by |
Definition at line 456 of file Matrix.cpp.
bool Mantid::Kernel::Matrix< T >::operator< | ( | const Matrix< T > & | A | ) | const |
Element by element comparison of < Always returns false if the Matrix have different sizes.
A | :: matrix to check. |
Definition at line 545 of file Matrix.cpp.
References Mantid::Kernel::Matrix< T >::m_numColumns, Mantid::Kernel::Matrix< T >::m_numRows, and Mantid::Kernel::Matrix< T >::m_rawData.
Matrix< T > & Mantid::Kernel::Matrix< T >::operator= | ( | const Matrix< T > & | A | ) |
Simple assignment operator.
A | :: Object to copy |
Definition at line 216 of file Matrix.cpp.
References Mantid::Kernel::Matrix< T >::m_numColumns, Mantid::Kernel::Matrix< T >::m_numRows, and Mantid::Kernel::Matrix< T >::m_rawData.
|
noexcept |
Definition at line 244 of file Matrix.cpp.
bool Mantid::Kernel::Matrix< T >::operator== | ( | const Matrix< T > & | A | ) | const |
Element by element comparison within tolerance.
Tolerance means that the value must be > tolerance and less than (diff/max)>tolerance Always returns 0 if the Matrix have different sizes
A | :: matrix to check. |
Definition at line 484 of file Matrix.cpp.
References Mantid::Kernel::equals().
bool Mantid::Kernel::Matrix< T >::operator>= | ( | const Matrix< T > & | A | ) | const |
Element by element comparison of >= Always returns false if the Matrix have different sizes.
A | :: matrix to check. |
Definition at line 566 of file Matrix.cpp.
References Mantid::Kernel::Matrix< T >::m_numColumns, Mantid::Kernel::Matrix< T >::m_numRows, and Mantid::Kernel::Matrix< T >::m_rawData.
|
inline |
|
inline |
Matrix< T > Mantid::Kernel::Matrix< T >::postMultiplyByDiagonal | ( | const std::vector< T > & | Dvec | ) | const |
post-multiply this*D
Creates a diagonal matrix D from the given vector Dvec and POST-multiplies the matrix by it (i.e.
M * D).
Dvec | :: diagonal matrix (just centre points) |
Definition at line 742 of file Matrix.cpp.
References Mantid::Geometry::X.
Matrix< T > Mantid::Kernel::Matrix< T >::preMultiplyByDiagonal | ( | const std::vector< T > & | Dvec | ) | const |
pre-multiply D*this
Creates a diagonal matrix D from the given vector Dvec and PRE-multiplies the matrix by it (i.e.
D * M).
Dvec | :: diagonal matrix (just centre points) |
Definition at line 719 of file Matrix.cpp.
References Mantid::Geometry::X.
void Mantid::Kernel::Matrix< T >::print |
Simple print out routine.
Definition at line 1511 of file Matrix.cpp.
|
private |
Applies a rotation to a particular point of tan(theta)=tau.
Note that you need both sin(theta) and tan(theta) because of sign preservation.
tau | :: tan(theta) |
s | :: sin(theta) |
i | :: first index (xpos) |
j | :: first index (ypos) |
k | :: second index (xpos) |
m | :: second index (ypos) |
Definition at line 699 of file Matrix.cpp.
References Mantid::Geometry::m.
Referenced by Mantid::DataHandling::SetSample::createFlatPlateXML(), Mantid::Kernel::Matrix< T >::Diagonalise(), and Mantid::DataHandling::SetSample::setSampleShape().
void Mantid::Kernel::Matrix< T >::setColumn | ( | const size_t | nCol, |
const std::vector< T > & | newCol | ||
) |
Definition at line 675 of file Matrix.cpp.
Referenced by Mantid::MDAlgorithms::MDNorm::buildSymmetryMatrix(), Mantid::MDAlgorithms::MDNorm::calQTransform(), Mantid::Geometry::SymmetryElementRotationGenerator::determineRotationSense(), Mantid::MDAlgorithms::CalculateCoverageDGS::exec(), Mantid::CurveFitting::Functions::GaussianComptonProfile::fillConstraintMatrix(), Mantid::CurveFitting::Functions::GramCharlierComptonProfile::fillConstraintMatrix(), Mantid::CurveFitting::Functions::MultivariateGaussianComptonProfile::fillConstraintMatrix(), Mantid::Crystal::PredictSatellitePeaks::predictOffsetsWithCrossTerms(), Mantid::Geometry::GridDetector::testIntersectionWithChildren(), Mantid::Geometry::RectangularDetector::testIntersectionWithChildren(), and Mantid::MDAlgorithms::MDNorm::validateInputs().
void Mantid::Kernel::Matrix< T >::setMem | ( | const size_t | a, |
const size_t | b | ||
) |
Sets the memory held in matrix.
a | :: number of rows |
b | :: number of columns |
Definition at line 586 of file Matrix.cpp.
Referenced by Mantid::Kernel::fillFromStream(), and Mantid::Kernel::Matrix< T >::Matrix().
void Mantid::Kernel::Matrix< T >::setRandom | ( | size_t | seed = 0 , |
double | rMin = -1 , |
||
double | rMax = 1 |
||
) |
initialize random matrix;
set matrix elements ito random values in the range from rMin to rMax
Definition at line 1520 of file Matrix.cpp.
References Mantid::Kernel::MersenneTwister::nextValue().
void Mantid::Kernel::Matrix< T >::setRow | ( | const size_t | nRow, |
const std::vector< T > & | newRow | ||
) |
Definition at line 686 of file Matrix.cpp.
Referenced by Mantid::MDAlgorithms::CutMD::exec(), Mantid::MDAlgorithms::IntegratePeaksMD2::getPinv(), Mantid::Geometry::OrientedLattice::GetUB(), Mantid::DataHandling::Mantid3MFFileIO::loadMeshObject(), Mantid::Geometry::IndexingUtils::Optimize_6dUB(), and Mantid::Geometry::IndexingUtils::Optimize_UB().
|
inline |
Access matrix sizes.
Definition at line 141 of file Matrix.h.
Referenced by Mantid::Algorithms::MaxEnt::applyDistancePenalty(), Mantid::Algorithms::MaxEnt::calculateChi(), Mantid::Algorithms::MaxentCalculator::getQuadraticCoefficients(), Mantid::Algorithms::MaxEnt::move(), Mantid::PythonInterface::Converters::MatrixToNDArray< ElementType, ConversionPolicy >::operator()(), and Mantid::Algorithms::MaxEnt::solveSVD().
void Mantid::Kernel::Matrix< T >::sortEigen | ( | Matrix< T > & | DiagMatrix | ) |
Sort eigenvectors.
Sorts the eigenvalues into increasing size.
Moves the EigenVectors correspondingly
DiagMatrix | :: matrix of the EigenValues |
Definition at line 1295 of file Matrix.cpp.
References Mantid::Kernel::Matrix< T >::Diagonal(), index, Mantid::Kernel::Matrix< T >::m_numColumns, Mantid::Kernel::Matrix< T >::m_numRows, and Mantid::Geometry::X.
Referenced by Mantid::Crystal::CalculateUMatrix::exec().
|
inline |
std::string Mantid::Kernel::Matrix< T >::str |
Convert the matrix into a simple linear string expression.
Definition at line 1564 of file Matrix.cpp.
Referenced by Mantid::Crystal::SelectCellOfType::exec(), Mantid::Crystal::SelectCellWithForm::exec(), Mantid::Crystal::TransformHKL::exec(), Mantid::DataObjects::MDBoxFlatTree::saveAffineTransformMatrix(), and Mantid::MDAlgorithms::ConvertCWSDExpToMomentum::setupTransferMatrix().
void Mantid::Kernel::Matrix< T >::swapCols | ( | const size_t | colI, |
const size_t | colJ | ||
) |
Swap cols (second V index)
Swap columns I and J.
colI | :: col I to swap |
colJ | :: col J to swap |
Definition at line 635 of file Matrix.cpp.
References tmp.
void Mantid::Kernel::Matrix< T >::swapRows | ( | const size_t | RowI, |
const size_t | RowJ | ||
) |
Swap rows (first V index)
Swap rows I and J.
RowI | :: row I to swap |
RowJ | :: row J to swap |
Definition at line 620 of file Matrix.cpp.
References tmp.
Referenced by Mantid::Kernel::Matrix< T >::GaussJordan().
std::vector< T > Mantid::Kernel::Matrix< T >::toRotation |
Transform the matrix to a rotation matrix, by normalizing each column to 1.
: | std::invalid_argument if the absolute value of the determinant is less then 1e-10 or not square matrix |
Definition at line 1462 of file Matrix.cpp.
References fabs, and Mantid::API::operator*().
Matrix< T > Mantid::Kernel::Matrix< T >::Tprime |
Transpose the matrix.
Transpose the matrix : Has transpose for a square matrix case.
Definition at line 766 of file Matrix.cpp.
References Mantid::Kernel::Matrix< T >::m_rawData, and Mantid::Kernel::Matrix< T >::Transpose().
Referenced by Mantid::Geometry::Quadratic::distance(), Mantid::Geometry::Goniometer::Goniometer(), Mantid::Geometry::Group::isInvariant(), and Mantid::Geometry::OrientedLattice::setUB().
T Mantid::Kernel::Matrix< T >::Trace |
Trace of the matrix.
Calculates the trace of the matrix.
Definition at line 1280 of file Matrix.cpp.
Referenced by Mantid::Geometry::SymmetryElementRotationGenerator::canProcess(), Mantid::Geometry::SymmetryElementMirrorGenerator::canProcess(), Mantid::Geometry::SymmetryElementRotationGenerator::determineSymbol(), and Mantid::Geometry::SymmetryOperation::getOrderFromMatrix().
Matrix< T > & Mantid::Kernel::Matrix< T >::Transpose |
Transpose the matrix.
Transpose the matrix : Has a in place transpose for a square matrix case.
Definition at line 793 of file Matrix.cpp.
Referenced by Mantid::DataObjects::CoordTransformAffine::buildNonOrthogonal(), Mantid::MDAlgorithms::IntegratePeaksMD2::calcCovar(), Mantid::Crystal::SaveHKL::exec(), Mantid::MDAlgorithms::MDNorm::getBinParameters(), Mantid::Geometry::SymmetryOperation::init(), Mantid::Crystal::LoadIsawUB::readModulatedUB(), and Mantid::Kernel::Matrix< T >::Tprime().
void Mantid::Kernel::Matrix< T >::write | ( | std::ostream & | Fh, |
int const | blockCnt = 0 |
||
) | const |
Write out function for blocks of 10 Columns.
Fh | :: file stream for output |
blockCnt | :: number of columns per line (0 == full) |
Definition at line 1531 of file Matrix.cpp.
void Mantid::Kernel::Matrix< T >::zeroMatrix |
Set the matrix to zero.
Zeros all elements of the matrix.
Definition at line 646 of file Matrix.cpp.
Referenced by Mantid::MDAlgorithms::IntegratePeaksMD2::calcCovar(), Mantid::Crystal::PeakHKLErrors::DerivRotationMatrixAboutRegAxis(), and Mantid::Crystal::PeakHKLErrors::RotationMatrixAboutRegAxis().
|
friend |
|
friend |
|
private |
Number of columns (y coordinate)
Definition at line 49 of file Matrix.h.
Referenced by Mantid::Kernel::Matrix< T >::GaussJordan(), Mantid::Kernel::Matrix< T >::Matrix(), Mantid::Kernel::Matrix< T >::operator+=(), Mantid::Kernel::Matrix< T >::operator-=(), Mantid::Kernel::Matrix< T >::operator<(), Mantid::Kernel::Matrix< T >::operator=(), Mantid::Kernel::Matrix< T >::operator>=(), Mantid::Kernel::Matrix< T >::sortEigen(), and Mantid::Kernel::Matrix< double >::toRotation().
|
private |
Number of rows (x coordinate)
Definition at line 48 of file Matrix.h.
Referenced by Mantid::Kernel::Matrix< T >::GaussJordan(), Mantid::Kernel::Matrix< T >::Matrix(), Mantid::Kernel::Matrix< T >::operator*=(), Mantid::Kernel::Matrix< T >::operator+=(), Mantid::Kernel::Matrix< T >::operator-=(), Mantid::Kernel::Matrix< T >::operator<(), Mantid::Kernel::Matrix< T >::operator=(), Mantid::Kernel::Matrix< T >::operator>=(), Mantid::Kernel::Matrix< T >::sortEigen(), and Mantid::Kernel::Matrix< double >::toRotation().
|
private |
Representation of 2D data.
Definition at line 59 of file Matrix.h.
Referenced by Mantid::Kernel::Matrix< T >::Diagonalise(), Mantid::Kernel::fillFromStream(), Mantid::Kernel::Matrix< T >::GaussJordan(), Mantid::Kernel::Matrix< T >::Invert(), Mantid::Kernel::Matrix< T >::Matrix(), Mantid::Kernel::Matrix< T >::operator+=(), Mantid::Kernel::Matrix< T >::operator-=(), Mantid::Kernel::Matrix< T >::operator<(), Mantid::Kernel::Matrix< T >::operator=(), Mantid::Kernel::Matrix< T >::operator>=(), Mantid::Kernel::Matrix< double >::setMem(), Mantid::Kernel::Matrix< double >::toRotation(), and Mantid::Kernel::Matrix< T >::Tprime().
|
private |