> ## Documentation Index
> Fetch the complete documentation index at: https://developer.synopsys.com/llms.txt
> Use this file to discover all available pages before exploring further.

# SymSparseMatrix Class Reference

Part of [tmath](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/group__tmath)

Symmetric sparse matrix class with selfadjoint storage.

## Public Types

| Type | Name |
| - | - |
|  typedef Eigen::SparseMatrix\< [TScalar](#ad33f729eda6e45412aac71cee702012f) > | [Base](#a1b5357921e32b1f6d262754172689b02) the underlying Eigen sparse matrix type |
| enum | [some\_enums](#ac260c934c749111f08dbbd4f34fa6b31) \{ [EIGENFLAGS](#ac260c934c749111f08dbbd4f34fa6b31aa3a6b8ca43e2cc4066bcd713dce45946) = Eigen::ColMajor\|Eigen::SelfAdjoint\|Eigen::Lower, [EIGENSYM](#ac260c934c749111f08dbbd4f34fa6b31a8951c38e5eb664af9398881f9a4929c7) = Eigen::Lower } defines Eigen flags to be used for modfying Eigen's algebra operators |
|  typedef Base::Index | [TEigenIndex](#a353dbc81e718cd4640b7c719b512892f) index type for Eigen matrices |
|  typedef number | [TScalar](#ad33f729eda6e45412aac71cee702012f) the data type of the coefficients (real number) |
|  typedef number | [TUnsignedIndex](#ab423d248b103558b5903c702c13335ae) an unsigned index type |

## Public Member Functions

| Type | Name |
| - | - |
| [SymSparseMatrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_sym_sparse_matrix.md) | [\_\_neg\_\_](#a84632b22bf5fafc23544ac244ed7cf4c) () const |
| char \* | [\_\_str\_\_](#adb0255d0035cd7783ce87f41a3cae5cc) () transforms this objects into a string, required by SWIG |
| | [Assign](#a18041cdb9f56d534e804a8663a42f96f) ([SymSparseMatrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_sym_sparse_matrix.md) other, bool keep\_data=true) assigns a new matrix to this object |
| [Base](#a1b5357921e32b1f6d262754172689b02) | [cast](#a3ecd74799c1d759b4b637bde5924e0f6) () const |
| [TUnsignedIndex](#ab423d248b103558b5903c702c13335ae) | [Cols](#a2ec082b93696e449a0eb430f1f00196e) () |
| [TUnsignedIndex](#ab423d248b103558b5903c702c13335ae) | [InnerSize](#a9c5c5e3890bd6be32b732fa324ca0954) () |
| [TUnsignedIndex](#ab423d248b103558b5903c702c13335ae) | [NonZeros](#ac83d198cac5c9247233b7024b3f2742a) () |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | [operator\*](#ac20eea8e7bdf72e549208fcb4ad002f9) ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) x) const |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | [operator\*](#ab20c65b6af96b99b1154078d249d8e38) ([MatrixBlock](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix_block.md) x) const |
| sparse::SparseMatrix | [operator\*](#ace104707c6359044a60cfbe690450f0a) ([SymSparseMatrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_sym_sparse_matrix.md) x) const |
| [SymSparseMatrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_sym_sparse_matrix.md) | [operator\*](#a28f7f66cb52fb2c2f35c4a7bd7ed62bb) (number x) const |
| [SymSparseMatrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_sym_sparse_matrix.md) | [operator+](#ac0c3dd32cb15da921dfec8981f7f4cb4) ([SymSparseMatrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_sym_sparse_matrix.md) x) const |
| [SymSparseMatrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_sym_sparse_matrix.md) | [operator-](#a34b2b4995ec1686198c90c538d0582d0) ([SymSparseMatrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_sym_sparse_matrix.md) x) const |
| [SymSparseMatrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_sym_sparse_matrix.md) | [operator/](#aaf4f97c6a5b85f197dafa600d32fc0dd) (number x) const |
| [TUnsignedIndex](#ab423d248b103558b5903c702c13335ae) | [OuterSize](#ac8a32a382f45637a59b805a83a1399e0) () |
| | [Print](#a6a84471f08e9842cce4e162251b007fd) (string format="%g ", TUnsignedIndex rows=20, [TUnsignedIndex](#ab423d248b103558b5903c702c13335ae) cols=20) const |
| | [Prune](#a611c0976718f1af2c5a0ee6a0f5e34a0) ([TScalar](#ad33f729eda6e45412aac71cee702012f) reference) sets all elements with absolute value \<= reference to zero and removes from storage |
| | [Prune](#a95e65c4fd2e14633c28dc24b75811ef7) ([TScalar](#ad33f729eda6e45412aac71cee702012f) reference, [TScalar](#ad33f729eda6e45412aac71cee702012f) epsilon) sets all elements with absolute value \<= reference\*epsilon to zero and removes from storage |
| [TUnsignedIndex](#ab423d248b103558b5903c702c13335ae) | [Rows](#a3c3320817fc198207404606c52e47fa3) () |
| | [SetZero](#a82fdaa2aa8c930c663007796e9aaa03f) () sets the object to zero (clears it) |
| | [Swap](#afd25d9b25754a820a98a56f5de06f799) ([SymSparseMatrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_sym_sparse_matrix.md) other) swaps the contents of this object |
| | [SymSparseMatrix](#a15b046fc5367041a7f1d20a651404efe) ([SymSparseMatrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_sym_sparse_matrix.md) ar, bool keep\_data=true) destructor |
| | [SymSparseMatrix](#a61ea47d9c774e26f36e076d140804575) ([SymSparseMatrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_sym_sparse_matrix.md) ar) copy constructor |
| | [SymSparseMatrix](#a7130f007f96ca68ce125aceb84e7ecf2) (sparse::SparseMatrix ar, bool keep\_data=true) copy constructor |
| [SymSparseMatrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_sym_sparse_matrix.md) | [Transpose](#afb5bc09a448327c9bf87f011d8715303) () |

## 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

```cpp theme={null}
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]

```cpp theme={null}
SymSparseMatrix(
    SymSparseMatrix ar,
    bool keep_data = true
)
```

destructor

copy constructor

**Parameters**

| Name | Description |
| - | - |
| ar | the source matrix |
| keep\_data | if true, this is a copy constructor. If false, the source matrix will be empty afterwards |

### SymSparseMatrix() \[2/3]

```cpp theme={null}
SymSparseMatrix(SymSparseMatrix ar)
```

copy constructor

**Parameters**

| Name | Description |
| - | - |
| ar | the source matrix |

### SymSparseMatrix() \[3/3]

```cpp theme={null}
SymSparseMatrix(
    sparse::SparseMatrix ar,
    bool keep_data = true
)
```

copy constructor

**Parameters**

| Name | Description |
| - | - |
| ar | the source matrix |
| keep\_data | if true, this is a copy constructor. If false, the source matrix will be empty afterwards |

## Member Function Documentation

### \_\_neg\_\_()

```cpp theme={null}
SymSparseMatrix __neg__() const
```

**Returns**

returns the unary minus (i.e. B = -A = -(\*this)) of this matric

### \_\_str\_\_()

```cpp theme={null}
char* __str__()
```

transforms this objects into a string, required by SWIG

**Returns**

a 0-terminated string

### Assign()

```cpp theme={null}
Assign(
    SymSparseMatrix other,
    bool keep_data = true
)
```

assigns a new matrix to this object

**Parameters**

| Name | Description |
| - | - |
| other | the other sparse matrix |
| keep\_data | if false, then the other matrix will be cleared |

### cast()

```cpp theme={null}
Base cast() const
```

**Returns**

a reference to this object, casted to the base class

### Cols()

```cpp theme={null}
TUnsignedIndex Cols()
```

**Returns**

the number of columns

### InnerSize()

```cpp theme={null}
TUnsignedIndex InnerSize()
```

**Returns**

the number of inner elements

### NonZeros()

```cpp theme={null}
TUnsignedIndex NonZeros()
```

**Returns**

the number of nonzeros

### operator\*() \[1/4]

```cpp theme={null}
Matrix operator*(Matrix x) const
```

overrides the sparsematrix-densematrix product.

**Returns**

returns the product of \*this and another dense matrix

**Parameters**

| Name | Description |
| - | - |
| x | the other dense matrix |

### operator\*() \[2/4]

```cpp theme={null}
Matrix operator*(MatrixBlock x) const
```

**Returns**

returns the product of \*this and another dense matrix

**Parameters**

| Name | Description |
| - | - |
| x | the other dense matrix |

### operator\*() \[3/4]

```cpp theme={null}
sparse::SparseMatrix operator*(SymSparseMatrix x) const
```

**Returns**

[SparseMatrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_sparse_matrix.md) returns the product of \*this and another symmetric sparse matrix

**Parameters**

| Name | Description |
| - | - |
| x | the other sparse matrix |

### operator\*() \[4/4]

```cpp theme={null}
SymSparseMatrix operator*(number x) const
```

**Returns**

returns the product of \*this and a scalar

**Parameters**

| Name | Description |
| - | - |
| x | the other scalar |

### operator+()

```cpp theme={null}
SymSparseMatrix operator+(SymSparseMatrix x) const
```

**Returns**

returns the sum of two sparse matrices

**Parameters**

| Name | Description |
| - | - |
| x | the other matrix |

### operator-()

```cpp theme={null}
SymSparseMatrix operator-(SymSparseMatrix x) const
```

**Returns**

returns the subtraction of two sparse matrices

**Parameters**

| Name | Description |
| - | - |
| x | the other matrix |

### operator/()

```cpp theme={null}
SymSparseMatrix operator/(number x) const
```

**Returns**

returns the division of \*this by a scalar

**Parameters**

| Name | Description |
| - | - |
| x | the other sparse matrix |

### OuterSize()

```cpp theme={null}
TUnsignedIndex OuterSize()
```

**Returns**

the number of sparse column vectors

### Print()

```cpp theme={null}
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**

| Name | Description |
| - | - |
| format | the format of a single element, see *printf* for details |
| rows | only print the first *rows* rows |
| cols | only print the first *cols* columns |

### Prune() \[1/2]

```cpp theme={null}
Prune(TScalar reference)
```

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

**Parameters**

| Name | Description |
| - | - |
| reference | the reference value (tolerance) |

### Prune() \[2/2]

```cpp theme={null}
Prune(
    TScalar reference,
    TScalar epsilon
)
```

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

**Parameters**

| Name | Description |
| - | - |
| reference | the reference value |
| epsilon | epsilon |

### Rows()

```cpp theme={null}
TUnsignedIndex Rows()
```

**Returns**

the number of rows

### Swap()

```cpp theme={null}
Swap(SymSparseMatrix other)
```

swaps the contents of this object

**Parameters**

| Name | Description |
| - | - |
| other | the other object |

### Transpose()

```cpp theme={null}
SymSparseMatrix Transpose()
```

**Returns**

the transpose
