Mantid
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
Mantid::Kernel::Matrix< T > Class Template Reference

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...
 
compSum () const
 Add up each component sums for the matrix. More...
 
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...
 
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...
 
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...
 
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...
 
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)
 

Detailed Description

template<typename T>
class Mantid::Kernel::Matrix< T >

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

Definition at line 42 of file Matrix.h.

Member Typedef Documentation

◆ CMemoryArray

template<typename T >
template<class U >
using Mantid::Kernel::Matrix< T >::CMemoryArray = std::unique_ptr<U[]>
private

1D memory allocation to be wrapped with pointers to the rows

Definition at line 52 of file Matrix.h.

◆ MatrixMemoryPtrs

template<typename T >
template<typename U >
using Mantid::Kernel::Matrix< T >::MatrixMemoryPtrs = std::unique_ptr<U *[]>
private

Pointers to rows in the raw data array to make it appear 2D.

Definition at line 54 of file Matrix.h.

◆ value_type

template<typename T >
using Mantid::Kernel::Matrix< T >::value_type = T

Enable users to retrieve the element type.

Definition at line 45 of file Matrix.h.

Constructor & Destructor Documentation

◆ Matrix() [1/7]

template<typename 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

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

◆ Matrix() [2/7]

template<typename T >
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.

Parameters
A:: Column vector to multiply
B:: Row vector to multiply

Definition at line 107 of file Matrix.cpp.

◆ Matrix() [3/7]

template<typename T >
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.

◆ Matrix() [4/7]

template<typename T >
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.

◆ Matrix() [5/7]

template<typename T >
Mantid::Kernel::Matrix< T >::Matrix ( const Matrix< T > &  A,
const size_t  nrow,
const size_t  ncol 
)

Constructor with for a missing row/column.

Parameters
A:: The input matrix
nrow:: number of row to miss
ncol:: number of column to miss

Definition at line 167 of file Matrix.cpp.

◆ Matrix() [6/7]

template<typename T >
Mantid::Kernel::Matrix< T >::Matrix ( const Matrix< T > &  A)

◆ Matrix() [7/7]

template<typename T >
Mantid::Kernel::Matrix< T >::Matrix ( Matrix< T > &&  other)
noexcept

Definition at line 237 of file Matrix.cpp.

Member Function Documentation

◆ averSymmetric()

template<typename T >
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.

◆ compSum()

template<typename T >
T Mantid::Kernel::Matrix< T >::compSum

Add up each component sums for the matrix.

Returns
\( \sum_i \sum_j V_{ij}^2 \)

Definition at line 1131 of file Matrix.cpp.

◆ determinant()

template<typename T >
T Mantid::Kernel::Matrix< T >::determinant

◆ Diagonal()

template<typename T >
std::vector< T > Mantid::Kernel::Matrix< T >::Diagonal

Returns a vector of the diagonal.

Returns the diagonal form as a vector.

Returns
Diagonal elements

Definition at line 1265 of file Matrix.cpp.

Referenced by Mantid::MDAlgorithms::IntegratePeaksMD2::calcCovar(), and Mantid::Kernel::Matrix< T >::sortEigen().

◆ Diagonalise()

template<typename T >
int Mantid::Kernel::Matrix< T >::Diagonalise ( Matrix< T > &  EigenVec,
Matrix< T > &  DiagMatrix 
) const

(only Symmetric matrix)

Attempt to diagonalise the matrix IF symmetric.

Parameters
EigenVec:: (output) the Eigenvectors matrix
DiagMatrix:: the diagonal matrix of eigenvalues
Returns
:: 1 on success 0 on failure

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

◆ equals()

template<typename T >
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

Parameters
A:: matrix to check.
Tolerance:: tolerance in comparing elements
Returns
true on success

Definition at line 499 of file Matrix.cpp.

References fabs, and Mantid::Kernel::Tolerance.

◆ factor()

template<typename T >
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.

Returns
the factored matrix

Definition at line 1063 of file Matrix.cpp.

References fabs.

Referenced by Mantid::Kernel::Matrix< T >::determinant().

◆ GaussJordan() [1/2]

void Mantid::Kernel::Matrix< int >::GaussJordan ( Kernel::Matrix< int > &  )
inline

Not valid for Integer.

Exceptions
std::invalid_argument

Definition at line 183 of file Matrix.h.

◆ GaussJordan() [2/2]

template<typename T >
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.

Parameters
B:: [input, output] Must have same dimensions as A. Returned as identity matrix. (?)
Exceptions
std::invalid_argumenton input error
std::runtime_errorif 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().

◆ getVector()

template<typename T >
std::vector< T > Mantid::Kernel::Matrix< T >::getVector

◆ identityMatrix()

template<typename T >
void Mantid::Kernel::Matrix< T >::identityMatrix

◆ Invert()

template<typename T >
T Mantid::Kernel::Matrix< T >::Invert

LU inversion routine.

If the Matrix is square then invert the matrix using LU decomposition.

Returns
Determinant (0 if the matrix is singular)

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

◆ invertTridiagonal()

template<typename T >
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.

References lambda, and value.

◆ isOrthogonal()

template<typename T >
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().

◆ isRotation()

template<typename T >
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().

◆ item()

template<typename T >
T Mantid::Kernel::Matrix< T >::item ( size_t  row,
size_t  col 
) const
inline

Definition at line 111 of file Matrix.h.

◆ lubcmp()

template<typename T >
void Mantid::Kernel::Matrix< T >::lubcmp ( int *  rowperm,
int &  interchange 
)
private

starts inversion process

Find biggest pivot and move to top row.

Then divide by pivot.

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

◆ lubksb()

template<typename T >
void Mantid::Kernel::Matrix< T >::lubksb ( int const *  rowperm,
double *  b 
)
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().

◆ multiplyPoint()

template<typename T >
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.

Parameters
in:: size of vector > this->nrows
out:: result of Matrix(This * Vec)
Exceptions
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().

◆ normVert()

template<typename T >
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.

◆ numCols()

template<typename T >
size_t Mantid::Kernel::Matrix< T >::numCols ( ) const
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().

◆ numRows()

template<typename T >
size_t Mantid::Kernel::Matrix< T >::numRows ( ) const
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().

◆ operator std::vector< T >()

template<typename T >
Mantid::Kernel::Matrix< T >::operator std::vector< T > ( ) const
inline

Definition at line 120 of file Matrix.h.

◆ operator!=()

template<typename T >
bool Mantid::Kernel::Matrix< T >::operator!= ( const Matrix< T > &  A) const

Element by Element comparison.

Parameters
A:: Matrix to check
Returns
true :: on succees
false :: failure

Definition at line 472 of file Matrix.cpp.

References Mantid::Kernel::operator==().

◆ operator*() [1/4]

template<typename T >
Matrix< T > Mantid::Kernel::Matrix< T >::operator* ( const Matrix< T > &  A) const

Basic matrix multiply.

Matrix multiplication THIS * A.

Parameters
A:: Matrix to multiply by (this->row must == A->columns)
Exceptions
MisMatch<size_t>if there is a size mismatch.
Returns
Matrix(This * A)

Definition at line 327 of file Matrix.cpp.

References Mantid::Geometry::X.

◆ operator*() [2/4]

template<typename T >
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.

Parameters
Vec:: size of vector > this->nrows
Exceptions
MisMatch<size_t>if there is a size mismatch.
Returns
Matrix(This * Vec)

Definition at line 349 of file Matrix.cpp.

◆ operator*() [3/4]

template<typename T >
Matrix< T > Mantid::Kernel::Matrix< T >::operator* ( const T &  Value) const

Multiply by constant.

Matrix multiplication THIS * Value.

Parameters
Value:: Scalar to multiply by
Returns
V * (this)

Definition at line 408 of file Matrix.cpp.

References Mantid::Geometry::X.

◆ operator*() [4/4]

template<typename T >
V3D Mantid::Kernel::Matrix< T >::operator* ( const V3D Vx) const

Multiply M*Vec.

Matrix multiplication THIS * V.

Parameters
Vx:: Colunm vector to multiply by
Exceptions
MisMatch<size_t>if there is a size mismatch.
Returns
Matrix(This * A)

Definition at line 388 of file Matrix.cpp.

References Mantid::Kernel::V3D::X().

◆ operator*=() [1/2]

template<typename T >
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.

Parameters
A:: Matrix to multiply by (this->row must == A->columns)
Returns
This *= A

Definition at line 431 of file Matrix.cpp.

References Mantid::Kernel::Matrix< T >::m_numRows, and Mantid::API::operator*().

◆ operator*=() [2/2]

template<typename T >
Matrix< T > & Mantid::Kernel::Matrix< T >::operator*= ( const T &  Value)

Multiply by constant.

Matrix multiplication THIS * Value.

Parameters
Value:: Scalar to multiply matrix by
Returns
*this

Definition at line 440 of file Matrix.cpp.

◆ operator+()

template<typename T >
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.

Parameters
A:: Matrix to add
Returns
Matrix(this + A)

Definition at line 299 of file Matrix.cpp.

References Mantid::Geometry::X.

◆ operator+=()

template<typename T >
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.

Parameters
A:: Matrix to add
Returns
Matrix(this + A)

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.

◆ operator-()

template<typename T >
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

Parameters
A:: Matrix to add
Returns
Matrix(this + A)

Definition at line 313 of file Matrix.cpp.

References Mantid::Geometry::X.

◆ operator-=()

template<typename T >
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.

Parameters
A:: Matrix to add
Returns
Ma

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.

◆ operator/=()

template<typename T >
Matrix< T > & Mantid::Kernel::Matrix< T >::operator/= ( const T &  Value)

Divide by constant.

Matrix divishio THIS / Value.

Parameters
Value:: Scalar to multiply matrix by
Returns
*this

Definition at line 456 of file Matrix.cpp.

◆ operator<()

template<typename T >
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.

Parameters
A:: matrix to check.
Returns
true if this < A

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.

◆ operator=() [1/2]

template<typename T >
Matrix< T > & Mantid::Kernel::Matrix< T >::operator= ( const Matrix< T > &  A)

Simple assignment operator.

Parameters
A:: Object to copy
Returns
the copied object

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.

◆ operator=() [2/2]

template<typename T >
Matrix< T > & Mantid::Kernel::Matrix< T >::operator= ( Matrix< T > &&  other)
noexcept

Definition at line 244 of file Matrix.cpp.

◆ operator==()

template<typename T >
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

Parameters
A:: matrix to check.
Returns
true on success

Definition at line 484 of file Matrix.cpp.

References Mantid::Kernel::equals().

◆ operator>=()

template<typename T >
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.

Parameters
A:: matrix to check.
Returns
true if this >= A

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.

◆ operator[]() [1/2]

template<typename T >
T * Mantid::Kernel::Matrix< T >::operator[] ( const size_t  row)
inline

Array accessor. Use, e.g. Matrix[row][col].

Definition at line 87 of file Matrix.h.

◆ operator[]() [2/2]

template<typename T >
const T * Mantid::Kernel::Matrix< T >::operator[] ( const size_t  row) const
inline

const Array accessor. Use, e.g. Matrix[row][col]

Definition at line 84 of file Matrix.h.

◆ postMultiplyByDiagonal()

template<typename T >
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).

Parameters
Dvec:: diagonal matrix (just centre points)
Returns
this*D

Definition at line 742 of file Matrix.cpp.

References Mantid::Geometry::X.

◆ preMultiplyByDiagonal()

template<typename T >
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).

Parameters
Dvec:: diagonal matrix (just centre points)
Returns
D*this

Definition at line 719 of file Matrix.cpp.

References Mantid::Geometry::X.

◆ print()

template<typename T >
void Mantid::Kernel::Matrix< T >::print

Simple print out routine.

Definition at line 1511 of file Matrix.cpp.

◆ rotate()

template<typename T >
void Mantid::Kernel::Matrix< T >::rotate ( double const  tau,
double const  s,
int const  i,
int const  j,
int const  k,
int const  m 
)
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.

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

◆ setColumn()

template<typename T >
void Mantid::Kernel::Matrix< T >::setColumn ( const size_t  nCol,
const std::vector< T > &  newCol 
)

◆ setMem()

template<typename T >
void Mantid::Kernel::Matrix< T >::setMem ( const size_t  a,
const size_t  b 
)

Sets the memory held in matrix.

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

◆ setRandom()

template<typename T >
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().

◆ setRow()

template<typename T >
void Mantid::Kernel::Matrix< T >::setRow ( const size_t  nRow,
const std::vector< T > &  newRow 
)

◆ size()

template<typename T >
std::pair< size_t, size_t > Mantid::Kernel::Matrix< T >::size ( ) const
inline

◆ sortEigen()

template<typename T >
void Mantid::Kernel::Matrix< T >::sortEigen ( Matrix< T > &  DiagMatrix)

Sort eigenvectors.

Sorts the eigenvalues into increasing size.

Moves the EigenVectors correspondingly

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

◆ Ssize()

template<typename T >
size_t Mantid::Kernel::Matrix< T >::Ssize ( ) const
inline

Return the smallest matrix size.

Definition at line 150 of file Matrix.h.

◆ str()

template<typename T >
std::string Mantid::Kernel::Matrix< T >::str

◆ swapCols()

template<typename T >
void Mantid::Kernel::Matrix< T >::swapCols ( const size_t  colI,
const size_t  colJ 
)

Swap cols (second V index)

Swap columns I and J.

Parameters
colI:: col I to swap
colJ:: col J to swap

Definition at line 635 of file Matrix.cpp.

References tmp.

◆ swapRows()

template<typename T >
void Mantid::Kernel::Matrix< T >::swapRows ( const size_t  RowI,
const size_t  RowJ 
)

Swap rows (first V index)

Swap rows I and J.

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

◆ toRotation()

template<typename T >
std::vector< T > Mantid::Kernel::Matrix< T >::toRotation

Transform the matrix to a rotation matrix, by normalizing each column to 1.

Returns
:: a vector of scaling factors
Exceptions
: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*().

◆ Tprime()

template<typename T >
Matrix< T > Mantid::Kernel::Matrix< T >::Tprime

Transpose the matrix.

Transpose the matrix : Has transpose for a square matrix case.

Returns
M^T

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

◆ Trace()

template<typename T >
T Mantid::Kernel::Matrix< T >::Trace

◆ Transpose()

template<typename T >
Matrix< T > & Mantid::Kernel::Matrix< T >::Transpose

◆ write()

template<typename T >
void Mantid::Kernel::Matrix< T >::write ( std::ostream &  Fh,
int const  blockCnt = 0 
) const

Write out function for blocks of 10 Columns.

Parameters
Fh:: file stream for output
blockCnt:: number of columns per line (0 == full)

Definition at line 1531 of file Matrix.cpp.

◆ zeroMatrix()

template<typename T >
void Mantid::Kernel::Matrix< T >::zeroMatrix

Friends And Related Function Documentation

◆ dumpToStream

template<typename T >
template<typename TYPE >
void dumpToStream ( std::ostream &  ,
const Kernel::Matrix< TYPE > &  ,
const char   
)
friend

◆ fillFromStream

template<typename T >
template<typename TYPE >
void fillFromStream ( std::istream &  ,
Kernel::Matrix< TYPE > &  ,
const char   
)
friend

Member Data Documentation

◆ m_numColumns

template<typename T >
size_t Mantid::Kernel::Matrix< T >::m_numColumns
private

◆ m_numRows

template<typename T >
size_t Mantid::Kernel::Matrix< T >::m_numRows
private

◆ m_rawData

template<typename T >
MatrixMemoryPtrs<T> Mantid::Kernel::Matrix< T >::m_rawData
private

◆ m_rawDataAlloc

template<typename T >
CMemoryArray<T> Mantid::Kernel::Matrix< T >::m_rawDataAlloc
private

Pointer to allocated memory.

Definition at line 57 of file Matrix.h.


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