MatrixBlock Class Reference
Last update: 16.07.2025A 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 TScalar * | TBuffer |
| 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 int * | OUTPUT { 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]
| MatrixBlock | ( | ) |
INTERNAL USE!!!!
- Note
- Do never use this constructor. Is needed by SWIG only!
◆ MatrixBlock() [2/4]
| MatrixBlock | ( | MatrixBlock | ar | ) |
destructor,
copy constructor
- Parameters
-
ar the 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
-
x the matrix to be referred to startRow the top left row index startCol the top left column index blockRows the numnber of rows blockCols the numnber of columns
◆ MatrixBlock() [4/4]
| MatrixBlock | ( | Matrix | x | ) |
constructor from full Matrix
- Parameters
-
x the 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
-
other the matrix B
◆ Add() [2/2]
| Add | ( | MatrixBlock | other | ) |
modifies this matrix by the matrix sum A+B
- Parameters
-
other the matrix B
◆ Assign()
| Assign | ( | MatrixBlock | ar | ) |
The assignment operator (copy by value)
- Parameters
-
ar the 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
-
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()
| MatrixBlock Col | ( | TUnsignedIndex | col | ) |
returns a reference to the 'col'th column
- Parameters
-
col the 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
-
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
◆ Div()
| Div | ( | TScalar | other | ) |
modifies this matrix by the scalar matrix quotient A/s
- Parameters
-
other the scalar s
◆ IsApprox() [1/2]
returns true if other and this are approx. identical
- Parameters
-
other the object to be compared s a 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
-
other the object to be compared s a tolerance for the equality test
- Returns
- the result of the operation
◆ IsApproxToConstant()
returns true if array is constant and approx. equal s
- Parameters
-
value the constant value to be compared with s a 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
-
s a 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
-
s a 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
-
s a 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
-
s a 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
-
s a 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
-
s a 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
-
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
◆ Mul()
| Mul | ( | TScalar | other | ) |
modifies this matrix by the scalar matrix product A*s
- Parameters
-
other the scalar s
◆ operator*() [1/3]
returns the matrix product A*B
- Parameters
-
other the matrix B
- Returns
- the result of the operation
◆ operator*() [2/3]
| Matrix operator* | ( | MatrixBlock | other | ) | const |
returns the matrix product A*B
- Parameters
-
other the matrix B
- Returns
- the result of the operation
◆ operator*() [3/3]
returns the scalar matrix product A*s
- Parameters
-
other the scalar s
- Returns
- the result of the operation
◆ operator+() [1/2]
returns the matrix sum A+B
- Parameters
-
other the matrix B
- Returns
- the result of the operation
◆ operator+() [2/2]
| Matrix operator+ | ( | MatrixBlock | other | ) | const |
returns the matrix sum A+B
- Parameters
-
other the matrix B
- Returns
- the result of the operation
◆ operator-() [1/2]
returns the matrix difference A-B
- Parameters
-
other the matrix B
- Returns
- the result of the operation
◆ operator-() [2/2]
| Matrix operator- | ( | MatrixBlock | other | ) | const |
returns the matrix difference A-B
- Parameters
-
other the matrix B
- Returns
- the result of the operation
◆ operator/()
returns the scalar matrix quotient A/s
- Parameters
-
other the scalar s
- Returns
- the result of the operation
◆ operator<()
returns a matrix of 1 and 0 indicating which element is less than x
- Parameters
-
x the scalar x
- Returns
- the result of the operation
◆ Row()
| MatrixBlock Row | ( | TUnsignedIndex | row | ) |
returns a reference to the 'row'th row
- Parameters
-
row the 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
-
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
◆ SetConstant()
| SetConstant | ( | TScalar | value | ) |
initializes the matrix with constant values
- Parameters
-
value the scalar value of the matrix
◆ SetLinearCols()
initializes the matrix with linear columns
- Parameters
-
a the value of the first row b the value of the last row
◆ SetLinearRows()
initializes the matrix with linear rows
- Parameters
-
a the value of the first column b the value of the last column
◆ Sub() [1/2]
| Sub | ( | Matrix | other | ) |
modifies this matrix by the matrix difference A-B
- Parameters
-
other the matrix B
◆ Sub() [2/2]
| Sub | ( | MatrixBlock | other | ) |
modifies this matrix by the matrix difference A-B
- Parameters
-
other the 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
-
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