tmath
Last update: 16.07.2025Math module, providing matrix operations. More...
Classes | |
| class | Archive |
| encapsulates I/O functions for Matrix More... | |
| class | Matrix |
| Standard matrix class. More... | |
| class | MatrixBlock |
| A generic view onto parts of a Matrix. More... | |
| class | MatrixCWise |
| coefficient wise access to Matrix More... | |
| class | MatrixEigenSym |
| Eigen decomposition of symmetric matrices. More... | |
| class | MUMPS |
| solver for sparse matrices using MUMPS. More... | |
| class | SparseLU |
| Base class of LU solvers. It already implements the standard LU decomposition. More... | |
| class | SparseMatrix |
| encapsulates sparse matrix classes and algorithms More... | |
| class | SparseSolver |
| The base class for sparse solvers. It provides a unified interface which can be used by generic algorithms. More... | |
| class | SymSparseMatrix |
| Symmetric sparse matrix class with selfadjoint storage. More... | |
| struct | TMumpsInterface< float > |
| a wrapper for the single precision MUMPS C API More... | |
| struct | TMumpsInterface< number > |
| a wrapper for the number precision MUMPS C API More... | |
Functions | |
| void | CBDraw (Matrix x, Matrix y, string f, Matrix colors, int width=512, int height=384, string format="", string range="", string legends="", string title="") |
| 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. More... | |
| void | CBDrawLines (Matrix m, string fi, int width=512, int height=384, bool drawLines=true) |
| 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 More... | |
| void | ComplexDivide (Matrix mr1, Matrix mi1, Matrix mr2, Matrix mi2, Matrix **ir, Matrix **ii) |
| Computes the real and imaginary parts of the componentwise quotient of two complex matrices defined by real and imaginary parts. | |
| void | ComplexDivide (Matrix mr1, Matrix mi1, number mr2, number mi2, Matrix **ir, Matrix **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 (Matrix mr1, Matrix mi1, Matrix **rval, Matrix **ival, Matrix **ir, Matrix **ii) |
| Computes the eigenvalues and the real and imaginary parts of the eigenvectors of a complex matrix. | |
| void | ComplexFromPolar (Matrix mr1, Matrix mi1, Matrix **ir, Matrix **ii) |
| Converts magnitude and phase angles into cartesian real and imaginary parts. | |
| void | ComplexMultiply (Matrix mr1, Matrix mi1, Matrix mr2, Matrix mi2, Matrix **ir, Matrix **ii) |
| Computes the real and imaginary parts of the componentwise product of two complex matrices defined by real and imaginary parts. | |
| void | ComplexMultiply (Matrix mr1, Matrix mi1, number mr2, number mi2, Matrix **ir, Matrix **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 (Matrix mr1, Matrix mi1, Matrix mr2, Matrix mi2, Matrix **ir, Matrix **ii) |
| encapsulates complex functions for Matrix More... | |
| void | ComplexToPolar (Matrix mr1, Matrix mi1, Matrix **ir, Matrix **ii) |
| Converts cartesian real and imaginary parts into magnitude and phase angles. | |
| Matrix | Derivative (Matrix m) |
| Matrix | Derivative (Matrix m, number dx) |
| number | Det (MatrixBlock mat) |
| encapsulates external functions for linalg objects More... | |
| Matrix | Diagonal (MatrixBlock mat) |
| Matrix | Diagonal (sparse::SparseMatrix mat) |
| Matrix | Diagonal (sparse::SymSparseMatrix mat) |
| Matrix | Exp (Matrix a, number f=1.) |
| number | gamma (number z) |
| Compute Gamma function. More... | |
| number | Gamma (number x) |
| Compute Gamma function. More... | |
| number | gauss1_pdf (number x) |
| Compute 1D standard normal density. More... | |
| number | gauss2_pdf (number x, number y, number rho) |
| Compute 2D standard normal density. More... | |
| number | gaussn_pdf (Matrix x, Matrix *irho, number detl) |
| Compute n-D standard normal density. More... | |
| Matrix | Identity (number i) |
| creates an identity matrix of dim i*i More... | |
| Matrix | Identity (number i, number j) |
| creates an identity matrix of dim i*j More... | |
| Image (Matrix m, string f, int posterize=0, bool bw=false) | |
| Write the contents of the matrix to a PNG file. More... | |
| 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. More... | |
| Matrix | Log (Matrix a, number f=1.) |
| Matrix | Log10 (Matrix a, number f=1.) |
| 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'. More... | |
| Matrix | operator+ (MatrixBlock a, Matrix b) |
| encapsulates external functions for linalg objects | |
| Matrix | operator+ (Matrix a, sparse::SparseMatrix b) |
| Matrix | operator+ (MatrixBlock a, sparse::SparseMatrix b) |
| Matrix | operator+ (sparse::SparseMatrix a, Matrix b) |
| Matrix | operator+ (sparse::SparseMatrix a, MatrixBlock b) |
| Matrix | operator+ (Matrix a, sparse::SymSparseMatrix b) |
| Matrix | operator+ (MatrixBlock a, sparse::SymSparseMatrix b) |
| Matrix | operator+ (sparse::SymSparseMatrix a, Matrix b) |
| Matrix | operator+ (sparse::SymSparseMatrix a, MatrixBlock b) |
| Matrix | operator- (MatrixBlock a, sparse::SparseMatrix b) |
| Matrix | operator- (sparse::SparseMatrix a, Matrix b) |
| Matrix | operator- (sparse::SparseMatrix a, MatrixBlock b) |
| Matrix | operator- (Matrix a, sparse::SymSparseMatrix b) |
| Matrix | operator- (MatrixBlock a, sparse::SymSparseMatrix b) |
| Matrix | operator- (sparse::SymSparseMatrix a, Matrix b) |
| Matrix | operator- (sparse::SymSparseMatrix a, MatrixBlock b) |
| 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'. More... | |
| Output (Matrix m, string file, string name, bool append=true) | |
| Write the contents of the matrix to a file containing tng code. More... | |
| Matrix | Pow (Matrix a, number f=1.) |
| Archive | ReadArchive (string file) |
| Matrix | Sin (Matrix a, number f=1.) |
| Matrix | SortByCol (Matrix m, Matrix cols) |
| Sort a matrix by multiple columns. More... | |
| Matrix | SortByRow (Matrix m, number row, bool ascending=true) |
| Sort a matrix by row. More... | |
| number | Trace (MatrixBlock mat) |
| returns the trace of the matrix More... | |
| number | Trace (sparse::SparseMatrix mat) |
| returns the trace of the matrix More... | |
| number | Trace (sparse::SymSparseMatrix mat) |
| returns the trace of the matrix More... | |
| Matrix | ZeroMatrix (number i, number j) |
| creates a zero matrix More... | |
| Matrix | ZeroVector (number i) |
| creates a zero column vector More... | |
Variables | |
| int cbdrawlinecomparefunc * | a |
Detailed Description
Math module, providing matrix operations.
Function Documentation
◆ CBDraw()
| 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
-
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()
| 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
-
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()
| 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
-
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()
| 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
Computes the color values in RGB space for assuming blue for minimum and red for maximum.
◆ ComplexProduct()
encapsulates complex functions for Matrix
Computes the real and imaginary parts of the product of two complex matrices defined by real and imaginary parts.
◆ Det()
| number Det | ( | MatrixBlock | mat | ) |
encapsulates external functions for linalg objects
Computes the determinant using LU
- Parameters
-
mat the matrix to be processed
- Returns
- the determinant of mat
◆ Diagonal()
| Matrix Diagonal | ( | MatrixBlock | mat | ) |
encapsulates external functions for linalg objects
◆ Exp()
- Returns
- a Matrix x with coefficientwise x=exp(a*f)
- Parameters
-
a the matrix a f the scalar factor f
◆ gamma()
| number gamma | ( | number | z | ) |
Compute Gamma function.
- Parameters
-
z argument
- Returns
- Gamma(z)
◆ Gamma()
| number Gamma | ( | number | x | ) |
Compute Gamma function.
- Parameters
-
x argument
- Returns
- Gamma(x)
◆ gauss1_pdf()
| number gauss1_pdf | ( | number | x | ) |
Compute 1D standard normal density.
- Parameters
-
x argument
- Returns
◆ gauss2_pdf()
| number gauss2_pdf | ( | number | x, |
| number | y, | ||
| number | rho | ||
| ) |
Compute 2D standard normal density.
- Parameters
-
x argument 1 y argument 2 rho correlation coefficient
- Returns
◆ gaussn_pdf()
Compute n-D standard normal density.
- Parameters
-
x values irho inverse correlation matrix detl determinant of correlation matrix
- Returns
◆ Identity() [1/2]
| Matrix Identity | ( | number | i | ) |
creates an identity matrix of dim i*i
- Parameters
-
i the row and column number
- Returns
- a matrix object
◆ Identity() [2/2]
| Matrix Identity | ( | number | i, |
| number | j | ||
| ) |
creates an identity matrix of dim i*j
- Parameters
-
i the row number j the column number
- Returns
- a matrix object
◆ Image() [1/2]
| Image | ( | Matrix | m, |
| string | f, | ||
| int | posterize = 0, |
||
| bool | bw = false |
||
| ) |
Write the contents of the matrix to a PNG file.
- Parameters
-
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]
| 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
-
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()
- Returns
- a Matrix x with coefficientwise x=log(a*f) (natural log)
- Parameters
-
a the matrix a f the scalar factor f
◆ Log10()
- Returns
- a Matrix x with coefficientwise x=log10(a*f) (log base 10)
- Parameters
-
a the matrix a f the scalar factor f
◆ MatrixInput()
| 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
-
f contains the file name
- Returns
- Matrix containing data on file
- Parameters
-
skip contains the number of lines to be skipped at the beginning (for headers etc)
◆ operator-()
| Matrix operator- | ( | MatrixBlock | a, |
| sparse::SparseMatrix | b | ||
| ) |
encapsulates external functions for linalg objects
◆ Output() [1/2]
| 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
-
m contains the matrix f contains the file name
◆ Output() [2/2]
| Output | ( | Matrix | m, |
| string | file, | ||
| string | name, | ||
| bool | append = true |
||
| ) |
Write the contents of the matrix to a file containing tng code.
- Parameters
-
m contains the matrix file contains the file name name contains the tng matrix object name
◆ Pow()
- Returns
- a Matrix x with coefficientwise x=pow(a,f)
- Parameters
-
a the matrix a f the scalar factor f
◆ Sin()
- Returns
- a Matrix x with coefficientwise x=sin(a*f)
- Parameters
-
a the matrix a f the scalar factor f
◆ SortByCol()
Sort a matrix by multiple columns.
- Parameters
-
m Matrix 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()
Sort a matrix by row.
- Parameters
-
m Matrix 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]
| number Trace | ( | MatrixBlock | mat | ) |
returns the trace of the matrix
encapsulates external functions for linalg objects
- Parameters
-
mat the matrix to be analyzed
- Returns
- the trace (a scalar)
◆ Trace() [2/3]
| number Trace | ( | sparse::SparseMatrix | mat | ) |
returns the trace of the matrix
- Parameters
-
mat the matrix to be analyzed
- Returns
- the trace (a scalar)
◆ Trace() [3/3]
| number Trace | ( | sparse::SymSparseMatrix | mat | ) |
returns the trace of the matrix
- Parameters
-
mat the matrix to be analyzed
- Returns
- the trace (a scalar)
◆ ZeroMatrix()
| Matrix ZeroMatrix | ( | number | i, |
| number | j | ||
| ) |
creates a zero matrix
- Parameters
-
i the row number j the column number
- Returns
- a matrix object
◆ ZeroVector()
| Matrix ZeroVector | ( | number | i | ) |
creates a zero column vector
- Parameters
-
i the vector dimension
- Returns
- a matrix object
Variable Documentation
◆ a
| int cbdrawlinecomparefunc * a |
Compare depth of two objects for writing to CBDraw file
- Parameters
-
a first object b second object
- Returns
- integer containing result of comparison