CbmRoot
Loading...
Searching...
No Matches
cbm::algo::kf::MatrixSym< T, N > Class Template Reference

The class describes a symmetric N x N matrix stored in a low-triangular way. More...

#include <KfMatrixSym.h>

Inheritance diagram for cbm::algo::kf::MatrixSym< T, N >:
[legend]
Collaboration diagram for cbm::algo::kf::MatrixSym< T, N >:
[legend]

Public Member Functions

 MatrixSym ()
 default constructor
 
 ~MatrixSym ()=default
 Default destructor.
 
operator() (int i, int j) const
 Get matrix element, indices can be runtime values.
 
template<int i, int j>
operator() (Tag< i, j >) const
 Get matrix element, ensuring that indices are known at compile time.
 
T & operator() (int i, int j)
 Get matrix element, indices can be runtime values.
 
template<int i, int j>
T & operator() (Tag< i, j >)
 Get matrix element, ensuring that indices are known at compile time.
 
template<typename... Args>
void Reset (Args... args)
 Resets to 0, diagonal elements to given values.
 
std::string ToString (int iv=-1) const
 Prints parameters to a string.
 
std::string ToStringCorrelations (int iv=-1) const
 Prints correlations to a string (assuming the matrix is a covariance matrix)
 
bool IsFinite () const
 Checks whether some parameters are finite.
 
bool IsSimdEntryConsistent (int iv) const
 Checks whether SIMD entry iv is consistent.
 
bool IsConsistent (int nSimdFilled=-1) const
 Checks whether the covariance matrix elements are consistent.
 
template<DoPrintDebug FlagPrintDebug = DoPrintDebug::Y>
bool IsFinite (std::stringstream *ss) const
 Checks whether some parameters are finite.
 
template<DoPrintDebug FlagPrintDebug = DoPrintDebug::Y>
bool IsSimdEntryConsistent (std::stringstream *ss, int iv) const
 Checks whether SIMD entry iv is consistent.
 
template<DoPrintDebug FlagPrintDebug = DoPrintDebug::Y>
bool IsConsistent (std::stringstream *ss, int nSimdFilled=-1) const
 Checks whether the covariance matrix elements are consistent.
 
template<class Archive>
void serialize (Archive &ar, const unsigned int)
 

Static Public Attributes

static constexpr int kDimension {N}
 matrix dimension
 
static constexpr int kNofElements {(N) * (N + 1) / 2}
 N of matrix elements.
 

Private Member Functions

template<int index, typename... Args>
void SetDiagonal (T val, Args... args)
 Helper method to set diagonal elements recursively.
 

Detailed Description

template<typename T, int N>
class cbm::algo::kf::MatrixSym< T, N >

The class describes a symmetric N x N matrix stored in a low-triangular way.

that is used for covariance matrices.

Definition at line 36 of file KfMatrixSym.h.

Constructor & Destructor Documentation

◆ MatrixSym()

template<typename T, int N>
cbm::algo::kf::MatrixSym< T, N >::MatrixSym ( )
inline

default constructor

Definition at line 42 of file KfMatrixSym.h.

◆ ~MatrixSym()

template<typename T, int N>
cbm::algo::kf::MatrixSym< T, N >::~MatrixSym ( )
default

Default destructor.

Member Function Documentation

◆ IsConsistent() [1/2]

template<typename T, int N>
bool cbm::algo::kf::MatrixSym< T, N >::IsConsistent ( int nSimdFilled = -1) const
inline

Checks whether the covariance matrix elements are consistent.

Parameters
nFillednumber of filled SIMD entries to check (if <0, all entries are checked)

Definition at line 109 of file KfMatrixSym.h.

Referenced by cbm::algo::kf::MatrixSym< T, kNofParameters >::IsConsistent().

◆ IsConsistent() [2/2]

template<typename T, int N>
template<DoPrintDebug FlagPrintDebug>
bool cbm::algo::kf::MatrixSym< T, N >::IsConsistent ( std::stringstream * ss,
int nSimdFilled = -1 ) const
inline

Checks whether the covariance matrix elements are consistent.

Parameters
printWhenWrongif true, prints details when matrix is not consistent
nFillednumber of filled SIMD entries to check (if <0, all entries are checked)

Definition at line 366 of file KfMatrixSym.h.

References IsSimdEntryConsistent(), cbm::algo::kf::fvec::size(), size(), ToString(), and cbm::algo::kf::Y.

◆ IsFinite() [1/2]

template<typename T, int N>
bool cbm::algo::kf::MatrixSym< T, N >::IsFinite ( ) const
inline

Checks whether some parameters are finite.

Definition at line 102 of file KfMatrixSym.h.

Referenced by cbm::algo::kf::MatrixSym< T, kNofParameters >::IsFinite(), and IsSimdEntryConsistent().

◆ IsFinite() [2/2]

template<typename T, int N>
template<DoPrintDebug FlagPrintDebug>
bool cbm::algo::kf::MatrixSym< T, N >::IsFinite ( std::stringstream * ss) const
inline

Checks whether some parameters are finite.

Definition at line 255 of file KfMatrixSym.h.

References cbm::algo::kf::utils::IsFinite(), kDimension, operator()(), and cbm::algo::kf::Y.

◆ IsSimdEntryConsistent() [1/2]

template<typename T, int N>
bool cbm::algo::kf::MatrixSym< T, N >::IsSimdEntryConsistent ( int iv) const
inline

Checks whether SIMD entry iv is consistent.

Definition at line 105 of file KfMatrixSym.h.

Referenced by IsConsistent(), and cbm::algo::kf::MatrixSym< T, kNofParameters >::IsSimdEntryConsistent().

◆ IsSimdEntryConsistent() [2/2]

template<typename T, int N>
template<DoPrintDebug FlagPrintDebug>
bool cbm::algo::kf::MatrixSym< T, N >::IsSimdEntryConsistent ( std::stringstream * ss,
int iv ) const
inline

Checks whether SIMD entry iv is consistent.

Definition at line 279 of file KfMatrixSym.h.

References cbm::algo::kf::utils::simd::GetSimdEntry(), IsFinite(), kDimension, sqrt(), ToString(), and cbm::algo::kf::Y.

◆ operator()() [1/4]

template<typename T, int N>
T & cbm::algo::kf::MatrixSym< T, N >::operator() ( int i,
int j )
inline

Get matrix element, indices can be runtime values.

Parameters
irow
jcolumn
Returns
matrix element

Definition at line 67 of file KfMatrixSym.h.

◆ operator()() [2/4]

template<typename T, int N>
T cbm::algo::kf::MatrixSym< T, N >::operator() ( int i,
int j ) const
inline

Get matrix element, indices can be runtime values.

Parameters
irow
jcolumn
Returns
matrix element

Definition at line 51 of file KfMatrixSym.h.

Referenced by IsFinite(), ToString(), and ToStringCorrelations().

◆ operator()() [3/4]

template<typename T, int N>
template<int i, int j>
T & cbm::algo::kf::MatrixSym< T, N >::operator() ( Tag< i, j > )
inline

Get matrix element, ensuring that indices are known at compile time.

Parameters
irow
jcolumn
Returns
matrix element

Definition at line 75 of file KfMatrixSym.h.

◆ operator()() [4/4]

template<typename T, int N>
template<int i, int j>
T cbm::algo::kf::MatrixSym< T, N >::operator() ( Tag< i, j > ) const
inline

Get matrix element, ensuring that indices are known at compile time.

Parameters
irow
jcolumn
Returns
matrix element

Definition at line 58 of file KfMatrixSym.h.

◆ Reset()

template<typename T, int N>
template<typename... Args>
void cbm::algo::kf::MatrixSym< T, N >::Reset ( Args... args)
inline

Resets to 0, diagonal elements to given values.


Other methods

Definition at line 85 of file KfMatrixSym.h.

◆ serialize()

template<typename T, int N>
template<class Archive>
void cbm::algo::kf::MatrixSym< T, N >::serialize ( Archive & ar,
const unsigned int  )
inline

Serialization

Definition at line 129 of file KfMatrixSym.h.

◆ SetDiagonal()

template<typename T, int N>
template<int index, typename... Args>
void cbm::algo::kf::MatrixSym< T, N >::SetDiagonal ( T val,
Args... args )
inlineprivate

Helper method to set diagonal elements recursively.

Definition at line 138 of file KfMatrixSym.h.

Referenced by cbm::algo::kf::MatrixSym< T, kNofParameters >::Reset(), and cbm::algo::kf::MatrixSym< T, kNofParameters >::SetDiagonal().

◆ ToString()

template<typename T, int N>
std::string cbm::algo::kf::MatrixSym< T, N >::ToString ( int iv = -1) const
inline

Prints parameters to a string.

Parameters
ivif >=0, prints only the iv-th elements of SIMD vectors

Implementation of inline methods for MatrixSym class

Definition at line 168 of file KfMatrixSym.h.

References kDimension, operator()(), and ToString().

◆ ToStringCorrelations()

template<typename T, int N>
std::string cbm::algo::kf::MatrixSym< T, N >::ToStringCorrelations ( int iv = -1) const
inline

Prints correlations to a string (assuming the matrix is a covariance matrix)

Parameters
ivif >=0, prints only the iv-th elements of SIMD vectors

Definition at line 207 of file KfMatrixSym.h.

References kDimension, operator()(), sqrt(), and ToStringCorrelations().

Referenced by ToStringCorrelations().

Member Data Documentation

◆ kDimension

template<typename T, int N>
int cbm::algo::kf::MatrixSym< T, N >::kDimension {N}
staticconstexpr

matrix dimension

Definition at line 38 of file KfMatrixSym.h.

Referenced by IsFinite(), IsSimdEntryConsistent(), ToString(), and ToStringCorrelations().

◆ kNofElements

template<typename T, int N>
int cbm::algo::kf::MatrixSym< T, N >::kNofElements {(N) * (N + 1) / 2}
staticconstexpr

N of matrix elements.

Definition at line 39 of file KfMatrixSym.h.


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