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

# Matrix Class Reference

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

Standard matrix class.

## Public Types

| Type | Name |
| - | - |
|  typedef Eigen::Matrix\< [TScalar](#ad33f729eda6e45412aac71cee702012f), Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor > | [Base](#a973c5b26a9107f3517a08587cff16bd2) the type of the ancestor class |
|  typedef [TScalar](#ad33f729eda6e45412aac71cee702012f) \* | [TBuffer](#a3541a03e0ef75e0b541a5969c9c998a2) the data type of the dynamic data buffer (pointer) |
|  typedef Base::Index | [TEigenIndex](#a353dbc81e718cd4640b7c719b512892f) index type for Eigen matrices |
|  typedef number | [TScalar](#ad33f729eda6e45412aac71cee702012f) the floating point number type of a mtrix element |
|  typedef number | [TUnsignedIndex](#ab423d248b103558b5903c702c13335ae) an unsigned index type |

## Public Member Functions

| Type | Name |
| - | - |
|  string | **\_\_getstate\_\_** () |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | [\_\_neg\_\_](#a2c73883479858e4c1c7b5f10120d384d) () const |
| | **\_\_setstate\_internal** (string state) |
| char \* | [\_\_str\_\_](#adb0255d0035cd7783ce87f41a3cae5cc) () transforms this objects into a string, required by SWIG |
| | [Add](#aae390486e349048d81ac273eb7aa9670) ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) other) modifies this matrix by the matrix sum A+B |
| | [Add](#a25e0ea5c8f9b3101114cbb16faf410f5) ([MatrixBlock](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix_block.md) other) modifies this matrix by the matrix sum A+B |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | [AddCol](#af4912b06072bc88055919100dd4df444) ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) m) returns an object including new data data |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | **AddRow** ([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) | [AppendCols](#a8d45e6e20e2284a40d69bf343b0b0359) ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) m) returns an object with modified data |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | [AppendRows](#ab43482ffc988b4e4fee38e3f4d7bfe50) ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) m) returns an object with modified data |
| | [Assign](#a087ab2e312c3f5ce4e20173db757fdf8) ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) ar) The assignment operator for matrices (data only) |
| | [Assign](#a6d654d1ab1ea88faee2c64103aec6703) ([MatrixBlock](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix_block.md) ar) The assignment operator for blocks (data only) |
| [MatrixBlock](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix_block.md) | [Block](#a8879d4398a0c2f56fe0fcfd5daa2e2a1) ([TUnsignedIndex](#ab423d248b103558b5903c702c13335ae) row, [TUnsignedIndex](#ab423d248b103558b5903c702c13335ae) col, [TUnsignedIndex](#ab423d248b103558b5903c702c13335ae) numrows, [TUnsignedIndex](#ab423d248b103558b5903c702c13335ae) numcols) returns a reference to a block starting at 'row','column' with size 'numrows'\*'numcols' |
| [MatrixBlock](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix_block.md) | [Col](#a08daeaee307e7a167c01319997a0fdd0) ([TUnsignedIndex](#ab423d248b103558b5903c702c13335ae) col) returns a reference to the 'col'th column |
| [TUnsignedIndex](#ab423d248b103558b5903c702c13335ae) | [Cols](#aeca933e9807a041c96c0ff00dce7fe81) () const |
| [MatrixBlock](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix_block.md) | [Cols](#a68d169caa3b3dbc2d105237205de4816) ([TUnsignedIndex](#ab423d248b103558b5903c702c13335ae) col1, [TUnsignedIndex](#ab423d248b103558b5903c702c13335ae) ncol) returns a block containing the ncol columns starting at column index col1 |
| void | [ConservativeResize](#ab8c24eb13027a50ecf2ab7406af4cc6b) ([TUnsignedIndex](#ab423d248b103558b5903c702c13335ae) rows, [TUnsignedIndex](#ab423d248b103558b5903c702c13335ae) cols=1) resizes the matrix to its new dimensions without destroying the contents. |
| [MatrixCWise](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix_c_wise.md) | [CW](#ae1c2d29afd675d763db255b6fd3362f7) () |
| | [Div](#a2e4ffbe13f1929444cbb608d5b941fb7) ([TScalar](#ad33f729eda6e45412aac71cee702012f) other) modifies this matrix by the scalar matrix quotient A/s |
| [TScalar](#ad33f729eda6e45412aac71cee702012f) | [Dot](#abfed915b7780c75668a49b9c9029e8be) ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) other) returns the scalar product of two vectors (a'b) |
| [TScalar](#ad33f729eda6e45412aac71cee702012f) | [Dot](#aab4bd2af115bd460e3cf5a789dc5108d) ([MatrixBlock](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix_block.md) other) returns the scalar product of two vectors (a'b) |
| [TScalar](#ad33f729eda6e45412aac71cee702012f) | [Dott](#aae92c980182f755faafdac5613004c20) ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) other) returns the weighted scalar product of this matrix and the given vector multiplied once from left and once from right (b'Ab) |
| [TScalar](#ad33f729eda6e45412aac71cee702012f) | [Dott](#a67c5a1cc69b21c0cad7c3765e093840f) ([MatrixBlock](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix_block.md) other) returns the weighted scalar product of this matrix and the given vector multiplied once from left and once from right (b'Ab) |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | [GetCols](#a8e9b9a6341a21706e7ab7fa74d85fb6b) ([TUnsignedIndex](#ab423d248b103558b5903c702c13335ae) col1, [TUnsignedIndex](#ab423d248b103558b5903c702c13335ae) ncol=1) returns an object providing copy of data |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | **GetCols** ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) indices) |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | **GetColsThread** ([TUnsignedIndex](#ab423d248b103558b5903c702c13335ae) col, [TUnsignedIndex](#ab423d248b103558b5903c702c13335ae) ncols) |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | **GetRows** ([TUnsignedIndex](#ab423d248b103558b5903c702c13335ae) row1, [TUnsignedIndex](#ab423d248b103558b5903c702c13335ae) nrow=1) |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | **GetRows** ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) indices) |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | **GetRowsThread** ([TUnsignedIndex](#ab423d248b103558b5903c702c13335ae) row, [TUnsignedIndex](#ab423d248b103558b5903c702c13335ae) nrows) |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | [InnerProduct](#ac9ff4aabff3596abf5955bae04b910ac) ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) other) returns the inner product of two matrices/vectors (a'\*b) |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | [InnerProduct](#ae3959900c4fac029b062c2becab74189) ([MatrixBlock](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix_block.md) other) returns the inner product of two matrices/vectors (a'\*b) |
| bool | [IsApprox](#a5e294708c28b3276177033f775b07959) ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) other, [TScalar](#ad33f729eda6e45412aac71cee702012f) s) const returns true if other and this are approx. identical |
| bool | [IsApproxToConstant](#ac6b5ff21f6e6dace60d84b61dca1be06) ([TScalar](#ad33f729eda6e45412aac71cee702012f) value, [TScalar](#ad33f729eda6e45412aac71cee702012f) s) returns true if array is constant and approx. equal s |
| bool | [IsDiagonal](#a01f5dd6f597e652c42bd3015ad507191) ([TScalar](#ad33f729eda6e45412aac71cee702012f) s) returns true if array is a diagonal matrix by precision s |
| bool | [IsIdentity](#aac69c6571245195e236f0c642c4a4a97) ([TScalar](#ad33f729eda6e45412aac71cee702012f) s) returns true if array is the identity matrix by precision s |
| bool | [IsLowerTriangular](#a52353850b8d700400f021350033e1d1f) ([TScalar](#ad33f729eda6e45412aac71cee702012f) s) returns true if array is a lower triangular matrix by precision s |
| bool | [IsScalar](#a087c6c345ee2a195620c445edce6ac3e) () |
| bool | [IsUnitary](#a532f94f1b94ee8d7c37b5778e665e171) ([TScalar](#ad33f729eda6e45412aac71cee702012f) s) returns true if array is a unitary matrix by precision s (is an orthonormal basis) |
| bool | [IsUpperTriangular](#aaa1b06c2e42742d84cf52d0339718d74) ([TScalar](#ad33f729eda6e45412aac71cee702012f) s) returns true if array is an upper triangular matrix by precision s |
| bool | [IsVector](#a4bf46091a7288ba42f1df85840d905a7) () |
| bool | [IsZero](#aaf6af85eb9b71f6e502c05cef31a4add) ([TScalar](#ad33f729eda6e45412aac71cee702012f) s) |
| | [Matrix](#a3aede62f513da27e6f61ae7a972b4f96) () destructor |
| | [Matrix](#ae5224f99e6ff6e4fb950942127f7e6a7) ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) ar) copy constructor |
| | [Matrix](#a02871da8f44599d14514aa0151bf069e) ([TUnsignedIndex](#ab423d248b103558b5903c702c13335ae) nrow, [TUnsignedIndex](#ab423d248b103558b5903c702c13335ae) ncol=1) constructs a matrix and allocates nrow\*ncol elements |
| | [Matrix](#af6fdd420eadda66bc8985006bc2bf33f) ([MatrixBlock](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix_block.md) x) constructs a matrix from a matrix block |
| | [Matrix](#a0cca63ba6c0409c3ead928e2344df131) (sparse::SparseMatrix x) copies from a sparse matrix |
| | [Matrix](#ab0ed2c94ee6d96d9f03d8e56b3e41730) (sparse::SymSparseMatrix x) copies from a symmetric sparse matrix |
| [TScalar](#ad33f729eda6e45412aac71cee702012f) | **MaxCoeff** ([TEigenIndex](#a353dbc81e718cd4640b7c719b512892f) \*OUTPUT, [TEigenIndex](#a353dbc81e718cd4640b7c719b512892f) \*OUTPUT) const |
| [TScalar](#ad33f729eda6e45412aac71cee702012f) | [MinCoeff](#a2f341a74fe43447f9cd684a645ea55b1) ([TEigenIndex](#a353dbc81e718cd4640b7c719b512892f) \*OUTPUT, [TEigenIndex](#a353dbc81e718cd4640b7c719b512892f) \*OUTPUT) const find the smallest element in the array returns the minimum element in the array |
| | [Mul](#a67ad9262c1ebdd144f96accf0222b777) ([TScalar](#ad33f729eda6e45412aac71cee702012f) other) modifies this matrix by the scalar matrix product A\*s |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | [operator\*](#a29e90840f4d196f9fd74cf8f59b94cb9) ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) other) const returns the matrix product A\*B |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | [operator\*](#a53936030c84cd000ecbf81d5fa6fb005) ([MatrixBlock](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix_block.md) other) const returns the matrix product A\*B |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | [operator\*](#ab37a095452e105c76034aca0303000d9) ([TScalar](#ad33f729eda6e45412aac71cee702012f) other) const returns the scalar matrix product A\*s |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | [operator+](#aab49eb12364bb2a0a4341e884029dfea) ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) other) const returns the matrix sum A+B |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | [operator+](#ae0cebd5d95ee9c112d3e835b1eb2f184) ([MatrixBlock](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix_block.md) other) const returns the matrix sum A+B |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | [operator-](#a2277ad125549453bb0e2e986287ead45) ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) other) const returns the matrix difference A-B |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | [operator-](#adb471a658b8d9f65134fb3ef7163d8c5) ([MatrixBlock](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix_block.md) other) const returns the matrix difference A-B |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | [operator/](#a380ed928adb0f77541239d3ed8a56f43) ([TScalar](#ad33f729eda6e45412aac71cee702012f) other) const returns the scalar matrix quotient A/s |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | [operator\<](#a872a8318f4c9b443d9268a2ac27ece7a) ([TScalar](#ad33f729eda6e45412aac71cee702012f) x) const returns a matrix of 1 and 0 indicating which element is less than x |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | [operator=](#af745b2c8e2616be12145fc40d890125a) ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) ar) copy assignment operator |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | [OuterProduct](#ac64b04d3ca8a4e032beeb4f5eeffeb02) ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) other) returns the outer product of two matrices/vectors (a\*b') |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | [OuterProduct](#ad12dccec7451d37c6d3a5d5dcac42c65) ([MatrixBlock](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix_block.md) other) returns the outer product of two matrices/vectors (a\*b') |
| | [Print](#a6a84471f08e9842cce4e162251b007fd) (string format="%g ", TUnsignedIndex rows=20, [TUnsignedIndex](#ab423d248b103558b5903c702c13335ae) cols=20) const prints the matrix up to the given rows and columns |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | [RemoveCol](#af7053eeaaf953b070ec4c3058f456cf3) ([TUnsignedIndex](#ab423d248b103558b5903c702c13335ae) col) returns an object of corresponding smaller size |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | **RemoveRow** ([TUnsignedIndex](#ab423d248b103558b5903c702c13335ae) row) |
| [MatrixBlock](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix_block.md) | [Row](#a90b7fd2d31acbef1bf30eef064fd5348) ([TUnsignedIndex](#ab423d248b103558b5903c702c13335ae) row) returns a reference to the 'row'th row |
| [TUnsignedIndex](#ab423d248b103558b5903c702c13335ae) | [Rows](#a9bc99715ea9c71ed92be5142140f505c) () const |
| [MatrixBlock](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix_block.md) | [Rows](#a60a48880d61ca9103ae8725dd71980d6) ([TUnsignedIndex](#ab423d248b103558b5903c702c13335ae) row1, [TUnsignedIndex](#ab423d248b103558b5903c702c13335ae) nrow) returns a block containing the nrow columns starting at column index row1 |
| void | [SetCols](#aa01aeb9db4f7058ce09c4cbc03d4ed0e) ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) m, [TUnsignedIndex](#ab423d248b103558b5903c702c13335ae) col) returns an object providing copy of data |
| | **SetColsThread** ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) m, [TUnsignedIndex](#ab423d248b103558b5903c702c13335ae) col) |
| | [SetConstant](#a7e9b8781289e118b3ea0fddfca5626d4) ([TScalar](#ad33f729eda6e45412aac71cee702012f) value) initializes the matrix with constant values |
|  void | [SetIdentity](#a14985545f226fa39181250a3f2616d8f) () initializes the matrix as identity matrix |
| void | [SetLinearCols](#ad075cdbd31856a54e55560db2e051d3a) ([TScalar](#ad33f729eda6e45412aac71cee702012f) [a](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/group__tmath#ga7e205066f67b9e3fd4c8cbd5859e8da3), [TScalar](#ad33f729eda6e45412aac71cee702012f) b) initializes the matrix with linear columns |
| | [SetLinearRows](#af141c5f38b1ec802761d4554daca44e4) ([TScalar](#ad33f729eda6e45412aac71cee702012f) [a](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/group__tmath#ga7e205066f67b9e3fd4c8cbd5859e8da3), [TScalar](#ad33f729eda6e45412aac71cee702012f) b) initializes the matrix with linear rows |
|  void | [SetOnes](#a3c651523d502a1e36640b61815c4e365) () initializes the matrix with constant values "1" |
|  void | [SetRandom](#aec924a4e001d87c82eaa2caad4dc8a74) () initializes the matrix with random values |
|  void | **SetRows** ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) m, [TUnsignedIndex](#ab423d248b103558b5903c702c13335ae) row) |
| | **SetRowsThread** ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) m, [TUnsignedIndex](#ab423d248b103558b5903c702c13335ae) row) |
|  void | [SetZero](#ae57e5aca5db002545e4b9335c8d9dbfa) () initializes the matrix with zeros |
| | [Sub](#a4fbbdfc36bec89e69078091d5e3fc724) ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) other) modifies this matrix by the matrix difference A-B |
| | [Sub](#a8ff14282011c997c57439e80c5e2f624) ([MatrixBlock](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix_block.md) other) modifies this matrix by the matrix difference A-B |
| | [Swap](#a8c07d898b8b4a9af07820bb9ff22ba6e) ([Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) ar) The swap operator for matrices (data only) |
| [Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) | [Transpose](#ada11290ae7810df3f90734047053700b) () const |
|  void | [TransposeInPlace](#a4a19e2c82194b4c92c8a17f7b64469e9) () transposes this matrix |

## Public Attributes

| Type | Name |
| - | - |
| apply | [int](#a0824d20c454aab42f337b2a6c0a81dc2) \{ [TEigenIndex](#a353dbc81e718cd4640b7c719b512892f) } find the largest element in the array returns the maximum element in the array |
|  apply [int](#a0824d20c454aab42f337b2a6c0a81dc2) \* | **OUTPUT** \{ [TEigenIndex](#a353dbc81e718cd4640b7c719b512892f) \*OUTPUT } |

## Detailed Description

Standard matrix class.

A class that represents storage for dense linalg objects.

The storage scheme is column\_major (FORTRAN). It is derived from Eigen::Matrix. Many operations have been added/overwritten for compatibility with scripting requirements. Most operations of Eigen2 are still available.

Basic Eigen linalg operators have been overloaded. To access a linalg operator from C++, for example the matrix product, type

```lua theme={null}
Matrix x,y,z;
...
z = x.Base::operator*(z)
```

This will give you the fastest operation possible within the Eigen library. The overloaded operators have some if-clauses and do not make use of expression templates what may harm performance.

[Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) offers a handling for complex numbers which differs from Eigen: The odd columns are the real parts and the odd columns contain the imaginary parts.

Some of the underlying Eigen methods are available for SWIG. They are not integrated into the error chacking system, though! neverthelesse, ften they are the most efficient methods. To distuingish between Eigen and own methods, the Eigen methods identifiers start with a noncapital first letter, our own methods start with a capital letter.

Operators for SWIG are provided using the methods **add**, etc., The SWIG-operators must be safeguarded, whereas the C++-operators should be the original Eigen2 operators. Therefore they must be defined separately on C++ level.

[Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) is useing a reference counter system. It is advised not to use 'delete [Matrix()](#a3aede62f513da27e6f61ae7a972b4f96);' to remove it from memory, but to use removeReference.

## Constructor & Destructor Documentation

### Matrix() \[1/6]

```cpp theme={null}
Matrix()
```

destructor

default constructor

### Matrix() \[2/6]

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

copy constructor

**Parameters**

| Name | Description |
| - | - |
| ar | the object to be copied |

### Matrix() \[3/6]

```cpp theme={null}
Matrix(
    TUnsignedIndex nrow,
    TUnsignedIndex ncol = 1
)
```

constructs a matrix and allocates nrow\*ncol elements

**Parameters**

| Name | Description |
| - | - |
| nrow | the number of rows |
| ncol | the number of columns |

### Matrix() \[4/6]

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

constructs a matrix from a matrix block

**Parameters**

| Name | Description |
| - | - |
| x | the object to be copied from |

### Matrix() \[5/6]

```cpp theme={null}
Matrix(sparse::SparseMatrix x)
```

copies from a sparse matrix

**Parameters**

| Name | Description |
| - | - |
| x | the object to be copied from |

### Matrix() \[6/6]

```cpp theme={null}
Matrix(sparse::SymSparseMatrix x)
```

copies from a symmetric sparse matrix

**Parameters**

| Name | Description |
| - | - |
| x | the object to be copied from |

## Member Function Documentation

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

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

**Returns**

unary minus (B=-A) Used by SWIG.

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

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

transforms this objects into a string, required by SWIG

**Returns**

a string

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

```cpp theme={null}
Add(Matrix other)
```

modifies this matrix by the matrix sum A+B

**Parameters**

| Name | Description |
| - | - |
| other | the matrix B |

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

```cpp theme={null}
Add(MatrixBlock other)
```

modifies this matrix by the matrix sum A+B

**Parameters**

| Name | Description |
| - | - |
| other | the matrix B |

### AppendCols()

```cpp theme={null}
Matrix AppendCols(Matrix m)
```

returns an object with modified data

**Parameters**

| Name | Description |
| - | - |
| m | the columns to be appended |

**Returns**

[Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) with columns appended

### AppendRows()

```cpp theme={null}
Matrix AppendRows(Matrix m)
```

returns an object with modified data

**Parameters**

| Name | Description |
| - | - |
| m | the rows to be appended |

**Returns**

[Matrix](https://developer.synopsys.com/docs/optislang/optislang-3d-postprocessing-script-api/class_matrix.md) with rows appended

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

```cpp theme={null}
Assign(Matrix ar)
```

The assignment operator for matrices (data only)

**Parameters**

| Name | Description |
| - | - |
| ar | the source object |

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

```cpp theme={null}
Assign(MatrixBlock ar)
```

The assignment operator for blocks (data only)

**Parameters**

| Name | Description |
| - | - |
| ar | the source object |

### Block()

```cpp theme={null}
MatrixBlock Block(
    TUnsignedIndex row,
    TUnsignedIndex col,
    TUnsignedIndex numrows,
    TUnsignedIndex numcols
)
```

returns a reference to a block starting at 'row','column' with size 'numrows'\*'numcols'

**Parameters**

| Name | Description |
| - | - |
| row | the top left row index |
| col | the top left column index |
| numrows | the number of rows of the matrix part |
| numcols | the number of columns of the matrix part |

**Returns**

a matrix block serving as a reference to the specified matrix part

### Col()

```cpp theme={null}
MatrixBlock Col(TUnsignedIndex col)
```

returns a reference to the 'col'th column

**Parameters**

| Name | Description |
| - | - |
| col | the requested column index |

**Returns**

a matrix block serving as a reference to the column

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

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

**Returns**

the number of cols

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

```cpp theme={null}
MatrixBlock Cols(
    TUnsignedIndex col1,
    TUnsignedIndex ncol
)
```

returns a block containing the ncol columns starting at column index col1

**Parameters**

| Name | Description |
| - | - |
| col1 | the left column index |
| ncol | the number of columns of the matrix part |

**Returns**

a matrix block serving as a reference to the specified matrix part

### ConservativeResize()

```cpp theme={null}
void ConservativeResize(
    TUnsignedIndex rows,
    TUnsignedIndex cols = 1
)
```

resizes the matrix to its new dimensions without destroying the contents.

**Parameters**

| Name | Description |
| - | - |
| rows | the number of rows after resize |
| cols | the number of columns after resize Internally it creates a copy of the object (nothing if memory is crucial). |

### CW()

```cpp theme={null}
MatrixCWise CW()
```

**Returns**

an object providing cwise access

### Div()

```cpp theme={null}
Div(TScalar other)
```

modifies this matrix by the scalar matrix quotient A/s

**Parameters**

| Name | Description |
| - | - |
| other | the scalar s |

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

```cpp theme={null}
TScalar Dot(Matrix other)
```

returns the scalar product of two vectors (a'b)

**Parameters**

| Name | Description |
| - | - |
| other | the vector b |

**Returns**

the result of the operation

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

```cpp theme={null}
TScalar Dot(MatrixBlock other)
```

returns the scalar product of two vectors (a'b)

**Parameters**

| Name | Description |
| - | - |
| other | the vector b |

**Returns**

the result of the operation

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

```cpp theme={null}
TScalar Dott(Matrix other)
```

returns the weighted scalar product of this matrix and the given vector multiplied once from left and once from right (b'Ab)

**Parameters**

| Name | Description |
| - | - |
| other | the vector b |

**Returns**

the result of the operation

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

```cpp theme={null}
TScalar Dott(MatrixBlock other)
```

returns the weighted scalar product of this matrix and the given vector multiplied once from left and once from right (b'Ab)

**Parameters**

| Name | Description |
| - | - |
| other | the vector b |

**Returns**

the result of the operation

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

```cpp theme={null}
Matrix InnerProduct(Matrix other)
```

returns the inner product of two matrices/vectors (a'\*b)

**Parameters**

| Name | Description |
| - | - |
| other | the vector/matrix b |

**Returns**

the result of the operation

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

```cpp theme={null}
Matrix InnerProduct(MatrixBlock other)
```

returns the inner product of two matrices/vectors (a'\*b)

**Parameters**

| Name | Description |
| - | - |
| other | the vector/matrix b |

**Returns**

the result of the operation

### IsApprox()

```cpp theme={null}
bool IsApprox(
    Matrix other,
    TScalar s
) const
```

returns true if other and this are approx. identical

**Parameters**

| Name | Description |
| - | - |
| other | the object to be compared |
| s | a tolerance for the equality test |

**Returns**

the result of the operation

### IsApproxToConstant()

```cpp theme={null}
bool IsApproxToConstant(
    TScalar value,
    TScalar s
)
```

returns true if array is constant and approx. equal s

**Parameters**

| Name | Description |
| - | - |
| value | the constant value to be compared with |
| s | a tolerance for the equality test |

**Returns**

the result of the operation

### IsDiagonal()

```cpp theme={null}
bool IsDiagonal(TScalar s)
```

returns true if array is a diagonal matrix by precision s

**Parameters**

| Name | Description |
| - | - |
| s | a tolerance for the test |

**Returns**

the result of the operation

### IsIdentity()

```cpp theme={null}
bool IsIdentity(TScalar s)
```

returns true if array is the identity matrix by precision s

**Parameters**

| Name | Description |
| - | - |
| s | a tolerance for the equality test |

**Returns**

the result of the operation

### IsLowerTriangular()

```cpp theme={null}
bool IsLowerTriangular(TScalar s)
```

returns true if array is a lower triangular matrix by precision s

**Parameters**

| Name | Description |
| - | - |
| s | a tolerance for the equality test |

**Returns**

the result of the operation

### IsScalar()

```cpp theme={null}
bool IsScalar()
```

**Returns**

true if array is a scalar

### IsUnitary()

```cpp theme={null}
bool IsUnitary(TScalar s)
```

returns true if array is a unitary matrix by precision s (is an orthonormal basis)

**Parameters**

| Name | Description |
| - | - |
| s | a tolerance for the equality test |

**Returns**

the result of the operation

### IsUpperTriangular()

```cpp theme={null}
bool IsUpperTriangular(TScalar s)
```

returns true if array is an upper triangular matrix by precision s

**Parameters**

| Name | Description |
| - | - |
| s | a tolerance for the equality test |

**Returns**

the result of the operation

### IsVector()

```cpp theme={null}
bool IsVector()
```

**Returns**

true if array is a vector

### IsZero()

```cpp theme={null}
bool IsZero(TScalar s)
```

**Returns**

true if array is a zero matrix by precision s

**Parameters**

| Name | Description |
| - | - |
| s | a tolerance for the equality test |

### MinCoeff()

```cpp theme={null}
TScalar MinCoeff(
    TEigenIndex * OUTPUT,
    TEigenIndex * OUTPUT
) const
```

find the smallest element in the array returns the minimum element in the array

**Parameters**

| Name | Description |
| - | - |
| row | will be modified and will contain the row position of the found value on return |
| col | will be modified and will contain the column position of the found value on return |

**Returns**

smallest elment

### Mul()

```cpp theme={null}
Mul(TScalar other)
```

modifies this matrix by the scalar matrix product A\*s

**Parameters**

| Name | Description |
| - | - |
| other | the scalar s |

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

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

returns the matrix product A\*B

**Parameters**

| Name | Description |
| - | - |
| other | the matrix B |

**Returns**

the result of the operation

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

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

returns the matrix product A\*B

**Parameters**

| Name | Description |
| - | - |
| other | the matrix B |

**Returns**

the result of the operation

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

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

returns the scalar matrix product A\*s

**Parameters**

| Name | Description |
| - | - |
| other | the scalar s |

**Returns**

the result of the operation

### operator+() \[1/2]

```cpp theme={null}
Matrix operator+(Matrix other) const
```

returns the matrix sum A+B

**Parameters**

| Name | Description |
| - | - |
| other | the matrix B |

**Returns**

the result of the operation

### operator+() \[2/2]

```cpp theme={null}
Matrix operator+(MatrixBlock other) const
```

returns the matrix sum A+B

**Parameters**

| Name | Description |
| - | - |
| other | the matrix B |

**Returns**

the result of the operation

### operator-() \[1/2]

```cpp theme={null}
Matrix operator-(Matrix other) const
```

returns the matrix difference A-B

**Parameters**

| Name | Description |
| - | - |
| other | the matrix B |

**Returns**

the result of the operation

### operator-() \[2/2]

```cpp theme={null}
Matrix operator-(MatrixBlock other) const
```

returns the matrix difference A-B

**Parameters**

| Name | Description |
| - | - |
| other | the matrix B |

**Returns**

the result of the operation

### operator/()

```cpp theme={null}
Matrix operator/(TScalar other) const
```

returns the scalar matrix quotient A/s

**Parameters**

| Name | Description |
| - | - |
| other | the scalar s |

**Returns**

the result of the operation

### operator\<()

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

returns a matrix of 1 and 0 indicating which element is less than x

**Parameters**

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

**Returns**

the result of the operation

### operator=()

```cpp theme={null}
Matrix operator=(Matrix ar)
```

copy assignment operator

**Parameters**

| Name | Description |
| - | - |
| ar | the object to be copy-assigned |

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

```cpp theme={null}
Matrix OuterProduct(Matrix other)
```

returns the outer product of two matrices/vectors (a\*b')

**Parameters**

| Name | Description |
| - | - |
| other | the vector/matrix b |

**Returns**

the result of the operation

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

```cpp theme={null}
Matrix OuterProduct(MatrixBlock other)
```

returns the outer product of two matrices/vectors (a\*b')

**Parameters**

| Name | Description |
| - | - |
| other | the vector/matrix b |

**Returns**

the result of the operation

### Print()

```cpp theme={null}
Print(
    string format = "%g ",
    TUnsignedIndex rows = 20,
    TUnsignedIndex cols = 20
) const
```

prints the matrix up to the given rows and columns

**Parameters**

| Name | Description |
| - | - |
| format | the format according to printf() |
| rows | the maximum number of rows to be printed |
| cols | the maximum number of columns to be printed |

### Row()

```cpp theme={null}
MatrixBlock Row(TUnsignedIndex row)
```

returns a reference to the 'row'th row

**Parameters**

| Name | Description |
| - | - |
| row | the requested row index |

**Returns**

a matrix block serving as a reference to the row

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

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

**Returns**

the number of rows

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

```cpp theme={null}
MatrixBlock Rows(
    TUnsignedIndex row1,
    TUnsignedIndex nrow
)
```

returns a block containing the nrow columns starting at column index row1

**Parameters**

| Name | Description |
| - | - |
| row1 | the right row index |
| nrow | the number of rows of the matrix part |

**Returns**

a matrix block serving as a reference to the specified matrix part

### SetCols()

```cpp theme={null}
void SetCols(
    Matrix m,
    TUnsignedIndex col
)
```

returns an object providing copy of data

changes object data in place

### SetConstant()

```cpp theme={null}
SetConstant(TScalar value)
```

initializes the matrix with constant values

**Parameters**

| Name | Description |
| - | - |
| value | the scalar value of the matrix |

### SetLinearCols()

```cpp theme={null}
void SetLinearCols(
    TScalar a,
    TScalar b
)
```

initializes the matrix with linear columns

**Parameters**

| Name | Description |
| - | - |
| a | the value of the first row |
| b | the value of the last row |

### SetLinearRows()

```cpp theme={null}
SetLinearRows(
    TScalar a,
    TScalar b
)
```

initializes the matrix with linear rows

**Parameters**

| Name | Description |
| - | - |
| a | the value of the first column |
| b | the value of the last column |

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

```cpp theme={null}
Sub(Matrix other)
```

modifies this matrix by the matrix difference A-B

**Parameters**

| Name | Description |
| - | - |
| other | the matrix B |

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

```cpp theme={null}
Sub(MatrixBlock other)
```

modifies this matrix by the matrix difference A-B

**Parameters**

| Name | Description |
| - | - |
| other | the matrix B |

### Swap()

```cpp theme={null}
Swap(Matrix ar)
```

The swap operator for matrices (data only)

**Parameters**

| Name | Description |
| - | - |
| ar | the other object. On output \*this will contain the input value of ar while ar contains the input value of \*this. |

### Transpose()

```cpp theme={null}
Matrix Transpose() const
```

**Returns**

the transpose

## Member Data Documentation

### int

```cpp theme={null}
apply int { TEigenIndex }
```

find the largest element in the array returns the maximum element in the array

**Parameters**

| Name | Description |
| - | - |
| row | will be modified and will contain the row position of the found value on return |
| col | will be modified and will contain the column position of the found value on return |

**Returns**

largest elment
