chrono::ChSparsityPatternLearner Class Reference

Description

A dummy matrix that acquires the sparsity pattern.

ChSparsityPatternLearner estimates the sparsity pattern without actually allocating any value, but the elements indexes. Other matrices (like ChCSMatrix) can acquire the sparsity pattern information from this matrix.

#include <ChCSMatrix.h>

Inheritance diagram for chrono::ChSparsityPatternLearner:
Collaboration diagram for chrono::ChSparsityPatternLearner:

Public Member Functions

 ChSparsityPatternLearner (int nrows, int ncols, bool row_major_format_in=true)
 
void SetElement (int insrow, int inscol, double insval, bool overwrite=true) override
 Set the value of the element with index (insrow, inscol) to insval. More...
 
double GetElement (int row, int col) const override
 Returns the value of the element with index (row, col). More...
 
void Reset (int row, int col, int nonzeros=0) override
 
bool Resize (int nrows, int ncols, int nonzeros=0) override
 
std::vector< std::list< int > > & GetSparsityPattern ()
 
bool IsRowMajor () const
 
int GetNNZ () const override
 Get the number of non-zero elements stored in this matrix.
 
- Public Member Functions inherited from chrono::ChSparseMatrix
 ChSparseMatrix (int nrows=0, int ncols=0, int nnz=0)
 Construct a sparse matrix with nrows and ncols and with nnz non-zero elements. More...
 
 ChSparseMatrix (const ChSparseMatrix &other)
 
int GetNumRows () const
 Get the number of rows of this matrix.
 
int GetNumColumns () const
 Get the number of columns of this matrix.
 
void SetType (SymmetryType type)
 Set the symmetry type for this sparse matrix (default: GENERAL). More...
 
SymmetryType GetType () const
 Return the symmetry type of this matrix.
 
void SetSparsityPatternLock (bool val)
 Enable/disable a lock on the matrix sparsity pattern (default: false).
 
virtual void LoadSparsityPattern (ChSparsityPatternLearner &sparsity_learner)
 (Optional) Force the update of the sparsity pattern More...
 
virtual bool Compress ()
 Optional compression method, typically invoked after all elements have been inserted. More...
 
virtual void PasteMatrix (const ChMatrix<> &matra, int insrow, int inscol, bool overwrite=true, bool transp=false)
 Paste a given matrix into this sparse matrix at position (insrow, inscol). More...
 
virtual void PasteClippedMatrix (const ChMatrix<> &matra, int cliprow, int clipcol, int nrows, int ncolumns, int insrow, int inscol, bool overwrite=true)
 Paste a clipped portion of the given matrix into this sparse matrix at position (insrow, inscol). More...
 
virtual int * GetCS_LeadingIndexArray () const
 Return the row|column index array in the CSR|CSC representation of this matrix.
 
virtual int * GetCS_TrailingIndexArray () const
 Return the column|row index array in the CSR|CSC representation of this matrix.
 
virtual double * GetCS_ValueArray () const
 Return the array of matrix values in the CSR|CSC representation of this matrix.
 
virtual void PasteTranspMatrix (const ChMatrix<> &matra, int insrow, int inscol)
 Same as PasteMatrix(), but with overwrite set to true and transp set to true. More...
 
virtual void PasteSumMatrix (const ChMatrix<> &matra, int insrow, int inscol)
 Same as PasteMatrix(), but with overwrite set to false and transp set to false. More...
 
virtual void PasteSumTranspMatrix (const ChMatrix<> &matra, int insrow, int inscol)
 Same as PasteMatrix(), but with overwrite set to false and transp set to true. More...
 
virtual void PasteSumClippedMatrix (const ChMatrix<> &matra, int cliprow, int clipcol, int nrows, int ncolumns, int insrow, int inscol)
 Same as PasteClippedMatrix(), but with overwrite set to false. More...
 

Protected Attributes

std::vector< std::list< int > > leadDim_list
 
bool row_major_format = true
 
int * leading_dimension
 
int * trailing_dimension
 
- Protected Attributes inherited from chrono::ChSparseMatrix
int m_num_rows
 number of rows
 
int m_num_cols
 number of columns
 
int m_nnz
 number of non-zero elements
 
SymmetryType m_type = GENERAL
 matrix type
 
bool m_lock = false
 indicate whether or not the matrix sparsity pattern should be locked
 
bool m_update_sparsity_pattern = false
 let the matrix acquire the sparsity pattern
 

Additional Inherited Members

- Public Types inherited from chrono::ChSparseMatrix
enum  SymmetryType { GENERAL, SYMMETRIC_POSDEF, SYMMETRIC_INDEF, STRUCTURAL_SYMMETRIC }
 Symmetry type of the matrix. More...
 

Member Function Documentation

double chrono::ChSparsityPatternLearner::GetElement ( int  row,
int  col 
) const
overridevirtual

Returns the value of the element with index (row, col).

Returns zero if an element is not stored.

Implements chrono::ChSparseMatrix.

void chrono::ChSparsityPatternLearner::SetElement ( int  insrow,
int  inscol,
double  insval,
bool  overwrite = true 
)
overridevirtual

Set the value of the element with index (insrow, inscol) to insval.

Parameters
[in]insrowrow index of the element;
[in]inscolcolumn index of the element;
[in]insvalvalue of the element;
[in]overwritetells if the new element should overwrite an existing element or be summed to it.

Implements chrono::ChSparseMatrix.