Skip to content

invert_matrix_modInvertMatrixModInvertMatrixModinvert_matrix_modT_invert_matrix_mod๐Ÿ”—

Short description๐Ÿ”—

invert_matrix_modInvertMatrixModInvertMatrixModinvert_matrix_modT_invert_matrix_mod โ€” Invert a matrix.

Signature๐Ÿ”—

invert_matrix_mod( matrix MatrixID, string MatrixType, real Epsilon )void InvertMatrixMod( const HTuple& MatrixID, const HTuple& MatrixType, const HTuple& Epsilon )static void HOperatorSet.InvertMatrixMod( HTuple matrixID, HTuple matrixType, HTuple epsilon )def invert_matrix_mod( matrix_id: HHandle, matrix_type: str, epsilon: float ) -> None

Herror T_invert_matrix_mod( const Htuple MatrixID, const Htuple MatrixType, const Htuple Epsilon )

void HMatrix::InvertMatrixMod( const HString& MatrixType, double Epsilon ) const

void HMatrix::InvertMatrixMod( const char* MatrixType, double Epsilon ) const

void HMatrix::InvertMatrixMod( const wchar_t* MatrixType, double Epsilon ) const (Windows only)

void HMatrix.InvertMatrixMod( string matrixType, double epsilon )

Description๐Ÿ”—

The operator invert_matrix_modInvertMatrixMod computes the inverse of the Matrix defined by the matrix handle MatrixIDmatrixIDmatrix_id. The input matrix is overwritten with the result. Access to the elements of the matrix is possible e.g., with the operator get_full_matrixGetFullMatrix.

For Epsilonepsilonepsilon = 0, the inverse is computed. The type of the Matrix can be selected via MatrixTypematrixTypematrix_type. The following values are supported: 'general'"general" for general, 'symmetric'"symmetric" for symmetric, 'positive_definite'"positive_definite" for symmetric positive definite, 'tridiagonal'"tridiagonal" for tridiagonal, 'upper_triangular'"upper_triangular" for upper triangular, 'permuted_upper_triangular'"permuted_upper_triangular" for permuted upper triangular, 'lower_triangular'"lower_triangular" for lower triangular, and 'permuted_lower_triangular'"permuted_lower_triangular" for permuted lower triangular matrices.

Example 1:

MatrixTypematrixTypematrix_type = 'general'"general", Epsilonepsilonepsilon = 00

\[\begin{eqnarray*} \texttt{Matrix} = \left[ \begin{array}{rrr} 1.0 & 3.0 & 3.0 \\ 4.0 & 5.0 & 6.0 \\ 5.0 & 5.0 & 7.0 \end{array} \right] \end{eqnarray*}\]
\[\begin{eqnarray*} \to \qquad \texttt{Matrix} = \left[ \begin{array}{rrr} -1.25 & 1.50 & -0.75 \\ -0.50 & 2.00 & -1.50 \\ 1.25 & -2.50 & 1.75 \end{array} \right] \end{eqnarray*}\]

Example 2:

MatrixTypematrixTypematrix_type = 'upper_triangular'"upper_triangular", Epsilonepsilonepsilon = 00

\[\begin{eqnarray*} \texttt{Matrix} = \left[ \begin{array}{rrr} 1.0 & 3.0 & 3.0 \\ 0 & 2.0 & 6.0 \\ 0 & 0 & 10.0 \end{array} \right] \end{eqnarray*}\]
\[\begin{eqnarray*} \to \qquad \texttt{Matrix} = \left[ \begin{array}{rrr} 1.00 & -1.50 & 0.60 \\ 0 & 0.50 & -0.30 \\ 0 & 0 & 0.10 \end{array} \right] \end{eqnarray*}\]

Example 3:

MatrixTypematrixTypematrix_type = 'permuted_upper_triangular'"permuted_upper_triangular", Epsilonepsilonepsilon = 00

\[\begin{eqnarray*} \texttt{Matrix} = \left[ \begin{array}{rrr} 1.0 & 3.0 & 3.0 \\ 0 & 0 & 10.0 \\ 0 & 2.0 & 6.0 \end{array} \right] \end{eqnarray*}\]
\[\begin{eqnarray*} \to \qquad \texttt{Matrix} = \left[ \begin{array}{rrr} 1.00 & -1.50 & 0.60 \\ 0 & 0.50 & -0.30 \\ 0 & 0 & 0.10 \end{array} \right] \end{eqnarray*}\]

For Epsilonepsilonepsilon > 0, the pseudo inverse is computed using a singular value decomposition (SVD). During the computation, all singular values less than the value Epsilonepsilonepsilon \(\times\) 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 MatrixTypematrixTypematrix_type = 'general'"general".

Example:

MatrixTypematrixTypematrix_type = 'general'"general", Epsilonepsilonepsilon = 2.2204e-162.2204e-16

\[\begin{eqnarray*} \texttt{Matrix} = \left[ \begin{array}{rrrr} 3.0 & 1.0 & -2.0 & 5.0 \\ -5.0 & 7.0 & 2.0 & -6.0 \\ -9.0 & -4.0 & 1.0 & 4.0 \end{array} \right] \end{eqnarray*}\]
\[\begin{eqnarray*} \to \qquad \texttt{Matrix} = \left[ \begin{array}{rrr} -0.0021 & -0.0482 & -0.0813 \\ 0.1435 & 0.1137 & -0.0137 \\ -0.0519 & -0.0015 & 0.0028 \\ 0.1518 & 0.0056 & 0.0526 \end{array} \right] \end{eqnarray*}\]

Note: The relative accuracy of the floating point representation of the used data type (double) is Epsilonepsilonepsilon = 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.

Attention๐Ÿ”—

For MatrixTypematrixTypematrix_type = 'symmetric'"symmetric", 'positive_definite'"positive_definite", or 'upper_triangular'"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 MatrixTypematrixTypematrix_type = 'lower_triangular'"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 MatrixTypematrixTypematrix_type = 'tridiagonal'"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_modInvertMatrixMod modifies the content of an already existing matrix.

Execution information๐Ÿ”—

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Processed without parallelization.

This operator modifies the state of the following input parameter:

During execution of this operator, access to the value of this parameter must be synchronized if it is used across multiple threads.

Parameters๐Ÿ”—

MatrixIDmatrixIDmatrix_id (input_control, state is modified) matrix โ†’ (handle)HTuple (HHandle)HMatrix, HTuple (IntPtr)HHandleHtuple (handle)

Matrix handle of the input matrix.

MatrixTypematrixTypematrix_type (input_control) string โ†’ (string)HTuple (HString)HTuple (string)strHtuple (char*)

The type of the input matrix.

Default: 'general'"general"
List of values: 'general', 'lower_triangular', 'permuted_lower_triangular', 'permuted_upper_triangular', 'positive_definite', 'symmetric', 'tridiagonal', 'upper_triangular'"general", "lower_triangular", "permuted_lower_triangular", "permuted_upper_triangular", "positive_definite", "symmetric", "tridiagonal", "upper_triangular"

Epsilonepsilonepsilon (input_control) real โ†’ (real)HTuple (double)HTuple (double)floatHtuple (double)

Type of inversion.

Default: 0.00.0
Suggested values: 0.0, 2.2204e-160.0, 2.2204e-16

Result๐Ÿ”—

If the parameters are valid, the operator invert_matrix_modInvertMatrixMod returns the value 2 (H_MSG_TRUE). If necessary, an exception is raised.

Combinations with other operators๐Ÿ”—

Combinations

Possible predecessors

create_matrixCreateMatrix

Possible successors

get_full_matrixGetFullMatrix, get_value_matrixGetValueMatrix

Alternatives

invert_matrixInvertMatrix

See also

transpose_matrixTransposeMatrix, transpose_matrix_modTransposeMatrixMod

References๐Ÿ”—

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.

Module๐Ÿ”—

Foundation