Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
ROOT::Math::SMatrix< T, D1, D2, R > Class Template Reference

template<class T, unsigned int D1, unsigned int D2 = D1, class R = MatRepStd<T, D1, D2>>
class ROOT::Math::SMatrix< T, D1, D2, R >

SMatrix: a generic fixed size D1 x D2 Matrix class.

The class is template on the scalar type, on the matrix sizes: D1 = number of rows and D2 = number of columns amd on the representation storage type. By default the representation is MatRepStd<T,D1,D2> (standard D1xD2 of type T), but it can be of type MatRepSym<T,D> for symmetric matrices DxD, where the storage is only D*(D+1)/2.

See SMatrix Class Properties.

Original author is Thorsten Glebe HERA-B Collaboration, MPI Heidelberg (Germany)

Authors
T. Glebe, L. Moneta and J. Palacios

Definition at line 101 of file SMatrix.h.

Classes

class  SMatrixRow
 
class  SMatrixRow_const
 

Public Types

— Matrix dimension —
enum  { kRows = D1 , kCols = D2 , kSize = D1*D2 }
 Enumeration defining the matrix dimension, number of rows, columns and size = rows*columns) More...
 
— Typedefs —
typedef T value_type
 contained scalar type
 
typedef R rep_type
 storage representation type
 
typedef T * iterator
 STL iterator interface.
 
typedef const T * const_iterator
 STL const_iterator interface.
 

Public Member Functions

— Constructors and Assignment —
 SMatrix ()
 Default constructor:
 
 SMatrix (SMatrixNoInit)
 construct from without initialization
 
 SMatrix (SMatrixIdentity)
 construct from an identity matrix
 
 SMatrix (const SMatrix< T, D1, D2, R > &rhs)
 copy constructor (from a matrix of the same representation
 
template<class R2 >
 SMatrix (const SMatrix< T, D1, D2, R2 > &rhs)
 construct from a matrix with different representation.
 
template<class A , class R2 >
 SMatrix (const Expr< A, T, D1, D2, R2 > &rhs)
 Construct from an expression.
 
template<class InputIterator >
 SMatrix (InputIterator begin, InputIterator end, bool triang=false, bool lower=true)
 Constructor with STL iterator interface.
 
template<class InputIterator >
 SMatrix (InputIterator begin, unsigned int size, bool triang=false, bool lower=true)
 Constructor with STL iterator interface.
 
 SMatrix (const SVector< T, D1 *(D2+1)/2 > &v, bool lower=true)
 constructor of a symmetrix a matrix from a SVector containing the lower (upper) triangular part.
 
 SMatrix (const T &rhs)
 Construct from a scalar value (only for size 1 matrices)
 
template<class M >
SMatrix< T, D1, D2, R > & operator= (const M &rhs)
 Assign from another compatible matrix.
 
SMatrix< T, D1, D2, R > & operator= (const SMatrix< T, D1, D2, R > &rhs)
 
template<class A , class R2 >
SMatrix< T, D1, D2, R > & operator= (const Expr< A, T, D1, D2, R2 > &rhs)
 Assign from a matrix expression.
 
SMatrix< T, D1, D2, R > & operator= (SMatrixIdentity)
 Assign from an identity matrix.
 
SMatrix< T, D1, D2, R > & operator= (const T &rhs)
 Assign from a scalar value (only for size 1 matrices)
 
— Access functions —
apply (unsigned int i) const
 access the parse tree with the index starting from zero and following the C convention for the order in accessing the matrix elements.
 
const T * Array () const
 return read-only pointer to internal array
 
T * Array ()
 return pointer to internal array
 
— STL-like interface —

The iterators access the matrix element in the order how they are stored in memory.

The C (row-major) convention is used, and in the case of symmetric matrices the iterator spans only the lower diagonal block. For example for a symmetric 3x3 matrices the order of the 6 elements \({a_0,...a_5}\) is:

\[ M = \left( \begin{array}{ccc} a_0 & a_1 & a_3 \\ a_1 & a_2 & a_4 \\ a_3 & a_4 & a_5 \end{array} \right) \]

iterator begin ()
 STL iterator interface.
 
iterator end ()
 STL iterator interface.
 
const_iterator begin () const
 STL const_iterator interface.
 
const_iterator end () const
 STL const_iterator interface.
 
template<class InputIterator >
void SetElements (InputIterator begin, InputIterator end, bool triang=false, bool lower=true)
 Set matrix elements with STL iterator interface.
 
template<class InputIterator >
void SetElements (InputIterator begin, unsigned int size, bool triang=false, bool lower=true)
 Constructor with STL iterator interface.
 
— Operators —
bool operator== (const T &rhs) const
 element wise comparison
 
bool operator!= (const T &rhs) const
 element wise comparison
 
template<class R2 >
bool operator== (const SMatrix< T, D1, D2, R2 > &rhs) const
 element wise comparison
 
bool operator!= (const SMatrix< T, D1, D2, R > &rhs) const
 element wise comparison
 
template<class A , class R2 >
bool operator== (const Expr< A, T, D1, D2, R2 > &rhs) const
 element wise comparison
 
template<class A , class R2 >
bool operator!= (const Expr< A, T, D1, D2, R2 > &rhs) const
 element wise comparison
 
bool operator> (const T &rhs) const
 element wise comparison
 
bool operator< (const T &rhs) const
 element wise comparison
 
template<class R2 >
bool operator> (const SMatrix< T, D1, D2, R2 > &rhs) const
 element wise comparison
 
template<class R2 >
bool operator< (const SMatrix< T, D1, D2, R2 > &rhs) const
 element wise comparison
 
template<class A , class R2 >
bool operator> (const Expr< A, T, D1, D2, R2 > &rhs) const
 element wise comparison
 
template<class A , class R2 >
bool operator< (const Expr< A, T, D1, D2, R2 > &rhs) const
 element wise comparison
 
const T & operator() (unsigned int i, unsigned int j) const
 read only access to matrix element, with indices starting from 0
 
T & operator() (unsigned int i, unsigned int j)
 read/write access to matrix element with indices starting from 0
 
const T & At (unsigned int i, unsigned int j) const
 read only access to matrix element, with indices starting from 0.
 
T & At (unsigned int i, unsigned int j)
 read/write access to matrix element with indices starting from 0.
 
SMatrixRow_const operator[] (unsigned int i) const
 read only access to matrix element, with indices starting from 0 : m[i][j]
 
SMatrixRow operator[] (unsigned int i)
 read/write access to matrix element with indices starting from 0 : m[i][j]
 
SMatrix< T, D1, D2, R > & operator+= (const T &rhs)
 addition with a scalar
 
template<class R2 >
SMatrix< T, D1, D2, R > & operator+= (const SMatrix< T, D1, D2, R2 > &rhs)
 addition with another matrix of any compatible representation
 
template<class A , class R2 >
SMatrix< T, D1, D2, R > & operator+= (const Expr< A, T, D1, D2, R2 > &rhs)
 addition with a compatible matrix expression
 
SMatrix< T, D1, D2, R > & operator-= (const T &rhs)
 subtraction with a scalar
 
template<class R2 >
SMatrix< T, D1, D2, R > & operator-= (const SMatrix< T, D1, D2, R2 > &rhs)
 subtraction with another matrix of any compatible representation
 
template<class A , class R2 >
SMatrix< T, D1, D2, R > & operator-= (const Expr< A, T, D1, D2, R2 > &rhs)
 subtraction with a compatible matrix expression
 
SMatrix< T, D1, D2, R > & operator*= (const T &rhs)
 multiplication with a scalar
 
template<class R2 >
SMatrix< T, D1, D2, R > & operator*= (const SMatrix< T, D1, D2, R2 > &rhs)
 multiplication with another compatible matrix (it is a real matrix multiplication) Note that this operation does not avid to create a temporary to store intermidiate result
 
template<class A , class R2 >
SMatrix< T, D1, D2, R > & operator*= (const Expr< A, T, D1, D2, R2 > &rhs)
 multiplication with a compatible matrix expression (it is a real matrix multiplication)
 
SMatrix< T, D1, D2, R > & operator/= (const T &rhs)
 division with a scalar
 
— Linear Algebra Functions —
bool Invert ()
 Invert a square Matrix ( this method changes the current matrix).
 
SMatrix< T, D1, D2, RInverse (int &ifail) const
 Invert a square Matrix and returns a new matrix.
 
bool InvertFast ()
 Fast Invertion of a square Matrix ( this method changes the current matrix).
 
SMatrix< T, D1, D2, RInverseFast (int &ifail) const
 Invert a square Matrix and returns a new matrix.
 
bool InvertChol ()
 Invertion of a symmetric positive defined Matrix using Choleski decomposition.
 
SMatrix< T, D1, D2, RInverseChol (int &ifail) const
 Invert of a symmetric positive defined Matrix using Choleski decomposition.
 
bool Det (T &det)
 determinant of square Matrix via Dfact.
 
bool Det2 (T &det) const
 determinant of square Matrix via Dfact.
 
— Matrix Slice Functions —
template<unsigned int D>
SMatrix< T, D1, D2, R > & Place_in_row (const SVector< T, D > &rhs, unsigned int row, unsigned int col)
 place a vector in a Matrix row
 
template<class A , unsigned int D>
SMatrix< T, D1, D2, R > & Place_in_row (const VecExpr< A, T, D > &rhs, unsigned int row, unsigned int col)
 place a vector expression in a Matrix row
 
template<unsigned int D>
SMatrix< T, D1, D2, R > & Place_in_col (const SVector< T, D > &rhs, unsigned int row, unsigned int col)
 place a vector in a Matrix column
 
template<class A , unsigned int D>
SMatrix< T, D1, D2, R > & Place_in_col (const VecExpr< A, T, D > &rhs, unsigned int row, unsigned int col)
 place a vector expression in a Matrix column
 
template<unsigned int D3, unsigned int D4, class R2 >
SMatrix< T, D1, D2, R > & Place_at (const SMatrix< T, D3, D4, R2 > &rhs, unsigned int row, unsigned int col)
 place a matrix in this matrix
 
template<class A , unsigned int D3, unsigned int D4, class R2 >
SMatrix< T, D1, D2, R > & Place_at (const Expr< A, T, D3, D4, R2 > &rhs, unsigned int row, unsigned int col)
 place a matrix expression in this matrix
 
SVector< T, D2 > Row (unsigned int therow) const
 return a full Matrix row as a vector (copy the content in a new vector)
 
SVector< T, D1 > Col (unsigned int thecol) const
 return a full Matrix column as a vector (copy the content in a new vector)
 
template<class SubVector >
SubVector SubRow (unsigned int therow, unsigned int col0=0) const
 return a slice of therow as a vector starting at the colum value col0 until col0+N, where N is the size of the vector (SubVector::kSize ) Condition col0+N <= D2
 
template<class SubVector >
SubVector SubCol (unsigned int thecol, unsigned int row0=0) const
 return a slice of the column as a vector starting at the row value row0 until row0+Dsub.
 
template<class SubMatrix >
SubMatrix Sub (unsigned int row0, unsigned int col0) const
 return a submatrix with the upper left corner at the values (row0, col0) and with sizes N1, N2 where N1 and N2 are the dimension of the sub-matrix (SubMatrix::kRows and SubMatrix::kCols ) Condition row0+N1 <= D1 && col0+N2 <=D2
 
SVector< T, D1 > Diagonal () const
 return diagonal elements of a matrix as a Vector.
 
template<class Vector >
void SetDiagonal (const Vector &v)
 Set the diagonal elements from a Vector Require that vector implements kSize since a check (statically) is done on diagonal size == vector size.
 
Trace () const
 return the trace of a matrix Sum of the diagonal elements
 
SVector< T, D1 *(D2+1)/2 > UpperBlock () const
 return the upper Triangular block of the matrices (including the diagonal) as a vector of sizes N = D1 * (D1 + 1)/2.
 
SVector< T, D1 *(D2+1)/2 > LowerBlock () const
 return the lower Triangular block of the matrices (including the diagonal) as a vector of sizes N = D1 * (D1 + 1)/2.
 
— Other Functions —
bool IsInUse (const T *p) const
 Function to check if a matrix is sharing same memory location of the passed pointer This function is used by the expression templates to avoid the alias problem during expression evaluation.
 
std::ostream & Print (std::ostream &os) const
 Print: used by operator<<()
 

Public Attributes

— Data Member —
R fRep
 Matrix Storage Object containing matrix data.
 

#include <Math/SMatrix.h>

Member Typedef Documentation

◆ const_iterator

template<class T , unsigned int D1, unsigned int D2 = D1, class R = MatRepStd<T, D1, D2>>
typedef const T* ROOT::Math::SMatrix< T, D1, D2, R >::const_iterator

STL const_iterator interface.

Definition at line 115 of file SMatrix.h.

◆ iterator

template<class T , unsigned int D1, unsigned int D2 = D1, class R = MatRepStd<T, D1, D2>>
typedef T* ROOT::Math::SMatrix< T, D1, D2, R >::iterator

STL iterator interface.

Definition at line 112 of file SMatrix.h.

◆ rep_type

template<class T , unsigned int D1, unsigned int D2 = D1, class R = MatRepStd<T, D1, D2>>
typedef R ROOT::Math::SMatrix< T, D1, D2, R >::rep_type

storage representation type

Definition at line 109 of file SMatrix.h.

◆ value_type

template<class T , unsigned int D1, unsigned int D2 = D1, class R = MatRepStd<T, D1, D2>>
typedef T ROOT::Math::SMatrix< T, D1, D2, R >::value_type

contained scalar type

Definition at line 106 of file SMatrix.h.

Member Enumeration Documentation

◆ anonymous enum

template<class T , unsigned int D1, unsigned int D2 = D1, class R = MatRepStd<T, D1, D2>>
anonymous enum

Enumeration defining the matrix dimension, number of rows, columns and size = rows*columns)

Enumerator
kRows 

return no. of matrix rows

kCols 

return no. of matrix columns

kSize 

return no of elements: rows*columns

Definition at line 234 of file SMatrix.h.

Constructor & Destructor Documentation

◆ SMatrix() [1/10]

template<class T , unsigned int D1, unsigned int D2, class R >
ROOT::Math::SMatrix< T, D1, D2, R >::SMatrix

Default constructor:

Definition at line 72 of file SMatrix.icc.

◆ SMatrix() [2/10]

template<class T , unsigned int D1, unsigned int D2 = D1, class R = MatRepStd<T, D1, D2>>
ROOT::Math::SMatrix< T, D1, D2, R >::SMatrix ( SMatrixNoInit  )
inline

construct from without initialization

Definition at line 129 of file SMatrix.h.

◆ SMatrix() [3/10]

template<class T , unsigned int D1, unsigned int D2, class R >
ROOT::Math::SMatrix< T, D1, D2, R >::SMatrix ( SMatrixIdentity  )

construct from an identity matrix

Definition at line 79 of file SMatrix.icc.

◆ SMatrix() [4/10]

template<class T , unsigned int D1, unsigned int D2, class R >
ROOT::Math::SMatrix< T, D1, D2, R >::SMatrix ( const SMatrix< T, D1, D2, R > &  rhs)

copy constructor (from a matrix of the same representation

Definition at line 93 of file SMatrix.icc.

◆ SMatrix() [5/10]

template<class T , unsigned int D1, unsigned int D2, class R >
template<class R2 >
ROOT::Math::SMatrix< T, D1, D2, R >::SMatrix ( const SMatrix< T, D1, D2, R2 > &  rhs)

construct from a matrix with different representation.

Works only from symmetric to general and not viceversa.

Definition at line 100 of file SMatrix.icc.

◆ SMatrix() [6/10]

template<class T , unsigned int D1, unsigned int D2, class R >
template<class A , class R2 >
ROOT::Math::SMatrix< T, D1, D2, R >::SMatrix ( const Expr< A, T, D1, D2, R2 > &  rhs)

Construct from an expression.

In case of symmetric matrices does not work if expression is of type general matrices. In case one needs to force the assignment from general to symmetric, one can use the ROOT::Math::AssignSym::Evaluate function.

Definition at line 107 of file SMatrix.icc.

◆ SMatrix() [7/10]

template<class T , unsigned int D1, unsigned int D2, class R >
template<class InputIterator >
ROOT::Math::SMatrix< T, D1, D2, R >::SMatrix ( InputIterator  begin,
InputIterator  end,
bool  triang = false,
bool  lower = true 
)

Constructor with STL iterator interface.

The data will be copied into the matrix

Parameters
beginstart iterator position
endend iterator position
triangif true only the triangular lower/upper part of the matrix is filled from the iterators
lowerif true the lower triangular part is filled

Size of the matrix must match size of the iterators, if triang is false, otherwise the size of the triangular block. In the case of symmetric matrices triang is considered always to be true (what-ever the user specifies) and the size of the iterators must be equal to the size of the triangular block, which is the number of independent elements of a symmetric matrix: N*(N+1)/2

Definition at line 117 of file SMatrix.icc.

◆ SMatrix() [8/10]

template<class T , unsigned int D1, unsigned int D2, class R >
template<class InputIterator >
ROOT::Math::SMatrix< T, D1, D2, R >::SMatrix ( InputIterator  begin,
unsigned int  size,
bool  triang = false,
bool  lower = true 
)

Constructor with STL iterator interface.

The data will be copied into the matrix

Parameters
beginstart iterator position
sizeiterator size
triangif true only the triangular lower/upper part of the matrix is filled from the iterators
lowerif true the lower triangular part is filled

Size of the iterators must not be larger than the size of the matrix representation. In the case of symmetric matrices the size is N*(N+1)/2.

Definition at line 125 of file SMatrix.icc.

◆ SMatrix() [9/10]

template<class T , unsigned int D1, unsigned int D2, class R >
ROOT::Math::SMatrix< T, D1, D2, R >::SMatrix ( const SVector< T, D1 *(D2+1)/2 > &  v,
bool  lower = true 
)

constructor of a symmetrix a matrix from a SVector containing the lower (upper) triangular part.

construct from upper/lower block

Definition at line 858 of file SMatrix.icc.

◆ SMatrix() [10/10]

template<class T , unsigned int D1, unsigned int D2, class R >
ROOT::Math::SMatrix< T, D1, D2, R >::SMatrix ( const T &  rhs)
explicit

Construct from a scalar value (only for size 1 matrices)

Definition at line 138 of file SMatrix.icc.

Member Function Documentation

◆ apply()

template<class T , unsigned int D1, unsigned int D2, class R >
T ROOT::Math::SMatrix< T, D1, D2, R >::apply ( unsigned int  i) const
inline

access the parse tree with the index starting from zero and following the C convention for the order in accessing the matrix elements.

Same convention for general and symmetric matrices.

Definition at line 627 of file SMatrix.icc.

◆ Array() [1/2]

template<class T , unsigned int D1, unsigned int D2, class R >
T * ROOT::Math::SMatrix< T, D1, D2, R >::Array
inline

return pointer to internal array

Definition at line 633 of file SMatrix.icc.

◆ Array() [2/2]

template<class T , unsigned int D1, unsigned int D2, class R >
const T * ROOT::Math::SMatrix< T, D1, D2, R >::Array
inline

return read-only pointer to internal array

Definition at line 630 of file SMatrix.icc.

◆ At() [1/2]

template<class T , unsigned int D1, unsigned int D2, class R >
T & ROOT::Math::SMatrix< T, D1, D2, R >::At ( unsigned int  i,
unsigned int  j 
)
inline

read/write access to matrix element with indices starting from 0.

Function will check index values and it will assert if they are wrong

Definition at line 660 of file SMatrix.icc.

◆ At() [2/2]

template<class T , unsigned int D1, unsigned int D2, class R >
const T & ROOT::Math::SMatrix< T, D1, D2, R >::At ( unsigned int  i,
unsigned int  j 
) const
inline

read only access to matrix element, with indices starting from 0.

Function will check index values and it will assert if they are wrong

Definition at line 653 of file SMatrix.icc.

◆ begin() [1/2]

template<class T , unsigned int D1, unsigned int D2, class R >
T * ROOT::Math::SMatrix< T, D1, D2, R >::begin
inline

STL iterator interface.

Definition at line 670 of file SMatrix.icc.

◆ begin() [2/2]

template<class T , unsigned int D1, unsigned int D2, class R >
const T * ROOT::Math::SMatrix< T, D1, D2, R >::begin
inline

STL const_iterator interface.

Definition at line 680 of file SMatrix.icc.

◆ Col()

template<class T , unsigned int D1, unsigned int D2, class R >
SVector< T, D1 > ROOT::Math::SMatrix< T, D1, D2, R >::Col ( unsigned int  thecol) const

return a full Matrix column as a vector (copy the content in a new vector)

Definition at line 590 of file SMatrix.icc.

◆ Det()

template<class T , unsigned int D1, unsigned int D2, class R >
bool ROOT::Math::SMatrix< T, D1, D2, R >::Det ( T &  det)
inline

determinant of square Matrix via Dfact.

Return true when the calculation is successfull.

Parameters
detwill contain the calculated determinant value Note: this will destroy the contents of the Matrix!

Definition at line 466 of file SMatrix.icc.

◆ Det2()

template<class T , unsigned int D1, unsigned int D2, class R >
bool ROOT::Math::SMatrix< T, D1, D2, R >::Det2 ( T &  det) const
inline

determinant of square Matrix via Dfact.

Return true when the calculation is successfull.

Parameters
detwill contain the calculated determinant value Note: this will preserve the content of the Matrix!

Definition at line 473 of file SMatrix.icc.

◆ Diagonal()

template<class T , unsigned int D1, unsigned int D2, class R >
SVector< T, D1 > ROOT::Math::SMatrix< T, D1, D2, R >::Diagonal

return diagonal elements of a matrix as a Vector.

It works only for squared matrices D1 == D2, otherwise it will produce a compile error

Definition at line 755 of file SMatrix.icc.

◆ end() [1/2]

template<class T , unsigned int D1, unsigned int D2, class R >
T * ROOT::Math::SMatrix< T, D1, D2, R >::end
inline

STL iterator interface.

Definition at line 675 of file SMatrix.icc.

◆ end() [2/2]

template<class T , unsigned int D1, unsigned int D2, class R >
const T * ROOT::Math::SMatrix< T, D1, D2, R >::end
inline

STL const_iterator interface.

Definition at line 685 of file SMatrix.icc.

◆ Inverse()

template<class T , unsigned int D1, unsigned int D2, class R >
SMatrix< T, D1, D2, R > ROOT::Math::SMatrix< T, D1, D2, R >::Inverse ( int ifail) const
inline

Invert a square Matrix and returns a new matrix.

In case the inversion fails the current matrix is returned.

Parameters
ifail. ifail will be set to 0 when inversion is successfull. See ROOT::Math::SMatrix::Invert for the inversion algorithm

Definition at line 419 of file SMatrix.icc.

◆ InverseChol()

template<class T , unsigned int D1, unsigned int D2, class R >
SMatrix< T, D1, D2, R > ROOT::Math::SMatrix< T, D1, D2, R >::InverseChol ( int ifail) const
inline

Invert of a symmetric positive defined Matrix using Choleski decomposition.

A compile error is given if the matrix is not of type symmetric and a run-time failure if the matrix is not positive defined. In case the inversion fails the current matrix is returned.

Parameters
ifail. ifail will be set to 0 when inversion is successfull. See ROOT::Math::SMatrix::InvertChol for the inversion algorithm

Definition at line 452 of file SMatrix.icc.

◆ InverseFast()

template<class T , unsigned int D1, unsigned int D2, class R >
SMatrix< T, D1, D2, R > ROOT::Math::SMatrix< T, D1, D2, R >::InverseFast ( int ifail) const
inline

Invert a square Matrix and returns a new matrix.

In case the inversion fails the current matrix is returned.

Parameters
ifail. ifail will be set to 0 when inversion is successfull. See ROOT::Math::SMatrix::InvertFast for the inversion algorithm

Definition at line 436 of file SMatrix.icc.

◆ Invert()

template<class T , unsigned int D1, unsigned int D2, class R >
bool ROOT::Math::SMatrix< T, D1, D2, R >::Invert
inline

Invert a square Matrix ( this method changes the current matrix).

Return true if inversion is successfull. The method used for general square matrices is the LU factorization taken from Dinv routine from the CERNLIB (written in C++ from CLHEP authors) In case of symmetric matrices Bunch-Kaufman diagonal pivoting method is used (The implementation is the one written by the CLHEP authors)

Definition at line 412 of file SMatrix.icc.

◆ InvertChol()

template<class T , unsigned int D1, unsigned int D2, class R >
bool ROOT::Math::SMatrix< T, D1, D2, R >::InvertChol
inline

Invertion of a symmetric positive defined Matrix using Choleski decomposition.

( this method changes the current matrix). Return true if inversion is successfull. The method used is based on Choleski decomposition A compile error is given if the matrix is not of type symmetric and a run-time failure if the matrix is not positive defined. For solving a linear system, it is possible to use also the function ROOT::Math::SolveChol(matrix, vector) which will be faster than performing the inversion

Definition at line 446 of file SMatrix.icc.

◆ InvertFast()

template<class T , unsigned int D1, unsigned int D2, class R >
bool ROOT::Math::SMatrix< T, D1, D2, R >::InvertFast
inline

Fast Invertion of a square Matrix ( this method changes the current matrix).

Return true if inversion is successfull. The method used is based on direct inversion using the Cramer rule for matrices upto 5x5. Afterwards the same default algorithm of Invert() is used. Note that this method is faster but can suffer from much larger numerical accuracy when the condition of the matrix is large

Definition at line 429 of file SMatrix.icc.

◆ IsInUse()

template<class T , unsigned int D1, unsigned int D2, class R >
bool ROOT::Math::SMatrix< T, D1, D2, R >::IsInUse ( const T *  p) const

Function to check if a matrix is sharing same memory location of the passed pointer This function is used by the expression templates to avoid the alias problem during expression evaluation.

When the matrix is in use, for example in operations like A = B * A, a temporary object storing the intermediate result is automatically created when evaluating the expression.

Definition at line 895 of file SMatrix.icc.

◆ LowerBlock()

template<class T , unsigned int D1, unsigned int D2, class R >
SVector< T, D1 *(D2+1)/2 > ROOT::Math::SMatrix< T, D1, D2, R >::LowerBlock

return the lower Triangular block of the matrices (including the diagonal) as a vector of sizes N = D1 * (D1 + 1)/2.

It works only for square matrices with D1==D2, otherwise it will produce a compile error

Definition at line 826 of file SMatrix.icc.

◆ operator!=() [1/3]

template<class T , unsigned int D1, unsigned int D2, class R >
template<class A , class R2 >
bool ROOT::Math::SMatrix< T, D1, D2, R >::operator!= ( const Expr< A, T, D1, D2, R2 > &  rhs) const
inline

element wise comparison

Definition at line 338 of file SMatrix.icc.

◆ operator!=() [2/3]

template<class T , unsigned int D1, unsigned int D2, class R >
bool ROOT::Math::SMatrix< T, D1, D2, R >::operator!= ( const SMatrix< T, D1, D2, R > &  rhs) const
inline

element wise comparison

Definition at line 332 of file SMatrix.icc.

◆ operator!=() [3/3]

template<class T , unsigned int D1, unsigned int D2, class R >
bool ROOT::Math::SMatrix< T, D1, D2, R >::operator!= ( const T &  rhs) const
inline

element wise comparison

Definition at line 327 of file SMatrix.icc.

◆ operator()() [1/2]

template<class T , unsigned int D1, unsigned int D2, class R >
T & ROOT::Math::SMatrix< T, D1, D2, R >::operator() ( unsigned int  i,
unsigned int  j 
)
inline

read/write access to matrix element with indices starting from 0

Definition at line 644 of file SMatrix.icc.

◆ operator()() [2/2]

template<class T , unsigned int D1, unsigned int D2, class R >
const T & ROOT::Math::SMatrix< T, D1, D2, R >::operator() ( unsigned int  i,
unsigned int  j 
) const
inline

read only access to matrix element, with indices starting from 0

Definition at line 639 of file SMatrix.icc.

◆ operator*=() [1/3]

template<class T , unsigned int D1, unsigned int D2, class R >
template<class A , class R2 >
SMatrix< T, D1, D2, R > & ROOT::Math::SMatrix< T, D1, D2, R >::operator*= ( const Expr< A, T, D1, D2, R2 > &  rhs)

multiplication with a compatible matrix expression (it is a real matrix multiplication)

Definition at line 276 of file SMatrix.icc.

◆ operator*=() [2/3]

template<class T , unsigned int D1, unsigned int D2, class R >
template<class R2 >
SMatrix< T, D1, D2, R > & ROOT::Math::SMatrix< T, D1, D2, R >::operator*= ( const SMatrix< T, D1, D2, R2 > &  rhs)

multiplication with another compatible matrix (it is a real matrix multiplication) Note that this operation does not avid to create a temporary to store intermidiate result

Definition at line 268 of file SMatrix.icc.

◆ operator*=() [3/3]

template<class T , unsigned int D1, unsigned int D2, class R >
SMatrix< T, D1, D2, R > & ROOT::Math::SMatrix< T, D1, D2, R >::operator*= ( const T &  rhs)

multiplication with a scalar

Definition at line 258 of file SMatrix.icc.

◆ operator+=() [1/3]

template<class T , unsigned int D1, unsigned int D2, class R >
template<class A , class R2 >
SMatrix< T, D1, D2, R > & ROOT::Math::SMatrix< T, D1, D2, R >::operator+= ( const Expr< A, T, D1, D2, R2 > &  rhs)

addition with a compatible matrix expression

Definition at line 217 of file SMatrix.icc.

◆ operator+=() [2/3]

template<class T , unsigned int D1, unsigned int D2, class R >
template<class R2 >
SMatrix< T, D1, D2, R > & ROOT::Math::SMatrix< T, D1, D2, R >::operator+= ( const SMatrix< T, D1, D2, R2 > &  rhs)

addition with another matrix of any compatible representation

Definition at line 207 of file SMatrix.icc.

◆ operator+=() [3/3]

template<class T , unsigned int D1, unsigned int D2, class R >
SMatrix< T, D1, D2, R > & ROOT::Math::SMatrix< T, D1, D2, R >::operator+= ( const T &  rhs)

addition with a scalar

Definition at line 197 of file SMatrix.icc.

◆ operator-=() [1/3]

template<class T , unsigned int D1, unsigned int D2, class R >
template<class A , class R2 >
SMatrix< T, D1, D2, R > & ROOT::Math::SMatrix< T, D1, D2, R >::operator-= ( const Expr< A, T, D1, D2, R2 > &  rhs)

subtraction with a compatible matrix expression

Definition at line 248 of file SMatrix.icc.

◆ operator-=() [2/3]

template<class T , unsigned int D1, unsigned int D2, class R >
template<class R2 >
SMatrix< T, D1, D2, R > & ROOT::Math::SMatrix< T, D1, D2, R >::operator-= ( const SMatrix< T, D1, D2, R2 > &  rhs)

subtraction with another matrix of any compatible representation

Definition at line 238 of file SMatrix.icc.

◆ operator-=() [3/3]

template<class T , unsigned int D1, unsigned int D2, class R >
SMatrix< T, D1, D2, R > & ROOT::Math::SMatrix< T, D1, D2, R >::operator-= ( const T &  rhs)

subtraction with a scalar

Definition at line 228 of file SMatrix.icc.

◆ operator/=()

template<class T , unsigned int D1, unsigned int D2, class R >
SMatrix< T, D1, D2, R > & ROOT::Math::SMatrix< T, D1, D2, R >::operator/= ( const T &  rhs)

division with a scalar

Definition at line 287 of file SMatrix.icc.

◆ operator<() [1/3]

template<class T , unsigned int D1, unsigned int D2, class R >
template<class A , class R2 >
bool ROOT::Math::SMatrix< T, D1, D2, R >::operator< ( const Expr< A, T, D1, D2, R2 > &  rhs) const

element wise comparison

Definition at line 399 of file SMatrix.icc.

◆ operator<() [2/3]

template<class T , unsigned int D1, unsigned int D2, class R >
template<class R2 >
bool ROOT::Math::SMatrix< T, D1, D2, R >::operator< ( const SMatrix< T, D1, D2, R2 > &  rhs) const

element wise comparison

Definition at line 389 of file SMatrix.icc.

◆ operator<() [3/3]

template<class T , unsigned int D1, unsigned int D2, class R >
bool ROOT::Math::SMatrix< T, D1, D2, R >::operator< ( const T &  rhs) const

element wise comparison

Definition at line 379 of file SMatrix.icc.

◆ operator=() [1/5]

template<class T , unsigned int D1, unsigned int D2, class R >
template<class A , class R2 >
SMatrix< T, D1, D2, R > & ROOT::Math::SMatrix< T, D1, D2, R >::operator= ( const Expr< A, T, D1, D2, R2 > &  rhs)

Assign from a matrix expression.

Definition at line 168 of file SMatrix.icc.

◆ operator=() [2/5]

template<class T , unsigned int D1, unsigned int D2, class R >
template<class M >
SMatrix< T, D1, D2, R > & ROOT::Math::SMatrix< T, D1, D2, R >::operator= ( const M &  rhs)

Assign from another compatible matrix.

Possible Symmetirc to general but NOT vice-versa

Definition at line 155 of file SMatrix.icc.

◆ operator=() [3/5]

template<class T , unsigned int D1, unsigned int D2, class R >
SMatrix< T, D1, D2, R > & ROOT::Math::SMatrix< T, D1, D2, R >::operator= ( const SMatrix< T, D1, D2, R > &  rhs)

Definition at line 161 of file SMatrix.icc.

◆ operator=() [4/5]

template<class T , unsigned int D1, unsigned int D2, class R >
SMatrix< T, D1, D2, R > & ROOT::Math::SMatrix< T, D1, D2, R >::operator= ( const T &  rhs)

Assign from a scalar value (only for size 1 matrices)

Definition at line 144 of file SMatrix.icc.

◆ operator=() [5/5]

template<class T , unsigned int D1, unsigned int D2, class R >
SMatrix< T, D1, D2, R > & ROOT::Math::SMatrix< T, D1, D2, R >::operator= ( SMatrixIdentity  )

Assign from an identity matrix.

Definition at line 177 of file SMatrix.icc.

◆ operator==() [1/3]

template<class T , unsigned int D1, unsigned int D2, class R >
template<class A , class R2 >
bool ROOT::Math::SMatrix< T, D1, D2, R >::operator== ( const Expr< A, T, D1, D2, R2 > &  rhs) const

element wise comparison

Definition at line 315 of file SMatrix.icc.

◆ operator==() [2/3]

template<class T , unsigned int D1, unsigned int D2, class R >
template<class R2 >
bool ROOT::Math::SMatrix< T, D1, D2, R >::operator== ( const SMatrix< T, D1, D2, R2 > &  rhs) const

element wise comparison

Definition at line 309 of file SMatrix.icc.

◆ operator==() [3/3]

template<class T , unsigned int D1, unsigned int D2, class R >
bool ROOT::Math::SMatrix< T, D1, D2, R >::operator== ( const T &  rhs) const

element wise comparison

Definition at line 299 of file SMatrix.icc.

◆ operator>() [1/3]

template<class T , unsigned int D1, unsigned int D2, class R >
template<class A , class R2 >
bool ROOT::Math::SMatrix< T, D1, D2, R >::operator> ( const Expr< A, T, D1, D2, R2 > &  rhs) const

element wise comparison

Definition at line 367 of file SMatrix.icc.

◆ operator>() [2/3]

template<class T , unsigned int D1, unsigned int D2, class R >
template<class R2 >
bool ROOT::Math::SMatrix< T, D1, D2, R >::operator> ( const SMatrix< T, D1, D2, R2 > &  rhs) const

element wise comparison

Definition at line 357 of file SMatrix.icc.

◆ operator>() [3/3]

template<class T , unsigned int D1, unsigned int D2, class R >
bool ROOT::Math::SMatrix< T, D1, D2, R >::operator> ( const T &  rhs) const

element wise comparison

Definition at line 347 of file SMatrix.icc.

◆ operator[]() [1/2]

template<class T , unsigned int D1, unsigned int D2 = D1, class R = MatRepStd<T, D1, D2>>
SMatrixRow ROOT::Math::SMatrix< T, D1, D2, R >::operator[] ( unsigned int  i)
inline

read/write access to matrix element with indices starting from 0 : m[i][j]

Definition at line 402 of file SMatrix.h.

◆ operator[]() [2/2]

template<class T , unsigned int D1, unsigned int D2 = D1, class R = MatRepStd<T, D1, D2>>
SMatrixRow_const ROOT::Math::SMatrix< T, D1, D2, R >::operator[] ( unsigned int  i) const
inline

read only access to matrix element, with indices starting from 0 : m[i][j]

Definition at line 398 of file SMatrix.h.

◆ Place_at() [1/2]

template<class T , unsigned int D1, unsigned int D2, class R >
template<class A , unsigned int D3, unsigned int D4, class R2 >
SMatrix< T, D1, D2, R > & ROOT::Math::SMatrix< T, D1, D2, R >::Place_at ( const Expr< A, T, D3, D4, R2 > &  rhs,
unsigned int  row,
unsigned int  col 
)

place a matrix expression in this matrix

Definition at line 564 of file SMatrix.icc.

◆ Place_at() [2/2]

template<class T , unsigned int D1, unsigned int D2, class R >
template<unsigned int D3, unsigned int D4, class R2 >
SMatrix< T, D1, D2, R > & ROOT::Math::SMatrix< T, D1, D2, R >::Place_at ( const SMatrix< T, D3, D4, R2 > &  rhs,
unsigned int  row,
unsigned int  col 
)

place a matrix in this matrix

Definition at line 552 of file SMatrix.icc.

◆ Place_in_col() [1/2]

template<class T , unsigned int D1, unsigned int D2, class R >
template<unsigned int D>
SMatrix< T, D1, D2, R > & ROOT::Math::SMatrix< T, D1, D2, R >::Place_in_col ( const SVector< T, D > &  rhs,
unsigned int  row,
unsigned int  col 
)

place a vector in a Matrix column

Definition at line 518 of file SMatrix.icc.

◆ Place_in_col() [2/2]

template<class T , unsigned int D1, unsigned int D2, class R >
template<class A , unsigned int D>
SMatrix< T, D1, D2, R > & ROOT::Math::SMatrix< T, D1, D2, R >::Place_in_col ( const VecExpr< A, T, D > &  rhs,
unsigned int  row,
unsigned int  col 
)

place a vector expression in a Matrix column

Definition at line 535 of file SMatrix.icc.

◆ Place_in_row() [1/2]

template<class T , unsigned int D1, unsigned int D2, class R >
template<unsigned int D>
SMatrix< T, D1, D2, R > & ROOT::Math::SMatrix< T, D1, D2, R >::Place_in_row ( const SVector< T, D > &  rhs,
unsigned int  row,
unsigned int  col 
)

place a vector in a Matrix row

Definition at line 484 of file SMatrix.icc.

◆ Place_in_row() [2/2]

template<class T , unsigned int D1, unsigned int D2, class R >
template<class A , unsigned int D>
SMatrix< T, D1, D2, R > & ROOT::Math::SMatrix< T, D1, D2, R >::Place_in_row ( const VecExpr< A, T, D > &  rhs,
unsigned int  row,
unsigned int  col 
)

place a vector expression in a Matrix row

Definition at line 501 of file SMatrix.icc.

◆ Print()

template<class T , unsigned int D1, unsigned int D2, class R >
std::ostream & ROOT::Math::SMatrix< T, D1, D2, R >::Print ( std::ostream &  os) const

Print: used by operator<<()

Definition at line 603 of file SMatrix.icc.

◆ Row()

template<class T , unsigned int D1, unsigned int D2, class R >
SVector< T, D2 > ROOT::Math::SMatrix< T, D1, D2, R >::Row ( unsigned int  therow) const

return a full Matrix row as a vector (copy the content in a new vector)

Definition at line 575 of file SMatrix.icc.

◆ SetDiagonal()

template<class T , unsigned int D1, unsigned int D2, class R >
template<class Vector >
void ROOT::Math::SMatrix< T, D1, D2, R >::SetDiagonal ( const Vector &  v)

Set the diagonal elements from a Vector Require that vector implements kSize since a check (statically) is done on diagonal size == vector size.

Definition at line 770 of file SMatrix.icc.

◆ SetElements() [1/2]

template<class T , unsigned int D1, unsigned int D2, class R >
template<class InputIterator >
void ROOT::Math::SMatrix< T, D1, D2, R >::SetElements ( InputIterator  begin,
InputIterator  end,
bool  triang = false,
bool  lower = true 
)

Set matrix elements with STL iterator interface.

The data will be copied into the matrix

Parameters
beginstart iterator position
endend iterator position
triangif true only the triangular lower/upper part of the matrix is filled from the iterators
lowerif true the lower triangular part is filled

Size of the matrix must match size of the iterators, if triang is false, otherwise the size of the triangular block. In the case of symmetric matrices triang is considered always to be true (what-ever the user specifies) and the size of the iterators must be equal to the size of the triangular block, which is the number of independent elements of a symmetric matrix: N*(N+1)/2

Definition at line 692 of file SMatrix.icc.

◆ SetElements() [2/2]

template<class T , unsigned int D1, unsigned int D2, class R >
template<class InputIterator >
void ROOT::Math::SMatrix< T, D1, D2, R >::SetElements ( InputIterator  begin,
unsigned int  size,
bool  triang = false,
bool  lower = true 
)

Constructor with STL iterator interface.

The data will be copied into the matrix

Parameters
beginstart iterator position
sizeiterator size
triangif true only the triangular lower/upper part of the matrix is filled from the iterators
lowerif true the lower triangular part is filled

Size of the iterators must not be larger than the size of the matrix representation. In the case of symmetric matrices the size is N*(N+1)/2.

Definition at line 699 of file SMatrix.icc.

◆ Sub()

template<class T , unsigned int D1, unsigned int D2, class R >
template<class SubMatrix >
SubMatrix ROOT::Math::SMatrix< T, D1, D2, R >::Sub ( unsigned int  row0,
unsigned int  col0 
) const

return a submatrix with the upper left corner at the values (row0, col0) and with sizes N1, N2 where N1 and N2 are the dimension of the sub-matrix (SubMatrix::kRows and SubMatrix::kCols ) Condition row0+N1 <= D1 && col0+N2 <=D2

Definition at line 745 of file SMatrix.icc.

◆ SubCol()

template<class T , unsigned int D1, unsigned int D2, class R >
template<class SubVector >
SubVector ROOT::Math::SMatrix< T, D1, D2, R >::SubCol ( unsigned int  thecol,
unsigned int  row0 = 0 
) const

return a slice of the column as a vector starting at the row value row0 until row0+Dsub.

where N is the size of the vector (SubVector::kSize ) Condition row0+N <= D1

Definition at line 728 of file SMatrix.icc.

◆ SubRow()

template<class T , unsigned int D1, unsigned int D2, class R >
template<class SubVector >
SubVector ROOT::Math::SMatrix< T, D1, D2, R >::SubRow ( unsigned int  therow,
unsigned int  col0 = 0 
) const

return a slice of therow as a vector starting at the colum value col0 until col0+N, where N is the size of the vector (SubVector::kSize ) Condition col0+N <= D2

Definition at line 712 of file SMatrix.icc.

◆ Trace()

template<class T , unsigned int D1, unsigned int D2, class R >
T ROOT::Math::SMatrix< T, D1, D2, R >::Trace

return the trace of a matrix Sum of the diagonal elements

Definition at line 784 of file SMatrix.icc.

◆ UpperBlock()

template<class T , unsigned int D1, unsigned int D2, class R >
SVector< T, D1 *(D2+1)/2 > ROOT::Math::SMatrix< T, D1, D2, R >::UpperBlock

return the upper Triangular block of the matrices (including the diagonal) as a vector of sizes N = D1 * (D1 + 1)/2.

It works only for square matrices with D1==D2, otherwise it will produce a compile error

Definition at line 797 of file SMatrix.icc.

Member Data Documentation

◆ fRep

template<class T , unsigned int D1, unsigned int D2 = D1, class R = MatRepStd<T, D1, D2>>
R ROOT::Math::SMatrix< T, D1, D2, R >::fRep

Matrix Storage Object containing matrix data.

Definition at line 686 of file SMatrix.h.

Libraries for ROOT::Math::SMatrix< T, D1, D2, R >:

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