    

 ## On this page

  

 

 # tmath

 Last update: 16.07.2025 

Math module, providing matrix operations. [More...](#details)

## <a name="nested-classes"></a>Classes

class [Archive](class_archive.xhtml) encapsulates I/O functions for [Matrix](class_matrix.xhtml "Standard matrix class. ") [More...](class_archive.xhtml#details)  
 class [Matrix](class_matrix.xhtml) Standard matrix class. [More...](class_matrix.xhtml#details)  
 class [MatrixBlock](class_matrix_block.xhtml) A generic view onto parts of a [Matrix](class_matrix.xhtml "Standard matrix class. "). [More...](class_matrix_block.xhtml#details)  
 class [MatrixCWise](class_matrix_c_wise.xhtml) coefficient wise access to [Matrix](class_matrix.xhtml "Standard matrix class. ") [More...](class_matrix_c_wise.xhtml#details)  
 class [MatrixEigenSym](class_matrix_eigen_sym.xhtml) Eigen decomposition of symmetric matrices. [More...](class_matrix_eigen_sym.xhtml#details)  
 class [MUMPS](class_m_u_m_p_s.xhtml) solver for sparse matrices using [MUMPS](class_m_u_m_p_s.xhtml "solver for sparse matrices using MUMPS. "). [More...](class_m_u_m_p_s.xhtml#details)  
 class [SparseLU](class_sparse_l_u.xhtml) Base class of LU solvers. It already implements the standard LU decomposition. [More...](class_sparse_l_u.xhtml#details)  
 class [SparseMatrix](class_sparse_matrix.xhtml) encapsulates sparse matrix classes and algorithms [More...](class_sparse_matrix.xhtml#details)  
 class [SparseSolver](class_sparse_solver.xhtml) The base class for sparse solvers. It provides a unified interface which can be used by generic algorithms. [More...](class_sparse_solver.xhtml#details)  
 class [SymSparseMatrix](class_sym_sparse_matrix.xhtml) Symmetric sparse matrix class with selfadjoint storage. [More...](class_sym_sparse_matrix.xhtml#details)  
 struct [TMumpsInterface&lt; float &gt;](struct_t_mumps_interface_3_01float_01_4.xhtml) a wrapper for the single precision [MUMPS](class_m_u_m_p_s.xhtml "solver for sparse matrices using MUMPS. ") C API [More...](struct_t_mumps_interface_3_01float_01_4.xhtml#details)  
 struct [TMumpsInterface&lt; number &gt;](struct_t_mumps_interface_3_01number_01_4.xhtml) a wrapper for the number precision [MUMPS](class_m_u_m_p_s.xhtml "solver for sparse matrices using MUMPS. ") C API [More...](struct_t_mumps_interface_3_01number_01_4.xhtml#details)  
 ## <a name="func-members"></a>Functions

void [CBDraw](group__tmath.xhtml#gaa49df972256db2c65bfbc3c0a9731810) ([Matrix](class_matrix.xhtml) x, [Matrix](class_matrix.xhtml) y, string f, [Matrix](class_matrix.xhtml) colors, int width=512, int height=384, string format="", string range="", string legends="", string title="")  [CBDraw2D](group__tmath.xhtml#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. [More...](#ga7f8225127275c08fbc6d73681002af81)  
 void [CBDrawLines](group__tmath.xhtml#gaa8f4565d42edceed51fab9674b8def24) ([Matrix](class_matrix.xhtml) m, string fi, int width=512, int height=384, bool drawLines=true) void [Colorize](group__tmath.xhtml#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](class_matrix.xhtml "Standard matrix class. ") [More...](#ga7bafa20434f03e5f2f5ea13fd928fd35)  
 <a id="gaa7ede76ecd855ed7006bbe7583ad3d57"></a>void [ComplexDivide](group__tmath.xhtml#gaa7ede76ecd855ed7006bbe7583ad3d57) ([Matrix](class_matrix.xhtml) mr1, [Matrix](class_matrix.xhtml) mi1, [Matrix](class_matrix.xhtml) mr2, [Matrix](class_matrix.xhtml) mi2, [Matrix](class_matrix.xhtml) \*\*ir, [Matrix](class_matrix.xhtml) \*\*ii) Computes the real and imaginary parts of the componentwise quotient of two complex matrices defined by real and imaginary parts.   
 <a id="ga72d273ba4923c03b80197cf1dcc04b3c"></a>void [ComplexDivide](group__tmath.xhtml#ga72d273ba4923c03b80197cf1dcc04b3c) ([Matrix](class_matrix.xhtml) mr1, [Matrix](class_matrix.xhtml) mi1, number mr2, number mi2, [Matrix](class_matrix.xhtml) \*\*ir, [Matrix](class_matrix.xhtml) \*\*ii) Computes the real and imaginary parts of the quotient of a complex matrix defined by real and imaginary parts with a complex number.   
 <a id="gaebc1dcd9b5504daf877773e80c64057c"></a>void [ComplexEigen](group__tmath.xhtml#gaebc1dcd9b5504daf877773e80c64057c) ([Matrix](class_matrix.xhtml) mr1, [Matrix](class_matrix.xhtml) mi1, [Matrix](class_matrix.xhtml) \*\*rval, [Matrix](class_matrix.xhtml) \*\*ival, [Matrix](class_matrix.xhtml) \*\*ir, [Matrix](class_matrix.xhtml) \*\*ii) Computes the eigenvalues and the real and imaginary parts of the eigenvectors of a complex matrix.   
 <a id="gac29f01cdb01836a4173840ba54719e38"></a>void [ComplexFromPolar](group__tmath.xhtml#gac29f01cdb01836a4173840ba54719e38) ([Matrix](class_matrix.xhtml) mr1, [Matrix](class_matrix.xhtml) mi1, [Matrix](class_matrix.xhtml) \*\*ir, [Matrix](class_matrix.xhtml) \*\*ii) Converts magnitude and phase angles into cartesian real and imaginary parts.   
 <a id="ga00d1333d86c6de7425ca5ed27ddf66f5"></a>void [ComplexMultiply](group__tmath.xhtml#ga00d1333d86c6de7425ca5ed27ddf66f5) ([Matrix](class_matrix.xhtml) mr1, [Matrix](class_matrix.xhtml) mi1, [Matrix](class_matrix.xhtml) mr2, [Matrix](class_matrix.xhtml) mi2, [Matrix](class_matrix.xhtml) \*\*ir, [Matrix](class_matrix.xhtml) \*\*ii) Computes the real and imaginary parts of the componentwise product of two complex matrices defined by real and imaginary parts.   
 <a id="ga2d5977396dda4c6111bffe4d56ff3019"></a>void [ComplexMultiply](group__tmath.xhtml#ga2d5977396dda4c6111bffe4d56ff3019) ([Matrix](class_matrix.xhtml) mr1, [Matrix](class_matrix.xhtml) mi1, number mr2, number mi2, [Matrix](class_matrix.xhtml) \*\*ir, [Matrix](class_matrix.xhtml) \*\*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](group__tmath.xhtml#gae3374c79e0aca1cf01013f4406e9207d) ([Matrix](class_matrix.xhtml) mr1, [Matrix](class_matrix.xhtml) mi1, [Matrix](class_matrix.xhtml) mr2, [Matrix](class_matrix.xhtml) mi2, [Matrix](class_matrix.xhtml) \*\*ir, [Matrix](class_matrix.xhtml) \*\*ii) encapsulates complex functions for [Matrix](class_matrix.xhtml "Standard matrix class. ") [More...](#gae3374c79e0aca1cf01013f4406e9207d)  
 <a id="gaf14a0e39b322e46c972b0d68add05390"></a>void [ComplexToPolar](group__tmath.xhtml#gaf14a0e39b322e46c972b0d68add05390) ([Matrix](class_matrix.xhtml) mr1, [Matrix](class_matrix.xhtml) mi1, [Matrix](class_matrix.xhtml) \*\*ir, [Matrix](class_matrix.xhtml) \*\*ii) Converts cartesian real and imaginary parts into magnitude and phase angles.   
 <a id="ga896c7b5610507c57c1ec489101716373"></a>[Matrix](class_matrix.xhtml) **Derivative** ([Matrix](class_matrix.xhtml) m) <a id="gaf8442cb28bb36dbef4fda69d07dc78b5"></a>[Matrix](class_matrix.xhtml) **Derivative** ([Matrix](class_matrix.xhtml) m, number dx) number [Det](group__tmath.xhtml#gac49838cff4d3f24197d0a4eed004ff03) ([MatrixBlock](class_matrix_block.xhtml) mat) encapsulates external functions for linalg objects [More...](#gac49838cff4d3f24197d0a4eed004ff03)  
 [Matrix](class_matrix.xhtml) [Diagonal](group__tmath.xhtml#ga8254292621c5c5c031e0dab39d47dba2) ([MatrixBlock](class_matrix_block.xhtml) mat) <a id="ga47845fbc662aac52b094b18bcff0ca37"></a>[Matrix](class_matrix.xhtml) **Diagonal** (sparse::SparseMatrix mat) <a id="ga16325328218d423f01279bed3b7c8ea1"></a>[Matrix](class_matrix.xhtml) **Diagonal** (sparse::SymSparseMatrix mat) [Matrix](class_matrix.xhtml) [Exp](group__tmath.xhtml#ga785291110e39eac68df81bebd9298eb0) ([Matrix](class_matrix.xhtml) [a](group__tmath.xhtml#ga7e205066f67b9e3fd4c8cbd5859e8da3), number f=1.) number [gamma](group__tmath.xhtml#ga258b7c8fcb4661abd3313383cfefd157) (number z) Compute Gamma function. [More...](#ga258b7c8fcb4661abd3313383cfefd157)  
 number [Gamma](group__tmath.xhtml#ga949984ac3a9530fdeea42b835a2d5b45) (number x) Compute Gamma function. [More...](#ga949984ac3a9530fdeea42b835a2d5b45)  
 number [gauss1\_pdf](group__tmath.xhtml#gadc7ae1340ec592f3a2755fee6d759567) (number x) Compute 1D standard normal density. [More...](#gadc7ae1340ec592f3a2755fee6d759567)  
 number [gauss2\_pdf](group__tmath.xhtml#ga0ee328e3bac7718ae82822aa04f832e5) (number x, number y, number rho) Compute 2D standard normal density. [More...](#ga0ee328e3bac7718ae82822aa04f832e5)  
 number [gaussn\_pdf](group__tmath.xhtml#ga279e096ff4b3a9c446f720ef2eec5238) ([Matrix](class_matrix.xhtml) x, [Matrix](class_matrix.xhtml) \*irho, number detl) Compute n-D standard normal density. [More...](#ga279e096ff4b3a9c446f720ef2eec5238)  
 [Matrix](class_matrix.xhtml) [Identity](group__tmath.xhtml#ga3cd5bc33a164a30ed3d9c58e8b794b05) (number i) creates an identity matrix of dim i\*i [More...](#ga3cd5bc33a164a30ed3d9c58e8b794b05)  
 [Matrix](class_matrix.xhtml) [Identity](group__tmath.xhtml#ga49a26299daa7e413246493723227093a) (number i, number j) creates an identity matrix of dim i\*j [More...](#ga49a26299daa7e413246493723227093a)  
  [Image](group__tmath.xhtml#ga765f84130bec2b716269005d2b1fa7f6) ([Matrix](class_matrix.xhtml) m, string f, int posterize=0, bool bw=false) Write the contents of the matrix to a PNG file. [More...](#ga765f84130bec2b716269005d2b1fa7f6)  
 void [Image](group__tmath.xhtml#gafd263a8b4943d597da69b1a62b894164) ([Matrix](class_matrix.xhtml) m, string f, number min, number max, int posterize=0, bool bw=false) Write the contents of the matrix to a PNG file. [More...](#gafd263a8b4943d597da69b1a62b894164)  
 [Matrix](class_matrix.xhtml) [Log](group__tmath.xhtml#gaa0e8fbd07a9e194f8a8d8b94b215f81c) ([Matrix](class_matrix.xhtml) [a](group__tmath.xhtml#ga7e205066f67b9e3fd4c8cbd5859e8da3), number f=1.) [Matrix](class_matrix.xhtml) [Log10](group__tmath.xhtml#gad71883d114b0992099acdfca78696034) ([Matrix](class_matrix.xhtml) [a](group__tmath.xhtml#ga7e205066f67b9e3fd4c8cbd5859e8da3), number f=1.) [Matrix](class_matrix.xhtml) [MatrixInput](group__tmath.xhtml#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'. [More...](#ga3443715ad367dffa254680cd437524f3)  
 <a id="ga253ab6184b07bc40764db7d9991f8bc4"></a>[Matrix](class_matrix.xhtml) [operator+](group__tmath.xhtml#ga253ab6184b07bc40764db7d9991f8bc4) ([MatrixBlock](class_matrix_block.xhtml) [a](group__tmath.xhtml#ga7e205066f67b9e3fd4c8cbd5859e8da3), [Matrix](class_matrix.xhtml) b) encapsulates external functions for linalg objects   
 <a id="gaa63823a584ef1110dfecb393ce49fd84"></a>[Matrix](class_matrix.xhtml) **operator+** ([Matrix](class_matrix.xhtml) [a](group__tmath.xhtml#ga7e205066f67b9e3fd4c8cbd5859e8da3), sparse::SparseMatrix b) <a id="ga93dbc5aa70076e317977bee8ac1c9cb8"></a>[Matrix](class_matrix.xhtml) **operator+** ([MatrixBlock](class_matrix_block.xhtml) [a](group__tmath.xhtml#ga7e205066f67b9e3fd4c8cbd5859e8da3), sparse::SparseMatrix b) <a id="gaaddb1a62d7f07598484e95467d7b9f9e"></a>[Matrix](class_matrix.xhtml) **operator+** (sparse::SparseMatrix [a](group__tmath.xhtml#ga7e205066f67b9e3fd4c8cbd5859e8da3), [Matrix](class_matrix.xhtml) b) <a id="gaec8910ab6dc0f2b836d7e293c9f0ab39"></a>[Matrix](class_matrix.xhtml) **operator+** (sparse::SparseMatrix [a](group__tmath.xhtml#ga7e205066f67b9e3fd4c8cbd5859e8da3), [MatrixBlock](class_matrix_block.xhtml) b) <a id="ga0754a954461f758e21fdc1e5c4761a57"></a>[Matrix](class_matrix.xhtml) **operator+** ([Matrix](class_matrix.xhtml) [a](group__tmath.xhtml#ga7e205066f67b9e3fd4c8cbd5859e8da3), sparse::SymSparseMatrix b) <a id="ga5381aeac87608b473aa22241ca3083d2"></a>[Matrix](class_matrix.xhtml) **operator+** ([MatrixBlock](class_matrix_block.xhtml) [a](group__tmath.xhtml#ga7e205066f67b9e3fd4c8cbd5859e8da3), sparse::SymSparseMatrix b) <a id="gab961d3a59f182290edc216a4c12edaf6"></a>[Matrix](class_matrix.xhtml) **operator+** (sparse::SymSparseMatrix [a](group__tmath.xhtml#ga7e205066f67b9e3fd4c8cbd5859e8da3), [Matrix](class_matrix.xhtml) b) <a id="ga8cb5b164f84ffe2e115045b40c5c59b4"></a>[Matrix](class_matrix.xhtml) **operator+** (sparse::SymSparseMatrix [a](group__tmath.xhtml#ga7e205066f67b9e3fd4c8cbd5859e8da3), [MatrixBlock](class_matrix_block.xhtml) b) [Matrix](class_matrix.xhtml) [operator-](group__tmath.xhtml#gaf93a891e801b6f578fd9aa0de8a09899) ([MatrixBlock](class_matrix_block.xhtml) [a](group__tmath.xhtml#ga7e205066f67b9e3fd4c8cbd5859e8da3), sparse::SparseMatrix b) <a id="ga70d6abcf2cb58ae41b14b040d96615cc"></a>[Matrix](class_matrix.xhtml) **operator-** (sparse::SparseMatrix [a](group__tmath.xhtml#ga7e205066f67b9e3fd4c8cbd5859e8da3), [Matrix](class_matrix.xhtml) b) <a id="ga16813922bcb89858209b6f569a3325e0"></a>[Matrix](class_matrix.xhtml) **operator-** (sparse::SparseMatrix [a](group__tmath.xhtml#ga7e205066f67b9e3fd4c8cbd5859e8da3), [MatrixBlock](class_matrix_block.xhtml) b) <a id="gac397f4411ba591f625cb766f03c51a04"></a>[Matrix](class_matrix.xhtml) **operator-** ([Matrix](class_matrix.xhtml) [a](group__tmath.xhtml#ga7e205066f67b9e3fd4c8cbd5859e8da3), sparse::SymSparseMatrix b) <a id="ga34afb6a7e9b4bc9ed08a19e21043db6e"></a>[Matrix](class_matrix.xhtml) **operator-** ([MatrixBlock](class_matrix_block.xhtml) [a](group__tmath.xhtml#ga7e205066f67b9e3fd4c8cbd5859e8da3), sparse::SymSparseMatrix b) <a id="ga6523a85fabfa139a828baefe15aee4b3"></a>[Matrix](class_matrix.xhtml) **operator-** (sparse::SymSparseMatrix [a](group__tmath.xhtml#ga7e205066f67b9e3fd4c8cbd5859e8da3), [Matrix](class_matrix.xhtml) b) <a id="gafc294f94834b9d0f5c32f3c2060381a5"></a>[Matrix](class_matrix.xhtml) **operator-** (sparse::SymSparseMatrix [a](group__tmath.xhtml#ga7e205066f67b9e3fd4c8cbd5859e8da3), [MatrixBlock](class_matrix_block.xhtml) b)  [Output](group__tmath.xhtml#ga845278691368936b7c95b17f7d4dd079) ([Matrix](class_matrix.xhtml) m, string f) Write the contents of the matrix to a text file ore binary file. Binary files must have the extension '.bin'. [More...](#ga845278691368936b7c95b17f7d4dd079)  
  [Output](group__tmath.xhtml#ga02eae3c862f19030646a0974f0b11496) ([Matrix](class_matrix.xhtml) m, string file, string name, bool append=true) Write the contents of the matrix to a file containing tng code. [More...](#ga02eae3c862f19030646a0974f0b11496)  
 [Matrix](class_matrix.xhtml) [Pow](group__tmath.xhtml#ga29c4e5931eb3a22e90799834b1b68d7d) ([Matrix](class_matrix.xhtml) [a](group__tmath.xhtml#ga7e205066f67b9e3fd4c8cbd5859e8da3), number f=1.) <a id="gaaed1185dca7f4f097b9134a70bad765a"></a>[Archive](class_archive.xhtml) **ReadArchive** (string file) [Matrix](class_matrix.xhtml) [Sin](group__tmath.xhtml#ga0b1a1930c803fe181176e5c5b4bf4964) ([Matrix](class_matrix.xhtml) [a](group__tmath.xhtml#ga7e205066f67b9e3fd4c8cbd5859e8da3), number f=1.) [Matrix](class_matrix.xhtml) [SortByCol](group__tmath.xhtml#gac6e9e51dc422bfbd9860b4b65f6f7f5f) ([Matrix](class_matrix.xhtml) m, [Matrix](class_matrix.xhtml) cols) Sort a matrix by multiple columns. [More...](#gac6e9e51dc422bfbd9860b4b65f6f7f5f)  
 [Matrix](class_matrix.xhtml) [SortByRow](group__tmath.xhtml#ga73e47f7e59461fc29473284056e37a92) ([Matrix](class_matrix.xhtml) m, number row, bool ascending=true) Sort a matrix by row. [More...](#ga73e47f7e59461fc29473284056e37a92)  
 number [Trace](group__tmath.xhtml#ga27d2b2f675b59ad6c5a313e3945b1d3e) ([MatrixBlock](class_matrix_block.xhtml) mat) returns the trace of the matrix [More...](#ga27d2b2f675b59ad6c5a313e3945b1d3e)  
 number [Trace](group__tmath.xhtml#gad2a507584b6ad3aeb7d74da3ebe47e3a) (sparse::SparseMatrix mat) returns the trace of the matrix [More...](#gad2a507584b6ad3aeb7d74da3ebe47e3a)  
 number [Trace](group__tmath.xhtml#gad49bbc7b61c0c2197290ae6e706d711b) (sparse::SymSparseMatrix mat) returns the trace of the matrix [More...](#gad49bbc7b61c0c2197290ae6e706d711b)  
 [Matrix](class_matrix.xhtml) [ZeroMatrix](group__tmath.xhtml#gae3e484630e8e2705b6d3a9a8bae29f66) (number i, number j) creates a zero matrix [More...](#gae3e484630e8e2705b6d3a9a8bae29f66)  
 [Matrix](class_matrix.xhtml) [ZeroVector](group__tmath.xhtml#ga3f4a03c007e95a28d84f4b41e1d84e4a) (number i) creates a zero column vector [More...](#ga3f4a03c007e95a28d84f4b41e1d84e4a)  
 ## <a name="var-members"></a>Variables

int cbdrawlinecomparefunc \* [a](group__tmath.xhtml#ga7e205066f67b9e3fd4c8cbd5859e8da3) <a id="details" name="details"></a>## Detailed Description

Math module, providing matrix operations.

## Function Documentation

<a id="gaa49df972256db2c65bfbc3c0a9731810"></a>## [◆ ](#gaa49df972256db2c65bfbc3c0a9731810)CBDraw()

 void CBDraw  ( [Matrix](class_matrix.xhtml)  *x*,    [Matrix](class_matrix.xhtml)  *y*,    string  *f*,    [Matrix](class_matrix.xhtml)  *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 xcontains the abscissa and must be one-dimensional (one row or one columns) ycontains the ordinates. formatdefines the labelling of the axes according to CBDraw conventions 



<a id="ga7f8225127275c08fbc6d73681002af81"></a>## [◆ ](#ga7f8225127275c08fbc6d73681002af81)CBDraw2D()

 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 mcontains the ordinates fcontains the file name widthdefines the width of the picture heightdefines the height of the picture formatdefines the labelling of the axes according to CBDraw conventions 



<a id="gaa8f4565d42edceed51fab9674b8def24"></a>## [◆ ](#gaa8f4565d42edceed51fab9674b8def24)CBDrawLines()

 void CBDrawLines  ( [Matrix](class_matrix.xhtml)  *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 mcontains the vertices of the lines ficontains the file name widthdefines the width of the picture heightdefines the height of the picture 



<a id="ga7bafa20434f03e5f2f5ea13fd928fd35"></a>## [◆ ](#ga7bafa20434f03e5f2f5ea13fd928fd35)Colorize()

 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](class_matrix.xhtml "Standard matrix class. ")

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





<a id="gae3374c79e0aca1cf01013f4406e9207d"></a>## [◆ ](#gae3374c79e0aca1cf01013f4406e9207d)ComplexProduct()

 void ComplexProduct  ( [Matrix](class_matrix.xhtml)  *mr1*,    [Matrix](class_matrix.xhtml)  *mi1*,    [Matrix](class_matrix.xhtml)  *mr2*,    [Matrix](class_matrix.xhtml)  *mi2*,    [Matrix](class_matrix.xhtml) \*\*  *ir*,    [Matrix](class_matrix.xhtml) \*\*  *ii*   ) 

encapsulates complex functions for [Matrix](class_matrix.xhtml "Standard matrix class. ")

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





<a id="gac49838cff4d3f24197d0a4eed004ff03"></a>## [◆ ](#gac49838cff4d3f24197d0a4eed004ff03)Det()

 number Det  ( [MatrixBlock](class_matrix_block.xhtml)  *mat*) 

encapsulates external functions for linalg objects

Computes the determinant using LU

Parameters matthe matrix to be processed Returnsthe determinant of *mat* 



<a id="ga8254292621c5c5c031e0dab39d47dba2"></a>## [◆ ](#ga8254292621c5c5c031e0dab39d47dba2)Diagonal()

 [Matrix](class_matrix.xhtml) Diagonal  ( [MatrixBlock](class_matrix_block.xhtml)  *mat*) 

encapsulates external functions for linalg objects





<a id="ga785291110e39eac68df81bebd9298eb0"></a>## [◆ ](#ga785291110e39eac68df81bebd9298eb0)Exp()

 [Matrix](class_matrix.xhtml) Exp  ( [Matrix](class_matrix.xhtml)  *a*,    number  *f* = `1.`   ) 

Returnsa [Matrix](class_matrix.xhtml "Standard matrix class. ") x with coefficientwise x=exp(a\*f) Parameters athe matrix a fthe scalar factor f 



<a id="ga258b7c8fcb4661abd3313383cfefd157"></a>## [◆ ](#ga258b7c8fcb4661abd3313383cfefd157)gamma()

 number gamma  ( number  *z*) 

Compute Gamma function.

Parameters zargument ReturnsGamma(z) 



<a id="ga949984ac3a9530fdeea42b835a2d5b45"></a>## [◆ ](#ga949984ac3a9530fdeea42b835a2d5b45)Gamma()

 number Gamma  ( number  *x*) 

Compute Gamma function.

Parameters xargument ReturnsGamma(x) 



<a id="gadc7ae1340ec592f3a2755fee6d759567"></a>## [◆ ](#gadc7ae1340ec592f3a2755fee6d759567)gauss1\_pdf()

 number gauss1\_pdf  ( number  *x*) 

Compute 1D standard normal density.

Parameters xargument ReturnsPDF 



<a id="ga0ee328e3bac7718ae82822aa04f832e5"></a>## [◆ ](#ga0ee328e3bac7718ae82822aa04f832e5)gauss2\_pdf()

 number gauss2\_pdf  ( number  *x*,    number  *y*,    number  *rho*   ) 

Compute 2D standard normal density.

Parameters xargument 1 yargument 2 rhocorrelation coefficient ReturnsPDF 



<a id="ga279e096ff4b3a9c446f720ef2eec5238"></a>## [◆ ](#ga279e096ff4b3a9c446f720ef2eec5238)gaussn\_pdf()

 number gaussn\_pdf  ( [Matrix](class_matrix.xhtml)  *x*,    [Matrix](class_matrix.xhtml) \*  *irho*,    number  *detl*   ) 

Compute n-D standard normal density.

Parameters xvalues irhoinverse correlation matrix detldeterminant of correlation matrix ReturnsPDF 



<a id="ga3cd5bc33a164a30ed3d9c58e8b794b05"></a>## [◆ ](#ga3cd5bc33a164a30ed3d9c58e8b794b05)Identity() \[1/2\]

 [Matrix](class_matrix.xhtml) Identity  ( number  *i*) 

creates an identity matrix of dim i\*i

Parameters ithe row and column number Returnsa matrix object 



<a id="ga49a26299daa7e413246493723227093a"></a>## [◆ ](#ga49a26299daa7e413246493723227093a)Identity() \[2/2\]

 [Matrix](class_matrix.xhtml) Identity  ( number  *i*,    number  *j*   ) 

creates an identity matrix of dim i\*j

Parameters ithe row number jthe column number Returnsa matrix object 



<a id="ga765f84130bec2b716269005d2b1fa7f6"></a>## [◆ ](#ga765f84130bec2b716269005d2b1fa7f6)Image() \[1/2\]

 Image  ( [Matrix](class_matrix.xhtml)  *m*,    string  *f*,    int  *posterize* = `0`,    bool  *bw* = `false`   ) 

Write the contents of the matrix to a PNG file.

Parameters mcontains the matrix fcontains the file name posterizecontrol the number of different colors actually used. if posterize==0, then colors vary smoothly. 



<a id="gafd263a8b4943d597da69b1a62b894164"></a>## [◆ ](#gafd263a8b4943d597da69b1a62b894164)Image() \[2/2\]

 void Image  ( [Matrix](class_matrix.xhtml)  *m*,    string  *f*,    number  *min*,    number  *max*,    int  *posterize* = `0`,    bool  *bw* = `false`   ) 

Write the contents of the matrix to a PNG file.

Parameters mcontains the matrix fcontains the file name posterizecontrol the number of different colors actually used. if posterize==0, then colors vary smoothly. minandmaxdefine the data range for colors. 



<a id="gaa0e8fbd07a9e194f8a8d8b94b215f81c"></a>## [◆ ](#gaa0e8fbd07a9e194f8a8d8b94b215f81c)Log()

 [Matrix](class_matrix.xhtml) Log  ( [Matrix](class_matrix.xhtml)  *a*,    number  *f* = `1.`   ) 

Returnsa [Matrix](class_matrix.xhtml "Standard matrix class. ") x with coefficientwise x=log(a\*f) (natural log) Parameters athe matrix a fthe scalar factor f 



<a id="gad71883d114b0992099acdfca78696034"></a>## [◆ ](#gad71883d114b0992099acdfca78696034)Log10()

 [Matrix](class_matrix.xhtml) Log10  ( [Matrix](class_matrix.xhtml)  *a*,    number  *f* = `1.`   ) 

Returnsa [Matrix](class_matrix.xhtml "Standard matrix class. ") x with coefficientwise x=log10(a\*f) (log base 10) Parameters athe matrix a fthe scalar factor f 



<a id="ga3443715ad367dffa254680cd437524f3"></a>## [◆ ](#ga3443715ad367dffa254680cd437524f3)MatrixInput()

 [Matrix](class_matrix.xhtml) 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 fcontains the file name Returns[Matrix](class_matrix.xhtml "Standard matrix class. ") containing data on file Parameters skipcontains the number of lines to be skipped at the beginning (for headers etc) 



<a id="gaf93a891e801b6f578fd9aa0de8a09899"></a>## [◆ ](#gaf93a891e801b6f578fd9aa0de8a09899)operator-()

 [Matrix](class_matrix.xhtml) operator-  ( [MatrixBlock](class_matrix_block.xhtml)  *a*,    sparse::SparseMatrix  *b*   ) 

encapsulates external functions for linalg objects





<a id="ga845278691368936b7c95b17f7d4dd079"></a>## [◆ ](#ga845278691368936b7c95b17f7d4dd079)Output() \[1/2\]

 Output  ( [Matrix](class_matrix.xhtml)  *m*,    string  *f*   ) 

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

Parameters mcontains the matrix fcontains the file name 



<a id="ga02eae3c862f19030646a0974f0b11496"></a>## [◆ ](#ga02eae3c862f19030646a0974f0b11496)Output() \[2/2\]

 Output  ( [Matrix](class_matrix.xhtml)  *m*,    string  *file*,    string  *name*,    bool  *append* = `true`   ) 

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

Parameters mcontains the matrix filecontains the file name namecontains the tng matrix object name 



<a id="ga29c4e5931eb3a22e90799834b1b68d7d"></a>## [◆ ](#ga29c4e5931eb3a22e90799834b1b68d7d)Pow()

 [Matrix](class_matrix.xhtml) Pow  ( [Matrix](class_matrix.xhtml)  *a*,    number  *f* = `1.`   ) 

Returnsa [Matrix](class_matrix.xhtml "Standard matrix class. ") x with coefficientwise x=pow(a,f) Parameters athe matrix a fthe scalar factor f 



<a id="ga0b1a1930c803fe181176e5c5b4bf4964"></a>## [◆ ](#ga0b1a1930c803fe181176e5c5b4bf4964)Sin()

 [Matrix](class_matrix.xhtml) Sin  ( [Matrix](class_matrix.xhtml)  *a*,    number  *f* = `1.`   ) 

Returnsa [Matrix](class_matrix.xhtml "Standard matrix class. ") x with coefficientwise x=sin(a\*f) Parameters athe matrix a fthe scalar factor f 



<a id="gac6e9e51dc422bfbd9860b4b65f6f7f5f"></a>## [◆ ](#gac6e9e51dc422bfbd9860b4b65f6f7f5f)SortByCol()

 [Matrix](class_matrix.xhtml) SortByCol  ( [Matrix](class_matrix.xhtml)  *m*,    [Matrix](class_matrix.xhtml)  *cols*   ) 

Sort a matrix by multiple columns.

Parameters m[Matrix](class_matrix.xhtml "Standard matrix class. ") to be sorted colsdefines 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. ReturnsSorted 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 -&gt; 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 



<a id="ga73e47f7e59461fc29473284056e37a92"></a>## [◆ ](#ga73e47f7e59461fc29473284056e37a92)SortByRow()

 [Matrix](class_matrix.xhtml) SortByRow  ( [Matrix](class_matrix.xhtml)  *m*,    number  *row*,    bool  *ascending* = `true`   ) 

Sort a matrix by row.

Parameters m[Matrix](class_matrix.xhtml "Standard matrix class. ") to be sorted rowrow defining sort order ascendingif true then it will be sorted in ascending order, else descending ReturnsSorted matrix 



<a id="ga27d2b2f675b59ad6c5a313e3945b1d3e"></a>## [◆ ](#ga27d2b2f675b59ad6c5a313e3945b1d3e)Trace() \[1/3\]

 number Trace  ( [MatrixBlock](class_matrix_block.xhtml)  *mat*) 

returns the trace of the matrix

encapsulates external functions for linalg objects

Parameters matthe matrix to be analyzed Returnsthe trace (a scalar) 



<a id="gad2a507584b6ad3aeb7d74da3ebe47e3a"></a>## [◆ ](#gad2a507584b6ad3aeb7d74da3ebe47e3a)Trace() \[2/3\]

 number Trace  ( sparse::SparseMatrix  *mat*) 

returns the trace of the matrix

Parameters matthe matrix to be analyzed Returnsthe trace (a scalar) 



<a id="gad49bbc7b61c0c2197290ae6e706d711b"></a>## [◆ ](#gad49bbc7b61c0c2197290ae6e706d711b)Trace() \[3/3\]

 number Trace  ( sparse::SymSparseMatrix  *mat*) 

returns the trace of the matrix

Parameters matthe matrix to be analyzed Returnsthe trace (a scalar) 



<a id="gae3e484630e8e2705b6d3a9a8bae29f66"></a>## [◆ ](#gae3e484630e8e2705b6d3a9a8bae29f66)ZeroMatrix()

 [Matrix](class_matrix.xhtml) ZeroMatrix  ( number  *i*,    number  *j*   ) 

creates a zero matrix

Parameters ithe row number jthe column number Returnsa matrix object 



<a id="ga3f4a03c007e95a28d84f4b41e1d84e4a"></a>## [◆ ](#ga3f4a03c007e95a28d84f4b41e1d84e4a)ZeroVector()

 [Matrix](class_matrix.xhtml) ZeroVector  ( number  *i*) 

creates a zero column vector

Parameters ithe vector dimension Returnsa matrix object 



## Variable Documentation

<a id="ga7e205066f67b9e3fd4c8cbd5859e8da3"></a>## [◆ ](#ga7e205066f67b9e3fd4c8cbd5859e8da3)a

 int cbdrawlinecomparefunc \* a

Compare depth of two objects for writing to CBDraw file

Parameters afirst object bsecond object Returnsinteger containing result of comparison