Skip to main content

optiSLang 3D Postprocessing Script API 2025 R1

MatrixBlock Class Reference

Last update: 16.07.2025

A generic view onto parts of a Matrix. More...

Public Types

typedef Eigen::Block< MatrixBase, Eigen::Dynamic, Eigen::Dynamic > Base
 the type of the ancestor class; here: an Eigen::Block
 
typedef Eigen::Matrix< TScalar, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor > MatrixBase
 the type of the Eigen matrix base class we refer to
 
typedef TScalarTBuffer
 the data type of the dynamic data buffer (pointer)
 
typedef MatrixBase::Index TEigenIndex
 index type for Eigen matrices
 
typedef number TScalar
 the floating point number type of a mtrix element
 
typedef number TUnsignedIndex
 an unsigned index type
 

Public Member Functions

Matrix __neg__ () const
 
char * __str__ ()
 transforms this objects into a string, required by SWIG More...
 
 Add (Matrix other)
 modifies this matrix by the matrix sum A+B More...
 
 Add (MatrixBlock other)
 modifies this matrix by the matrix sum A+B More...
 
 Assign (Matrix ar)
 
 Assign (MatrixBlock ar)
 The assignment operator (copy by value) More...
 
MatrixBlock Block (TUnsignedIndex row, TUnsignedIndex col, TUnsignedIndex numrows, TUnsignedIndex numcols)
 returns a reference to a block starting at 'row','column' with size 'numrows'*'numcols' More...
 
MatrixBlock Col (TUnsignedIndex col)
 returns a reference to the 'col'th column More...
 
TUnsignedIndex Cols () const
 
MatrixBlock Cols (TUnsignedIndex col1, TUnsignedIndex ncol)
 returns a block containing the ncol columns starting at column index col1 More...
 
 Div (TScalar other)
 modifies this matrix by the scalar matrix quotient A/s More...
 
Matrix GetCols (TUnsignedIndex col1, TUnsignedIndex ncol=1)
 returns an object providing copy of data
 
Matrix GetCols (Matrix indices)
 
Matrix GetRows (TUnsignedIndex row1, TUnsignedIndex nrow=1)
 
Matrix GetRows (Matrix indices)
 
bool IsApprox (Matrix other, TScalar s)
 returns true if other and this are approx. identical More...
 
bool IsApprox (MatrixBlock other, TScalar s) const
 returns true if other and this are approx. identical More...
 
bool IsApproxToConstant (TScalar value, TScalar s)
 returns true if array is constant and approx. equal s More...
 
bool IsDiagonal (TScalar s)
 returns true if array is a diagonal matrix by precision s More...
 
bool IsIdentity (TScalar s)
 returns true if array is the identity matrix by precision s More...
 
bool IsLowerTriangular (TScalar s)
 returns true if array is a lower triangular matrix by precision s More...
 
bool IsScalar ()
 
bool IsUnitary (TScalar s)
 returns true if array is a unitary matrix by precision s (is an orthonormal basis) More...
 
bool IsUpperTriangular (TScalar s)
 returns true if array is an upper triangular matrix by precision s More...
 
bool IsVector ()
 
bool IsZero (TScalar s)
 
 MatrixBlock ()
 INTERNAL USE!!!! More...
 
 MatrixBlock (MatrixBlock ar)
 destructor, More...
 
 MatrixBlock (Matrix x, TUnsignedIndex startRow, TUnsignedIndex startCol, TUnsignedIndex blockRows, TUnsignedIndex blockCols)
 constructor from Matrix More...
 
 MatrixBlock (Matrix x)
 constructor from full Matrix More...
 
TScalar MaxCoeff (TEigenIndex *OUTPUT, TEigenIndex *OUTPUT) const
 
TScalar MinCoeff (TEigenIndex *OUTPUT, TEigenIndex *OUTPUT) const
 find the smallest element in the array More...
 
 Mul (TScalar other)
 modifies this matrix by the scalar matrix product A*s More...
 
Matrix operator* (Matrix other) const
 returns the matrix product A*B More...
 
Matrix operator* (MatrixBlock other) const
 returns the matrix product A*B More...
 
Matrix operator* (TScalar other) const
 returns the scalar matrix product A*s More...
 
Matrix operator+ (Matrix other) const
 returns the matrix sum A+B More...
 
Matrix operator+ (MatrixBlock other) const
 returns the matrix sum A+B More...
 
Matrix operator- (Matrix other) const
 returns the matrix difference A-B More...
 
Matrix operator- (MatrixBlock other) const
 returns the matrix difference A-B More...
 
Matrix operator/ (TScalar other) const
 returns the scalar matrix quotient A/s More...
 
Matrix operator< (TScalar x) const
 returns a matrix of 1 and 0 indicating which element is less than x More...
 
MatrixBlock Row (TUnsignedIndex row)
 returns a reference to the 'row'th row More...
 
TUnsignedIndex Rows () const
 
MatrixBlock Rows (TUnsignedIndex row1, TUnsignedIndex nrow)
 returns a block containing the nrow columns starting at column index row1 More...
 
 SetConstant (TScalar value)
 initializes the matrix with constant values More...
 
 SetIdentity ()
 initializes the matrix as identity matrix
 
 SetLinearCols (TScalar a, TScalar b)
 initializes the matrix with linear columns More...
 
 SetLinearRows (TScalar a, TScalar b)
 initializes the matrix with linear rows More...
 
 SetOnes ()
 initializes the matrix with constant values "1"
 
 SetRandom ()
 initializes the matrix with random values
 
 SetZero ()
 initializes the matrix with zeros
 
 Sub (Matrix other)
 modifies this matrix by the matrix difference A-B More...
 
 Sub (MatrixBlock other)
 modifies this matrix by the matrix difference A-B More...
 
Matrix Transpose ()
 

Public Attributes

apply int { TEigenIndex }
 find the largest element in the array More...
 
apply intOUTPUT { TEigenIndex *OUTPUT }
 

Detailed Description

A generic view onto parts of a Matrix.

Objects of this kind do not create a data buffer, but use the data buffer of an existing Matrix object. The object saves the indices of the part of the refered matrix object it refers to (start position and size). A matrix block may represent a view onto

  • the whole matrix
  • columns
  • rows
  • arbitrary submatrices

Matrix blocks themeselves behave like Matrix objects. Most of the operators and some external functions are defined. You can even assign values to the block (which in turn will change the data of the referred matrix).

By using a reference counting system it is guaranteed that the refered object will not be deleted before the MatrixBlock is deleted.

Constructor & Destructor Documentation

◆ MatrixBlock() [1/4]

INTERNAL USE!!!!

Note
Do never use this constructor. Is needed by SWIG only!

◆ MatrixBlock() [2/4]

destructor,

copy constructor

Parameters
arthe matrix block to be copied from (it will refer to the same matrix)

◆ MatrixBlock() [3/4]

MatrixBlock ( Matrix  x,
TUnsignedIndex  startRow,
TUnsignedIndex  startCol,
TUnsignedIndex  blockRows,
TUnsignedIndex  blockCols 
)

constructor from Matrix

Parameters
xthe matrix to be referred to
startRowthe top left row index
startColthe top left column index
blockRowsthe numnber of rows
blockColsthe numnber of columns

◆ MatrixBlock() [4/4]

constructor from full Matrix

Parameters
xthe matrix to be referred to

Member Function Documentation

◆ __neg__()

Matrix __neg__ ( ) const
Returns
unary minus (B=-A) Used by SWIG.

◆ __str__()

char* __str__ ( )

transforms this objects into a string, required by SWIG

Returns
a string

◆ Add() [1/2]

Add ( Matrix  other)

modifies this matrix by the matrix sum A+B

Parameters
otherthe matrix B

◆ Add() [2/2]

Add ( MatrixBlock  other)

modifies this matrix by the matrix sum A+B

Parameters
otherthe matrix B

◆ Assign()

Assign ( MatrixBlock  ar)

The assignment operator (copy by value)

Parameters
arthe input matrix to be read from

◆ Block()

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
rowthe top left row index
colthe top left column index
numrowsthe number of rows of the matrix part
numcolsthe number of columns of the matrix part
Returns
a matrix block serving as a reference to the specified matrix part

◆ Col()

returns a reference to the 'col'th column

Parameters
colthe requested column index
Returns
a matrix block serving as a reference to the column

◆ Cols() [1/2]

TUnsignedIndex Cols ( ) const
Returns
the number of cols

◆ Cols() [2/2]

MatrixBlock Cols ( TUnsignedIndex  col1,
TUnsignedIndex  ncol 
)

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

Parameters
col1the left column index
ncolthe number of columns of the matrix part
Returns
a matrix block serving as a reference to the specified matrix part

◆ Div()

Div ( TScalar  other)

modifies this matrix by the scalar matrix quotient A/s

Parameters
otherthe scalar s

◆ IsApprox() [1/2]

bool IsApprox ( Matrix  other,
TScalar  s 
)

returns true if other and this are approx. identical

Parameters
otherthe object to be compared
sa tolerance for the equality test
Returns
the result of the operation

◆ IsApprox() [2/2]

bool IsApprox ( MatrixBlock  other,
TScalar  s 
) const

returns true if other and this are approx. identical

Parameters
otherthe object to be compared
sa tolerance for the equality test
Returns
the result of the operation

◆ IsApproxToConstant()

bool IsApproxToConstant ( TScalar  value,
TScalar  s 
)

returns true if array is constant and approx. equal s

Parameters
valuethe constant value to be compared with
sa tolerance for the equality test
Returns
the result of the operation

◆ IsDiagonal()

bool IsDiagonal ( TScalar  s)

returns true if array is a diagonal matrix by precision s

Parameters
sa tolerance for the test
Returns
the result of the operation

◆ IsIdentity()

bool IsIdentity ( TScalar  s)

returns true if array is the identity matrix by precision s

Parameters
sa tolerance for the equality test
Returns
the result of the operation

◆ IsLowerTriangular()

bool IsLowerTriangular ( TScalar  s)

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

Parameters
sa tolerance for the equality test
Returns
the result of the operation

◆ IsScalar()

bool IsScalar ( )
Returns
true if array is a scalar

◆ IsUnitary()

bool IsUnitary ( TScalar  s)

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

Parameters
sa tolerance for the equality test
Returns
the result of the operation

◆ IsUpperTriangular()

bool IsUpperTriangular ( TScalar  s)

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

Parameters
sa tolerance for the equality test
Returns
the result of the operation

◆ IsVector()

bool IsVector ( )
Returns
true if array is a vector

◆ IsZero()

bool IsZero ( TScalar  s)
Returns
true if array is a zero matrix by precision s
Parameters
sa tolerance for the equality test

◆ MinCoeff()

TScalar MinCoeff ( TEigenIndex OUTPUT,
TEigenIndex OUTPUT 
) const

find the smallest element in the array

Returns
returns the minimum element in the array
Parameters
rowwill be modified and will contain the row position of the found value on return
colwill be modified and will contain the column position of the found value on return

◆ Mul()

Mul ( TScalar  other)

modifies this matrix by the scalar matrix product A*s

Parameters
otherthe scalar s

◆ operator*() [1/3]

Matrix operator* ( Matrix  other) const

returns the matrix product A*B

Parameters
otherthe matrix B
Returns
the result of the operation

◆ operator*() [2/3]

Matrix operator* ( MatrixBlock  other) const

returns the matrix product A*B

Parameters
otherthe matrix B
Returns
the result of the operation

◆ operator*() [3/3]

Matrix operator* ( TScalar  other) const

returns the scalar matrix product A*s

Parameters
otherthe scalar s
Returns
the result of the operation

◆ operator+() [1/2]

Matrix operator+ ( Matrix  other) const

returns the matrix sum A+B

Parameters
otherthe matrix B
Returns
the result of the operation

◆ operator+() [2/2]

Matrix operator+ ( MatrixBlock  other) const

returns the matrix sum A+B

Parameters
otherthe matrix B
Returns
the result of the operation

◆ operator-() [1/2]

Matrix operator- ( Matrix  other) const

returns the matrix difference A-B

Parameters
otherthe matrix B
Returns
the result of the operation

◆ operator-() [2/2]

Matrix operator- ( MatrixBlock  other) const

returns the matrix difference A-B

Parameters
otherthe matrix B
Returns
the result of the operation

◆ operator/()

Matrix operator/ ( TScalar  other) const

returns the scalar matrix quotient A/s

Parameters
otherthe scalar s
Returns
the result of the operation

◆ operator<()

Matrix operator< ( TScalar  x) const

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

Parameters
xthe scalar x
Returns
the result of the operation

◆ Row()

returns a reference to the 'row'th row

Parameters
rowthe requested row index
Returns
a matrix block serving as a reference to the row

◆ Rows() [1/2]

TUnsignedIndex Rows ( ) const
Returns
the number of rows

◆ Rows() [2/2]

MatrixBlock Rows ( TUnsignedIndex  row1,
TUnsignedIndex  nrow 
)

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

Parameters
row1the right row index
nrowthe number of rows of the matrix part
Returns
a matrix block serving as a reference to the specified matrix part

◆ SetConstant()

SetConstant ( TScalar  value)

initializes the matrix with constant values

Parameters
valuethe scalar value of the matrix

◆ SetLinearCols()

SetLinearCols ( TScalar  a,
TScalar  b 
)

initializes the matrix with linear columns

Parameters
athe value of the first row
bthe value of the last row

◆ SetLinearRows()

SetLinearRows ( TScalar  a,
TScalar  b 
)

initializes the matrix with linear rows

Parameters
athe value of the first column
bthe value of the last column

◆ Sub() [1/2]

Sub ( Matrix  other)

modifies this matrix by the matrix difference A-B

Parameters
otherthe matrix B

◆ Sub() [2/2]

Sub ( MatrixBlock  other)

modifies this matrix by the matrix difference A-B

Parameters
otherthe matrix B

◆ Transpose()

Matrix Transpose ( )
Returns
the transpose

Member Data Documentation

◆ int

apply int { TEigenIndex }

find the largest element in the array

Returns
returns the maximum element in the array
Parameters
rowwill be modified and will contain the row position of the found value on return
colwill be modified and will contain the column position of the found value on return

Connect with Ansys