Skip to main content

optiSLang 3D Postprocessing Script API 2025 R1

tmath

Last update: 16.07.2025

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

◆ 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

◆ 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
mcontains the vertices of the lines
ficontains the file name
widthdefines the width of the picture
heightdefines 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()

void ComplexProduct ( Matrix  mr1,
Matrix  mi1,
Matrix  mr2,
Matrix  mi2,
Matrix **  ir,
Matrix **  ii 
)

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
matthe matrix to be processed
Returns
the determinant of mat

◆ Diagonal()

Matrix Diagonal ( MatrixBlock  mat)

encapsulates external functions for linalg objects

◆ Exp()

Matrix Exp ( Matrix  a,
number  f = 1. 
)
Returns
a Matrix x with coefficientwise x=exp(a*f)
Parameters
athe matrix a
fthe scalar factor f

◆ gamma()

number gamma ( number  z)

Compute Gamma function.

Parameters
zargument
Returns
Gamma(z)

◆ Gamma()

number Gamma ( number  x)

Compute Gamma function.

Parameters
xargument
Returns
Gamma(x)

◆ gauss1_pdf()

number gauss1_pdf ( number  x)

Compute 1D standard normal density.

Parameters
xargument
Returns
PDF

◆ gauss2_pdf()

number gauss2_pdf ( number  x,
number  y,
number  rho 
)

Compute 2D standard normal density.

Parameters
xargument 1
yargument 2
rhocorrelation coefficient
Returns
PDF

◆ gaussn_pdf()

number gaussn_pdf ( Matrix  x,
Matrix irho,
number  detl 
)

Compute n-D standard normal density.

Parameters
xvalues
irhoinverse correlation matrix
detldeterminant of correlation matrix
Returns
PDF

◆ Identity() [1/2]

Matrix Identity ( number  i)

creates an identity matrix of dim i*i

Parameters
ithe 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
ithe row number
jthe 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
mcontains the matrix
fcontains the file name
posterizecontrol 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
mcontains the matrix
fcontains the file name
posterizecontrol the number of different colors actually used. if posterize==0, then colors vary smoothly.
minand
maxdefine the data range for colors.

◆ Log()

Matrix Log ( Matrix  a,
number  f = 1. 
)
Returns
a Matrix x with coefficientwise x=log(a*f) (natural log)
Parameters
athe matrix a
fthe scalar factor f

◆ Log10()

Matrix Log10 ( Matrix  a,
number  f = 1. 
)
Returns
a Matrix x with coefficientwise x=log10(a*f) (log base 10)
Parameters
athe matrix a
fthe 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
fcontains the file name
Returns
Matrix containing data on file
Parameters
skipcontains 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
mcontains the matrix
fcontains 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
mcontains the matrix
filecontains the file name
namecontains the tng matrix object name

◆ Pow()

Matrix Pow ( Matrix  a,
number  f = 1. 
)
Returns
a Matrix x with coefficientwise x=pow(a,f)
Parameters
athe matrix a
fthe scalar factor f

◆ Sin()

Matrix Sin ( Matrix  a,
number  f = 1. 
)
Returns
a Matrix x with coefficientwise x=sin(a*f)
Parameters
athe matrix a
fthe scalar factor f

◆ SortByCol()

Matrix SortByCol ( Matrix  m,
Matrix  cols 
)

Sort a matrix by multiple columns.

Parameters
mMatrix 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.
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()

Matrix SortByRow ( Matrix  m,
number  row,
bool  ascending = true 
)

Sort a matrix by row.

Parameters
mMatrix to be sorted
rowrow defining sort order
ascendingif 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
matthe matrix to be analyzed
Returns
the trace (a scalar)

◆ Trace() [2/3]

number Trace ( sparse::SparseMatrix  mat)

returns the trace of the matrix

Parameters
matthe matrix to be analyzed
Returns
the trace (a scalar)

◆ Trace() [3/3]

number Trace ( sparse::SymSparseMatrix  mat)

returns the trace of the matrix

Parameters
matthe matrix to be analyzed
Returns
the trace (a scalar)

◆ ZeroMatrix()

Matrix ZeroMatrix ( number  i,
number  j 
)

creates a zero matrix

Parameters
ithe row number
jthe column number
Returns
a matrix object

◆ ZeroVector()

Matrix ZeroVector ( number  i)

creates a zero column vector

Parameters
ithe vector dimension
Returns
a matrix object

Variable Documentation

◆ a

int cbdrawlinecomparefunc * a

Compare depth of two objects for writing to CBDraw file

Parameters
afirst object
bsecond object
Returns
integer containing result of comparison

Connect with Ansys