Project
Loading...
Searching...
No Matches
o2::fwdalign::SymMatrix Class Reference

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
 
SymMatrixoperator= (const SymMatrix &src)
 assignment operator
 
SymMatrixoperator+= (const SymMatrix &src)
 add operator
 
SymMatrixoperator-= (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
 
TMatrixDBaseSetRowIndexArray (Int_t *) override
 
TMatrixDBaseSetColIndexArray (Int_t *) override
 
TMatrixDBaseGetSub (Int_t, Int_t, Int_t, Int_t, TMatrixDBase &, Option_t *) const override
 
TMatrixDBaseSetSub (Int_t, Int_t, const TMatrixDBase &) override
 
TMatrixDBaseResizeTo (Int_t, Int_t, Int_t) override
 
TMatrixDBaseResizeTo (Int_t, Int_t, Int_t, Int_t, Int_t) override
 
SymMatrixDecomposeChol ()
 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)
 
- Public Member Functions inherited from o2::fwdalign::MatrixSq
 MatrixSq ()
 
 MatrixSq (const MatrixSq &src)
 
 ~MatrixSq () override=default
 
MatrixSqoperator= (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
 
TMatrixDBaseSetRowIndexArray (Int_t *) override
 
TMatrixDBaseSetColIndexArray (Int_t *) override
 
TMatrixDBaseGetSub (Int_t, Int_t, Int_t, Int_t, TMatrixDBase &, Option_t *) const override
 
TMatrixDBaseSetSub (Int_t, Int_t, const TMatrixDBase &) override
 
TMatrixDBaseResizeTo (Int_t, Int_t, Int_t) override
 
TMatrixDBaseResizeTo (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)
 
- Protected Member Functions inherited from o2::fwdalign::MatrixSq
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.
 
- Protected Attributes inherited from o2::fwdalign::MatrixSq
Bool_t fSymmetric
 is the matrix symmetric? Only lower triangle is filled
 

Static Protected Attributes

static SymMatrixfgBuffer = nullptr
 buffer for fast solution
 
static Int_t fgCopyCnt = 0
 matrix copy counter
 

Additional Inherited Members

- Static Public Member Functions inherited from o2::fwdalign::MatrixSq
static Bool_t IsZero (Double_t x, Double_t thresh=1e-64)
 

Detailed Description

Fast symmetric matrix with dynamically expandable size.

Only part can be used for matrix operations. It is defined as:

Parameters
fNColsrows built by constructor (GetSizeBooked)
fNRowsnumber of rows added dynamically (automatically added on assignment to row), GetNRowAdded
fNRowIndextotal size (fNCols+fNRows), GetSize
fRowLwbactual size to used for given operation, by default = total size, GetSizeUsed

Definition at line 37 of file SymMatrix.h.

Constructor & Destructor Documentation

◆ SymMatrix() [1/3]

SymMatrix::SymMatrix ( )

default constructor

Definition at line 29 of file SymMatrix.cxx.

◆ SymMatrix() [2/3]

SymMatrix::SymMatrix ( Int_t  size)

constructor for matrix with defined size

Definition at line 38 of file SymMatrix.cxx.

◆ SymMatrix() [3/3]

SymMatrix::SymMatrix ( const SymMatrix mat)

copy constructor

Definition at line 52 of file SymMatrix.cxx.

◆ ~SymMatrix()

SymMatrix::~SymMatrix ( )
override

destructor

Definition at line 82 of file SymMatrix.cxx.

Member Function Documentation

◆ AddRows()

void SymMatrix::AddRows ( int  nrows = 1)

add empty rows

Definition at line 460 of file SymMatrix.cxx.

◆ AddToRow()

void o2::fwdalign::SymMatrix::AddToRow ( Int_t  r,
Double_t *  valc,
Int_t *  indc,
Int_t  n 
)
inlineoverridevirtual

Implements o2::fwdalign::MatrixSq.

Definition at line 273 of file SymMatrix.h.

◆ ClassDefOverride()

o2::fwdalign::SymMatrix::ClassDefOverride ( SymMatrix  ,
 
)
protected

◆ Clear()

void SymMatrix::Clear ( Option_t *  option = "")
overridevirtual

clear dynamic part

Implements o2::fwdalign::MatrixSq.

Definition at line 166 of file SymMatrix.cxx.

◆ DecomposeChol()

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.

◆ DiagElem() [1/2]

Double_t o2::fwdalign::SymMatrix::DiagElem ( Int_t  r) const
inlineoverridevirtual

Implements o2::fwdalign::MatrixSq.

Definition at line 77 of file SymMatrix.h.

◆ DiagElem() [2/2]

Double_t & o2::fwdalign::SymMatrix::DiagElem ( Int_t  r)
inlineoverridevirtual

Implements o2::fwdalign::MatrixSq.

Definition at line 78 of file SymMatrix.h.

◆ GetColIndexArray() [1/2]

const Int_t * o2::fwdalign::SymMatrix::GetColIndexArray ( ) const
inlineoverride

Definition at line 117 of file SymMatrix.h.

◆ GetColIndexArray() [2/2]

Int_t * o2::fwdalign::SymMatrix::GetColIndexArray ( )
inlineoverride

Definition at line 122 of file SymMatrix.h.

◆ GetDensity()

Float_t SymMatrix::GetDensity ( ) const
overridevirtual

get fraction of non-zero elements

Implements o2::fwdalign::MatrixSq.

Definition at line 184 of file SymMatrix.cxx.

◆ GetEl()

Double_t o2::fwdalign::SymMatrix::GetEl ( Int_t  row,
Int_t  col 
) const
inlineprotected

Definition at line 208 of file SymMatrix.h.

◆ GetIndex()

Int_t o2::fwdalign::SymMatrix::GetIndex ( Int_t  row,
Int_t  col 
) const
inlineprotectedvirtual

Definition at line 222 of file SymMatrix.h.

◆ GetMatrixArray() [1/2]

const Double_t * o2::fwdalign::SymMatrix::GetMatrixArray ( ) const
inlineoverride

Definition at line 105 of file SymMatrix.h.

◆ GetMatrixArray() [2/2]

Double_t * o2::fwdalign::SymMatrix::GetMatrixArray ( )
inlineoverride

Definition at line 106 of file SymMatrix.h.

◆ GetRow()

Double_t * SymMatrix::GetRow ( Int_t  r)

get pointer on the row

Definition at line 539 of file SymMatrix.cxx.

◆ GetRowIndexArray() [1/2]

const Int_t * o2::fwdalign::SymMatrix::GetRowIndexArray ( ) const
inlineoverride

Definition at line 107 of file SymMatrix.h.

◆ GetRowIndexArray() [2/2]

Int_t * o2::fwdalign::SymMatrix::GetRowIndexArray ( )
inlineoverride

Definition at line 112 of file SymMatrix.h.

◆ GetSize()

Int_t o2::fwdalign::SymMatrix::GetSize ( ) const
inlineoverridevirtual

Reimplemented from o2::fwdalign::MatrixSq.

Definition at line 57 of file SymMatrix.h.

◆ GetSizeAdded()

Int_t o2::fwdalign::SymMatrix::GetSizeAdded ( ) const
inline

Definition at line 60 of file SymMatrix.h.

◆ GetSizeBooked()

Int_t o2::fwdalign::SymMatrix::GetSizeBooked ( ) const
inline

Definition at line 59 of file SymMatrix.h.

◆ GetSizeUsed()

Int_t o2::fwdalign::SymMatrix::GetSizeUsed ( ) const
inline

Definition at line 58 of file SymMatrix.h.

◆ GetSub()

TMatrixDBase & o2::fwdalign::SymMatrix::GetSub ( Int_t  ,
Int_t  ,
Int_t  ,
Int_t  ,
TMatrixDBase ,
Option_t *   
) const
inlineoverride

Definition at line 137 of file SymMatrix.h.

◆ InvertChol() [1/2]

Bool_t SymMatrix::InvertChol ( )

Invert matrix using Choleski decomposition.

Definition at line 296 of file SymMatrix.cxx.

◆ InvertChol() [2/2]

void SymMatrix::InvertChol ( SymMatrix mchol)

Invert using provided Choleski decomposition, provided the Cholseki's L matrix.

Definition at line 309 of file SymMatrix.cxx.

◆ Multiply()

Bool_t SymMatrix::Multiply ( const SymMatrix right)

multiply from the right

Definition at line 230 of file SymMatrix.cxx.

◆ MultiplyByVec() [1/2]

void SymMatrix::MultiplyByVec ( const Double_t *  vecIn,
Double_t *  vecOut 
) const
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.

◆ MultiplyByVec() [2/2]

void o2::fwdalign::SymMatrix::MultiplyByVec ( const TVectorD &  vecIn,
TVectorD &  vecOut 
) const
inlineoverridevirtual

Reimplemented from o2::fwdalign::MatrixSq.

Definition at line 254 of file SymMatrix.h.

◆ operator()() [1/2]

Double_t o2::fwdalign::SymMatrix::operator() ( Int_t  rown,
Int_t  coln 
) const
inlineoverridevirtual

Implements o2::fwdalign::MatrixSq.

Definition at line 229 of file SymMatrix.h.

◆ operator()() [2/2]

Double_t & o2::fwdalign::SymMatrix::operator() ( Int_t  rown,
Int_t  coln 
)
inlineoverridevirtual

Implements o2::fwdalign::MatrixSq.

Definition at line 242 of file SymMatrix.h.

◆ operator+=()

SymMatrix & SymMatrix::operator+= ( const SymMatrix src)

add operator

Definition at line 136 of file SymMatrix.cxx.

◆ operator-=()

SymMatrix & SymMatrix::operator-= ( const SymMatrix src)

minus operator

Definition at line 151 of file SymMatrix.cxx.

◆ operator=()

SymMatrix & SymMatrix::operator= ( const SymMatrix src)

assignment operator

Definition at line 92 of file SymMatrix.cxx.

◆ Print()

void SymMatrix::Print ( const Option_t *  option = "") const
override

print itself

Definition at line 198 of file SymMatrix.cxx.

◆ Reset()

void SymMatrix::Reset ( )
overridevirtual

Implements o2::fwdalign::MatrixSq.

Definition at line 482 of file SymMatrix.cxx.

◆ ResizeTo() [1/2]

TMatrixDBase & o2::fwdalign::SymMatrix::ResizeTo ( Int_t  ,
Int_t  ,
Int_t   
)
inlineoverride

Definition at line 147 of file SymMatrix.h.

◆ ResizeTo() [2/2]

TMatrixDBase & o2::fwdalign::SymMatrix::ResizeTo ( Int_t  ,
Int_t  ,
Int_t  ,
Int_t  ,
Int_t   
)
inlineoverride

Definition at line 152 of file SymMatrix.h.

◆ Scale()

void o2::fwdalign::SymMatrix::Scale ( Double_t  coeff)
inline

Definition at line 260 of file SymMatrix.h.

◆ SetColIndexArray()

TMatrixDBase & o2::fwdalign::SymMatrix::SetColIndexArray ( Int_t *  )
inlineoverride

Definition at line 132 of file SymMatrix.h.

◆ SetEl()

void o2::fwdalign::SymMatrix::SetEl ( Int_t  row,
Int_t  col,
Double_t  val 
)
inlineprotected

Definition at line 209 of file SymMatrix.h.

◆ SetRowIndexArray()

TMatrixDBase & o2::fwdalign::SymMatrix::SetRowIndexArray ( Int_t *  )
inlineoverride

Definition at line 127 of file SymMatrix.h.

◆ SetSizeUsed()

void o2::fwdalign::SymMatrix::SetSizeUsed ( Int_t  sz)
inline

Definition at line 89 of file SymMatrix.h.

◆ SetSub()

TMatrixDBase & o2::fwdalign::SymMatrix::SetSub ( Int_t  ,
Int_t  ,
const TMatrixDBase  
)
inlineoverride

Definition at line 142 of file SymMatrix.h.

◆ SolveChol() [1/4]

Bool_t SymMatrix::SolveChol ( const TVectorD &  brhs,
TVectorD &  bsol,
Bool_t  invert = kFALSE 
)

Definition at line 453 of file SymMatrix.cxx.

◆ SolveChol() [2/4]

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.

◆ SolveChol() [3/4]

Bool_t SymMatrix::SolveChol ( Double_t *  brhs,
Double_t *  bsol,
Bool_t  invert = kFALSE 
)

Definition at line 446 of file SymMatrix.cxx.

◆ SolveChol() [4/4]

Bool_t SymMatrix::SolveChol ( TVectorD &  brhs,
Bool_t  invert = kFALSE 
)

Definition at line 440 of file SymMatrix.cxx.

◆ SolveCholN()

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.

◆ SolveSpmInv()

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.

Member Data Documentation

◆ fElems

Double_t* o2::fwdalign::SymMatrix::fElems
protected

Elements booked by constructor.

Definition at line 212 of file SymMatrix.h.

◆ fElemsAdd

Double_t** o2::fwdalign::SymMatrix::fElemsAdd
protected

Elements (rows) added dynamicaly.

Definition at line 213 of file SymMatrix.h.

◆ fgBuffer

SymMatrix * SymMatrix::fgBuffer = nullptr
staticprotected

buffer for fast solution

Definition at line 215 of file SymMatrix.h.

◆ fgCopyCnt

Int_t SymMatrix::fgCopyCnt = 0
staticprotected

matrix copy counter

Definition at line 216 of file SymMatrix.h.


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