1.8.0
CCC
 
Loading...
Searching...
No Matches
gstlrn::MatrixSquare Class Reference

#include <MatrixSquare.hpp>

Inheritance diagram for gstlrn::MatrixSquare:
gstlrn::MatrixDense gstlrn::AMatrix gstlrn::AStringable gstlrn::ICloneable gstlrn::MatrixSymmetric

Public Member Functions

 MatrixSquare (Id nrow=0)
 
 MatrixSquare (const MatrixSquare &r)
 
 MatrixSquare (const AMatrix &m)
 
MatrixSquareoperator= (const MatrixSquare &r)
 
virtual ~MatrixSquare ()
 
virtual double determinant (void) const
 ICloneable interface.
 
bool isSquare (bool printWhyNot=false) const override
 
bool mustBeSymmetric () const override
 
Id getNSize () const
 
void resetFromVVD (const 1 &tab, bool byCol=true) override
 Reset the matrix from an array of double values.
 
double trace () const
 
void innerMatrix (const MatrixSquare &x, const AMatrix &r1, const AMatrix &r2)
 
void prodDiagByVector (const 1 &diag)
 
void divideDiagByVector (const 1 &diag)
 
void prodByDiagInPlace (Id mode, const 1 &c)
 
double normVec (const 1 &vec)
 
Id decomposeLU (MatrixSquare &tls, MatrixSquare &tus, double eps=EPSILON20)
 
Id computeEigen (bool optionPositive=true)
 
- Public Member Functions inherited from gstlrn::MatrixDense
 MatrixDense (Id nrow=0, Id ncol=0)
 
 MatrixDense (const MatrixDense &r)
 
 MatrixDense (const AMatrix &r)
 
MatrixDenseoperator= (const MatrixDense &r)
 
virtual ~MatrixDense ()
 
bool isDense () const override
 Cloneable interface.
 
bool isSparse () const override
 
double getValue (Id irow, Id icol) const override
 
void setValue (Id irow, Id icol, double value) override
 
void updValue (Id irow, Id icol, const EOperator &oper, double value) override
 
void setColumn (Id icol, const 1 &tab) override
 
void setColumnToConstant (Id icol, double value) override
 
void setRow (Id irow, const 1 &tab) override
 
void setRowToConstant (Id irow, double value) override
 
void setDiagonal (const 1 &tab) override
 
void setDiagonalToConstant (double value=1.) override
 
void addScalar (double v) override
 
void addScalarDiag (double v) override
 
void prodScalar (double v) override
 
void fill (double value) override
 
void multiplyRow (const 1 &vec) override
 
void multiplyColumn (const 1 &vec) override
 
void divideRow (const 1 &vec) override
 
void divideColumn (const 1 &vec) override
 
 getRow (Id irow) const override
 
 getColumn (Id icol) const override
 
void prodMatMatInPlace (const AMatrix *x, const AMatrix *y, bool transposeX=false, bool transposeY=false) override
 
void prodNormMatMatInPlace (const AMatrix *a, const AMatrix *m, bool transpose=false) override
 
void prodNormMatVecInPlace (const AMatrix *a, const 1 &vec, bool transpose=false) override
 
void prodNormMatInPlace (const AMatrix *a, bool transpose=false) override
 
void linearCombination (double val1, const AMatrix *mat1, double val2=1., const AMatrix *mat2=nullptr, double val3=1., const AMatrix *mat3=nullptr) override
 
void addMat (const AMatrix &y, double cx=1., double cy=1.) override
 
const & getEigenValues () const
 
const MatrixSquaregetEigenVectors () const
 
Id invert2 (MatrixDense &res) const
 
void unsample (const AMatrix *A, const 1 &rowFetch, const 1 &colFetch, bool flagInvertRow=false, bool flagInvertCol=false)
 Set the values contained in 'A' into the current matrix.
 
MatrixDense compressMatLC (const MatrixDense &matLC, bool transpose=false)
 Perform the compressing product, according to 'transpose'.
 
void addRow (Id nrow_added=1)
 
void addColumn (Id ncolumn_added=1)
 
constvect getColumnPtr (Id icol) const
 
constvect getViewOnColumn (Id icol) const
 
vect getViewOnColumnModify (Id icol)
 
Eigen::Map< const Eigen::MatrixXd > eigenMat () const
 
Eigen::Map< Eigen::MatrixXd > eigenMat ()
 
- Public Member Functions inherited from gstlrn::AMatrix
 AMatrix (Id nrow=0, Id ncol=0)
 
 AMatrix (const AMatrix &m)
 
AMatrixoperator= (const AMatrix &m)
 
virtual ~AMatrix ()
 
String toString (const AStringFormat *strfmt=nullptr) const override
 Interface to AStringable.
 
virtual bool isSymmetric (double eps=EPSILON10, bool printWhyNot=false) const
 
virtual void reset (Id nrows, Id ncols)
 
virtual void resetFromValue (Id nrows, Id ncols, double value)
 Reset the matrix to new dimensions and fill with a new value.
 
virtual void resetFromArray (Id nrows, Id ncols, const double *tab, bool byCol=true)
 Reset the matrix from an array of double values.
 
virtual void resetFromVD (Id nrows, Id ncols, const 1 &tab, bool byCol=true)
 Reset the matrix from a vector of double values.
 
virtual void transposeInPlace ()
 
virtual AMatrixtranspose () const
 
virtual NF_Triplet getMatrixToTriplet (Id shiftRow=0, Id shiftCol=0) const
 
void clear ()
 
void resize (Id nrows, Id ncols)
 Resize the matrix to new dimensions (this method doesn't change the storage type)
 
bool isValid (Id irow, Id icol, bool printWhyNot=false) const
 
bool isIdentity (bool printWhyNot=false) const
 
void addValue (Id irow, Id icol, double value)
 
bool isSame (const AMatrix &m, double eps=EPSILON4, bool printWhyNot=false)
 
bool isSameSize (const AMatrix &m) const
 
bool empty () const
 
double compare (const AMatrix &mat) const
 
Id getNRows () const
 
Id getNCols () const
 
Id size () const
 
 getValues (bool byCol=true) const
 
const & getDiagonal (Id shift=0) const
 
bool isColumnDefined (Id icol) const
 
bool isRowDefined (Id irow) const
 
Id getNColDefined () const
 
Id getNRowDefined () const
 
 getColumnByRowRange (Id icol, Id rowFrom, Id rowTo) const
 
bool isNonNegative (bool verbose=false) const
 
 prodMatVec (const 1 &x, bool transpose=false) const
 
void prodMatVecInPlace (const 1 &x, 1 &y, bool transpose=false) const
 
void prodMatVecInPlaceC (const constvect x, vect y, bool transpose=false) const
 
void addProdMatVecInPlaceC (const constvect x, vect y, bool transpose=false) const
 
 prodVecMat (const 1 &x, bool transpose=false) const
 
void prodVecMatInPlace (const 1 &x, 1 &y, bool transpose=false) const
 
void prodVecMatInPlaceC (const constvect x, vect y, bool transpose=false) const
 
void addProdVecMatInPlaceC (const constvect x, vect y, bool transpose=false) const
 
double prodVecMatVec (const 1 &x, const 1 &y) const
 
void prodMat (const AMatrix *matY, bool transposeY=false)
 
Id invert ()
 
Id solve (const 1 &b, 1 &x) const
 
void dumpElements (const String &title, Id ifrom, Id ito) const
 
void dumpStatistics (const String &title) const
 
void setIdentity (double value=1.)
 
void fillRandom (Id seed=432432, double zeroPercent=0)
 
void setValues (const 1 &values, bool byCol=true)
 
double getMeanByColumn (Id icol) const
 
double getMinimum () const
 
double getMaximum () const
 
double getNormInf () const
 
void copyReduce (const AMatrix *x, const 1 &validRows, const 1 &validCols)
 
void copyElements (const AMatrix &m, double factor=1.)
 
void makePositiveColumn ()
 
void dumpRange (const char *title)
 
double operator() (Id row, Id col) const
 
double & operator() (Id row, Id col)
 
- Public Member Functions inherited from gstlrn::AStringable
 AStringable ()
 
 AStringable (const AStringable &r)
 
AStringableoperator= (const AStringable &r)
 
virtual ~AStringable ()
 
virtual void display (const AStringFormat *strfmt=nullptr) const final
 
virtual void display (Id level) const final
 
- Public Member Functions inherited from gstlrn::ICloneable
 ICloneable ()
 
virtual ~ICloneable ()
 
virtual ICloneableclone () const =0
 
std::shared_ptr< ICloneablecloneShared () const
 
std::unique_ptr< ICloneablecloneUnique () const
 

Static Public Member Functions

static MatrixSquarecreateFromVVD (const 1 &X)
 
static MatrixSquarecreateFromVD (const 1 &X, Id nrow, bool byCol=false, bool invertColumnOrder=false)
 
static MatrixSquarecreateFromTridiagonal (const 1 &vecdiag, const 1 &vecinf, const 1 &vecsup)
 Create a square matrix from three diagonals.
 
- Static Public Member Functions inherited from gstlrn::MatrixDense
static MatrixDensecreate (const MatrixDense *mat)
 
static MatrixDensecreate (Id nrow, Id ncol)
 
static double traceProd (const MatrixDense &a, MatrixDense &b)
 
static MatrixDensecreateFromVVD (const 1 &X)
 
static MatrixDensecreateFromVD (const 1 &X, Id nrow, Id ncol, bool byCol=false, bool invertColumnOrder=false)
 
static MatrixDenseglue (const AMatrix *A1, const AMatrix *A2, bool flagShiftRow, bool flagShiftCol)
 
static bool sample (MatrixDense &res, const AMatrix &A, const 1 &rowKeep=1(), const 1 &colKeep=1(), bool flagInvertRow=false, bool flagInvertCol=false)
 Create an output Rectangular Matrix by selecting some rows and columns of the Input matrix 'A'.
 
static void sum (const MatrixDense *mat1, const MatrixDense *mat2, MatrixDense *mat3)
 

Public Attributes

 DECLARE_TOTL
 Has a specific implementation in the Target language.
 
- Public Attributes inherited from gstlrn::MatrixDense
 DECLARE_TOTL
 Has a specific implementation in the Target language.
 

Constructor & Destructor Documentation

◆ MatrixSquare() [1/3]

gstlrn::MatrixSquare::MatrixSquare ( Id  nrow = 0)

◆ MatrixSquare() [2/3]

gstlrn::MatrixSquare::MatrixSquare ( const MatrixSquare r)

◆ MatrixSquare() [3/3]

gstlrn::MatrixSquare::MatrixSquare ( const AMatrix m)

◆ ~MatrixSquare()

gstlrn::MatrixSquare::~MatrixSquare ( )
virtual

Member Function Documentation

◆ computeEigen()

Id gstlrn::MatrixSquare::computeEigen ( bool  optionPositive = true)

◆ createFromTridiagonal()

MatrixSquare * gstlrn::MatrixSquare::createFromTridiagonal ( const 1 &  vecdiag,
const 1 &  vecinf,
const 1 &  vecsup 
)
static

Create a square matrix from three diagonals.

Parameters
vecdiagVector of information along the diagonal
vecinfVector of information along the line below the diagonal
vecsupVector of information along the line above the diagonal
Returns
Returned matrix

◆ createFromVD()

MatrixSquare * gstlrn::MatrixSquare::createFromVD ( const 1 &  X,
Id  nrow,
bool  byCol = false,
bool  invertColumnOrder = false 
)
static

◆ createFromVVD()

MatrixSquare * gstlrn::MatrixSquare::createFromVVD ( const 1 &  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 square matrix
Remarks
: the matrix is transposed implicitly while reading

◆ decomposeLU()

Id gstlrn::MatrixSquare::decomposeLU ( MatrixSquare tls,
MatrixSquare tus,
double  eps = EPSILON20 
)

LU Decomposition of a square matrix (not necessarily symmetric)

Parameters
tlsOutput square matrix containing lower triangle (stored columnwise)
tusOutput square matrix containing upper triangle (stored linewise)
epsTolerance
Remarks
The output matrices 'tus' and 'tls' must be dimensioned beforehand

◆ determinant()

double gstlrn::MatrixSquare::determinant ( void  ) const
virtual

ICloneable interface.

Interface for AMatrix

◆ divideDiagByVector()

void gstlrn::MatrixSquare::divideDiagByVector ( const 1 &  diag)

Divide the diagonal by a vector

◆ getNSize()

Id gstlrn::MatrixSquare::getNSize ( ) const
inline

Returns the size of the matrix (nrows=ncols)

◆ innerMatrix()

void gstlrn::MatrixSquare::innerMatrix ( const MatrixSquare x,
const AMatrix r1,
const AMatrix r2 
)

Perform inner product

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

Parameters
xSquare matrix
r1Left Hand Matrix
r2Right Hand Matrix
Remarks
The number of rows of Y must be equal to the dimension of X
The output matrix is square with dimension equal to the number of columns of Y

◆ isSquare()

bool gstlrn::MatrixSquare::isSquare ( bool  printWhyNot = false) const
inlineoverridevirtual

Check if the matrix is (non empty) square

Reimplemented from gstlrn::AMatrix.

◆ mustBeSymmetric()

bool gstlrn::MatrixSquare::mustBeSymmetric ( ) const
inlineoverridevirtual

Say if the matrix must be symmetric

Reimplemented from gstlrn::MatrixDense.

Reimplemented in gstlrn::MatrixSymmetric.

◆ normVec()

double gstlrn::MatrixSquare::normVec ( const 1 &  vec)

◆ operator=()

MatrixSquare & gstlrn::MatrixSquare::operator= ( const MatrixSquare r)

◆ prodByDiagInPlace()

void gstlrn::MatrixSquare::prodByDiagInPlace ( Id  mode,
const 1 &  c 
)

Multiply by a Diagonal matrix provided as VectorDouble (in place)

Performs the 'this' %*% diag(c) where c is a vector

Parameters
[in]mode0: c as is; 1: sqrt(c); 2: 1/c; 3: 1/sqrt(c)
[in]cvector

◆ prodDiagByVector()

void gstlrn::MatrixSquare::prodDiagByVector ( const 1 &  diag)

Multiply the diagonal by a vector

◆ resetFromVVD()

void gstlrn::MatrixSquare::resetFromVVD ( const 1 &  tab,
bool  byCol = true 
)
overridevirtual

Reset the matrix from an array of double values.

Parameters
tabThe array of values
byColTrue if values are column-major in the array

Reimplemented from gstlrn::AMatrix.

Reimplemented in gstlrn::MatrixSymmetric.

◆ trace()

double gstlrn::MatrixSquare::trace ( ) const

Member Data Documentation

◆ DECLARE_TOTL

gstlrn::MatrixSquare::DECLARE_TOTL

Has a specific implementation in the Target language.


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