![]() |
Project
|
Fast symmetric matrix with dynamically expandable size. More...
#include <SymMatrix.h>
Inherits o2::fwdalign::MatrixSq.
Public Member Functions | |
SymMatrix () | |
default constructor | |
SymMatrix (Int_t size) | |
constructor for matrix with defined size | |
SymMatrix (const SymMatrix &mat) | |
copy constructor | |
~SymMatrix () override | |
destructor | |
void | Clear (Option_t *option="") override |
clear dynamic part | |
void | Reset () override |
Int_t | GetSize () const override |
Int_t | GetSizeUsed () const |
Int_t | GetSizeBooked () const |
Int_t | GetSizeAdded () const |
Float_t | GetDensity () const override |
get fraction of non-zero elements | |
SymMatrix & | operator= (const SymMatrix &src) |
assignment operator | |
SymMatrix & | operator+= (const SymMatrix &src) |
add operator | |
SymMatrix & | operator-= (const SymMatrix &src) |
minus operator | |
Double_t | operator() (Int_t rown, Int_t coln) const override |
Double_t & | operator() (Int_t rown, Int_t coln) override |
Double_t | DiagElem (Int_t r) const override |
Double_t & | DiagElem (Int_t r) override |
Double_t * | GetRow (Int_t r) |
get pointer on the row | |
void | Print (const Option_t *option="") const override |
print itself | |
void | AddRows (int nrows=1) |
add empty rows | |
void | SetSizeUsed (Int_t sz) |
void | Scale (Double_t coeff) |
Bool_t | Multiply (const SymMatrix &right) |
multiply from the right | |
void | MultiplyByVec (const Double_t *vecIn, Double_t *vecOut) const override |
fill vecOut by matrix*vecIn | |
void | MultiplyByVec (const TVectorD &vecIn, TVectorD &vecOut) const override |
void | AddToRow (Int_t r, Double_t *valc, Int_t *indc, Int_t n) override |
const Double_t * | GetMatrixArray () const override |
Double_t * | GetMatrixArray () override |
const Int_t * | GetRowIndexArray () const override |
Int_t * | GetRowIndexArray () override |
const Int_t * | GetColIndexArray () const override |
Int_t * | GetColIndexArray () override |
TMatrixDBase & | SetRowIndexArray (Int_t *) override |
TMatrixDBase & | SetColIndexArray (Int_t *) override |
TMatrixDBase & | GetSub (Int_t, Int_t, Int_t, Int_t, TMatrixDBase &, Option_t *) const override |
TMatrixDBase & | SetSub (Int_t, Int_t, const TMatrixDBase &) override |
TMatrixDBase & | ResizeTo (Int_t, Int_t, Int_t) override |
TMatrixDBase & | ResizeTo (Int_t, Int_t, Int_t, Int_t, Int_t) override |
SymMatrix * | DecomposeChol () |
Return a matrix with Choleski decomposition. | |
void | InvertChol (SymMatrix *mchol) |
Invert using provided Choleski decomposition, provided the Cholseki's L matrix. | |
Bool_t | InvertChol () |
Invert matrix using Choleski decomposition. | |
Bool_t | SolveChol (Double_t *brhs, Bool_t invert=kFALSE) |
Solves the set of n linear equations A x = b. | |
Bool_t | SolveChol (Double_t *brhs, Double_t *bsol, Bool_t invert=kFALSE) |
Bool_t | SolveChol (TVectorD &brhs, Bool_t invert=kFALSE) |
Bool_t | SolveChol (const TVectorD &brhs, TVectorD &bsol, Bool_t invert=kFALSE) |
Bool_t | SolveCholN (Double_t *bn, int nRHS, Bool_t invert=kFALSE) |
Solves the set of n linear equations A x = b; this version solve multiple RHSs at once. | |
int | SolveSpmInv (double *vecB, Bool_t stabilize=kTRUE) |
Obtain solution of a system of linear equations with symmetric matrix and the inverse (using 'singular-value friendly' GAUSS pivot) | |
![]() | |
MatrixSq () | |
MatrixSq (const MatrixSq &src) | |
~MatrixSq () override=default | |
MatrixSq & | operator= (const MatrixSq &src) |
= operator | |
virtual Double_t | Query (Int_t rown, Int_t coln) const |
virtual Double_t | QueryDiag (Int_t rc) const |
void | Print (Option_t *option="") const override=0 |
virtual void | PrintCOO () const |
print matrix in COO sparse format | |
Bool_t | IsSymmetric () const override |
void | SetSymmetric (Bool_t v=kTRUE) |
const Double_t * | GetMatrixArray () const override |
Double_t * | GetMatrixArray () override |
const Int_t * | GetRowIndexArray () const override |
Int_t * | GetRowIndexArray () override |
const Int_t * | GetColIndexArray () const override |
Int_t * | GetColIndexArray () override |
TMatrixDBase & | SetRowIndexArray (Int_t *) override |
TMatrixDBase & | SetColIndexArray (Int_t *) override |
TMatrixDBase & | GetSub (Int_t, Int_t, Int_t, Int_t, TMatrixDBase &, Option_t *) const override |
TMatrixDBase & | SetSub (Int_t, Int_t, const TMatrixDBase &) override |
TMatrixDBase & | ResizeTo (Int_t, Int_t, Int_t) override |
TMatrixDBase & | ResizeTo (Int_t, Int_t, Int_t, Int_t, Int_t) override |
virtual void | Allocate (Int_t, Int_t, Int_t, Int_t, Int_t, Int_t) |
Protected Member Functions | |
virtual Int_t | GetIndex (Int_t row, Int_t col) const |
Double_t | GetEl (Int_t row, Int_t col) const |
void | SetEl (Int_t row, Int_t col, Double_t val) |
ClassDefOverride (SymMatrix, 0) | |
![]() | |
void | Swap (int &r, int &c) const |
ClassDefOverride (MatrixSq, 1) | |
Protected Attributes | |
Double_t * | fElems |
Elements booked by constructor. | |
Double_t ** | fElemsAdd |
Elements (rows) added dynamicaly. | |
![]() | |
Bool_t | fSymmetric |
is the matrix symmetric? Only lower triangle is filled | |
Static Protected Attributes | |
static SymMatrix * | fgBuffer = nullptr |
buffer for fast solution | |
static Int_t | fgCopyCnt = 0 |
matrix copy counter | |
Additional Inherited Members | |
![]() | |
static Bool_t | IsZero (Double_t x, Double_t thresh=1e-64) |
Fast symmetric matrix with dynamically expandable size.
Only part can be used for matrix operations. It is defined as:
fNCols | rows built by constructor (GetSizeBooked) |
fNRows | number of rows added dynamically (automatically added on assignment to row), GetNRowAdded |
fNRowIndex | total size (fNCols+fNRows), GetSize |
fRowLwb | actual size to used for given operation, by default = total size, GetSizeUsed |
Definition at line 37 of file SymMatrix.h.
SymMatrix::SymMatrix | ( | ) |
default constructor
Definition at line 29 of file SymMatrix.cxx.
SymMatrix::SymMatrix | ( | Int_t | size | ) |
constructor for matrix with defined size
Definition at line 38 of file SymMatrix.cxx.
SymMatrix::SymMatrix | ( | const SymMatrix & | mat | ) |
copy constructor
Definition at line 52 of file SymMatrix.cxx.
|
override |
destructor
Definition at line 82 of file SymMatrix.cxx.
add empty rows
Definition at line 460 of file SymMatrix.cxx.
|
inlineoverridevirtual |
Implements o2::fwdalign::MatrixSq.
Definition at line 273 of file SymMatrix.h.
|
protected |
|
overridevirtual |
SymMatrix * SymMatrix::DecomposeChol | ( | ) |
Return a matrix with Choleski decomposition.
Adopted from Numerical Recipes in C, ch.2-9, http://www.nr.com consturcts Cholesky decomposition of SYMMETRIC and POSITIVELY-DEFINED matrix a (a=L*Lt) Only upper triangle of the matrix has to be filled. In opposite to function from the book, the matrix is modified: lower triangle and diagonal are refilled.
Definition at line 258 of file SymMatrix.cxx.
|
inlineoverridevirtual |
Implements o2::fwdalign::MatrixSq.
Definition at line 77 of file SymMatrix.h.
|
inlineoverridevirtual |
Implements o2::fwdalign::MatrixSq.
Definition at line 78 of file SymMatrix.h.
|
inlineoverride |
Definition at line 117 of file SymMatrix.h.
|
inlineoverride |
Definition at line 122 of file SymMatrix.h.
|
overridevirtual |
get fraction of non-zero elements
Implements o2::fwdalign::MatrixSq.
Definition at line 184 of file SymMatrix.cxx.
|
inlineprotected |
Definition at line 208 of file SymMatrix.h.
|
inlineprotectedvirtual |
Definition at line 222 of file SymMatrix.h.
|
inlineoverride |
Definition at line 105 of file SymMatrix.h.
|
inlineoverride |
Definition at line 106 of file SymMatrix.h.
Double_t * SymMatrix::GetRow | ( | Int_t | r | ) |
get pointer on the row
Definition at line 539 of file SymMatrix.cxx.
|
inlineoverride |
Definition at line 107 of file SymMatrix.h.
|
inlineoverride |
Definition at line 112 of file SymMatrix.h.
|
inlineoverridevirtual |
Reimplemented from o2::fwdalign::MatrixSq.
Definition at line 57 of file SymMatrix.h.
|
inline |
Definition at line 60 of file SymMatrix.h.
|
inline |
Definition at line 59 of file SymMatrix.h.
|
inline |
Definition at line 58 of file SymMatrix.h.
|
inlineoverride |
Definition at line 137 of file SymMatrix.h.
Bool_t SymMatrix::InvertChol | ( | ) |
Invert matrix using Choleski decomposition.
Definition at line 296 of file SymMatrix.cxx.
Invert using provided Choleski decomposition, provided the Cholseki's L matrix.
Definition at line 309 of file SymMatrix.cxx.
Bool_t SymMatrix::Multiply | ( | const SymMatrix & | right | ) |
multiply from the right
Definition at line 230 of file SymMatrix.cxx.
|
overridevirtual |
fill vecOut by matrix*vecIn
vector should be of the same size as the matrix
Reimplemented from o2::fwdalign::MatrixSq.
Definition at line 219 of file SymMatrix.cxx.
|
inlineoverridevirtual |
Reimplemented from o2::fwdalign::MatrixSq.
Definition at line 254 of file SymMatrix.h.
|
inlineoverridevirtual |
Implements o2::fwdalign::MatrixSq.
Definition at line 229 of file SymMatrix.h.
|
inlineoverridevirtual |
Implements o2::fwdalign::MatrixSq.
Definition at line 242 of file SymMatrix.h.
add operator
Definition at line 136 of file SymMatrix.cxx.
minus operator
Definition at line 151 of file SymMatrix.cxx.
assignment operator
Definition at line 92 of file SymMatrix.cxx.
|
override |
print itself
Definition at line 198 of file SymMatrix.cxx.
|
overridevirtual |
Implements o2::fwdalign::MatrixSq.
Definition at line 482 of file SymMatrix.cxx.
|
inlineoverride |
Definition at line 147 of file SymMatrix.h.
|
inlineoverride |
Definition at line 152 of file SymMatrix.h.
|
inline |
Definition at line 260 of file SymMatrix.h.
|
inlineoverride |
Definition at line 132 of file SymMatrix.h.
|
inlineprotected |
Definition at line 209 of file SymMatrix.h.
|
inlineoverride |
Definition at line 127 of file SymMatrix.h.
|
inline |
Definition at line 89 of file SymMatrix.h.
|
inlineoverride |
Definition at line 142 of file SymMatrix.h.
Bool_t SymMatrix::SolveChol | ( | const TVectorD & | brhs, |
TVectorD & | bsol, | ||
Bool_t | invert = kFALSE |
||
) |
Definition at line 453 of file SymMatrix.cxx.
Bool_t SymMatrix::SolveChol | ( | Double_t * | brhs, |
Bool_t | invert = kFALSE |
||
) |
Solves the set of n linear equations A x = b.
Adopted from Numerical Recipes in C, ch.2-9, http://www.nr.com Solves the set of n linear equations A x = b, where a is a positive-definite symmetric matrix. a[1..n][1..n] is the output of the routine CholDecomposw. Only the lower triangle of a is accessed. b[1..n] is input as the right-hand side vector. The solution vector is returned in b[1..n].
Definition at line 351 of file SymMatrix.cxx.
Bool_t SymMatrix::SolveChol | ( | Double_t * | brhs, |
Double_t * | bsol, | ||
Bool_t | invert = kFALSE |
||
) |
Definition at line 446 of file SymMatrix.cxx.
Bool_t SymMatrix::SolveChol | ( | TVectorD & | brhs, |
Bool_t | invert = kFALSE |
||
) |
Definition at line 440 of file SymMatrix.cxx.
Bool_t SymMatrix::SolveCholN | ( | Double_t * | bn, |
int | nRHS, | ||
Bool_t | invert = kFALSE |
||
) |
Solves the set of n linear equations A x = b; this version solve multiple RHSs at once.
Adopted from Numerical Recipes in C, ch.2-9, http://www.nr.com Solves the set of n linear equations A x = b, where a is a positive-definite symmetric matrix. a[1..n][1..n] is the output of the routine CholDecomposw. Only the lower triangle of a is accessed. b[1..n] is input as the right-hand side vector. The solution vector is returned in b[1..n]. This version solve multiple RHSs at once
Definition at line 393 of file SymMatrix.cxx.
int SymMatrix::SolveSpmInv | ( | double * | vecB, |
Bool_t | stabilize = kTRUE |
||
) |
Obtain solution of a system of linear equations with symmetric matrix and the inverse (using 'singular-value friendly' GAUSS pivot)
Solution a la MP1: gaussian eliminations
Definition at line 552 of file SymMatrix.cxx.
|
protected |
Elements booked by constructor.
Definition at line 212 of file SymMatrix.h.
|
protected |
Elements (rows) added dynamicaly.
Definition at line 213 of file SymMatrix.h.
|
staticprotected |
buffer for fast solution
Definition at line 215 of file SymMatrix.h.
|
staticprotected |
matrix copy counter
Definition at line 216 of file SymMatrix.h.