gstlearn  1.0.0
CCC
MatrixSquareSymmetric Class Reference

#include <MatrixSquareSymmetric.hpp>

Inheritance diagram for MatrixSquareSymmetric:
AMatrixSquare AMatrix AStringable ICloneable

Public Member Functions

 MatrixSquareSymmetric (int nrow=0)
 
 MatrixSquareSymmetric (const MatrixSquareSymmetric &m)
 
 MatrixSquareSymmetric (const AMatrix &m)
 
MatrixSquareSymmetricoperator= (const MatrixSquareSymmetric &r)
 
virtual ~MatrixSquareSymmetric ()
 
virtual String toString (const AStringFormat *strfmt=nullptr) const override
 ICloneable interface. More...
 
bool mustBeSymmetric () const final
 
virtual bool mustBeDiagonal () const override
 
virtual bool mustBeDiagCst () const override
 
bool isSymmetric (bool printWhyNot=false) const final
 TODO : isPositiveDefinite. More...
 
void initMatTri (int nsize, double *tab)
 
void normSingleMatrix (const AMatrix &x)
 
void normTSingleMatrix (const AMatrix &x)
 
MatrixSquareSymmetricreduce (const VectorInt &validRows) const
 
- Public Member Functions inherited from AMatrixSquare
virtual ~AMatrixSquare ()
 
int getNSize () const
 
void normMatrix (const AMatrixSquare &x, const AMatrix &y)
 
void normTMatrix (const AMatrixSquare &x, const AMatrix &y)
 
double trace () const
 
void innerMatrix (const AMatrixSquare &x, const AMatrix &r1, const AMatrix &r2)
 
void prodDiagByVector (const VectorDouble &diag)
 
void divideDiagByVector (const VectorDouble &diag)
 
virtual double determinant (void) const
 
- Public Member Functions inherited from AMatrix
virtual ~AMatrix ()
 
void init (int nrows, int ncols)
 
void reset (int nrows, int ncols, double value=0.)
 
void resetFromArray (int nrows, int ncols, const double *tab, bool byCol=true)
 
void resetFromVD (int nrows, int ncols, const VectorDouble &tab, bool byCol=true)
 
void resetFromVVD (const VectorVectorDouble &tab, bool byCol=true)
 
virtual void setColumn (int icol, const VectorDouble &tab)
 
virtual void setRow (int irow, const VectorDouble &tab)
 
virtual void setDiagonal (const VectorDouble &tab)
 
virtual void setDiagonal (double value=1.)
 
virtual bool isSparse () const
 
virtual bool isSquare (bool printWhyNot=false) const
 
virtual bool isValid (int irow, int icol, bool printWhyNot=false) const
 
virtual bool isIdentity (bool printWhyNot=false) const
 
virtual bool isDiagonal (bool printWhyNot=false) const
 
virtual bool isDiagCst (bool printWhyNot=false) const
 
virtual void transposeInPlace ()
 
virtual AMatrixtranspose () const
 
virtual void addScalar (double v)
 
virtual void addScalarDiag (double v)
 
virtual void prodScalar (double v)
 
virtual double getValue (int irow, int icol) const
 
virtual double & getValueRef (int irow, int icol)
 
virtual void setValue (int irow, int icol, double value)
 
virtual void setValuesByArrays (const VectorInt &irows, const VectorInt &icols, const VectorDouble &values)
 
virtual void addMatrix (const AMatrix &y)
 
virtual void prodMatrix (const AMatrix &x, const AMatrix &y)
 
virtual void linearCombination (double cx, double cy, const AMatrix &y)
 
bool isSame (const AMatrix &m, double eps=EPSILON10)
 
bool isSameSize (const AMatrix &m) const
 
bool isEmpty () const
 
double compare (const AMatrix &mat) const
 
int getNRows () const
 
int getNCols () const
 
int getNTotal () const
 
VectorDouble getValues (bool byCol=true) const
 
VectorDouble getDiagonal (int shift=0) const
 
VectorDouble getRow (int irow) const
 
VectorDouble getColumn (int icol) const
 
bool isColumnDefined (int icol) const
 
bool isRowDefined (int irow) const
 
int getNumberColumnDefined () const
 
int getNumberRowDefined () const
 
void add (int irow, int icol, double value)
 
void add (const AMatrix &tab, double value=1.)
 
void subtract (const AMatrix &tab, double value=1.)
 
void getValuesAsTriplets (VectorInt &irows, VectorInt &icols, VectorDouble &values) const
 
void prodVector (const double *inv, double *outv) const
 
void prodVector (const VectorDouble &inv, VectorDouble &outv) const
 
void multiplyRow (const VectorDouble &vec)
 
void multiplyColumn (const VectorDouble &vec)
 
void divideRow (const VectorDouble &vec)
 
void divideColumn (const VectorDouble &vec)
 
double quadraticMatrix (const VectorDouble &x, const VectorDouble &y)
 
int invert ()
 
int solve (const VectorDouble &b, VectorDouble &x) const
 
void dumpElements (const String &title, int ifrom, int ito) const
 
void setIdentity (double value=1.)
 
void fill (double value)
 
void fillRandom (int seed=432432, double zeroPercent=0.1)
 
void setValues (const VectorDouble &values, bool byCol=true)
 
double getMeanByColumn (int icol) const
 
double getMinimum () const
 
double getMaximum () const
 
void copyReduce (const AMatrix *x, const VectorInt &activeRows, const VectorInt &activeCols)
 
void setFlagCheckAddress (bool flagCheckAddress)
 
double operator() (int row, int col) const
 
double & operator() (int row, int col)
 
- Public Member Functions inherited from AStringable
 AStringable ()
 
 AStringable (const AStringable &r)
 
AStringableoperator= (const AStringable &r)
 
virtual ~AStringable ()
 
virtual void display (const AStringFormat *strfmt=nullptr) const final
 
virtual void display (int level) const final
 
- Public Member Functions inherited from ICloneable
 ICloneable ()
 
virtual ~ICloneable ()
 
virtual ICloneableclone () const =0
 

Static Public Member Functions

static MatrixSquareSymmetriccreateFromVVD (const VectorVectorDouble &X)
 

Public Attributes

 DECLARE_TOTL
 Has a specific implementation in the Target language. More...
 

Protected Member Functions

virtual double & _getValueRef (int irow, int icol) override
 
- Protected Member Functions inherited from AMatrixSquare
 AMatrixSquare (int nrow=0)
 
 AMatrixSquare (const AMatrixSquare &m)
 
AMatrixSquareoperator= (const AMatrixSquare &r)
 
void _setNSize (int nval)
 
bool _isNumberValid (int nrows, int ncols) const
 
- Protected Member Functions inherited from AMatrix
 AMatrix (int nrow=0, int ncol=0)
 
 AMatrix (const AMatrix &m)
 
AMatrixoperator= (const AMatrix &m)
 
virtual void _clearContents ()
 
void _setNCols (int ncols)
 
void _setNRows (int nrows)
 
bool _isNumbersValid (int nrows, int ncols) const
 
bool _isColumnValid (int icol) const
 
bool _isRowValid (int irow) const
 
bool _isIndexValid (int irow, int icol) const
 
bool _isRowVectorConsistent (const VectorDouble &tab)
 
bool _isColVectorConsistent (const VectorDouble &tab)
 
bool _isVectorSizeConsistent (int nrows, int ncols, const VectorDouble &tab)
 
bool _isRankValid (int rank) const
 
void _clear ()
 
void _fillFromVVD (const VectorVectorDouble &X)
 
bool _getFlagCheckAddress () const
 

Private Member Functions

virtual bool _isCompatible (const AMatrix &m) const override
 
virtual bool _isPhysicallyPresent (int irow, int icol) const override
 
virtual int _getIndexToRank (int irow, int icol) const override
 
virtual double _getValue (int irow, int icol) const override
 
virtual double _getValue (int irank) const override
 
virtual void _setValue (int irow, int icol, double value) override
 
virtual void _setValue (int irank, double value) override
 
virtual void _transposeInPlace () override
 
virtual void _setValues (const double *values, bool byCol=true) override
 
virtual int _getMatrixSize () const override
 
virtual void _allocate () override
 
virtual void _deallocate () override
 
virtual void _prodVector (const double *inv, double *outv) const override
 
virtual int _invert () override
 
virtual int _solve (const VectorDouble &b, VectorDouble &x) const override
 
void _recopy (const MatrixSquareSymmetric &r)
 

Private Attributes

VectorDouble _squareSymMatrix
 

Detailed Description

Square Symmetric matrices are stored as Lower Triangular matrices stored by column

Constructor & Destructor Documentation

◆ MatrixSquareSymmetric() [1/3]

MatrixSquareSymmetric::MatrixSquareSymmetric ( int  nrow = 0)

◆ MatrixSquareSymmetric() [2/3]

MatrixSquareSymmetric::MatrixSquareSymmetric ( const MatrixSquareSymmetric m)

◆ MatrixSquareSymmetric() [3/3]

MatrixSquareSymmetric::MatrixSquareSymmetric ( const AMatrix m)

◆ ~MatrixSquareSymmetric()

MatrixSquareSymmetric::~MatrixSquareSymmetric ( )
virtual

Member Function Documentation

◆ _allocate()

void MatrixSquareSymmetric::_allocate ( )
overrideprivatevirtual

Implements AMatrix.

◆ _deallocate()

void MatrixSquareSymmetric::_deallocate ( )
overrideprivatevirtual

Implements AMatrix.

◆ _getIndexToRank()

int MatrixSquareSymmetric::_getIndexToRank ( int  irow,
int  icol 
) const
overrideprivatevirtual

Implements AMatrix.

◆ _getMatrixSize()

int MatrixSquareSymmetric::_getMatrixSize ( ) const
overrideprivatevirtual

Returns the number of elements actually stored as members in subsequent classes

Implements AMatrix.

◆ _getValue() [1/2]

double MatrixSquareSymmetric::_getValue ( int  irank) const
overrideprivatevirtual

Implements AMatrix.

◆ _getValue() [2/2]

double MatrixSquareSymmetric::_getValue ( int  irow,
int  icol 
) const
overrideprivatevirtual

Implements AMatrix.

◆ _getValueRef()

double & MatrixSquareSymmetric::_getValueRef ( int  irow,
int  icol 
)
overrideprotectedvirtual

Implements AMatrix.

◆ _invert()

int MatrixSquareSymmetric::_invert ( )
overrideprivatevirtual

Implements AMatrix.

◆ _isCompatible()

virtual bool MatrixSquareSymmetric::_isCompatible ( const AMatrix m) const
inlineoverrideprivatevirtual

Implements AMatrix.

◆ _isPhysicallyPresent()

bool MatrixSquareSymmetric::_isPhysicallyPresent ( int  ,
int   
) const
overrideprivatevirtual

Say if (irow, icol) is stored physically or not

Reimplemented from AMatrix.

◆ _prodVector()

void MatrixSquareSymmetric::_prodVector ( const double *  inv,
double *  outv 
) const
overrideprivatevirtual

Implements AMatrix.

◆ _recopy()

void MatrixSquareSymmetric::_recopy ( const MatrixSquareSymmetric r)
private

◆ _setValue() [1/2]

void MatrixSquareSymmetric::_setValue ( int  irank,
double  value 
)
overrideprivatevirtual

Implements AMatrix.

◆ _setValue() [2/2]

void MatrixSquareSymmetric::_setValue ( int  irow,
int  icol,
double  value 
)
overrideprivatevirtual

Implements AMatrix.

◆ _setValues()

void MatrixSquareSymmetric::_setValues ( const double *  values,
bool  byCol = true 
)
overrideprivatevirtual
Warning
: values is provided as a square complete matrix

Reimplemented from AMatrix.

◆ _solve()

int MatrixSquareSymmetric::_solve ( const VectorDouble b,
VectorDouble x 
) const
overrideprivatevirtual

Implements AMatrix.

◆ _transposeInPlace()

virtual void MatrixSquareSymmetric::_transposeInPlace ( )
inlineoverrideprivatevirtual

Implements AMatrix.

◆ createFromVVD()

MatrixSquareSymmetric * MatrixSquareSymmetric::createFromVVD ( const VectorVectorDouble X)
static

Converts a VectorVectorDouble into a Matrix Note: the input argument is stored by row (if coming from [] specification)

Parameters
XInput VectorVectorDouble argument
Returns
The returned matrix
Remarks
: the matrix is transposed implicitly while reading

◆ initMatTri()

void MatrixSquareSymmetric::initMatTri ( int  nsize,
double *  tab 
)

Loading values from an Upper Triangular matrix

Parameters
nsize
tab

◆ isSymmetric()

bool MatrixSquareSymmetric::isSymmetric ( bool  printWhyNot = false) const
inlinefinalvirtual

TODO : isPositiveDefinite.

Is the matrix symmetrical ?

Reimplemented from AMatrix.

◆ mustBeDiagCst()

virtual bool MatrixSquareSymmetric::mustBeDiagCst ( ) const
inlineoverridevirtual

Say if the matrix must be diagonal constant

Reimplemented from AMatrix.

◆ mustBeDiagonal()

virtual bool MatrixSquareSymmetric::mustBeDiagonal ( ) const
inlineoverridevirtual

Say if the matrix must be diagonal

Reimplemented from AMatrix.

◆ mustBeSymmetric()

bool MatrixSquareSymmetric::mustBeSymmetric ( ) const
inlinefinalvirtual

Say if the matrix must be symmetric

Reimplemented from AMatrix.

◆ normSingleMatrix()

void MatrixSquareSymmetric::normSingleMatrix ( const AMatrix x)

Perform the product: this = t(X) %*% X

Parameters
xMatrix [nrow, ncol] where ncol = this->getNSize()

◆ normTSingleMatrix()

void MatrixSquareSymmetric::normTSingleMatrix ( const AMatrix x)

Perform the product: this = X %*% t(X)

Parameters
xMatrix [nrow, ncol] where nrow = this->getNSize()

◆ operator=()

MatrixSquareSymmetric & MatrixSquareSymmetric::operator= ( const MatrixSquareSymmetric r)

◆ reduce()

MatrixSquareSymmetric * MatrixSquareSymmetric::reduce ( const VectorInt validRows) const

◆ toString()

String MatrixSquareSymmetric::toString ( const AStringFormat strfmt = nullptr) const
overridevirtual

ICloneable interface.

AStringable Interface

Reimplemented from AMatrix.

Member Data Documentation

◆ _squareSymMatrix

VectorDouble MatrixSquareSymmetric::_squareSymMatrix
private

◆ DECLARE_TOTL

MatrixSquareSymmetric::DECLARE_TOTL

Has a specific implementation in the Target language.


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