![]() |
Diana Software
|
Interface for matrices in Diana analysis. More...
Public Member Functions | |
| QMatrix () | |
| default constructor More... | |
| QMatrix (UInt_t nrow, UInt_t ncol) | |
| constructor nrow x ncol More... | |
| QMatrix (const QVector &vec) | |
| constructor from QVector More... | |
| QMatrix (const QMatrix &orig) | |
| copy constructor More... | |
| virtual | ~QMatrix () |
| destructor More... | |
| void | Resize (UInt_t nrow, UInt_t ncol) |
| resize a QMatrix More... | |
| void | Clear () |
| reset members to default values More... | |
| UInt_t | GetNRow () const |
| get number rows More... | |
| UInt_t | GetNCol () const |
| get number of columns More... | |
| void | Initialize (double val=0) |
| initialize all elements (default to 0) More... | |
| void | SetToIdentity () |
| initialize to identity More... | |
| void | SetCol (UInt_t ncol, const QVector &vec) |
| set column to specific vector More... | |
| void | SetRow (UInt_t nrow, const QVector &vec) |
| set row to specific vectors More... | |
| void | Set (const std::map< int, int > &p) |
| get a QMatrix from a map More... | |
| QVector | GetCol (UInt_t ncol) |
| get column More... | |
| QVector | GetCol (UInt_t ncol) const |
| get column More... | |
| QVector | GetRow (UInt_t nrow) |
| get row More... | |
| QVector | GetRow (UInt_t nrow) const |
| get row More... | |
| QVector | GetDiaganol () |
| Get the diaganol. More... | |
| QVector | GetDiaganol () const |
| Get the diaganol. More... | |
| QVector | GetRowByColumnIntValue (UInt_t col, int val) const |
| get row matching the integer value val in column col if more than one value is found in column the first matching row is returned More... | |
| double & | operator() (UInt_t i, UInt_t j) |
| retrieve an element More... | |
| const double & | operator() (UInt_t i, UInt_t j) const |
| retrieve an element More... | |
| const QMatrix & | operator= (const QMatrix &orig) |
| copy the content of another matrix More... | |
| QMatrix | operator- () |
| revert sign to all components More... | |
| const QMatrix & | operator*= (double t) |
| multiplication by scalar More... | |
| const QMatrix & | operator*= (const QMatrix &other) |
| multiplication by another QMatrix More... | |
| const QMatrix & | operator/= (double t) |
| division by scalar More... | |
| const QMatrix & | operator+= (const QMatrix &mat) |
| add a QMatrix More... | |
| const QMatrix & | operator-= (const QMatrix &mat) |
| subtract a QMatrix More... | |
| const QMatrix & | Mult (const QMatrix &mat) |
| Multiply element by element. More... | |
| const QMatrix & | Div (const QMatrix &mat) |
| Divide element by element. More... | |
| QMatrix | operator* (const QMatrix &mat) const |
| Matrix product. More... | |
| QMatrix | operator* (double t) const |
| Multiplication by scalar. More... | |
| QMatrix | operator/ (double t) const |
| Division by scalar. More... | |
| QMatrix | operator+ (const QMatrix &mat) const |
| sum matrix More... | |
| QMatrix | operator- (const QMatrix &mat) const |
| subtract matrix More... | |
| QVector | operator* (const QVector &vec) const |
| matrix-vector product More... | |
| QMatrix | T () const |
| transpose returns a different matrix transposed wrt the original More... | |
| const QMatrix & | Transpose () |
| transpose More... | |
| QMatrix | Inv () const |
| inverse returns a different matrix inverted wrt the original More... | |
| const QMatrix & | Invert () |
| inverse inverts the matrix itself More... | |
| double | Det () const |
| Determinant. More... | |
| QMatrix | GetCholeskyDecomposition () const |
| Cholesky Decomposition. More... | |
| const QMatrix & | CholeskyDecompose () |
| Cholesky Decomposition. More... | |
| void | CholeskySolveX (const QVector &Y, QVector &X) const |
| Solve for X using Cholesky decomposition. More... | |
| QMatrix | GetSubMatrix (UInt_t nI, UInt_t nJ, UInt_t startI=0, UInt_t startJ=0) |
| Get a sub matrix of the matrix. More... | |
| const QMatrix | GetSubMatrix (UInt_t nI, UInt_t nJ, UInt_t startI=0, UInt_t startJ=0) const |
| Get a sub matrix of the matrix. More... | |
| QMatrix | GetSummedAreaMatrix () const |
| Create a summed area matrix. More... | |
| void | SetElement (UInt_t i, UInt_t j, Double_t val) |
Public Member Functions inherited from QObject | |
| QObject () | |
| default constructor More... | |
| virtual | ~QObject () |
| destructor More... | |
| QObject & | operator= (const QObject &rhs) |
| operator= More... | |
| void | Validate () |
| make object valid More... | |
| void | InValidate () |
| make object non valid More... | |
| bool | IsValid () const |
| check wheter object is valid More... | |
| void | SetWrite (bool write=true) |
| write or not this object More... | |
| bool | GetWrite () const |
| check wheter write or not this object More... | |
| bool | IsRequired () const |
| check wheter this object is required by some module More... | |
| void | SetIsRequired (bool required=true) |
| set that this object is required More... | |
| bool | IsJustAdded () const |
| check wheter this object has been just added by some module More... | |
| void | SetIsJustAdded (bool added=true) |
| set that this object has been just added More... | |
| void | Reset () |
| set object to non valid and calls Clear() More... | |
| virtual bool | Fill (QObject *evData) const =0 |
| calls operator= of inheriting classes. Validity flag and bits are not copied. This function is automatically declared/implemented in derived classes by QObjectDef/QObjectImp. If evData type mismatches returns false, true otherwise. More... | |
| void | FullyFill (QObject *evData) const |
| calls Fill(QObject*) if this QObject IsValid(). Copies Validity flag and bits More... | |
| virtual QObject * | Duplicate () const =0 |
| create object of same type, this function is automatically declared/implemented in derived classes by QObjectDef/QObjectImp More... | |
| virtual void | Dump (std::ostream &o) const |
| print content to stream (intended for screen print or log files) More... | |
| virtual void | Print () const |
| print content on screen More... | |
| virtual QError | WriteOnStream (std::ostream &o) const |
| print content to stream (intended for storage in text files) More... | |
| virtual QError | ReadFromStream (std::istream &o) |
| fill content from stream (intended for storage in text files) More... | |
| void | CopyBits (QObject *obj) const |
| copy validity and temporary bits to another QObject More... | |
| virtual void | Draw (Option_t *option="") |
Protected Member Functions | |
| QMatrix (const gsl_matrix *mat) | |
| constructor from gsl_matrix More... | |
| QMatrix (const double *orig) | |
| QMatrix (double *data, const UInt_t nrow, const UInt_t ncol, const UInt_t tda=0) | |
| void | SetMat () const |
| double & | GetElement (UInt_t i, UInt_t j) |
| const double & | GetElement (UInt_t i, UInt_t j) const |
| UInt_t | MemRowElements () const |
Static Protected Member Functions | |
| static void | MatrixCopy (const double *orig, const UInt_t Nrow, const UInt_t Ncol, double *dest, UInt_t origTda=0, UInt_t destTda=0) |
| Static method to copy a matrix from one data location to another. More... | |
Private Member Functions | |
| QObjectDef (QMatrix, 3) | |
Private Attributes | |
| Bool_t | fDataOwner |
| This owns the memory. More... | |
| UInt_t | fSize |
| UInt_t | fNCol |
| UInt_t | fTda |
| UInt_t | fAllocSize |
| Double_t * | fData |
| gsl_matrix * | fMat |
Friends | |
| class | QVector |
| class | QMatrixC |
Additional Inherited Members | |
Public Types inherited from QObject | |
| enum | { kIsValid = BIT(15) , kWrite = BIT(0) , kIsRequired = BIT(1) , kIsJustAdded = BIT(2) } |
| TObject bits. More... | |
Static Public Member Functions inherited from QObject | |
| static QObject * | New (const char *object) |
Interface for matrices in Diana analysis.
Every class written within the DIANA framework should use this class for matrix handling
Definition at line 24 of file QMatrix.hh.
| QMatrix::QMatrix | ( | ) |
default constructor
Definition at line 51 of file QMatrix.cc.
| QMatrix::QMatrix | ( | UInt_t | nrow, |
| UInt_t | ncol | ||
| ) |
constructor nrow x ncol
| nrow | number of rows |
| ncol | number of columns |
Definition at line 62 of file QMatrix.cc.
References Resize().
| QMatrix::QMatrix | ( | const QVector & | vec | ) |
constructor from QVector
| vec | QVector of origin |
Definition at line 74 of file QMatrix.cc.
References QVector::ArrayCopy(), fData, QVector::fData, fSize, QVector::fStride, Resize(), QVector::Size(), and vec.
| QMatrix::QMatrix | ( | const QMatrix & | orig | ) |
copy constructor
| orig | QMatrix of origin |
Definition at line 87 of file QMatrix.cc.
References fData, GetNCol(), GetNRow(), MatrixCopy(), MemRowElements(), and Resize().
|
virtual |
destructor
Definition at line 129 of file QMatrix.cc.
References QVector::ArrayFree(), fAllocSize, fData, fDataOwner, fMat, fNCol, fSize, and fTda.
|
protected |
constructor from gsl_matrix
| mat | gsl_matrix of origin |
Definition at line 101 of file QMatrix.cc.
References fData, GetNCol(), GetNRow(), MatrixCopy(), MemRowElements(), and Resize().
|
protected |
|
protected |
Definition at line 113 of file QMatrix.cc.
| const QMatrix & QMatrix::CholeskyDecompose | ( | ) |
Cholesky Decomposition.
Perform a Cholesky decomposition of a matrix, A, IN PLACE.
A=LL^T
Where L is a lower triangular, with positive real values along the diagonal.
The input matrix must be positive definite, otherwise the function will return an error.
The output matrix has the components of the matrix L in the lower triangle and the components of L^T in the upper triangle. The elements in the diagonal (the overlap) are the same for both L and L^T.
The entire algorithm can be done in place. Resulting matrix resides in the same memory location as it did before.
Definition at line 470 of file QMatrix.cc.
References err, fMat, and SetMat().
Referenced by GetCholeskyDecomposition().
Solve for X using Cholesky decomposition.
Solves the equation A*X=Y for X, using a Cholesky decomposition.
IMPORTANT: This ASSUMES that the matrix has already been cholesky decomposed. This is done to save memory, since Cholesky can be done in place.
Definition at line 482 of file QMatrix.cc.
References err, fMat, QVector::fMathVec, GetNRow(), QERR_SIZE_NOT_MATCH, QVector::Resize(), SetMat(), QVector::SetMathVector(), and QVector::Size().
|
virtual |
reset members to default values
Implements QObject.
Definition at line 139 of file QMatrix.cc.
References Resize().
| double QMatrix::Det | ( | ) | const |
Divide element by element.
divide element by element (a'_ij=a_ij/b_ij) --> NOT division between matrices
Keeps memory the same.
| mat |
Definition at line 359 of file QMatrix.cc.
| QMatrix QMatrix::GetCholeskyDecomposition | ( | ) | const |
Cholesky Decomposition.
Out of place version of CholeskyDecompose().
Definition at line 477 of file QMatrix.cc.
References CholeskyDecompose().
| QVector QMatrix::GetCol | ( | UInt_t | ncol | ) |
get column
| ncol | col index |
Returns a new vector with its own memory
Definition at line 221 of file QMatrix.cc.
References fData, GetNRow(), MemRowElements(), and QVector.
Referenced by MRawDataFilter::GetCuts(), operator*(), and LASCIIGlobalWriter::SetQMatrix().
| QVector QMatrix::GetCol | ( | UInt_t | ncol | ) | const |
get column
| ncol | col index |
Returns a new vector with its own memory
Definition at line 225 of file QMatrix.cc.
References fMat, QVector::fMathVec, GetNRow(), SetMat(), and QVector::SetMathVector().
| QVector QMatrix::GetDiaganol | ( | ) |
Get the diaganol.
Returned a new vector with its own memory
Definition at line 246 of file QMatrix.cc.
References fData, GetNRow(), MemRowElements(), and QVector.
| QVector QMatrix::GetDiaganol | ( | ) | const |
Get the diaganol.
Returned a new vector with its own memory
Definition at line 250 of file QMatrix.cc.
References GetNCol().
|
protected |
Definition at line 268 of file QMatrix.cc.
References DianaThrow, fData, GetNCol(), GetNRow(), MemRowElements(), QERR_OUT_OF_RANGE, and SetMat().
Referenced by operator()(), and SetElement().
|
protected |
Definition at line 280 of file QMatrix.cc.
References DianaThrow, fData, GetNCol(), GetNRow(), MemRowElements(), QERR_OUT_OF_RANGE, and SetMat().
|
inline |
get number of columns
Definition at line 68 of file QMatrix.hh.
References fNCol.
Referenced by MTestModule::Do(), MTestModule::Done(), GetDiaganol(), GetElement(), GetRow(), GetSubMatrix(), GetSummedAreaMatrix(), Initialize(), operator*=(), operator=(), QMatrix(), QMatrixC::QMatrixC(), Resize(), LASCIIGlobalWriter::SetQMatrix(), SetRow(), and Transpose().
|
inline |
get number rows
Definition at line 63 of file QMatrix.hh.
Referenced by CholeskySolveX(), Det(), MTestModule::Do(), MTestModule::Done(), GetCol(), GetDiaganol(), GetElement(), GetRowByColumnIntValue(), GetSubMatrix(), GetSummedAreaMatrix(), Initialize(), Invert(), operator*=(), operator=(), QMatrix(), QMatrixC::QMatrixC(), Resize(), SetCol(), SetMat(), LASCIIGlobalWriter::SetQMatrix(), and Transpose().
| QVector QMatrix::GetRow | ( | UInt_t | nrow | ) |
get row
| nrow | row index |
Returns a new vector with its own memory
Definition at line 234 of file QMatrix.cc.
References fData, fNCol, MemRowElements(), and QVector.
Referenced by MTestModule::Done(), and GetRowByColumnIntValue().
| QVector QMatrix::GetRow | ( | UInt_t | nrow | ) | const |
get row
| nrow | row index |
Returns a new vector with its own memory
Definition at line 238 of file QMatrix.cc.
References fMat, QVector::fMathVec, GetNCol(), SetMat(), and QVector::SetMathVector().
| QVector QMatrix::GetRowByColumnIntValue | ( | UInt_t | col, |
| int | val | ||
| ) | const |
get row matching the integer value val in column col if more than one value is found in column the first matching row is returned
| col | column index |
| val | value to be matched |
Definition at line 258 of file QMatrix.cc.
| QMatrix QMatrix::GetSubMatrix | ( | UInt_t | nI, |
| UInt_t | nJ, | ||
| UInt_t | startI = 0, |
||
| UInt_t | startJ = 0 |
||
| ) |
Get a sub matrix of the matrix.
Return an nI x nJ matrix starting at (startI,startJ). (Note that I corresponds to row, and J to column).
Definition at line 495 of file QMatrix.cc.
References fData, fTda, GetNCol(), GetNRow(), MemRowElements(), and QERR_SIZE_NOT_MATCH.
| const QMatrix QMatrix::GetSubMatrix | ( | UInt_t | nI, |
| UInt_t | nJ, | ||
| UInt_t | startI = 0, |
||
| UInt_t | startJ = 0 |
||
| ) | const |
Get a sub matrix of the matrix.
Return an nI x nJ matrix starting at (startI,startJ). (Note that I corresponds to row, and J to column).
Definition at line 506 of file QMatrix.cc.
References fData, fTda, GetNCol(), GetNRow(), MemRowElements(), and QERR_SIZE_NOT_MATCH.
| QMatrix QMatrix::GetSummedAreaMatrix | ( | ) | const |
| void QMatrix::Initialize | ( | double | val = 0 | ) |
initialize all elements (default to 0)
| val | initialization value |
Definition at line 163 of file QMatrix.cc.
References fData, GetNCol(), GetNRow(), and MemRowElements().
| QMatrix QMatrix::Inv | ( | ) | const |
inverse returns a different matrix inverted wrt the original
Definition at line 429 of file QMatrix.cc.
References Invert().
| const QMatrix & QMatrix::Invert | ( | ) |
inverse inverts the matrix itself
Uses an LU decomposition. And requires enough memory for the LU decomposition matrix.
Inverted matrix is stored in same memory location.
Definition at line 436 of file QMatrix.cc.
References err, fMat, fNCol, GetNRow(), and SetMat().
Referenced by Inv().
|
staticprotected |
Static method to copy a matrix from one data location to another.
| orig | The location in memory of the original data |
| Nrow,Ncol | The size of the original matrix |
| dest | The memory location of the destination (must be already allocated). |
| origTda,destTda | The trailing dimension of the origin/destination matrix. This is the number of memory locations following the last element of each row before the start of the next row. If destTda<Ncol, it defaults to origTda. If origTda<Ncol, it defaults to origNcol. |
Definition at line 28 of file QMatrix.cc.
References DianaThrow, and QERR_SIZE_NOT_MATCH.
Referenced by operator=(), and QMatrix().
|
inlineprotected |
Definition at line 451 of file QMatrix.hh.
Referenced by GetCol(), GetDiaganol(), GetElement(), GetRow(), GetSubMatrix(), Initialize(), operator=(), and QMatrix().
Multiply element by element.
multiply element by element (a'_ij=a_ij*b_ij) --> NOT product between matrices
Keeps memory the same
| mat |
Definition at line 351 of file QMatrix.cc.
|
inline |
retrieve an element
| i | ith row |
| j | jth col |
Definition at line 162 of file QMatrix.hh.
References GetElement().
|
inline |
retrieve an element
version for objects that cannot modify the QMatrix
| i | ith row |
| j | jth col |
Definition at line 171 of file QMatrix.hh.
References GetElement().
Matrix product.
| mat | right element |
Definition at line 367 of file QMatrix.cc.
matrix-vector product
| vec | right element |
Definition at line 402 of file QMatrix.cc.
| QMatrix QMatrix::operator* | ( | double | t | ) | const |
Multiplication by scalar.
| t | scalar |
Definition at line 374 of file QMatrix.cc.
multiplication by another QMatrix
A*=B; replaces A with a matrix with the appropriate dimensions of A*B (matrix product)
Reallocates memory if resizing occurs.
| other |
Definition at line 316 of file QMatrix.cc.
References fMat, GetNCol(), GetNRow(), Resize(), and SetMat().
| const QMatrix & QMatrix::operator*= | ( | double | t | ) |
multiplication by scalar
Keeps memory the same
| t | scaler multiplier |
Definition at line 309 of file QMatrix.cc.
References fMat, and SetMat().
Referenced by operator-(), and operator/=().
add a QMatrix
Keeps memory the same
| mat |
Definition at line 335 of file QMatrix.cc.
| QMatrix QMatrix::operator- | ( | ) |
subtract matrix
| mat | right element |
Definition at line 395 of file QMatrix.cc.
subtract a QMatrix
Keeps memory the same.
| mat |
Definition at line 343 of file QMatrix.cc.
| QMatrix QMatrix::operator/ | ( | double | t | ) | const |
Division by scalar.
| t | scalar |
Definition at line 381 of file QMatrix.cc.
| const QMatrix & QMatrix::operator/= | ( | double | t | ) |
division by scalar
Keeps memory the same.
| t |
Definition at line 330 of file QMatrix.cc.
References operator*=().
copy the content of another matrix
Allocates new memory if needed.
| orig | QMatrix of origin |
Definition at line 293 of file QMatrix.cc.
References fData, fMat, fSize, GetNCol(), GetNRow(), MatrixCopy(), MemRowElements(), and Resize().
|
private |
| void QMatrix::Resize | ( | UInt_t | nrow, |
| UInt_t | ncol | ||
| ) |
resize a QMatrix
| nrow | new number of rows |
| ncol | new number of cols |
Definition at line 143 of file QMatrix.cc.
References QVector::ArrayAlloc(), QVector::ArrayFree(), DianaThrow, fAllocSize, fData, fDataOwner, fMat, fNCol, fSize, fTda, GetNCol(), GetNRow(), and QERR_SIZE_NOT_MATCH.
Referenced by Clear(), operator*=(), operator=(), QMatrix(), and Set().
| void QMatrix::Set | ( | const std::map< int, int > & | p | ) |
| void QMatrix::SetCol | ( | UInt_t | ncol, |
| const QVector & | vec | ||
| ) |
set column to specific vector
| ncol | column index |
| vec | initialization vector |
Definition at line 179 of file QMatrix.cc.
References DianaThrow, fMat, QVector::fMathVec, GetNRow(), QERR_SIZE_NOT_MATCH, SetMat(), QVector::SetMathVector(), QVector::Size(), and vec.
Referenced by LASCIIGlobalReader::GetQObject().
|
inline |
Definition at line 408 of file QMatrix.hh.
References GetElement().
|
protected |
Definition at line 531 of file QMatrix.cc.
References fData, fMat, fNCol, fTda, and GetNRow().
Referenced by CholeskyDecompose(), CholeskySolveX(), Det(), Div(), GetCol(), GetElement(), GetRow(), Invert(), Mult(), operator*=(), operator+=(), operator-=(), Set(), SetCol(), SetRow(), SetToIdentity(), and Transpose().
| void QMatrix::SetRow | ( | UInt_t | nrow, |
| const QVector & | vec | ||
| ) |
set row to specific vectors
| nrow | row index |
| vec | initialization vector |
Definition at line 192 of file QMatrix.cc.
References DianaThrow, fMat, QVector::fMathVec, GetNCol(), QERR_SIZE_NOT_MATCH, SetMat(), QVector::SetMathVector(), QVector::Size(), and vec.
Referenced by QVector::T().
| void QMatrix::SetToIdentity | ( | ) |
| QMatrix QMatrix::T | ( | ) | const |
transpose returns a different matrix transposed wrt the original
Definition at line 410 of file QMatrix.cc.
References Transpose().
| const QMatrix & QMatrix::Transpose | ( | ) |
transpose
transposes the matrix itself
If the matrix is the data owner, it will update fNCol and fTda. If the matrix is NOT the data owner, the matrix MUST be square, otherwise it will throw an error.
Definition at line 417 of file QMatrix.cc.
References DianaThrow, fDataOwner, fMat, fNCol, fTda, GetNCol(), GetNRow(), QERR_SIZE_NOT_MATCH, and SetMat().
Referenced by T().
|
friend |
Definition at line 467 of file QMatrix.hh.
|
friend |
Definition at line 466 of file QMatrix.hh.
Referenced by GetCol(), GetDiaganol(), and GetRow().
|
private |
Definition at line 462 of file QMatrix.hh.
Referenced by Resize(), and ~QMatrix().
|
private |
Definition at line 463 of file QMatrix.hh.
Referenced by GetCol(), GetDiaganol(), GetElement(), GetRow(), GetSubMatrix(), Initialize(), operator=(), QMatrix(), Resize(), SetMat(), and ~QMatrix().
|
private |
This owns the memory.
Definition at line 456 of file QMatrix.hh.
Referenced by Resize(), Transpose(), and ~QMatrix().
|
mutableprivate |
Definition at line 464 of file QMatrix.hh.
Referenced by CholeskyDecompose(), CholeskySolveX(), Det(), Div(), GetCol(), GetRow(), Invert(), Mult(), operator*=(), operator+=(), operator-=(), operator=(), QMatrix(), Resize(), Set(), SetCol(), SetMat(), SetRow(), SetToIdentity(), Transpose(), and ~QMatrix().
|
private |
Definition at line 459 of file QMatrix.hh.
Referenced by Det(), GetNCol(), GetNRow(), GetRow(), Invert(), MemRowElements(), QMatrix(), Resize(), SetMat(), Transpose(), and ~QMatrix().
|
private |
Definition at line 458 of file QMatrix.hh.
Referenced by GetNRow(), operator=(), QMatrix(), Resize(), and ~QMatrix().
|
private |
Definition at line 460 of file QMatrix.hh.
Referenced by GetSubMatrix(), MemRowElements(), QMatrix(), Resize(), SetMat(), Transpose(), and ~QMatrix().