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

# tmath

Math module, providing matrix operations.

## Classes

| Type | Name |
| - | - |
| class | [Archive](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_archive.md) encapsulates I/O functions for [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) |
| class | [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) Standard matrix class. |
| class | [MatrixBlock](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix_block.md) A generic view onto parts of a [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md). |
| class | [MatrixCWise](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix_c_wise.md) coefficient wise access to [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) |
| class | [MatrixEigenSym](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix_eigen_sym.md) Eigen decomposition of symmetric matrices. |
| class | [MUMPS](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_m_u_m_p_s.md) solver for sparse matrices using [MUMPS](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_m_u_m_p_s.md). |
| class | [SparseLU](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_sparse_l_u.md) Base class of LU solvers. It already implements the standard LU decomposition. |
| class | [SparseMatrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_sparse_matrix.md) encapsulates sparse matrix classes and algorithms |
| class | [SparseSolver](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_sparse_solver.md) The base class for sparse solvers. It provides a unified interface which can be used by generic algorithms. |
| class | [SymSparseMatrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_sym_sparse_matrix.md) Symmetric sparse matrix class with selfadjoint storage. |
| struct | [TMumpsInterface\< float >](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/struct_t_mumps_interface_3_01float_01_4.md) a wrapper for the single precision [MUMPS](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_m_u_m_p_s.md) C API |
| struct | [TMumpsInterface\< number >](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/struct_t_mumps_interface_3_01number_01_4.md) a wrapper for the number precision [MUMPS](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_m_u_m_p_s.md) C API |

## Functions

| Type | Name |
| - | - |
| void | [CBDraw](#gaa49df972256db2c65bfbc3c0a9731810) ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) x, [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) y, string f, [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) colors, int width=512, int height=384, string format="", string range="", string legends="", string title="") |
| | [CBDraw2D](#ga7f8225127275c08fbc6d73681002af81) (Matrixm, string fi, string frame\_label, string legend\_label, int width=512) Write the contents of the matrix as color plot to a CBDraw file. |
| void | [CBDrawLines](#gaa8f4565d42edceed51fab9674b8def24) ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) m, string fi, int width=512, int height=384, bool drawLines=true) |
| void | [Colorize](#ga7bafa20434f03e5f2f5ea13fd928fd35) (number xmin, number xmax, number val1, int posterize, bool bw, unsigned charr, unsigned char g, unsigned char b) encapsulates I/O functions for [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) |
|  void | [ComplexDivide](#gaa7ede76ecd855ed7006bbe7583ad3d57) ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) mr1, [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) mi1, [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) mr2, [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) mi2, [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) \*\*ir, [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) \*\*ii) Computes the real and imaginary parts of the componentwise quotient of two complex matrices defined by real and imaginary parts. |
|  void | [ComplexDivide](#ga72d273ba4923c03b80197cf1dcc04b3c) ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) mr1, [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) mi1, number mr2, number mi2, [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) \*\*ir, [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) \*\*ii) Computes the real and imaginary parts of the quotient of a complex matrix defined by real and imaginary parts with a complex number. |
|  void | [ComplexEigen](#gaebc1dcd9b5504daf877773e80c64057c) ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) mr1, [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) mi1, [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) \*\*rval, [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) \*\*ival, [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) \*\*ir, [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) \*\*ii) Computes the eigenvalues and the real and imaginary parts of the eigenvectors of a complex matrix. |
|  void | [ComplexFromPolar](#gac29f01cdb01836a4173840ba54719e38) ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) mr1, [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) mi1, [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) \*\*ir, [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) \*\*ii) Converts magnitude and phase angles into cartesian real and imaginary parts. |
|  void | [ComplexMultiply](#ga00d1333d86c6de7425ca5ed27ddf66f5) ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) mr1, [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) mi1, [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) mr2, [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) mi2, [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) \*\*ir, [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) \*\*ii) Computes the real and imaginary parts of the componentwise product of two complex matrices defined by real and imaginary parts. |
|  void | [ComplexMultiply](#ga2d5977396dda4c6111bffe4d56ff3019) ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) mr1, [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) mi1, number mr2, number mi2, [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) \*\*ir, [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) \*\*ii) Computes the real and imaginary parts of the product of a complex matrix defined by real and imaginary parts with a complex number. |
| void | [ComplexProduct](#gae3374c79e0aca1cf01013f4406e9207d) ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) mr1, [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) mi1, [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) mr2, [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) mi2, [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) \*\*ir, [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) \*\*ii) encapsulates complex functions for [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) |
|  void | [ComplexToPolar](#gaf14a0e39b322e46c972b0d68add05390) ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) mr1, [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) mi1, [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) \*\*ir, [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) \*\*ii) Converts cartesian real and imaginary parts into magnitude and phase angles. |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | **Derivative** ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) m) |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | **Derivative** ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) m, number dx) |
| number | [Det](#gac49838cff4d3f24197d0a4eed004ff03) ([MatrixBlock](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix_block.md) mat) encapsulates external functions for linalg objects |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | [Diagonal](#ga8254292621c5c5c031e0dab39d47dba2) ([MatrixBlock](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix_block.md) mat) |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | **Diagonal** (sparse::SparseMatrix mat) |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | **Diagonal** (sparse::SymSparseMatrix mat) |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | [Exp](#ga785291110e39eac68df81bebd9298eb0) ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) [a](#ga7e205066f67b9e3fd4c8cbd5859e8da3), number f=1.) |
| number | [gamma](#ga258b7c8fcb4661abd3313383cfefd157) (number z) Compute Gamma function. |
| number | [Gamma](#ga949984ac3a9530fdeea42b835a2d5b45) (number x) Compute Gamma function. |
| number | [gauss1\_pdf](#gadc7ae1340ec592f3a2755fee6d759567) (number x) Compute 1D standard normal density. |
| number | [gauss2\_pdf](#ga0ee328e3bac7718ae82822aa04f832e5) (number x, number y, number rho) Compute 2D standard normal density. |
| number | [gaussn\_pdf](#ga279e096ff4b3a9c446f720ef2eec5238) ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) x, [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) \*irho, number detl) Compute n-D standard normal density. |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | [Identity](#ga3cd5bc33a164a30ed3d9c58e8b794b05) (number i) creates an identity matrix of dim i\*i |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | [Identity](#ga49a26299daa7e413246493723227093a) (number i, number j) creates an identity matrix of dim i\*j |
| | [Image](#ga765f84130bec2b716269005d2b1fa7f6) ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) m, string f, int posterize=0, bool bw=false) Write the contents of the matrix to a PNG file. |
| void | [Image](#gafd263a8b4943d597da69b1a62b894164) ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) m, string f, number min, number max, int posterize=0, bool bw=false) Write the contents of the matrix to a PNG file. |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | [Log](#gaa0e8fbd07a9e194f8a8d8b94b215f81c) ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) [a](#ga7e205066f67b9e3fd4c8cbd5859e8da3), number f=1.) |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | [Log10](#gad71883d114b0992099acdfca78696034) ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) [a](#ga7e205066f67b9e3fd4c8cbd5859e8da3), number f=1.) |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | [MatrixInput](#ga3443715ad367dffa254680cd437524f3) (string f, int skip=0, string seps="") Reads a matrix from a text file or binary file. Binary files must have the extension '.bin'. |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | [operator+](#ga253ab6184b07bc40764db7d9991f8bc4) ([MatrixBlock](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix_block.md) [a](#ga7e205066f67b9e3fd4c8cbd5859e8da3), [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) b) encapsulates external functions for linalg objects |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | **operator+** ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) [a](#ga7e205066f67b9e3fd4c8cbd5859e8da3), sparse::SparseMatrix b) |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | **operator+** ([MatrixBlock](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix_block.md) [a](#ga7e205066f67b9e3fd4c8cbd5859e8da3), sparse::SparseMatrix b) |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | **operator+** (sparse::SparseMatrix [a](#ga7e205066f67b9e3fd4c8cbd5859e8da3), [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) b) |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | **operator+** (sparse::SparseMatrix [a](#ga7e205066f67b9e3fd4c8cbd5859e8da3), [MatrixBlock](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix_block.md) b) |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | **operator+** ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) [a](#ga7e205066f67b9e3fd4c8cbd5859e8da3), sparse::SymSparseMatrix b) |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | **operator+** ([MatrixBlock](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix_block.md) [a](#ga7e205066f67b9e3fd4c8cbd5859e8da3), sparse::SymSparseMatrix b) |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | **operator+** (sparse::SymSparseMatrix [a](#ga7e205066f67b9e3fd4c8cbd5859e8da3), [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) b) |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | **operator+** (sparse::SymSparseMatrix [a](#ga7e205066f67b9e3fd4c8cbd5859e8da3), [MatrixBlock](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix_block.md) b) |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | [operator-](#gaf93a891e801b6f578fd9aa0de8a09899) ([MatrixBlock](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix_block.md) [a](#ga7e205066f67b9e3fd4c8cbd5859e8da3), sparse::SparseMatrix b) |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | **operator-** (sparse::SparseMatrix [a](#ga7e205066f67b9e3fd4c8cbd5859e8da3), [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) b) |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | **operator-** (sparse::SparseMatrix [a](#ga7e205066f67b9e3fd4c8cbd5859e8da3), [MatrixBlock](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix_block.md) b) |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | **operator-** ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) [a](#ga7e205066f67b9e3fd4c8cbd5859e8da3), sparse::SymSparseMatrix b) |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | **operator-** ([MatrixBlock](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix_block.md) [a](#ga7e205066f67b9e3fd4c8cbd5859e8da3), sparse::SymSparseMatrix b) |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | **operator-** (sparse::SymSparseMatrix [a](#ga7e205066f67b9e3fd4c8cbd5859e8da3), [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) b) |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | **operator-** (sparse::SymSparseMatrix [a](#ga7e205066f67b9e3fd4c8cbd5859e8da3), [MatrixBlock](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix_block.md) b) |
| | [Output](#ga845278691368936b7c95b17f7d4dd079) ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) m, string f) Write the contents of the matrix to a text file ore binary file. Binary files must have the extension '.bin'. |
| | [Output](#ga02eae3c862f19030646a0974f0b11496) ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) m, string file, string name, bool append=true) Write the contents of the matrix to a file containing tng code. |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | [Pow](#ga29c4e5931eb3a22e90799834b1b68d7d) ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) [a](#ga7e205066f67b9e3fd4c8cbd5859e8da3), number f=1.) |
| [Archive](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_archive.md) | **ReadArchive** (string file) |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | [Sin](#ga0b1a1930c803fe181176e5c5b4bf4964) ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) [a](#ga7e205066f67b9e3fd4c8cbd5859e8da3), number f=1.) |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | [SortByCol](#gac6e9e51dc422bfbd9860b4b65f6f7f5f) ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) m, [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) cols) Sort a matrix by multiple columns. |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | [SortByRow](#ga73e47f7e59461fc29473284056e37a92) ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) m, number row, bool ascending=true) Sort a matrix by row. |
| number | [Trace](#ga27d2b2f675b59ad6c5a313e3945b1d3e) ([MatrixBlock](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix_block.md) mat) returns the trace of the matrix |
| number | [Trace](#gad2a507584b6ad3aeb7d74da3ebe47e3a) (sparse::SparseMatrix mat) returns the trace of the matrix |
| number | [Trace](#gad49bbc7b61c0c2197290ae6e706d711b) (sparse::SymSparseMatrix mat) returns the trace of the matrix |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | [ZeroMatrix](#gae3e484630e8e2705b6d3a9a8bae29f66) (number i, number j) creates a zero matrix |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | [ZeroVector](#ga3f4a03c007e95a28d84f4b41e1d84e4a) (number i) creates a zero column vector |

## Variables

| Type | Name |
| - | - |
| int cbdrawlinecomparefunc \* | [a](#ga7e205066f67b9e3fd4c8cbd5859e8da3) |

## Detailed Description

Math module, providing matrix operations.

## Function Documentation

### CBDraw()

```cpp theme={null}
void CBDraw(
    Matrix x,
    Matrix y,
    string f,
    Matrix colors,
    int width = 512,
    int height = 384,
    string format = "",
    string range = "",
    string legends = "",
    string title = ""
)
```

Write the contents of the matrix to a CBDraw file. CBDraw files must have the extension '.cb'.

**Parameters**

| Name | Description |
| - | - |
| x | contains the abscissa and must be one-dimensional (one row or one columns) |
| y | contains the ordinates. |
| format | defines the labelling of the axes according to CBDraw conventions |

### CBDraw2D()

```cpp theme={null}
CBDraw2D(
    Matrixm,
    string fi,
    string frame_label,
    string legend_label,
    int width = 512
)
```

Write the contents of the matrix as color plot to a CBDraw file.

Write the contents of the matrix to a CBDraw file. CBDraw files must have the extension '.cb'. The abscissa is generated from the indices

**Parameters**

| Name | Description |
| - | - |
| m | contains the ordinates |
| f | contains the file name |
| width | defines the width of the picture |
| height | defines the height of the picture |
| format | defines the labelling of the axes according to CBDraw conventions |

### CBDrawLines()

```cpp theme={null}
void CBDrawLines(
    Matrix m,
    string fi,
    int width = 512,
    int height = 384,
    bool drawLines = true
)
```

Write the contents of the matrix as lines to a CBDraw file. CBDraw files must have the extension '.cb'.

**Parameters**

| Name | Description |
| - | - |
| m | contains the vertices of the lines |
| fi | contains the file name |
| width | defines the width of the picture |
| height | defines the height of the picture |

### Colorize()

```cpp theme={null}
void Colorize(
    number xmin,
    number xmax,
    number val1,
    int posterize,
    bool bw,
    unsigned charr,
    unsigned char g,
    unsigned char b
)
```

encapsulates I/O functions for [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md)

Computes the color values in RGB space for assuming blue for minimum and red for maximum.

### ComplexProduct()

```cpp theme={null}
void ComplexProduct(
    Matrix mr1,
    Matrix mi1,
    Matrix mr2,
    Matrix mi2,
    Matrix ** ir,
    Matrix ** ii
)
```

encapsulates complex functions for [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md)

Computes the real and imaginary parts of the product of two complex matrices defined by real and imaginary parts.

### Det()

```cpp theme={null}
number Det(MatrixBlock mat)
```

encapsulates external functions for linalg objects

Computes the determinant using LU

**Parameters**

| Name | Description |
| - | - |
| mat | the matrix to be processed |

**Returns**

the determinant of *mat*

### Diagonal()

```cpp theme={null}
Matrix Diagonal(MatrixBlock mat)
```

encapsulates external functions for linalg objects

### Exp()

```cpp theme={null}
Matrix Exp(
    Matrix a,
    number f = 1.
)
```

**Returns**

a [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) x with coefficientwise x=exp(a\*f)

**Parameters**

| Name | Description |
| - | - |
| a | the matrix a |
| f | the scalar factor f |

### gamma()

```cpp theme={null}
number gamma(number z)
```

Compute Gamma function.

**Parameters**

| Name | Description |
| - | - |
| z | argument |

**Returns**

Gamma(z)

### Gamma()

```cpp theme={null}
number Gamma(number x)
```

Compute Gamma function.

**Parameters**

| Name | Description |
| - | - |
| x | argument |

**Returns**

Gamma(x)

### gauss1\_pdf()

```cpp theme={null}
number gauss1_pdf(number x)
```

Compute 1D standard normal density.

**Parameters**

| Name | Description |
| - | - |
| x | argument |

**Returns**

PDF

### gauss2\_pdf()

```cpp theme={null}
number gauss2_pdf(
    number x,
    number y,
    number rho
)
```

Compute 2D standard normal density.

**Parameters**

| Name | Description |
| - | - |
| x | argument 1 |
| y | argument 2 |
| rho | correlation coefficient |

**Returns**

PDF

### gaussn\_pdf()

```cpp theme={null}
number gaussn_pdf(
    Matrix x,
    Matrix * irho,
    number detl
)
```

Compute n-D standard normal density.

**Parameters**

| Name | Description |
| - | - |
| x | values |
| irho | inverse correlation matrix |
| detl | determinant of correlation matrix |

**Returns**

PDF

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

```cpp theme={null}
Matrix Identity(number i)
```

creates an identity matrix of dim i\*i

**Parameters**

| Name | Description |
| - | - |
| i | the row and column number |

**Returns**

a matrix object

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

```cpp theme={null}
Matrix Identity(
    number i,
    number j
)
```

creates an identity matrix of dim i\*j

**Parameters**

| Name | Description |
| - | - |
| i | the row number |
| j | the column number |

**Returns**

a matrix object

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

```cpp theme={null}
Image(
    Matrix m,
    string f,
    int posterize = 0,
    bool bw = false
)
```

Write the contents of the matrix to a PNG file.

**Parameters**

| Name | Description |
| - | - |
| m | contains the matrix |
| f | contains the file name |
| posterize | control the number of different colors actually used. if posterize==0, then colors vary smoothly. |

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

```cpp theme={null}
void Image(
    Matrix m,
    string f,
    number min,
    number max,
    int posterize = 0,
    bool bw = false
)
```

Write the contents of the matrix to a PNG file.

**Parameters**

| Name | Description |
| - | - |
| m | contains the matrix |
| f | contains the file name |
| posterize | control the number of different colors actually used. if posterize==0, then colors vary smoothly. |
| min | and |
| max | define the data range for colors. |

### Log()

```cpp theme={null}
Matrix Log(
    Matrix a,
    number f = 1.
)
```

**Returns**

a [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) x with coefficientwise x=log(a\*f) (natural log)

**Parameters**

| Name | Description |
| - | - |
| a | the matrix a |
| f | the scalar factor f |

### Log10()

```cpp theme={null}
Matrix Log10(
    Matrix a,
    number f = 1.
)
```

**Returns**

a [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) x with coefficientwise x=log10(a\*f) (log base 10)

**Parameters**

| Name | Description |
| - | - |
| a | the matrix a |
| f | the scalar factor f |

### MatrixInput()

```cpp theme={null}
Matrix MatrixInput(
    string f,
    int skip = 0,
    string seps = ""
)
```

Reads a matrix from a text file or binary file. Binary files must have the extension '.bin'.

**Parameters**

| Name | Description |
| - | - |
| f | contains the file name |

**Returns**

[Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) containing data on file

**Parameters**

| Name | Description |
| - | - |
| skip | contains the number of lines to be skipped at the beginning (for headers etc) |

### operator-()

```cpp theme={null}
Matrix operator-(
    MatrixBlock a,
    sparse::SparseMatrix b
)
```

encapsulates external functions for linalg objects

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

```cpp theme={null}
Output(
    Matrix m,
    string f
)
```

Write the contents of the matrix to a text file ore binary file. Binary files must have the extension '.bin'.

**Parameters**

| Name | Description |
| - | - |
| m | contains the matrix |
| f | contains the file name |

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

```cpp theme={null}
Output(
    Matrix m,
    string file,
    string name,
    bool append = true
)
```

Write the contents of the matrix to a file containing tng code.

**Parameters**

| Name | Description |
| - | - |
| m | contains the matrix |
| file | contains the file name |
| name | contains the tng matrix object name |

### Pow()

```cpp theme={null}
Matrix Pow(
    Matrix a,
    number f = 1.
)
```

**Returns**

a [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) x with coefficientwise x=pow(a,f)

**Parameters**

| Name | Description |
| - | - |
| a | the matrix a |
| f | the scalar factor f |

### Sin()

```cpp theme={null}
Matrix Sin(
    Matrix a,
    number f = 1.
)
```

**Returns**

a [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) x with coefficientwise x=sin(a\*f)

**Parameters**

| Name | Description |
| - | - |
| a | the matrix a |
| f | the scalar factor f |

### SortByCol()

```cpp theme={null}
Matrix SortByCol(
    Matrix m,
    Matrix cols
)
```

Sort a matrix by multiple columns.

**Parameters**

| Name | Description |
| - | - |
| m | [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) to be sorted |
| cols | defines the sort order for the individual columns. Is a vector of size numCols(); The first index is the first index, the last index the last index to sort for. |

**Returns**

Sorted matrix Example: to\_sort: 0 1 2 0 1 1 1 1 2 2 9 9 3 5 8 4 4 4 7 2 5 3 4 3 cols: 1 2 3 0 -> first sort for column #1, then for columns #2, columns #3 and #0 and less important here in this example sorted matrix: 1 1 1 1 0 1 2 0 2 2 9 9 5 3 4 3 4 4 7 2 3 5 8 4

### SortByRow()

```cpp theme={null}
Matrix SortByRow(
    Matrix m,
    number row,
    bool ascending = true
)
```

Sort a matrix by row.

**Parameters**

| Name | Description |
| - | - |
| m | [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) to be sorted |
| row | row defining sort order |
| ascending | if true then it will be sorted in ascending order, else descending |

**Returns**

Sorted matrix

### Trace() \[1/3]

```cpp theme={null}
number Trace(MatrixBlock mat)
```

returns the trace of the matrix

encapsulates external functions for linalg objects

**Parameters**

| Name | Description |
| - | - |
| mat | the matrix to be analyzed |

**Returns**

the trace (a scalar)

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

```cpp theme={null}
number Trace(sparse::SparseMatrix mat)
```

returns the trace of the matrix

**Parameters**

| Name | Description |
| - | - |
| mat | the matrix to be analyzed |

**Returns**

the trace (a scalar)

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

```cpp theme={null}
number Trace(sparse::SymSparseMatrix mat)
```

returns the trace of the matrix

**Parameters**

| Name | Description |
| - | - |
| mat | the matrix to be analyzed |

**Returns**

the trace (a scalar)

### ZeroMatrix()

```cpp theme={null}
Matrix ZeroMatrix(
    number i,
    number j
)
```

creates a zero matrix

**Parameters**

| Name | Description |
| - | - |
| i | the row number |
| j | the column number |

**Returns**

a matrix object

### ZeroVector()

```cpp theme={null}
Matrix ZeroVector(number i)
```

creates a zero column vector

**Parameters**

| Name | Description |
| - | - |
| i | the vector dimension |

**Returns**

a matrix object

## Variable Documentation

### a

```cpp theme={null}
int cbdrawlinecomparefunc * a
```

Compare depth of two objects for writing to CBDraw file

**Parameters**

| Name | Description |
| - | - |
| a | first object |
| b | second object |

**Returns**

integer containing result of comparison
