Skip to main content

optiSLang 3D Postprocessing Script API 2025 R1

SymSparseMatrix Class Reference

Last update: 16.07.2025

Symmetric sparse matrix class with selfadjoint storage. More...

Public Types

typedef Eigen::SparseMatrix< TScalarBase
 the underlying Eigen sparse matrix type
 
enum  some_enums { EIGENFLAGS = Eigen::ColMajor|Eigen::SelfAdjoint|Eigen::Lower, EIGENSYM = Eigen::Lower }
 defines Eigen flags to be used for modfying Eigen's algebra operators More...
 
typedef Base::Index TEigenIndex
 index type for Eigen matrices
 
typedef number TScalar
 the data type of the coefficients (real number)
 
typedef number TUnsignedIndex
 an unsigned index type
 

Public Member Functions

SymSparseMatrix __neg__ () const
 
char * __str__ ()
 transforms this objects into a string, required by SWIG More...
 
 Assign (SymSparseMatrix other, bool keep_data=true)
 assigns a new matrix to this object More...
 
Base cast () const
 
TUnsignedIndex Cols ()
 
TUnsignedIndex InnerSize ()
 
TUnsignedIndex NonZeros ()
 
Matrix operator* (Matrix x) const
 
Matrix operator* (MatrixBlock x) const
 
sparse::SparseMatrix operator* (SymSparseMatrix x) const
 
SymSparseMatrix operator* (number x) const
 
SymSparseMatrix operator+ (SymSparseMatrix x) const
 
SymSparseMatrix operator- (SymSparseMatrix x) const
 
SymSparseMatrix operator/ (number x) const
 
TUnsignedIndex OuterSize ()
 
 Print (string format="%g ", TUnsignedIndex rows=20, TUnsignedIndex cols=20) const
 
 Prune (TScalar reference)
 sets all elements with absolute value <= reference to zero and removes from storage More...
 
 Prune (TScalar reference, TScalar epsilon)
 sets all elements with absolute value <= reference*epsilon to zero and removes from storage More...
 
TUnsignedIndex Rows ()
 
 SetZero ()
 sets the object to zero (clears it)
 
 Swap (SymSparseMatrix other)
 swaps the contents of this object More...
 
 SymSparseMatrix (SymSparseMatrix ar, bool keep_data=true)
 destructor More...
 
 SymSparseMatrix (SymSparseMatrix ar)
 copy constructor More...
 
 SymSparseMatrix (sparse::SparseMatrix ar, bool keep_data=true)
 copy constructor More...
 
SymSparseMatrix Transpose ()
 

Detailed Description

Symmetric sparse matrix class with selfadjoint storage.

This class represents a symmetric sparse matrix. Only the lower triangular part and the diagonal are stored. The upper triangular part is "emulated".

Member Enumeration Documentation

◆ some_enums

enum some_enums

defines Eigen flags to be used for modfying Eigen's algebra operators

Enumerator
EIGENFLAGS 

column major, symmetric, lower triangular

EIGENSYM 

lower triangular

Constructor & Destructor Documentation

◆ SymSparseMatrix() [1/3]

SymSparseMatrix ( SymSparseMatrix  ar,
bool  keep_data = true 
)

destructor

copy constructor

Parameters
arthe source matrix
keep_dataif true, this is a copy constructor. If false, the source matrix will be empty afterwards

◆ SymSparseMatrix() [2/3]

copy constructor

Parameters
arthe source matrix

◆ SymSparseMatrix() [3/3]

SymSparseMatrix ( sparse::SparseMatrix  ar,
bool  keep_data = true 
)

copy constructor

Parameters
arthe source matrix
keep_dataif true, this is a copy constructor. If false, the source matrix will be empty afterwards

Member Function Documentation

◆ __neg__()

SymSparseMatrix __neg__ ( ) const
Returns
returns the unary minus (i.e. B = -A = -(*this)) of this matric

◆ __str__()

char* __str__ ( )

transforms this objects into a string, required by SWIG

Returns
a 0-terminated string

◆ Assign()

Assign ( SymSparseMatrix  other,
bool  keep_data = true 
)

assigns a new matrix to this object

Parameters
otherthe other sparse matrix
keep_dataif false, then the other matrix will be cleared

◆ cast()

Base cast ( ) const
Returns
a reference to this object, casted to the base class

◆ Cols()

TUnsignedIndex Cols ( )
Returns
the number of columns

◆ InnerSize()

TUnsignedIndex InnerSize ( )
Returns
the number of inner elements

◆ NonZeros()

TUnsignedIndex NonZeros ( )
Returns
the number of nonzeros

◆ operator*() [1/4]

Matrix operator* ( Matrix  x) const

overrides the sparsematrix-densematrix product.

Returns
returns the product of *this and another dense matrix
Parameters
xthe other dense matrix

◆ operator*() [2/4]

Matrix operator* ( MatrixBlock  x) const
Returns
returns the product of *this and another dense matrix
Parameters
xthe other dense matrix

◆ operator*() [3/4]

sparse::SparseMatrix operator* ( SymSparseMatrix  x) const
Returns
SparseMatrix returns the product of *this and another symmetric sparse matrix
Parameters
xthe other sparse matrix

◆ operator*() [4/4]

SymSparseMatrix operator* ( number  x) const
Returns
returns the product of *this and a scalar
Parameters
xthe other scalar

◆ operator+()

SymSparseMatrix operator+ ( SymSparseMatrix  x) const
Returns
returns the sum of two sparse matrices
Parameters
xthe other matrix

◆ operator-()

SymSparseMatrix operator- ( SymSparseMatrix  x) const
Returns
returns the subtraction of two sparse matrices
Parameters
xthe other matrix

◆ operator/()

SymSparseMatrix operator/ ( number  x) const
Returns
returns the division of *this by a scalar
Parameters
xthe other sparse matrix

◆ OuterSize()

TUnsignedIndex OuterSize ( )
Returns
the number of sparse column vectors

◆ Print()

Print ( string  format = "%g ",
TUnsignedIndex  rows = 20,
TUnsignedIndex  cols = 20 
) const

prints the sparse matrix up to the given rows and columns (internally a temporary dense matrix will be created)

Parameters
formatthe format of a single element, see printf for details
rowsonly print the first rows rows
colsonly print the first cols columns

◆ Prune() [1/2]

Prune ( TScalar  reference)

sets all elements with absolute value <= reference to zero and removes from storage

Parameters
referencethe reference value (tolerance)

◆ Prune() [2/2]

Prune ( TScalar  reference,
TScalar  epsilon 
)

sets all elements with absolute value <= reference*epsilon to zero and removes from storage

Parameters
referencethe reference value
epsilonepsilon

◆ Rows()

TUnsignedIndex Rows ( )
Returns
the number of rows

◆ Swap()

Swap ( SymSparseMatrix  other)

swaps the contents of this object

Parameters
otherthe other object

◆ Transpose()

SymSparseMatrix Transpose ( )
Returns
the transpose

Connect with Ansys