Operators |
invert_matrix_mod — Invert a matrix.
invert_matrix_mod( : : MatrixID, MatrixType, Epsilon : )
The operator invert_matrix_mod computes the inverse of the Matrix defined by the matrix handle MatrixID. The input matrix is overwritten with the result. Access to the elements of the matrix is possible e.g. with the operator get_full_matrix.
For Epsilon = 0, the inverse is computed. The type of the Matrix can be selected via MatrixType. The following values are supported: 'general' for general, 'symmetric' for symmetric, 'positive_definite' for symmetric positive definite, 'tridiagonal' for tridiagonal, 'upper_triangular' for upper triangular, 'permuted_upper_triangular' for permuted upper triangular, 'lower_triangular' for lower triangular, and 'permuted_lower_triangular' for permuted lower triangular matrices.
Example 1:
/ 1.0 3.0 3.0 \ Matrix = | 4.0 5.0 6.0 | \ 5.0 5.0 7.0 / MatrixType = 'general' Epsilon = 0 / -1.25 1.50 -0.75 \ -> Matrix = | -0.50 2.00 -1.50 | \ 1.25 -2.50 1.75 /
Example 2:
/ 1.0 3.0 3.0 \ Matrix = | 0 2.0 6.0 | \ 0 0 10.0 / MatrixType = 'upper_triangular' Epsilon = 0 / 1.00 -1.50 0.60 \ -> Matrix = | 0 0.50 -0.30 | \ 0 0 0.10 /
Example 3:
/ 1.0 3.0 3.0 \ Matrix = | 0 0 10.0 | \ 0 2.0 6.0 / MatrixType = 'permuted_upper_triangular' Epsilon = 0 / 1.00 -1.50 0.60 \ -> Matrix = | 0 0.50 -0.30 | \ 0 0 0.10 /
For Epsilon > 0, the pseudo inverse is computed using a singular value decomposition (SVD). During the computation, all singular values less than the value Epsilon * the largest singular value are set to 0. For these values no internal division is done to prevent a division by zero. If a square matrix is computed with the SVD algorithm the computation takes more time. The type of the matrix must be set to MatrixType = 'general' .
Example:
/ 3.0 1.0 -2.0 5.0 \ Matrix = | -5.0 7.0 2.0 -6.0 | \ -9.0 -4.0 1.0 4.0 / MatrixType = 'general' Epsilon = 2.2204e-16 / -0.0021 -0.0482 -0.0813 \ | 0.1435 0.1137 -0.0137 | -> MatrixInv = | -0.0519 -0.0015 0.0028 | \ 0.1518 0.0056 0.0526 /
Note: The relative accuracy of the floating point representation of the used data type (double) is Epsilon = 2.2204e-16.
It should be also noted that in the examples there are differences in the meaning of the numbers of the output matrices: The results of the elements are per definition a certain value if the number of this value is shown as an integer number, e.g., 0 or 1. If the number is shown as a floating point number, e.g., 0.0 or 1.0, the value is computed.
For MatrixType = 'symmetric' , 'positive_definite' , or 'upper_triangular' the upper triangular part of the input Matrix must contain the relevant information of the matrix. The strictly lower triangular part of the matrix is not referenced. For MatrixType = 'lower_triangular' the lower triangular part of the input Matrix must contain the relevant information of the matrix. The strictly upper triangular part of the matrix is not referenced. For MatrixType = 'tridiagonal' , only the main diagonal, the superdiagonal, and the subdiagonal of the input Matrix are used. The other parts of the matrix are not referenced. If the referenced part of the input Matrix is not of the specified type, an exception is raised.
invert_matrix_mod modifies the content of an already existing matrix.
Matrix handle of the input matrix.
The type of the input matrix.
Default value: 'general'
List of values: 'general' , 'lower_triangular' , 'permuted_lower_triangular' , 'permuted_upper_triangular' , 'positive_definite' , 'symmetric' , 'tridiagonal' , 'upper_triangular'
Type of inversion.
Default value: 0.0
Suggested values: 0.0, 2.2204e-16
If the parameters are valid, the operator invert_matrix_mod returns the value 2 (H_MSG_TRUE). If necessary, an exception is raised.
get_full_matrix, get_value_matrix
transpose_matrix, transpose_matrix_mod
David Poole: “Linear Algebra: A Modern Introduction”; Thomson;
Belmont; 2006.
Gene H. Golub, Charles F. van Loan: “Matrix Computations”; The
Johns Hopkins University Press; Baltimore and London; 1996.
Foundation
Operators |