Logo ROOT   6.08/07
Reference Guide
List of all members | Classes | List of all members
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 33 of file BinaryOperators.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 More...
 
typedef R rep_type
 storage representation type More...
 
typedef T * iterator
 STL iterator interface. More...
 
typedef const T * const_iterator
 STL const_iterator interface. More...
 

Public Member Functions

--- Constructors and Assignment ---
 SMatrix ()
 Default constructor: More...
 
 SMatrix (SMatrixNoInit)
 construct from without initialization More...
 
 SMatrix (SMatrixIdentity)
 construct from an identity matrix More...
 
 SMatrix (const SMatrix< T, D1, D2, R > &rhs)
 copy constructor (from a matrix of the same representation More...
 
template<class R2 >
 SMatrix (const SMatrix< T, D1, D2, R2 > &rhs)
 construct from a matrix with different representation. More...
 
template<class A , class R2 >
 SMatrix (const Expr< A, T, D1, D2, R2 > &rhs)
 Construct from an expression. More...
 
template<class InputIterator >
 SMatrix (InputIterator begin, InputIterator end, bool triang=false, bool lower=true)
 Constructor with STL iterator interface. More...
 
template<class InputIterator >
 SMatrix (InputIterator begin, unsigned int size, bool triang=false, bool lower=true)
 Constructor with STL iterator interface. More...
 
 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. More...
 
 SMatrix (const T &rhs)
 Construct from a scalar value (only for size 1 matrices) More...
 
template<class M >
SMatrix< T, D1, D2, R > & operator= (const M &rhs)
 Assign from another compatible matrix. More...
 
template<class A , class R2 >
SMatrix< T, D1, D2, R > & operator= (const Expr< A, T, D1, D2, R2 > &rhs)
 Assign from a matrix expression. More...
 
SMatrix< T, D1, D2, R > & operator= (SMatrixIdentity)
 Assign from an identity matrix. More...
 
SMatrix< T, D1, D2, R > & operator= (const T &rhs)
 Assign from a scalar value (only for size 1 matrices) More...
 
--- 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. More...
 
const T * Array () const
 return read-only pointer to internal array More...
 
T * Array ()
 return pointer to internal array More...
 
--- 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. More...
 
iterator end ()
 STL iterator interface. More...
 
const_iterator begin () const
 STL const_iterator interface. More...
 
const_iterator end () const
 STL const_iterator interface. More...
 
template<class InputIterator >
void SetElements (InputIterator begin, InputIterator end, bool triang=false, bool lower=true)
 Set matrix elements with STL iterator interface. More...
 
template<class InputIterator >
void SetElements (InputIterator begin, unsigned int size, bool triang=false, bool lower=true)
 Constructor with STL iterator interface. More...
 
--- Operators ---
bool operator== (const T &rhs) const
 element wise comparison More...
 
bool operator!= (const T &rhs) const
 element wise comparison More...
 
template<class R2 >
bool operator== (const SMatrix< T, D1, D2, R2 > &rhs) const
 element wise comparison More...
 
bool operator!= (const SMatrix< T, D1, D2, R > &rhs) const
 element wise comparison More...
 
template<class A , class R2 >
bool operator== (const Expr< A, T, D1, D2, R2 > &rhs) const
 element wise comparison More...
 
template<class A , class R2 >
bool operator!= (const Expr< A, T, D1, D2, R2 > &rhs) const
 element wise comparison More...
 
bool operator> (const T &rhs) const
 element wise comparison More...
 
bool operator< (const T &rhs) const
 element wise comparison More...
 
template<class R2 >
bool operator> (const SMatrix< T, D1, D2, R2 > &rhs) const
 element wise comparison More...
 
template<class R2 >
bool operator< (const SMatrix< T, D1, D2, R2 > &rhs) const
 element wise comparison More...
 
template<class A , class R2 >
bool operator> (const Expr< A, T, D1, D2, R2 > &rhs) const
 element wise comparison More...
 
template<class A , class R2 >
bool operator< (const Expr< A, T, D1, D2, R2 > &rhs) const
 element wise comparison More...
 
const T & operator() (unsigned int i, unsigned int j) const
 read only access to matrix element, with indices starting from 0 More...
 
T & operator() (unsigned int i, unsigned int j)
 read/write access to matrix element with indices starting from 0 More...
 
const T & At (unsigned int i, unsigned int j) const
 read only access to matrix element, with indices starting from 0. More...
 
T & At (unsigned int i, unsigned int j)
 read/write access to matrix element with indices starting from 0. More...
 
SMatrixRow_const operator[] (unsigned int i) const
 read only access to matrix element, with indices starting from 0 : m[i][j] More...
 
SMatrixRow operator[] (unsigned int i)
 read/write access to matrix element with indices starting from 0 : m[i][j] More...
 
SMatrix< T, D1, D2, R > & operator+= (const T &rhs)
 addition with a scalar More...
 
template<class R2 >
SMatrix< T, D1, D2, R > & operator+= (const SMatrix< T, D1, D2, R2 > &rhs)
 addition with another matrix of any compatible representation More...
 
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 More...
 
SMatrix< T, D1, D2, R > & operator-= (const T &rhs)
 subtraction with a scalar More...
 
template<class R2 >
SMatrix< T, D1, D2, R > & operator-= (const SMatrix< T, D1, D2, R2 > &rhs)
 subtraction with another matrix of any compatible representation More...
 
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 More...
 
SMatrix< T, D1, D2, R > & operator*= (const T &rhs)
 multiplication with a scalar More...
 
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 More...
 
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) More...
 
SMatrix< T, D1, D2, R > & operator/= (const T &rhs)
 division with a scalar More...
 
--- Linear Algebra Functions ---
bool Invert ()
 Invert a square Matrix ( this method changes the current matrix). More...
 
SMatrix< T, D1, D2, RInverse (int &ifail) const
 Invert a square Matrix and returns a new matrix. More...
 
bool InvertFast ()
 Fast Invertion of a square Matrix ( this method changes the current matrix). More...
 
SMatrix< T, D1, D2, RInverseFast (int &ifail) const
 Invert a square Matrix and returns a new matrix. More...
 
bool InvertChol ()
 Invertion of a symmetric positive defined Matrix using Choleski decomposition. More...
 
SMatrix< T, D1, D2, RInverseChol (int &ifail) const
 Invert of a symmetric positive defined Matrix using Choleski decomposition. More...
 
bool Det (T &det)
 determinant of square Matrix via Dfact. More...
 
bool Det2 (T &det) const
 determinant of square Matrix via Dfact. More...
 
--- 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 More...
 
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 More...
 
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 More...
 
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 More...
 
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 More...
 
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 More...
 
SVector< T, D2 > Row (unsigned int therow) const
 return a full Matrix row as a vector (copy the content in a new vector) More...
 
SVector< T, D1 > Col (unsigned int thecol) const
 return a full Matrix column as a vector (copy the content in a new vector) More...
 
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 More...
 
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. More...
 
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 More...
 
SVector< T, D1 > Diagonal () const
 return diagonal elements of a matrix as a Vector. More...
 
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. More...
 
Trace () const
 return the trace of a matrix Sum of the diagonal elements More...
 
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. More...
 
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. More...
 
--- 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. More...
 
std::ostream & Print (std::ostream &os) const
 Print: used by operator<<() More...
 

Public Attributes

--- Data Member ---
R fRep
 Matrix Storage Object containing matrix data. More...
 

#include <Math/BinaryOperators.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 144 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 141 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 138 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 135 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 261 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 77 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 158 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 84 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 98 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 105 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 112 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 122 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 130 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 857 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 143 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 626 of file SMatrix.icc.

◆ Array() [1/2]

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

return read-only pointer to internal array

Definition at line 629 of file SMatrix.icc.

◆ Array() [2/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 632 of file SMatrix.icc.

◆ At() [1/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 652 of file SMatrix.icc.

◆ At() [2/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 659 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 669 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 ( ) const
inline

STL const_iterator interface.

Definition at line 679 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 589 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 465 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 472 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 ( ) const

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 754 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 674 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 ( ) const
inline

STL const_iterator interface.

Definition at line 684 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 418 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 451 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 435 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 411 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 445 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 428 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 894 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 ( ) const

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 825 of file SMatrix.icc.

◆ operator!=() [1/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 326 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 331 of file SMatrix.icc.

◆ operator!=() [3/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 337 of file SMatrix.icc.

◆ operator()() [1/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 638 of file SMatrix.icc.

◆ operator()() [2/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 643 of file SMatrix.icc.

◆ operator*=() [1/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 257 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 267 of file SMatrix.icc.

◆ operator*=() [3/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 275 of file SMatrix.icc.

◆ operator+=() [1/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 196 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 206 of file SMatrix.icc.

◆ operator+=() [3/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 216 of file SMatrix.icc.

◆ operator-=() [1/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 227 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 237 of file SMatrix.icc.

◆ operator-=() [3/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 247 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 286 of file SMatrix.icc.

◆ operator<() [1/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 378 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 388 of file SMatrix.icc.

◆ operator<() [3/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 398 of file SMatrix.icc.

◆ operator=() [1/4]

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 160 of file SMatrix.icc.

◆ operator=() [2/4]

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 167 of file SMatrix.icc.

◆ operator=() [3/4]

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 176 of file SMatrix.icc.

◆ operator=() [4/4]

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 149 of file SMatrix.icc.

◆ operator==() [1/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 298 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 308 of file SMatrix.icc.

◆ operator==() [3/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 314 of file SMatrix.icc.

◆ operator>() [1/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 346 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 356 of file SMatrix.icc.

◆ operator>() [3/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 366 of file SMatrix.icc.

◆ operator[]() [1/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 425 of file SMatrix.h.

◆ operator[]() [2/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 429 of file SMatrix.h.

◆ Place_at() [1/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 551 of file SMatrix.icc.

◆ Place_at() [2/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 563 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 517 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 534 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 483 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 500 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 602 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 574 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 769 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 691 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 698 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 744 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 727 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 711 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 ( ) const

return the trace of a matrix Sum of the diagonal elements

Definition at line 783 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 ( ) const

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 796 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 713 of file SMatrix.h.


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