4 #ifndef ROOT_Math_SMatrix
5 #define ROOT_Math_SMatrix
93 template <
class T,
unsigned int D>
class SVector;
122 unsigned int D2 = D1,
175 template <
class A,
class R2>
192 template<
class InputIterator>
193 SMatrix(InputIterator
begin, InputIterator
end,
bool triang =
false,
bool lower =
true);
206 template<
class InputIterator>
207 SMatrix(InputIterator
begin,
unsigned int size,
bool triang =
false,
bool lower =
true);
213 #ifndef UNSUPPORTED_TEMPLATE_EXPRESSION
216 template<
unsigned int N>
236 template <
class A,
class R2>
271 T apply(
unsigned int i)
const;
317 template<
class InputIterator>
318 void SetElements(InputIterator
begin, InputIterator
end,
bool triang =
false,
bool lower =
true);
331 template<
class InputIterator>
332 void SetElements(InputIterator
begin,
unsigned int size,
bool triang =
false,
bool lower =
true);
346 template <
class A,
class R2>
349 template <
class A,
class R2>
361 bool operator<(const SMatrix<T,D1,D2,R2>& rhs)
const;
363 template <
class A,
class R2>
366 template <
class A,
class R2>
367 bool operator<(const Expr<A,T,D1,D2,R2>& rhs)
const;
372 const T&
operator()(
unsigned int i,
unsigned int j)
const;
382 const T&
At(
unsigned int i,
unsigned int j)
const;
387 T&
At(
unsigned int i,
unsigned int j);
419 SMatrixRow_const
operator[](
unsigned int i)
const {
return SMatrixRow_const(*
this, i); }
423 SMatrixRow
operator[](
unsigned int i) {
return SMatrixRow(*
this, i); }
440 template <
class A,
class R2>
457 template <
class A,
class R2>
478 template <
class A,
class R2>
564 bool Det2(
T& det)
const;
570 template <
unsigned int D>
575 template <
class A,
unsigned int D>
580 template <
unsigned int D>
585 template <
class A,
unsigned int D>
590 template <
unsigned int D3,
unsigned int D4,
class R2>
595 template <
class A,
unsigned int D3,
unsigned int D4,
class R2>
615 template <
class SubVector>
616 SubVector
SubRow(
unsigned int therow,
unsigned int col0 = 0 )
const;
623 template <
class SubVector>
624 SubVector
SubCol(
unsigned int thecol,
unsigned int row0 = 0)
const;
631 template <
class SubMatrix >
632 SubMatrix
Sub(
unsigned int row0,
unsigned int col0)
const;
645 template <
class Vector>
660 #ifndef UNSUPPORTED_TEMPLATE_EXPRESSION
663 template<
class SubVector>
672 #ifndef UNSUPPORTED_TEMPLATE_EXPRESSION
675 template<
class SubVector>
695 std::ostream&
Print(std::ostream& os)
const;
717 template <
class T,
unsigned int D1,
unsigned int D2,
class R>
718 inline std::ostream& operator<<(std::ostream& os, const ROOT::Math::SMatrix<T,D1,D2,R>& rhs) {
719 return rhs.Print(os);
SMatrix< T, D1, D2, R > & operator+=(const T &rhs)
addition with a scalar
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
SMatrix< T, D1, D2, R > & operator*=(const T &rhs)
multiplication with a scalar
void SetDiagonal(const Vector &v)
Set the diagonal elements from a Vector Require that vector implements kSize since a check (staticall...
bool operator==(const T &rhs) const
element wise comparison
SMatrix< T, D1, D2, R > InverseChol(int &ifail) const
Invert of a symmetric positive defined Matrix using Choleski decomposition.
SMatrix< T, D1, D2, R > & operator/=(const T &rhs)
division with a scalar
return no. of matrix rows
SMatrix< T, D1, D2, R > & operator-=(const T &rhs)
subtraction with a scalar
SMatrix< T, D1, D2, R > & operator=(const M &rhs)
Assign from another compatible matrix.
T * iterator
STL iterator interface.
SMatrix< T, D1, D2, R > * fMat
bool Invert()
Invert a square Matrix ( this method changes the current matrix).
bool InvertFast()
Fast Invertion of a square Matrix ( this method changes the current matrix).
bool InvertChol()
Invertion of a symmetric positive defined Matrix using Choleski decomposition.
SVector< T, D1 > Diagonal() const
return diagonal elements of a matrix as a Vector.
bool Det2(T &det) const
determinant of square Matrix via Dfact.
return no of elements: rows*columns
const T * const_iterator
STL const_iterator interface.
bool Det(T &det)
determinant of square Matrix via Dfact.
SMatrix: a generic fixed size D1 x D2 Matrix class.
T apply(unsigned int i) const
access the parse tree with the index starting from zero and following the C convention for the order ...
SMatrix()
Default constructor:
const T * Array() const
return read-only pointer to internal array
const T & operator[](int j) const
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 = D...
SVector< T, D1 > Col(unsigned int thecol) const
return a full Matrix column as a vector (copy the content in a new vector)
R rep_type
storage representation type
Expression wrapper class for Matrix objects.
R fRep
Matrix Storage Object containing matrix data.
return no. of matrix columns
SMatrix< T, D1, D2, R > InverseFast(int &ifail) const
Invert a square Matrix and returns a new matrix.
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]
iterator begin()
STL iterator interface.
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.
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
bool IsInUse(const T *p) const
Function to check if a matrix is sharing same memory location of the passed pointer This function is ...
SMatrix(SMatrixNoInit)
construct from without initialization
const T & operator()(unsigned int i, unsigned int j) const
read only access to matrix element, with indices starting from 0
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 = D...
bool operator<(const T &rhs) const
element wise comparison
SMatrixRow_const(const SMatrix< T, D1, D2, R > &rhs, unsigned int i)
T value_type
contained scalar type
SMatrixRow(SMatrix< T, D1, D2, R > &rhs, unsigned int i)
std::ostream & Print(std::ostream &os) const
Print: used by operator<<()
const T & At(unsigned int i, unsigned int j) const
read only access to matrix element, with indices starting from 0.
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...
bool operator>(const T &rhs) const
element wise comparison
const SMatrix< T, D1, D2, R > * fMat
T Trace() const
return the trace of a matrix Sum of the diagonal elements
Expression wrapper class for Vector objects.
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
bool operator!=(const T &rhs) const
element wise comparison
SVector< T, D2 > Row(unsigned int therow) const
return a full Matrix row as a vector (copy the content in a new vector)
SMatrix< T, D1, D2, R > Inverse(int &ifail) const
Invert a square Matrix and returns a new matrix.
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
void SetElements(InputIterator begin, InputIterator end, bool triang=false, bool lower=true)
Set matrix elements with STL iterator interface.
SVector: a generic fixed size Vector class.
iterator end()
STL iterator interface.