Diana Software
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
QMatrixCArray Class Reference

An array of complex matrices that have been laid out in memory. More...

Public Member Functions

 QMatrixCArray ()
 Default ctor. More...
 
 QMatrixCArray (const QMatrixCArray &in)
 
virtual ~QMatrixCArray ()
 
virtual void Clear ()
 Clear the data in memory. More...
 
void Initialize (double Re, double Im=0)
 Initialize the values of the matrix. More...
 
void Initialize (const QComplex &Val)
 Initialize the values of the matrix. More...
 
void Invert ()
 Invert the matrices in place. More...
 
void CholeskyDecompose ()
 Cholesky decompose the matrices in place. More...
 
virtual void CholeskySolveX (const Diana::QVectorC &Y, Diana::QVectorC &X) const
 Solve the equation AX=Y for X. More...
 

Protected Member Functions

 QMatrixCArray (UInt_t nMatrix, UInt_t nRow, UInt_t nCol)
 
const QMatrixCArrayoperator= (const QMatrixCArray &in)
 
void Resize (UInt_t nMatrix, UInt_t nRow, UInt_t nCol)
 Resize, destroys all data in memory. More...
 
UInt_t GetSize () const
 Return the total number of doubles in memory. More...
 
UInt_t GetNMatrix () const
 Return the number of matrices stored. More...
 
UInt_t GetNRow () const
 Return the number of rows in each matrix. More...
 
UInt_t GetNCol () const
 Return the number of columns in each matrix. More...
 
QMatrixC GetMatrix (UInt_t idx)
 Return the vector of values in the (idx1,idx2) position. More...
 
const QMatrixC GetMatrix (UInt_t idx) const
 Return the vector of values in the (idx1,idx2) position. More...
 
Diana::QVectorC GetVector (UInt_t idx1, UInt_t idx2)
 Return the vector of values in the (idx1,idx2) position. More...
 
const Diana::QVectorC GetVector (UInt_t idx1, UInt_t idx2) const
 Return the vector of values in the (idx1,idx2) position. More...
 
 ClassDef (QMatrixCArray, 2)
 

Protected Attributes

Bool_t fDataOwner
 
UInt_t fSize
 Number of double values in fData. More...
 
UInt_t fNMatrix
 Number of identical matrices. More...
 
UInt_t fNRow
 Number of rows in each matrix. More...
 
UInt_t fNCol
 Number of columns in each matrix. More...
 
Double_t * fData
 Pointer to the head of the data. More...
 

Detailed Description

An array of complex matrices that have been laid out in memory.

Author
J. Ouellet

fData is an array of fNMatrix X fNRow X fNCol X 2 values. (The two comes from the fact that its complex).

The data are laid out as follows:

f1_00 f1_01 .. f1_0N f2_00 f2_01 .. f2_0N .... FM_01 .. FM_0N
f1_10 f1_11 .. f1_1N f2_10 f2_11 .. f2_1N .... FM_11 .. FM_1N
..
f1_N0 f1_N1 .. f1_NN f2_N0 f2_N1 .. f2_NN .... FM_N1 .. FM_NN

(In the complex case, each element represents two doubles).

In this way, the matrix rows are contiguous in memory, the matrix k begins at fData+k*NCol and has trailing dimension (tda) of NMatrix*NCol. The vector of (i,j)th elements from the NMatrix matrices is a vector beginning at fData+i*NCol*Matrix+j with stride NCol.

Definition at line 35 of file QMatrixCArray.hh.

Constructor & Destructor Documentation

◆ QMatrixCArray() [1/3]

QMatrixCArray::QMatrixCArray ( )

Default ctor.

◆ QMatrixCArray() [2/3]

QMatrixCArray::QMatrixCArray ( const QMatrixCArray in)

Definition at line 16 of file QMatrixCArray.cc.

References fData, fNCol, fNMatrix, fNRow, fSize, and Resize().

◆ ~QMatrixCArray()

QMatrixCArray::~QMatrixCArray ( )
virtual

Definition at line 38 of file QMatrixCArray.cc.

References Clear().

◆ QMatrixCArray() [3/3]

QMatrixCArray::QMatrixCArray ( UInt_t  nMatrix,
UInt_t  nRow,
UInt_t  nCol 
)
protected

Definition at line 27 of file QMatrixCArray.cc.

References Resize().

Member Function Documentation

◆ CholeskyDecompose()

void QMatrixCArray::CholeskyDecompose ( )

Cholesky decompose the matrices in place.

Computationally this amounts to NMatrix * (NRow X NCol) Cholesky decompositions.

The decomposition is done in place and requires no extra memory.

Definition at line 117 of file QMatrixCArray.cc.

References QMatrixC::CholeskyDecompose(), GetMatrix(), and GetNMatrix().

◆ CholeskySolveX()

void QMatrixCArray::CholeskySolveX ( const Diana::QVectorC &  Y,
Diana::QVectorC &  X 
) const
virtual

Solve the equation AX=Y for X.

Uses a Cholesky decomposition of a matrix to solve the equation

AX = (LL^T)X=Y.

Computationally this splits the problem up into NMatrix Cholesky solutions and tacks them together.

NOTE: This assumes that the matrices have been Cholesky decomposed already.

Definition at line 124 of file QMatrixCArray.cc.

References DianaThrow, and QERR_SIZE_NOT_MATCH.

◆ ClassDef()

QMatrixCArray::ClassDef ( QMatrixCArray  ,
 
)
protected

◆ Clear()

void QMatrixCArray::Clear ( )
virtual

Clear the data in memory.

Definition at line 42 of file QMatrixCArray.cc.

References QVector::ArrayFree(), fData, fDataOwner, fNCol, fNMatrix, fNRow, and fSize.

Referenced by operator=(), and ~QMatrixCArray().

◆ GetMatrix() [1/2]

QMatrixC QMatrixCArray::GetMatrix ( UInt_t  idx)
protected

Return the vector of values in the (idx1,idx2) position.

Returns the matrix in position idx of all the matrices. The returned QMatrixC is not the owner of the memory and operates on the data in the location where it is stored in fData.

Definition at line 79 of file QMatrixCArray.cc.

References DianaThrow, fData, fNCol, fNMatrix, fNRow, and QERR_SIZE_NOT_MATCH.

Referenced by CholeskyDecompose(), and Invert().

◆ GetMatrix() [2/2]

const QMatrixC QMatrixCArray::GetMatrix ( UInt_t  idx) const
protected

Return the vector of values in the (idx1,idx2) position.

Returns the matrix in position idx of all the matrices. The returned QMatrixC is not the owner of the memory and operates on the data in the location where it is stored in fData.

This is the constant version, and the resulting QMatrixC is const.

Definition at line 87 of file QMatrixCArray.cc.

References DianaThrow, fData, fNCol, fNMatrix, fNRow, and QERR_SIZE_NOT_MATCH.

◆ GetNCol()

UInt_t QMatrixCArray::GetNCol ( ) const
inlineprotected

Return the number of columns in each matrix.

Definition at line 110 of file QMatrixCArray.hh.

References fNCol.

Referenced by Resize().

◆ GetNMatrix()

UInt_t QMatrixCArray::GetNMatrix ( ) const
inlineprotected

Return the number of matrices stored.

Definition at line 104 of file QMatrixCArray.hh.

References fNMatrix.

Referenced by CholeskyDecompose(), Invert(), and Resize().

◆ GetNRow()

UInt_t QMatrixCArray::GetNRow ( ) const
inlineprotected

Return the number of rows in each matrix.

Definition at line 107 of file QMatrixCArray.hh.

References fNRow.

Referenced by Resize().

◆ GetSize()

UInt_t QMatrixCArray::GetSize ( ) const
inlineprotected

Return the total number of doubles in memory.

Definition at line 102 of file QMatrixCArray.hh.

References fSize.

◆ GetVector() [1/2]

Diana::QVectorC QMatrixCArray::GetVector ( UInt_t  idx1,
UInt_t  idx2 
)
protected

Return the vector of values in the (idx1,idx2) position.

Returns the vector of values in the (idx1,idx2) position of all the matrices. The returned QVectorC is not the owner of the memory and operates on the data in the location where it is stored in fData.

Definition at line 95 of file QMatrixCArray.cc.

References DianaThrow, fData, fNCol, fNMatrix, fNRow, and QERR_SIZE_NOT_MATCH.

◆ GetVector() [2/2]

const Diana::QVectorC QMatrixCArray::GetVector ( UInt_t  idx1,
UInt_t  idx2 
) const
protected

Return the vector of values in the (idx1,idx2) position.

Returns the vector of values in the (idx1,idx2) position of all the matrices. The returned QVectorC is not the owner of the memory and operates on the data in the location where it is stored in fData.

This is the constant version, and the resulting QVectorC is const.

Definition at line 103 of file QMatrixCArray.cc.

References DianaThrow, fData, fNCol, fNMatrix, fNRow, and QERR_SIZE_NOT_MATCH.

◆ Initialize() [1/2]

void QMatrixCArray::Initialize ( const QComplex Val)

Initialize the values of the matrix.

Definition at line 76 of file QMatrixCArray.cc.

References QComplex::Im(), Initialize(), and QComplex::Re().

◆ Initialize() [2/2]

void QMatrixCArray::Initialize ( double  Re,
double  Im = 0 
)

Initialize the values of the matrix.

Definition at line 71 of file QMatrixCArray.cc.

References fData, fSize, Im(), and Re().

Referenced by Initialize().

◆ Invert()

void QMatrixCArray::Invert ( )

Invert the matrices in place.

Computationally this amounts to NMatrix * (NRow X NCol) matrix inversions.

The inversions proceed through an LU decomposition. And require copying the matrix to another memory location.

Definition at line 111 of file QMatrixCArray.cc.

References GetMatrix(), GetNMatrix(), and QMatrixC::Invert().

◆ operator=()

const QMatrixCArray & QMatrixCArray::operator= ( const QMatrixCArray in)
protected

Definition at line 51 of file QMatrixCArray.cc.

References Clear(), fData, fNCol, fNMatrix, fNRow, fSize, and Resize().

◆ Resize()

void QMatrixCArray::Resize ( UInt_t  nMatrix,
UInt_t  nRow,
UInt_t  nCol 
)
protected

Resize, destroys all data in memory.

Definition at line 57 of file QMatrixCArray.cc.

References QVector::ArrayAlloc(), QVector::ArrayFree(), DianaThrow, fData, fDataOwner, fNCol, fNMatrix, fNRow, fSize, GetNCol(), GetNMatrix(), GetNRow(), and QERR_SIZE_NOT_MATCH.

Referenced by operator=(), and QMatrixCArray().

Member Data Documentation

◆ fData

Double_t* QMatrixCArray::fData
protected

Pointer to the head of the data.

Definition at line 170 of file QMatrixCArray.hh.

Referenced by Clear(), GetMatrix(), GetVector(), Initialize(), operator=(), QMatrixCArray(), and Resize().

◆ fDataOwner

Bool_t QMatrixCArray::fDataOwner
protected

Definition at line 155 of file QMatrixCArray.hh.

Referenced by Clear(), and Resize().

◆ fNCol

UInt_t QMatrixCArray::fNCol
protected

Number of columns in each matrix.

Definition at line 167 of file QMatrixCArray.hh.

Referenced by Clear(), GetMatrix(), GetNCol(), GetVector(), operator=(), QMatrixCArray(), and Resize().

◆ fNMatrix

UInt_t QMatrixCArray::fNMatrix
protected

Number of identical matrices.

Definition at line 161 of file QMatrixCArray.hh.

Referenced by Clear(), GetMatrix(), GetNMatrix(), GetVector(), operator=(), QMatrixCArray(), and Resize().

◆ fNRow

UInt_t QMatrixCArray::fNRow
protected

Number of rows in each matrix.

Definition at line 164 of file QMatrixCArray.hh.

Referenced by Clear(), GetMatrix(), GetNRow(), GetVector(), operator=(), QMatrixCArray(), and Resize().

◆ fSize

UInt_t QMatrixCArray::fSize
protected

Number of double values in fData.

Definition at line 158 of file QMatrixCArray.hh.

Referenced by Clear(), GetSize(), Initialize(), operator=(), QMatrixCArray(), and Resize().


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