1.11.1
CCC
 
Loading...
Searching...
No Matches
gstlrn::AMatrix Class Referenceabstract

#include <AMatrix.hpp>

Inheritance diagram for gstlrn::AMatrix:
gstlrn::AStringable gstlrn::ICloneable gstlrn::MatrixDense gstlrn::MatrixSparse gstlrn::MatrixSquare gstlrn::Table gstlrn::InvNuggetOp gstlrn::ProjMatrix gstlrn::MatrixSymmetric

Detailed Description

This class is the root of the Matrix organization in gstlearn A matrix is a 2-D organization: it is characterized by its number of rows and its number of columns. Although the user should not bother with this remark, the elements of a matrix processed in 'gstlearn' are stored in a Row-major format. This is to say that the internal rank of an element characterized by its row and column numbers is: (icol * getNRows() + irow)

Since gstlearn version v1.3:

  • Dense Matrices storage and algebra rely on Eigen3 library
  • Sparse Matrices storage and algebra rely on Eigen3 library

Public Member Functions

 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 isSparse () const =0
 
virtual bool isDense () const =0
 
virtual bool isSquare (bool printWhyNot=false) const
 
virtual bool isSymmetric (double eps=EPSILON10, bool printWhyNot=false) const
 
virtual bool mustBeSymmetric () const
 
virtual void setValue (Id irow, Id icol, double value)=0
 
virtual void updValue (Id irow, Id icol, const EOperator &oper, double value)=0
 
virtual void setColumn (Id icol, const 1 &tab)=0
 
virtual void setColumnToConstant (Id icol, double value)=0
 
virtual void setRow (Id irow, const 1 &tab)=0
 
virtual void setRowToConstant (Id irow, double value)=0
 
virtual void setDiagonal (const 1 &tab)=0
 
virtual void setDiagonalToConstant (double value=1.)=0
 
virtual void multiplyRow (const 1 &vec)=0
 
virtual void multiplyColumn (const 1 &vec)=0
 
virtual void divideRow (const 1 &vec)=0
 
virtual void divideColumn (const 1 &vec)=0
 
virtual double getValue (Id irow, Id icol) const =0
 
virtual getRow (Id irow) const
 
virtual getColumn (Id icol) const
 
virtual void fill (double value)=0
 
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 resetFromVVD (const 1 &tab, bool byCol=true)
 Reset the matrix from an array of double values.
 
virtual void transposeInPlace ()
 
virtual AMatrixtranspose () const
 
virtual void prodMatMatInPlace (const AMatrix *x, const AMatrix *y, bool transposeX=false, bool transposeY=false)
 
virtual void prodNormMatMatInPlace (const AMatrix *a, const AMatrix *m, bool transpose=false)
 
virtual void prodNormMatVecInPlace (const AMatrix *a, const 1 &vec, bool transpose=false)
 
virtual void prodNormMatInPlace (const AMatrix *a, bool transpose=false)
 
double prodVecMatVec (const 1 &x, const 1 &y) 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
 
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.)
 
virtual void fillRandom (double zeroPercent=0, Id seed=432432)
 
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
 

Static Public Member Functions

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.
 

Constructor & Destructor Documentation

◆ AMatrix() [1/3]

gstlrn::AMatrix::AMatrix ( Id  nrow = 0,
Id  ncol = 0 
)

◆ AMatrix() [2/3]

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

◆ AMatrix() [3/3]

gstlrn::AMatrix::AMatrix ( AMatrix &&  m)
default

◆ ~AMatrix()

gstlrn::AMatrix::~AMatrix ( )
virtual

Member Function Documentation

◆ add() [1/2]

template<typename T >
static T gstlrn::AMatrix::add ( const T &  other,
double  cst 
)
inlinestatic

Return 'other' + 'cst'.

Template Parameters
TType of the matrix
Parameters
otherInput matrix
cstConstant value to be added

◆ add() [2/2]

template<typename T >
static T gstlrn::AMatrix::add ( const T &  other1,
const T &  other2 
)
inlinestatic

Return 'other1' + 'other2'.

Template Parameters
TType of the matrix
Parameters
other1First Input matrix
other2Second Input matrix

◆ addInPlace() [1/2]

template<typename T >
static void gstlrn::AMatrix::addInPlace ( T &  res,
const T &  other,
double  cst 
)
inlinestatic

Operate 'res' = 'other' + 'cst'.

Template Parameters
TType of the matrix
Parameters
resOutput Matrix
otherInput matrix
cstConstant value to be added

◆ addInPlace() [2/2]

template<typename T >
static void gstlrn::AMatrix::addInPlace ( T &  res,
const T &  other1,
const T &  other2 
)
inlinestatic

Operate: 'res' = 'other1' + 'other2'.

Template Parameters
TType of the matrix
Parameters
resOutput matrix
other1First Input matrix
other2Second Input matrix

◆ addValue()

void gstlrn::AMatrix::addValue ( Id  irow,
Id  icol,
double  value 
)

Add a value to a matrix term

◆ areIdentical()

template<typename T >
static bool gstlrn::AMatrix::areIdentical ( const T &  a,
const T &  b,
bool  verbose = false 
)
inlinestatic

Check if two matrices are exactly identical.

Template Parameters
T
Parameters
aFirst matrix
bSecond matrix
verboseVerbose flag

◆ clear()

void gstlrn::AMatrix::clear ( )

◆ compare()

double gstlrn::AMatrix::compare ( const AMatrix mat) const

Returns the sum of absolute difference between argument and this

◆ copyElements()

void gstlrn::AMatrix::copyElements ( const AMatrix m,
double  factor = 1. 
)

Copy the contents of matrix 'm' into 'this' Warning: matrices must have the same dimensions (not checked)

Parameters
mInput matrix
factorMultiplicative factor (applied to each element)

◆ copyReduce()

void gstlrn::AMatrix::copyReduce ( const AMatrix x,
const 1 &  validRows,
const 1 &  validCols 
)

◆ divideColumn()

virtual void gstlrn::AMatrix::divideColumn ( const 1 &  vec)
pure virtual

Divide a Matrix column-wise

Implemented in gstlrn::MatrixDense, and gstlrn::MatrixSparse.

◆ divideRow()

virtual void gstlrn::AMatrix::divideRow ( const 1 &  vec)
pure virtual

Divide a Matrix row-wise

Implemented in gstlrn::MatrixDense, and gstlrn::MatrixSparse.

◆ dumpElements()

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

Dump a specific range of samples from the internal storage

◆ dumpRange()

void gstlrn::AMatrix::dumpRange ( const char *  title)

◆ dumpStatistics()

void gstlrn::AMatrix::dumpStatistics ( const String title) const

Dump statistics on the Matrix

◆ empty()

bool gstlrn::AMatrix::empty ( ) const
inline

Returns if the current matrix is Empty

◆ fill()

virtual void gstlrn::AMatrix::fill ( double  value)
pure virtual

Set all the values of the Matrix at once

Implemented in gstlrn::MatrixDense, and gstlrn::MatrixSparse.

◆ fillRandom()

void gstlrn::AMatrix::fillRandom ( double  zeroPercent = 0,
Id  seed = 432432 
)
virtual

Reimplemented in gstlrn::MatrixSparse.

◆ getColumn()

gstlrn::AMatrix::getColumn ( Id  icol) const
virtual

Extract a Column

Reimplemented in gstlrn::MatrixDense.

◆ getColumnByRowRange()

gstlrn::AMatrix::getColumnByRowRange ( Id  icol,
Id  rowFrom,
Id  rowTo 
) const

Extract a portion of a Column

◆ getDiagonal()

const & gstlrn::AMatrix::getDiagonal ( Id  shift = 0) const

Extract a Diagonal (main or secondary) of this

◆ getMatrixToTriplet()

NF_Triplet gstlrn::AMatrix::getMatrixToTriplet ( Id  shiftRow = 0,
Id  shiftCol = 0 
) const
virtual

Extract the contents of the matrix

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

Reimplemented in gstlrn::MatrixSparse.

◆ getMaximum()

double gstlrn::AMatrix::getMaximum ( ) const

◆ getMeanByColumn()

double gstlrn::AMatrix::getMeanByColumn ( Id  icol) const

◆ getMinimum()

double gstlrn::AMatrix::getMinimum ( ) const

◆ getNColDefined()

Id gstlrn::AMatrix::getNColDefined ( ) const

Define the number of defined columns

◆ getNCols()

Id gstlrn::AMatrix::getNCols ( ) const
inline

Returns the number of columns

◆ getNormInf()

double gstlrn::AMatrix::getNormInf ( ) const

◆ getNRowDefined()

Id gstlrn::AMatrix::getNRowDefined ( ) const

Define the number of defined rows

◆ getNRows()

Id gstlrn::AMatrix::getNRows ( ) const
inline

Returns the number of rows

◆ getRow()

gstlrn::AMatrix::getRow ( Id  irow) const
virtual

Extract a Row

Reimplemented in gstlrn::MatrixDense.

◆ getValue()

virtual double gstlrn::AMatrix::getValue ( Id  irow,
Id  icol 
) const
pure virtual

Gets the value at row 'irow' and column 'icol'

Implemented in gstlrn::MatrixDense, and gstlrn::MatrixSparse.

◆ getValues()

gstlrn::AMatrix::getValues ( bool  byCol = true) const

Returns the contents of the whole matrix as a VectorDouble

◆ invert()

Id gstlrn::AMatrix::invert ( )

Matrix inversion in place

◆ isColumnDefined()

bool gstlrn::AMatrix::isColumnDefined ( Id  icol) const

Checks if a Column is valid (contains a non TEST value)

◆ isDense()

virtual bool gstlrn::AMatrix::isDense ( ) const
pure virtual

Returns if the matrix belongs to the MatrixDense class

Implemented in gstlrn::MatrixDense, and gstlrn::MatrixSparse.

◆ isIdentity()

bool gstlrn::AMatrix::isIdentity ( bool  printWhyNot = false) const

Check if the matrix is square and Identity

Indicate if the current matrix is the Identity

Parameters
printWhyNotPrint the message is the answer is false
Returns
true if the current matrix is the Identity

◆ isNonNegative()

bool gstlrn::AMatrix::isNonNegative ( bool  verbose = false) const

Check if the matrix does not contain any negative element

Check if all the elements of a matrix are non-negative

Returns
True if the matrix is non-negative; False otherwise
Parameters
[in]verboseTrue for the verbose option

◆ isRowDefined()

bool gstlrn::AMatrix::isRowDefined ( Id  irow) const

Checks if a Row is valid (contains a non TEST value)

◆ isSame()

bool gstlrn::AMatrix::isSame ( const AMatrix m,
double  eps = EPSILON4,
bool  printWhyNot = false 
)

Check if a matrix is the same as me (norm L1)

Check that Matrix 'm' is equal to the current Matrix

Parameters
mMatrix to be compared to the current Matrix
epsEpsilon for double equality comparison
printWhyNotPrint the message is the answer is false
Returns
true if 'm' is equal to the current Matrix

◆ isSameSize()

bool gstlrn::AMatrix::isSameSize ( const AMatrix m) const

Check that 'm' has the same dimensions as 'this'

Check that Matrix 'm' share the same dimensions as current one

Parameters
mMatrix to be compared to the current Matrix
Returns
true if 'm' has same dimensions as the current Matrix
Remarks
: message is issued if dimensions are different

◆ isSparse()

virtual bool gstlrn::AMatrix::isSparse ( ) const
pure virtual

Returns if the current matrix is Sparse

Implemented in gstlrn::MatrixDense, and gstlrn::MatrixSparse.

◆ isSquare()

bool gstlrn::AMatrix::isSquare ( bool  printWhyNot = false) const
virtual

Check if the matrix is (non empty) square

Indicate if the given matrce is a square matrix

Parameters
printWhyNotPrint the message is the answer is false
Returns
true if the matrix is square

Reimplemented in gstlrn::MatrixSquare.

◆ isSymmetric()

bool gstlrn::AMatrix::isSymmetric ( double  eps = EPSILON10,
bool  printWhyNot = false 
) const
virtual

Check if the input matrix is (non empty and square) symmetric

Indicate if the current matrix is symmetric

Parameters
epsEpsilon for double equality comparison
printWhyNotPrint the message is the answer is false
Returns
true if the current matrix is symmetric

Reimplemented in gstlrn::MatrixSymmetric.

◆ isValid()

bool gstlrn::AMatrix::isValid ( Id  irow,
Id  icol,
bool  printWhyNot = false 
) const

Indicate if the given indices are valid for the current matrix size

Indicate if the given indices are valid for the current matrix size

Parameters
irowRow index
icolColumn index
printWhyNotPrint the message is the answer is false
Returns
true if indices are valid for the current matrix size

◆ linearCombination()

template<typename T >
static T gstlrn::AMatrix::linearCombination ( double  addition,
double  val1,
const T &  other1,
double  val2 = 0.,
const T &  other2 = T(),
double  val3 = 0.,
const T &  other3 = T() 
)
inlinestatic

Return: 'val1' * 'other1' + 'val2' * 'other2' + 'val3' * 'other3' + 'addition'.

Template Parameters
T
Parameters
additionConstant to be added to the linear combination
val1Weight of the first matrix
other1First matrix
val2Weight of the second matrix
other2Second matrix
val3Weight of the third matrix
other3Third matrix

◆ linearCombinationInPlace()

template<typename T >
static void gstlrn::AMatrix::linearCombinationInPlace ( T &  res,
double  addition,
double  val1,
const T &  other1,
double  val2 = 0.,
const T &  other2 = T(),
double  val3 = 0.,
const T &  other3 = T() 
)
inlinestatic

Operate: 'res' = 'val1' * 'other1' + 'val2' * 'other2' + 'val3' * 'other3' + 'addition'.

Template Parameters
T
Parameters
resOutput matrix
additionConstant to be added to the linear combination
val1Weight of the first matrix
other1First matrix
val2Weight of the second matrix
other2Second matrix
val3Weight of the third matrix
other3Third matrix

◆ makePositiveColumn()

void gstlrn::AMatrix::makePositiveColumn ( )

Modify the contents of the matrix so that each column has a positive sum of elements. If this is not the case, simply invert the sign of the column

◆ multiplyColumn()

virtual void gstlrn::AMatrix::multiplyColumn ( const 1 &  vec)
pure virtual

Multiply a Matrix column-wise

Implemented in gstlrn::MatrixDense, and gstlrn::MatrixSparse.

◆ multiplyRow()

virtual void gstlrn::AMatrix::multiplyRow ( const 1 &  vec)
pure virtual

Multiply a Matrix row-wise

Implemented in gstlrn::MatrixDense, and gstlrn::MatrixSparse.

◆ mustBeSymmetric()

virtual bool gstlrn::AMatrix::mustBeSymmetric ( ) const
inlinevirtual

Say if the matrix must be symmetric

Reimplemented in gstlrn::MatrixSymmetric, gstlrn::MatrixDense, and gstlrn::MatrixSquare.

◆ operator()() [1/2]

double & gstlrn::AMatrix::operator() ( Id  row,
Id  col 
)
inline

Set value operator

◆ operator()() [2/2]

double gstlrn::AMatrix::operator() ( Id  row,
Id  col 
) const
inline

Get value operator

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ prodHadamard()

template<typename T >
static T gstlrn::AMatrix::prodHadamard ( const T &  other1,
const T &  other2 
)
inlinestatic

Return: 'other1' * 'other2' (where '*' designates the element-wise product)

Template Parameters
TType of the matrix
Parameters
other1First input matrix
other2Second input matrix

◆ prodHadamardInPlace()

template<typename T >
static void gstlrn::AMatrix::prodHadamardInPlace ( T &  res,
const T &  other1,
const T &  other2 
)
inlinestatic

Operate: 'res' = 'other1' * 'other2' (where '*' designates the element-wise prodtc)

Template Parameters
TType of the matrix
Parameters
resOutput matrix
other1First input matrix
other2Second input matrix

◆ prodMatMatInPlace() [1/2]

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

Perform 'this' = 'x' * 'y'

Store the product of 'x'(or 't(x)') by 'y' (or 't(y') in this

Parameters
xFirst Matrix
ySecond matrix
transposeXTrue if first matrix must be transposed
transposeYTrue if second matrix must be transposed

Reimplemented in gstlrn::MatrixDense, and gstlrn::MatrixSparse.

◆ prodMatMatInPlace() [2/2]

template<class MA , class MB , class MC >
static void gstlrn::AMatrix::prodMatMatInPlace ( MA &  A,
const MB &  B,
const MC &  C,
bool  transposeB = false,
bool  transposeC = false 
)
inlinestatic

◆ prodnorm() [1/2]

template<typename T >
static T gstlrn::AMatrix::prodnorm ( const T &  a,
const 1 &  vec,
bool  transpose = false 
)
inlinestatic

Return: 'a_t' * 'vec' * 'a' or 'a' * 'vec' * 'a_t' (where 'a_t' is the transpose of 'a')

Template Parameters
T
Parameters
aFirst matrix
vecVector
transposeTrue if first 'a' is transposed; otherwise second 'a' is transposed

◆ prodnorm() [2/2]

template<typename T >
static T gstlrn::AMatrix::prodnorm ( const T &  a,
const T &  m = T(),
bool  transpose = false 
)
inlinestatic

Return: 'a_t' * 'm' * 'a' or 'a' * 'm' * 'a_t' (where 'a_t' is the transpose of 'a')

Template Parameters
T
Parameters
aFirst matrix
mSecond matrix (may be omitted)
transposeTrue if first 'a' is transposed; otherwise second 'a' is transposed

◆ prodnormInPlace() [1/2]

template<typename T >
static void gstlrn::AMatrix::prodnormInPlace ( T &  res,
const T &  a,
const 1 &  vec,
bool  transpose = false 
)
inlinestatic

Operate: 'res' = 'a_t' * 'vec' * 'a' or 'a' * 'vec' * 'a_t' (where 'a_t' is the transpose of 'a')

Template Parameters
T
Parameters
resOutput matrix
aFirst matrix
vecVector
transposeTrue if first 'a' is transposed; otherwise second 'a' is transposed

◆ prodnormInPlace() [2/2]

template<typename T >
static void gstlrn::AMatrix::prodnormInPlace ( T &  res,
const T &  a,
const T &  m = T(),
bool  transpose = false 
)
inlinestatic

Operate: 'res' = 'a_t' * 'm' * 'a' or 'a' * 'm' * 'a_t' (where 'a_t' is the transpose of 'a')

Template Parameters
T
Parameters
resOutput matrix
aFirst matrix
mSecond matrix (may be omitted)
transposeTrue if first 'a' is transposed; otherwise second 'a' is transposed

◆ prodNormMatInPlace()

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

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

Reimplemented in gstlrn::MatrixDense, and gstlrn::MatrixSparse.

◆ prodNormMatMatInPlace()

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

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

Product 't(A)' %*% 'M' %*% 'A' or 'A' %*% 'M' %*% 't(A)' stored in 'this'

Parameters
aMatrix A
mMatrix M
transposeTrue for first implementation, False for the second

Reimplemented in gstlrn::MatrixDense, and gstlrn::MatrixSparse.

◆ prodNormMatVecInPlace()

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

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

Reimplemented in gstlrn::MatrixDense, and gstlrn::MatrixSparse.

◆ product() [1/4]

template<typename T >
static gstlrn::AMatrix::product ( const 1 &  vec,
const T &  other,
bool  transpose = false,
bool  flagInit = true 
)
inlinestatic

Return: 'vec' * 'other'.

Template Parameters
T
Parameters
otherFirst matrix
vecVector
transposeTrue if 'other' must be transposed
flagInitTrue if the resulting vector must be initialized beforehand

◆ product() [2/4]

template<typename T >
static gstlrn::AMatrix::product ( const T &  other,
const 1 &  vec,
bool  transpose = false,
bool  flagInit = true 
)
inlinestatic

Return: 'other' * 'vec'.

Template Parameters
T
Parameters
otherFirst matrix
vecVector
transposeTrue if 'other' must be transposed
flagInitTrue if the resulting vector must be initialized beforehand

◆ product() [3/4]

template<typename T >
static T gstlrn::AMatrix::product ( const T &  other,
double  cst 
)
inlinestatic

Return 'other' * 'cst'.

Template Parameters
TType of the matrix
Parameters
otherInput matrix
cstConstant value to be multiplied

◆ product() [4/4]

template<typename T >
static T gstlrn::AMatrix::product ( const T &  other1,
const T &  other2,
bool  transpose1 = false,
bool  transpose2 = false 
)
inlinestatic

Return: 'other1' * 'other2'.

Template Parameters
T
Parameters
other1First matrix
other2Second matrix
transpose1True if 'other1' must be transposed
transpose2True if 'other2' must be transposed

◆ productInPlace() [1/7]

template<typename T >
static void gstlrn::AMatrix::productInPlace ( 1 &  res,
const 1 &  vec,
const T &  other,
bool  transpose = false,
bool  flagInit = true 
)
inlinestatic

Operate: 'res' = 'vec' * 'other'.

Template Parameters
T
Parameters
resOutput vector
otherFirst matrix
vecVector
transposeTrue if 'other' must be transposed
flagInitTrue if the resulting vector must be initialized beforehand

◆ productInPlace() [2/7]

template<typename T >
static void gstlrn::AMatrix::productInPlace ( 1 &  res,
const T &  other,
const 1 &  vec,
bool  transpose = false,
bool  flagInit = true 
)
inlinestatic

Operate: 'res' = 'other' * 'vec'.

Template Parameters
T
Parameters
resOutput vector
otherFirst matrix
vecVector
transposeTrue if 'other' must be transposed
flagInitTrue if the resulting vector must be initialized beforehand

◆ productInPlace() [3/7]

template<typename T >
static void gstlrn::AMatrix::productInPlace ( T &  res,
const T &  other,
double  cst 
)
inlinestatic

Operate: 'res' = 'other' * 'cst'.

Template Parameters
TType of the matrix
Parameters
resOutput matrix
otherInput matrix
cstConstant value to be multiplied

◆ productInPlace() [4/7]

template<typename T >
static void gstlrn::AMatrix::productInPlace ( T &  res,
const T &  other1,
const T &  other2,
bool  transpose1 = false,
bool  transpose2 = false 
)
inlinestatic

Operate: 'res' = 'other1' * 'other2'.

Template Parameters
T
Parameters
resOutput matrix
other1First matrix
other2Second matrix
transpose1True if 'other1' must be transposed
transpose2True if 'other2' must be transposed

◆ productInPlace() [5/7]

template<typename T >
static void gstlrn::AMatrix::productInPlace ( T &  res,
const T &  other2,
bool  transpose2 = false 
)
inlinestatic

Operate: 'res' = 'res' * 'other1'.

Template Parameters
T
Parameters
resOutput matrix
other2First matrix
transpose2True if 'other2' must be transposed

◆ productInPlace() [6/7]

template<typename T >
static void gstlrn::AMatrix::productInPlace ( vect  res,
const constvect  vec,
const T &  other,
bool  transpose = false,
bool  flagInit = true 
)
inlinestatic

Operate: 'res' = 'vec' * 'other'.

Template Parameters
T
Parameters
resOutput vector
otherFirst matrix
vecVector
transposeTrue if 'other' must be transposed
flagInitTrue if the resulting vector must be initialized beforehand

◆ productInPlace() [7/7]

template<typename T >
static void gstlrn::AMatrix::productInPlace ( vect  res,
const T &  other,
const constvect  vec,
bool  transpose = false,
bool  flagInit = true 
)
inlinestatic

Operate: 'res' = 'other' * 'vec'.

Template Parameters
T
Parameters
resOutput matrix
otherFirst matrix
vecVector
transposeTrue if 'other' must be transposed
flagInitTrue if the resulting vector must be initialized beforehand

◆ prodVecMatVec()

double gstlrn::AMatrix::prodVecMatVec ( const 1 &  x,
const 1 &  y 
) const

Perform x %*% 'this' %*% y

◆ reset()

void gstlrn::AMatrix::reset ( Id  nrows,
Id  ncols 
)
virtual

Reimplemented in gstlrn::Table.

◆ resetFromArray()

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

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

◆ resetFromValue()

void gstlrn::AMatrix::resetFromValue ( Id  nrows,
Id  ncols,
double  value 
)
virtual

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

◆ resetFromVD()

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

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

◆ resetFromVVD()

void gstlrn::AMatrix::resetFromVVD ( const 1 &  tab,
bool  byCol = true 
)
virtual

Reset the matrix from an array of double values.

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

Reimplemented in gstlrn::MatrixSparse, gstlrn::MatrixSquare, and gstlrn::MatrixSymmetric.

◆ resize()

void gstlrn::AMatrix::resize ( Id  nrows,
Id  ncols 
)

Resize the matrix to new dimensions (this method doesn't change the storage type)

Modify the dimension of the matrix (if needed)

Parameters
nrowsNew number of rows
ncolsNew number of columns

◆ setColumn()

virtual void gstlrn::AMatrix::setColumn ( Id  icol,
const 1 &  tab 
)
pure virtual

Set the contents of a Column

Implemented in gstlrn::MatrixDense, and gstlrn::MatrixSparse.

◆ setColumnToConstant()

virtual void gstlrn::AMatrix::setColumnToConstant ( Id  icol,
double  value 
)
pure virtual

Set the contents of a Column to a constant value

Implemented in gstlrn::MatrixDense, and gstlrn::MatrixSparse.

◆ setDiagonal()

virtual void gstlrn::AMatrix::setDiagonal ( const 1 &  tab)
pure virtual

Set the contents of the (main) Diagonal

Implemented in gstlrn::MatrixDense, and gstlrn::MatrixSparse.

◆ setDiagonalToConstant()

virtual void gstlrn::AMatrix::setDiagonalToConstant ( double  value = 1.)
pure virtual

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

Implemented in gstlrn::MatrixDense, and gstlrn::MatrixSparse.

◆ setIdentity()

void gstlrn::AMatrix::setIdentity ( double  value = 1.)

Sets the matrix as Identity

◆ setRow()

virtual void gstlrn::AMatrix::setRow ( Id  irow,
const 1 &  tab 
)
pure virtual

Set the contents of a Row

Implemented in gstlrn::MatrixDense, and gstlrn::MatrixSparse.

◆ setRowToConstant()

virtual void gstlrn::AMatrix::setRowToConstant ( Id  irow,
double  value 
)
pure virtual

Set the contents of a Row to a constant value

Implemented in gstlrn::MatrixDense, and gstlrn::MatrixSparse.

◆ setValue()

virtual void gstlrn::AMatrix::setValue ( Id  irow,
Id  icol,
double  value 
)
pure virtual

Sets the value at row 'irow' and column 'icol'

Implemented in gstlrn::MatrixDense, and gstlrn::MatrixSparse.

◆ setValues()

void gstlrn::AMatrix::setValues ( const 1 &  values,
bool  byCol = true 
)

Filling the matrix with an array of values Note that this array is ALWAYS dimensioned to the total number of elements in the matrix. Kept for compatibility with old code where matrix contents was stored as a VectorDouble

Parameters
values
byColtrue for Column major; false for Row Major

◆ size()

Id gstlrn::AMatrix::size ( ) const
inline

Get the total number of elements of the (full) matrix (as for VectorT)

◆ solve()

Id gstlrn::AMatrix::solve ( const 1 &  b,
1 &  x 
) const

Solving the Matrix Linear system

◆ toString()

String gstlrn::AMatrix::toString ( const AStringFormat strfmt = nullptr) const
overridevirtual

Interface to AStringable.

Reimplemented from gstlrn::AStringable.

Reimplemented in gstlrn::ProjMatrix, and gstlrn::Table.

◆ transpose()

AMatrix * gstlrn::AMatrix::transpose ( ) const
virtual

Transpose the matrix and return it as a copy

Reimplemented in gstlrn::MatrixSparse.

◆ transposeInPlace()

void gstlrn::AMatrix::transposeInPlace ( )
virtual

Transpose the matrix in place

◆ updValue()

virtual void gstlrn::AMatrix::updValue ( Id  irow,
Id  icol,
const EOperator &  oper,
double  value 
)
pure virtual

Update the value at row 'irow' and column 'icol'

Implemented in gstlrn::MatrixDense, and gstlrn::MatrixSparse.


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