1.11.1
CCC
 
Loading...
Searching...
No Matches
gstlrn::MatrixSparse Class Reference

#include <MatrixSparse.hpp>

Inheritance diagram for gstlrn::MatrixSparse:
gstlrn::AMatrix gstlrn::ASimulableMatrix gstlrn::AStringable gstlrn::ICloneable gstlrn::ASimulable gstlrn::ALinearOp gstlrn::InvNuggetOp gstlrn::ProjMatrix

Detailed Description

Sparse Matrix

Handle a sparse matrix that can be symmetrical, square or not. Storage relies on Eigen3 Library. Storage relies on Eigen3 Library.

Public Member Functions

 MatrixSparse (Id nrow=0, Id ncol=0, Id ncolmax=-1)
 
 MatrixSparse (const MatrixSparse &m)
 
MatrixSparseoperator= (const MatrixSparse &m)
 
 MatrixSparse (MatrixSparse &&m)=default
 
MatrixSparseoperator= (MatrixSparse &&m)=default
 
virtual ~MatrixSparse ()
 
DECLARE_TOLATEX Id getSize () const override
 Cloneable interface.
 
const MatrixSparsegetQMat () const override
 Interface for AMatrix.
 
bool isSparse () const override
 
bool isDense () const override
 
double getValue (Id row, Id col) 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 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
 
void resetFromValue (Id nrows, Id ncols, double value) override
 Reset the matrix to new dimensions and fill with a new value.
 
void resetFromArray (Id nrows, Id ncols, const double *tab, bool byCol=true) override
 Reset the matrix from an array of double values.
 
void resetFromVD (Id nrows, Id ncols, const 1 &tab, bool byCol=true) override
 Reset the matrix from a vector of double values.
 
void resetFromVVD (const 1 &tab, bool byCol=true) override
 Reset the matrix from an array of double values.
 
MatrixSparsetranspose () 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
 
NF_Triplet getMatrixToTriplet (Id shiftRow=0, Id shiftCol=0) const override
 
MatrixSparseaddCst (double a)
 
MatrixSparseprodCst (double a)
 
MatrixSparsegetRowAsMatrixSparse (Id irow, double coeff=1.) const
 
MatrixSparsegetColumnAsMatrixSparse (Id icol, double coeff=1.) const
 
Id addVecInPlaceEigen (const Eigen::Map< const Eigen::VectorXd > &xm, Eigen::Map< Eigen::VectorXd > &ym) const
 
void resetFromTriplet (const NF_Triplet &NF_T)
 
void fillRandom (double zeroPercent=0, Id seed=432432) override
 Fill a sparse matrix with random values, using a given seed and a percentage of zero values.
 
Id addVecInPlace (const constvect x, vect y) const
 
void addValue (Id row, Id col, double value)
 
double L1Norm () const
 
void getStats (Id *nrows, Id *ncols, Id *count, double *percent) const
 
Id scaleByDiag ()
 
Id addVecInPlaceVD (const 1 &x, 1 &y) const
 
void setConstant (double value)
 
 extractDiag (Id oper_choice=1) const
 
void prodNormDiagVecInPlace (const 1 &vec, Id oper=1)
 
MatrixSparseextractSubmatrixByRanks (const 1 &rank_rows, const 1 &rank_cols) const
 
MatrixSparseextractSubmatrixByColor (const 1 &colors, Id ref_color, bool row_ok, bool col_ok)
 
 colorCoding () const
 
Id getNonZeros () const
 
void gibbs (Id iech, const 1 &zcur, double *yk, double *sk)
 
Id forwardLU (const 1 &b, 1 &x, bool flagLower=true) const
 
void forceDimension (Id maxRows, Id maxCols)
 
 getNonZeroCols (Id irow) const
 
 getNonZeroRows (Id icol) const
 
void setDiagonal (const Eigen::Map< const Eigen::VectorXd > &tab)
 
void setDiagonal (const constvect tab)
 
MatrixSparseoperator+= (double a)
 
MatrixSparseoperator-= (double a)
 
MatrixSparse operator+ (double a) const
 
MatrixSparse operator- (double a) const
 
MatrixSparseoperator*= (double a)
 
MatrixSparse operator* (double a) const
 
MatrixSparseoperator/= (double a)
 
MatrixSparse operator/ (double a) const
 
const EigenSparseMatrix & eigenMat () const
 
EigenSparseMatrix & eigenMat ()
 
- Public Member Functions inherited from gstlrn::AMatrix
 AMatrix (Id nrow=0, Id ncol=0)
 
 AMatrix (const AMatrix &m)
 
AMatrixoperator= (const AMatrix &m)
 
 AMatrix (AMatrix &&m)=default
 
AMatrixoperator= (AMatrix &&m)=default
 
virtual ~AMatrix ()
 
String toString (const AStringFormat *strfmt=nullptr) const override
 Interface to AStringable.
 
virtual bool isSquare (bool printWhyNot=false) const
 
virtual bool isSymmetric (double eps=EPSILON10, bool printWhyNot=false) const
 
virtual bool mustBeSymmetric () const
 
virtual getRow (Id irow) const
 
virtual getColumn (Id icol) const
 
virtual void reset (Id nrows, Id ncols)
 
virtual void transposeInPlace ()
 
double prodVecMatVec (const 1 &x, const 1 &y) 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
 
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 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
 
void printConcreteClassName () const
 
- Public Member Functions inherited from gstlrn::ICloneable
 ICloneable ()
 
virtual ~ICloneable ()
 
virtual ICloneableclone () const =0
 
std::shared_ptr< ICloneablecloneShared () const
 
std::unique_ptr< ICloneablecloneUnique () const
 
- Public Member Functions inherited from gstlrn::ASimulableMatrix
 ASimulableMatrix ()
 
virtual ~ASimulableMatrix ()
 
double computeLogDet (Id nMC=1) const override
 
- Public Member Functions inherited from gstlrn::ASimulable
 ASimulable ()
 
 ASimulable (const ASimulable &m)=default
 
ASimulableoperator= (const ASimulable &m)=default
 
 ASimulable (ASimulable &&m)=default
 
ASimulableoperator= (ASimulable &&m)=default
 
virtual ~ASimulable ()=default
 
Id evalSimulate (const 1 &whitenoise, 1 &outv) const
 
 evalSimulate (const 1 &whitenoise) const
 
 simulate () const
 
Id evalSimulate (const constvect whitenoise, vect result) const
 
Id addSimulateToDest (const constvect whitenoise, vect outv) const
 
- Public Member Functions inherited from gstlrn::ALinearOp
 ALinearOp ()
 
 ALinearOp (const ALinearOp &m)=default
 
 ALinearOp (ALinearOp &&m)=default
 
ALinearOpoperator= (const ALinearOp &m)=default
 
ALinearOpoperator= (ALinearOp &&m)=default
 
virtual ~ALinearOp ()=default
 
Id evalDirect (const 1 &inv, 1 &outv) const
 
 evalDirect (const 1 &in) const
 
virtual void multiplyByValueAndAddDiagonal (double v1=1., double v2=0.) const
 
virtual void resetModif () const
 
void setUseFactor (bool usefactor)
 
Id evalDirect (constvect inv, vect outv) const
 
Id addToDest (const constvect inv, vect outv) const
 
Id addToDest (const ::Eigen::VectorXd &inv, ::Eigen::VectorXd &outv) const
 

Static Public Member Functions

static MatrixSparsecreateFromMatrix (const MatrixSparse &mat)
 
static void _addGeneral (MatrixSparse &res, const MatrixSparse &other, double cst)
 
static void _addGeneral (MatrixSparse &res, const MatrixSparse &other1, const MatrixSparse &other2)
 Add matrices 'other1' and 'other2' and store the result in 'res' This code is alais-safe, as it does not modify 'other1' and 'other2' and only writes to 'res'.
 
static void _prodGeneral (MatrixSparse &res, const MatrixSparse &other, double cst)
 
static void _prodGeneral (MatrixSparse &res, const MatrixSparse &other1, const MatrixSparse &other2)
 Make the elementwise product of matrices 'other1' and 'other2' and store the result in 'res' This code is alais-safe, as it does not modify 'other1' and 'other2' and only writes to 'res'.
 
static void _productGeneral (MatrixSparse &res, const MatrixSparse &other1, const MatrixSparse &other2, bool transpose1=false, bool transpose2=false)
 
static void _prodVecAddGeneral (1 &res, const MatrixSparse &other, const 1 &vec, bool transpose=false, bool flagInvert=false)
 Add the Product of a matrix by a vector.
 
static void _prodVecAddGeneral (vect &res, const MatrixSparse &other, const constvect &vec, bool transpose=false, bool flagInvert=false)
 Add the Product of a matrix by a vector.
 
static void _prodnormGeneral (MatrixSparse &res, const MatrixSparse &a, const MatrixSparse &m=MatrixSparse(), bool transpose=false)
 
static void _prodnormGeneral (MatrixSparse &res, const MatrixSparse &a, const 1 &vec, bool transpose=false)
 
static bool _areIdenticalGeneral (const MatrixSparse &a, const MatrixSparse &b, bool verbose=false)
 
static MatrixSparsecreateFromCopy (const MatrixSparse *mat)
 
static MatrixSparsecreate (Id nrow, Id ncol)
 
static MatrixSparsecreateFromTriplet (const NF_Triplet &NF_T, Id nrow=0, Id ncol=0, Id nrowmax=-1)
 
static MatrixSparsecreateFillRandom (Id nrow, Id ncol, double zeroPercent=0.1, Id seed=143743)
 
static MatrixDensecreateFromSparse (const MatrixSparse &mat)
 
static MatrixSparseIdentity (Id nrow, double value=1.)
 
static MatrixSparseaddMatMat (const MatrixSparse *x, const MatrixSparse *y, double cx=1., double cy=1.)
 
static MatrixSparsediagVec (const 1 &vec)
 
static MatrixSparsediagConstant (Id number, double value=1.)
 
static MatrixSparsediagMat (MatrixSparse *A, Id oper_choice)
 
static MatrixSparseglue (const MatrixSparse *A1, const MatrixSparse *A2, bool flagShiftRow, bool flagShiftCol)
 
static void glueInPlace (MatrixSparse *A1, const MatrixSparse *A2, bool flagShiftRow, bool flagShiftCol)
 
static void dumpElements (const String &title, Id ifrom, Id ito)
 
- Static Public Member Functions inherited from gstlrn::AMatrix
template<class MA , class MB , class MC >
static void prodMatMatInPlace (MA &A, const MB &B, const MC &C, bool transposeB=false, bool transposeC=false)
 
template<typename T >
static T add (const T &other, double cst)
 Return 'other' + 'cst'.
 
template<typename T >
static void addInPlace (T &res, const T &other, double cst)
 Operate 'res' = 'other' + 'cst'.
 
template<typename T >
static T add (const T &other1, const T &other2)
 Return 'other1' + 'other2'.
 
template<typename T >
static void addInPlace (T &res, const T &other1, const T &other2)
 Operate: 'res' = 'other1' + 'other2'.
 
template<typename T >
static T product (const T &other, double cst)
 Return 'other' * 'cst'.
 
template<typename T >
static void productInPlace (T &res, const T &other, double cst)
 Operate: 'res' = 'other' * 'cst'.
 
template<typename T >
static T prodHadamard (const T &other1, const T &other2)
 Return: 'other1' * 'other2' (where '*' designates the element-wise product)
 
template<typename T >
static void prodHadamardInPlace (T &res, const T &other1, const T &other2)
 Operate: 'res' = 'other1' * 'other2' (where '*' designates the element-wise prodtc)
 
template<typename T >
static T linearCombination (double addition, double val1, const T &other1, double val2=0., const T &other2=T(), double val3=0., const T &other3=T())
 Return: 'val1' * 'other1' + 'val2' * 'other2' + 'val3' * 'other3' + 'addition'.
 
template<typename T >
static void linearCombinationInPlace (T &res, double addition, double val1, const T &other1, double val2=0., const T &other2=T(), double val3=0., const T &other3=T())
 Operate: 'res' = 'val1' * 'other1' + 'val2' * 'other2' + 'val3' * 'other3' + 'addition'.
 
template<typename T >
static T product (const T &other1, const T &other2, bool transpose1=false, bool transpose2=false)
 Return: 'other1' * 'other2'.
 
template<typename T >
static void productInPlace (T &res, const T &other1, const T &other2, bool transpose1=false, bool transpose2=false)
 Operate: 'res' = 'other1' * 'other2'.
 
template<typename T >
static void productInPlace (T &res, const T &other2, bool transpose2=false)
 Operate: 'res' = 'res' * 'other1'.
 
template<typename T >
static product (const T &other, const 1 &vec, bool transpose=false, bool flagInit=true)
 Return: 'other' * 'vec'.
 
template<typename T >
static void productInPlace (1 &res, const T &other, const 1 &vec, bool transpose=false, bool flagInit=true)
 Operate: 'res' = 'other' * 'vec'.
 
template<typename T >
static void productInPlace (vect res, const T &other, const constvect vec, bool transpose=false, bool flagInit=true)
 Operate: 'res' = 'other' * 'vec'.
 
template<typename T >
static product (const 1 &vec, const T &other, bool transpose=false, bool flagInit=true)
 Return: 'vec' * 'other'.
 
template<typename T >
static void productInPlace (1 &res, const 1 &vec, const T &other, bool transpose=false, bool flagInit=true)
 Operate: 'res' = 'vec' * 'other'.
 
template<typename T >
static void productInPlace (vect res, const constvect vec, const T &other, bool transpose=false, bool flagInit=true)
 Operate: 'res' = 'vec' * 'other'.
 
template<typename T >
static T prodnorm (const T &a, const T &m=T(), bool transpose=false)
 Return: 'a_t' * 'm' * 'a' or 'a' * 'm' * 'a_t' (where 'a_t' is the transpose of 'a')
 
template<typename T >
static void prodnormInPlace (T &res, const T &a, const T &m=T(), bool transpose=false)
 Operate: 'res' = 'a_t' * 'm' * 'a' or 'a' * 'm' * 'a_t' (where 'a_t' is the transpose of 'a')
 
template<typename T >
static T prodnorm (const T &a, const 1 &vec, bool transpose=false)
 Return: 'a_t' * 'vec' * 'a' or 'a' * 'vec' * 'a_t' (where 'a_t' is the transpose of 'a')
 
template<typename T >
static void prodnormInPlace (T &res, const T &a, const 1 &vec, bool transpose=false)
 Operate: 'res' = 'a_t' * 'vec' * 'a' or 'a' * 'vec' * 'a_t' (where 'a_t' is the transpose of 'a')
 
template<typename T >
static bool areIdentical (const T &a, const T &b, bool verbose=false)
 Check if two matrices are exactly identical.
 

Public Attributes

 DECLARE_TOTL
 Has a specific implementation in the Target language.
 

Constructor & Destructor Documentation

◆ MatrixSparse() [1/3]

gstlrn::MatrixSparse::MatrixSparse ( Id  nrow = 0,
Id  ncol = 0,
Id  ncolmax = -1 
)

◆ MatrixSparse() [2/3]

gstlrn::MatrixSparse::MatrixSparse ( const MatrixSparse m)

◆ MatrixSparse() [3/3]

gstlrn::MatrixSparse::MatrixSparse ( MatrixSparse &&  m)
default

◆ ~MatrixSparse()

gstlrn::MatrixSparse::~MatrixSparse ( )
virtual

Member Function Documentation

◆ _addGeneral() [1/2]

void gstlrn::MatrixSparse::_addGeneral ( MatrixSparse res,
const MatrixSparse other,
double  cst 
)
static

◆ _addGeneral() [2/2]

void gstlrn::MatrixSparse::_addGeneral ( MatrixSparse res,
const MatrixSparse other1,
const MatrixSparse other2 
)
static

Add matrices 'other1' and 'other2' and store the result in 'res' This code is alais-safe, as it does not modify 'other1' and 'other2' and only writes to 'res'.

Parameters
resResulting matrix
other1First matrix
other2Second matrix

◆ _areIdenticalGeneral()

bool gstlrn::MatrixSparse::_areIdenticalGeneral ( const MatrixSparse a,
const MatrixSparse b,
bool  verbose = false 
)
static

◆ _prodGeneral() [1/2]

void gstlrn::MatrixSparse::_prodGeneral ( MatrixSparse res,
const MatrixSparse other,
double  cst 
)
static

◆ _prodGeneral() [2/2]

void gstlrn::MatrixSparse::_prodGeneral ( MatrixSparse res,
const MatrixSparse other1,
const MatrixSparse other2 
)
static

Make the elementwise product of matrices 'other1' and 'other2' and store the result in 'res' This code is alais-safe, as it does not modify 'other1' and 'other2' and only writes to 'res'.

Parameters
resResulting matrix
other1First matrix
other2Second matrix

◆ _prodnormGeneral() [1/2]

void gstlrn::MatrixSparse::_prodnormGeneral ( MatrixSparse res,
const MatrixSparse a,
const 1 &  vec,
bool  transpose = false 
)
static

◆ _prodnormGeneral() [2/2]

void gstlrn::MatrixSparse::_prodnormGeneral ( MatrixSparse res,
const MatrixSparse a,
const MatrixSparse m = MatrixSparse(),
bool  transpose = false 
)
static

◆ _productGeneral()

void gstlrn::MatrixSparse::_productGeneral ( MatrixSparse res,
const MatrixSparse other1,
const MatrixSparse other2,
bool  transpose1 = false,
bool  transpose2 = false 
)
static

◆ _prodVecAddGeneral() [1/2]

void gstlrn::MatrixSparse::_prodVecAddGeneral ( 1 &  res,
const MatrixSparse other,
const 1 &  vec,
bool  transpose = false,
bool  flagInvert = false 
)
static

Add the Product of a matrix by a vector.

Parameters
resResulting vector
otherInput matrix
vecInput vector
transposeShould the matrix 'other' be transposed
flagInvertProduct 'other' * 'vec' (F) or 'vec' * 'other' (T)

◆ _prodVecAddGeneral() [2/2]

void gstlrn::MatrixSparse::_prodVecAddGeneral ( vect res,
const MatrixSparse other,
const constvect vec,
bool  transpose = false,
bool  flagInvert = false 
)
static

Add the Product of a matrix by a vector.

Parameters
resResulting vector
otherInput matrix
vecInput vector
transposeShould the matrix 'other' be transposed
flagInvertProduct 'other' * 'vec' (F) or 'vec' * 'other' (T)

◆ addCst()

MatrixSparse & gstlrn::MatrixSparse::addCst ( double  a)

New methods for operator overloading

New methodes for operator overloading

◆ addMatMat()

MatrixSparse * gstlrn::MatrixSparse::addMatMat ( const MatrixSparse x,
const MatrixSparse y,
double  cx = 1.,
double  cy = 1. 
)
static

◆ addValue()

void gstlrn::MatrixSparse::addValue ( Id  row,
Id  col,
double  value 
)

◆ addVecInPlace()

Id gstlrn::MatrixSparse::addVecInPlace ( const constvect  x,
vect  y 
) const

◆ addVecInPlaceEigen()

Id gstlrn::MatrixSparse::addVecInPlaceEigen ( const Eigen::Map< const Eigen::VectorXd > &  xm,
Eigen::Map< Eigen::VectorXd > &  ym 
) const

◆ addVecInPlaceVD()

Id gstlrn::MatrixSparse::addVecInPlaceVD ( const 1 &  x,
1 &  y 
) const

◆ colorCoding()

gstlrn::MatrixSparse::colorCoding ( ) const

◆ create()

MatrixSparse * gstlrn::MatrixSparse::create ( Id  nrow,
Id  ncol 
)
static

◆ createFillRandom()

MatrixSparse * gstlrn::MatrixSparse::createFillRandom ( Id  nrow,
Id  ncol,
double  zeroPercent = 0.1,
Id  seed = 143743 
)
static

◆ createFromCopy()

MatrixSparse * gstlrn::MatrixSparse::createFromCopy ( const MatrixSparse mat)
static

◆ createFromMatrix()

MatrixSparse * gstlrn::MatrixSparse::createFromMatrix ( const MatrixSparse mat)
static

◆ createFromSparse()

MatrixDense * gstlrn::MatrixSparse::createFromSparse ( const MatrixSparse mat)
static

◆ createFromTriplet()

MatrixSparse * gstlrn::MatrixSparse::createFromTriplet ( const NF_Triplet NF_T,
Id  nrow = 0,
Id  ncol = 0,
Id  nrowmax = -1 
)
static

◆ diagConstant()

MatrixSparse * gstlrn::MatrixSparse::diagConstant ( Id  number,
double  value = 1. 
)
static

◆ diagMat()

MatrixSparse * gstlrn::MatrixSparse::diagMat ( MatrixSparse A,
Id  oper_choice 
)
static

Construct a sparse matrix with the diagonal of 'A', where each element is transformed

Parameters
AInput sparse matrix
oper_choiceOperation on the diagonal term (see Utilities::operate_XXX)
Returns

◆ diagVec()

MatrixSparse * gstlrn::MatrixSparse::diagVec ( const 1 &  vec)
static

◆ divideColumn()

void gstlrn::MatrixSparse::divideColumn ( const 1 &  vec)
overridevirtual

Divide the matrix column-wise

Divide a Matrix column-wise

Implements gstlrn::AMatrix.

◆ divideRow()

void gstlrn::MatrixSparse::divideRow ( const 1 &  vec)
overridevirtual

Divide the matrix row-wise

Divide a Matrix row-wise

Implements gstlrn::AMatrix.

◆ dumpElements()

void gstlrn::MatrixSparse::dumpElements ( const String title,
Id  ifrom,
Id  ito 
)
static

Dump a specific range of samples from the internal storage

◆ eigenMat() [1/2]

EigenSparseMatrix & gstlrn::MatrixSparse::eigenMat ( )
inline

◆ eigenMat() [2/2]

const EigenSparseMatrix & gstlrn::MatrixSparse::eigenMat ( ) const
inline

◆ extractDiag()

gstlrn::MatrixSparse::extractDiag ( Id  oper_choice = 1) const

◆ extractSubmatrixByColor()

MatrixSparse * gstlrn::MatrixSparse::extractSubmatrixByColor ( const 1 &  colors,
Id  ref_color,
bool  row_ok,
bool  col_ok 
)

◆ extractSubmatrixByRanks()

MatrixSparse * gstlrn::MatrixSparse::extractSubmatrixByRanks ( const 1 &  rank_rows,
const 1 &  rank_cols 
) const

◆ fill()

void gstlrn::MatrixSparse::fill ( double  value)
overridevirtual

Set all the values of the matrix at once

Parameters
valueConstant value used for filling 'this'

Implements gstlrn::AMatrix.

◆ fillRandom()

void gstlrn::MatrixSparse::fillRandom ( double  zeroPercent = 0,
Id  seed = 432432 
)
overridevirtual

Fill a sparse matrix with random values, using a given seed and a percentage of zero values.

Set all the values of the Matrix with random values

Parameters
zeroPercentPercentage of zero values (between 0 and 1)
seedRandom seed for reproducibility
Remarks
The method also ensures that the last element of the matrix (at position [nrow-1, ncol-1]) is non-zero

Reimplemented from gstlrn::AMatrix.

◆ forceDimension()

void gstlrn::MatrixSparse::forceDimension ( Id  maxRows,
Id  maxCols 
)

◆ forwardLU()

Id gstlrn::MatrixSparse::forwardLU ( const 1 &  b,
1 &  x,
bool  flagLower = true 
) const

◆ getColumnAsMatrixSparse()

MatrixSparse * gstlrn::MatrixSparse::getColumnAsMatrixSparse ( Id  icol,
double  coeff = 1. 
) const

Extract a Column

◆ getMatrixToTriplet()

NF_Triplet gstlrn::MatrixSparse::getMatrixToTriplet ( Id  shiftRow = 0,
Id  shiftCol = 0 
) const
overridevirtual

Extract the contents of the matrix

From a matrix of any type, creates the triplet (specific format for creating efficiently a Sparse matrix) It only takes the only non-zero elements of the matrix

Reimplemented from gstlrn::AMatrix.

◆ getNonZeroCols()

gstlrn::MatrixSparse::getNonZeroCols ( Id  irow) const

◆ getNonZeroRows()

gstlrn::MatrixSparse::getNonZeroRows ( Id  icol) const

◆ getNonZeros()

Id gstlrn::MatrixSparse::getNonZeros ( ) const
inline

◆ getQMat()

const MatrixSparse & gstlrn::MatrixSparse::getQMat ( ) const
inlineoverridevirtual

Interface for AMatrix.

Implements gstlrn::ASimulableMatrix.

◆ getRowAsMatrixSparse()

MatrixSparse * gstlrn::MatrixSparse::getRowAsMatrixSparse ( Id  irow,
double  coeff = 1. 
) const

Extract a Row

◆ getSize()

DECLARE_TOLATEX Id gstlrn::MatrixSparse::getSize ( ) const
inlineoverridevirtual

Cloneable interface.

Interface for ALinearOp

Implements gstlrn::ALinearOp.

◆ getStats()

void gstlrn::MatrixSparse::getStats ( Id nrows,
Id ncols,
Id count,
double *  percent 
) const

◆ getValue()

double gstlrn::MatrixSparse::getValue ( Id  row,
Id  col 
) const
overridevirtual

Get the value from a matrix cell

Implements gstlrn::AMatrix.

◆ gibbs()

void gstlrn::MatrixSparse::gibbs ( Id  iech,
const 1 &  zcur,
double *  yk,
double *  sk 
)

◆ glue()

MatrixSparse * gstlrn::MatrixSparse::glue ( const MatrixSparse A1,
const MatrixSparse A2,
bool  flagShiftRow,
bool  flagShiftCol 
)
static

◆ glueInPlace()

void gstlrn::MatrixSparse::glueInPlace ( MatrixSparse A1,
const MatrixSparse A2,
bool  flagShiftRow,
bool  flagShiftCol 
)
static

◆ Identity()

MatrixSparse * gstlrn::MatrixSparse::Identity ( Id  nrow,
double  value = 1. 
)
static

◆ isDense()

bool gstlrn::MatrixSparse::isDense ( ) const
inlineoverridevirtual

Returns if the matrix belongs to the MatrixSparse class (avoids dynamic_cast)

Implements gstlrn::AMatrix.

◆ isSparse()

bool gstlrn::MatrixSparse::isSparse ( ) const
inlineoverridevirtual

Returns if the current matrix is Sparse

Implements gstlrn::AMatrix.

◆ L1Norm()

double gstlrn::MatrixSparse::L1Norm ( ) const

◆ multiplyColumn()

void gstlrn::MatrixSparse::multiplyColumn ( const 1 &  vec)
overridevirtual

Multiply the matrix column-wise

Multiply a Matrix column-wise

Implements gstlrn::AMatrix.

◆ multiplyRow()

void gstlrn::MatrixSparse::multiplyRow ( const 1 &  vec)
overridevirtual

Multiply the matrix row-wise

Multiply a Matrix row-wise

Implements gstlrn::AMatrix.

◆ operator*()

MatrixSparse gstlrn::MatrixSparse::operator* ( double  a) const
inline

◆ operator*=()

MatrixSparse & gstlrn::MatrixSparse::operator*= ( double  a)
inline

◆ operator+()

MatrixSparse gstlrn::MatrixSparse::operator+ ( double  a) const
inline

◆ operator+=()

MatrixSparse & gstlrn::MatrixSparse::operator+= ( double  a)
inline

◆ operator-()

MatrixSparse gstlrn::MatrixSparse::operator- ( double  a) const
inline

◆ operator-=()

MatrixSparse & gstlrn::MatrixSparse::operator-= ( double  a)
inline

◆ operator/()

MatrixSparse gstlrn::MatrixSparse::operator/ ( double  a) const
inline

◆ operator/=()

MatrixSparse & gstlrn::MatrixSparse::operator/= ( double  a)
inline

◆ operator=() [1/2]

MatrixSparse & gstlrn::MatrixSparse::operator= ( const MatrixSparse m)

◆ operator=() [2/2]

MatrixSparse & gstlrn::MatrixSparse::operator= ( MatrixSparse &&  m)
default

◆ prodCst()

MatrixSparse & gstlrn::MatrixSparse::prodCst ( double  a)

◆ prodMatMatInPlace()

void gstlrn::MatrixSparse::prodMatMatInPlace ( const AMatrix x,
const AMatrix y,
bool  transposeX = false,
bool  transposeY = false 
)
overridevirtual

Multiply matrix 'x' by matrix 'y' and store the result in 'this'

Store the product of 'x' by 'y' in this

Parameters
xFirst Matrix
ySecond matrix
transposeXTrue if First matrix is transposed
transposeYTrue if Second matrix is transposed

Reimplemented from gstlrn::AMatrix.

◆ prodNormDiagVecInPlace()

void gstlrn::MatrixSparse::prodNormDiagVecInPlace ( const 1 &  vec,
Id  oper_choice = 1 
)

Perform: 'this' = diag('vec') %*% 'A' %*% diag('vec')

Parameters
vecInput Vector
oper_choiceType of transformation

◆ prodNormMatInPlace()

void gstlrn::MatrixSparse::prodNormMatInPlace ( const AMatrix a,
bool  transpose = false 
)
overridevirtual

Perform 'this' = 't(A)' %*% 'A' or 'A' %*% 't(A)'

Reimplemented from gstlrn::AMatrix.

◆ prodNormMatMatInPlace()

void gstlrn::MatrixSparse::prodNormMatMatInPlace ( const AMatrix a,
const AMatrix m,
bool  transpose = false 
)
overridevirtual

Perform 'this' = 't(A)' %*% 'M' %*% 'A' or 'A' %*% 'M' %*% 't(A)'

Reimplemented from gstlrn::AMatrix.

◆ prodNormMatVecInPlace()

void gstlrn::MatrixSparse::prodNormMatVecInPlace ( const AMatrix a,
const 1 &  vec,
bool  transpose = false 
)
overridevirtual

Perform 'this' = 't(A)' %*% ['vec'] %*% 'A' or 'A' %*% ['vec'] %*% 't(A)'

Reimplemented from gstlrn::AMatrix.

◆ resetFromArray()

void gstlrn::MatrixSparse::resetFromArray ( Id  nrows,
Id  ncols,
const double *  tab,
bool  byCol = true 
)
overridevirtual

Reset the matrix from an array of double values.

Parameters
nrowsNew number of rows
ncolsNew number of columns
tabThe array of values
byColTrue if values are column-major in the array

Reimplemented from gstlrn::AMatrix.

◆ resetFromTriplet()

void gstlrn::MatrixSparse::resetFromTriplet ( const NF_Triplet NF_T)

◆ resetFromValue()

void gstlrn::MatrixSparse::resetFromValue ( Id  nrows,
Id  ncols,
double  value 
)
overridevirtual

Reset the matrix to new dimensions and fill with a new value.

Parameters
nrowsNew number of rows
ncolsNew number of columns
valueThe new value used to fill the matrix

Reimplemented from gstlrn::AMatrix.

◆ resetFromVD()

void gstlrn::MatrixSparse::resetFromVD ( Id  nrows,
Id  ncols,
const 1 &  tab,
bool  byCol = true 
)
overridevirtual

Reset the matrix from a vector of double values.

Parameters
nrowsNew number of rows
ncolsNew number of columns
tabThe vector of values
byColTrue if values are column-major in the vector

Reimplemented from gstlrn::AMatrix.

◆ resetFromVVD()

void gstlrn::MatrixSparse::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.

◆ scaleByDiag()

Id gstlrn::MatrixSparse::scaleByDiag ( )

◆ setColumn()

void gstlrn::MatrixSparse::setColumn ( Id  icol,
const 1 &  tab 
)
overridevirtual

Set the contents of a Column

Fill a column of an already existing Sparse matrix, using 'tab' as entry The input 'tab' corresponds to the whole column contents

Parameters
icolColumn rank
tabVector containing the information (Dimension: nrows)

Implements gstlrn::AMatrix.

◆ setColumnToConstant()

void gstlrn::MatrixSparse::setColumnToConstant ( Id  icol,
double  value 
)
overridevirtual

Set the contents of a Column to a constant

Implements gstlrn::AMatrix.

◆ setConstant()

void gstlrn::MatrixSparse::setConstant ( double  value)

◆ setDiagonal() [1/3]

void gstlrn::MatrixSparse::setDiagonal ( const 1 &  tab)
overridevirtual

Set the contents of the (main) Diagonal

Implements gstlrn::AMatrix.

◆ setDiagonal() [2/3]

void gstlrn::MatrixSparse::setDiagonal ( const constvect  tab)

◆ setDiagonal() [3/3]

void gstlrn::MatrixSparse::setDiagonal ( const Eigen::Map< const Eigen::VectorXd > &  tab)

◆ setDiagonalToConstant()

void gstlrn::MatrixSparse::setDiagonalToConstant ( double  value = 1.)
overridevirtual

Set the contents of the (main) Diagonal to a constant value

Implements gstlrn::AMatrix.

◆ setRow()

void gstlrn::MatrixSparse::setRow ( Id  irow,
const 1 &  tab 
)
overridevirtual

Set the contents of a Row

Fill a row of an already existing Sparse matrix, using 'tab' as entry The input 'tab' corresponds to the whole row contents

Parameters
irowRow rank
tabVector containing the information (Dimension: ncols)
Warning
: This method only copies the values at the non-zero existing entries

Implements gstlrn::AMatrix.

◆ setRowToConstant()

void gstlrn::MatrixSparse::setRowToConstant ( Id  irow,
double  value 
)
overridevirtual

Set the contents of a Row to a constant

Implements gstlrn::AMatrix.

◆ setValue()

void gstlrn::MatrixSparse::setValue ( Id  irow,
Id  icol,
double  value 
)
overridevirtual

Set the value for a matrix cell

Implements gstlrn::AMatrix.

◆ transpose()

MatrixSparse * gstlrn::MatrixSparse::transpose ( ) const
overridevirtual

Transpose the matrix and return it as a copy

Reimplemented from gstlrn::AMatrix.

◆ updValue()

void gstlrn::MatrixSparse::updValue ( Id  irow,
Id  icol,
const EOperator &  oper,
double  value 
)
overridevirtual

Modifies the contents of a matrix cell

Implements gstlrn::AMatrix.

Member Data Documentation

◆ DECLARE_TOTL

gstlrn::MatrixSparse::DECLARE_TOTL

Has a specific implementation in the Target language.


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