Compute the sign and logarithm of the determinant of a square invertible matrix.
double matrix::SLogDet(
|
Parameters
sign
[out] Factor by which the determinant can be reconstructed as sign*exp(log_det). For a real matrix, contains the determinant sign. The sign value is zero in case of an error or a singular matrix.
log_det
[out] Calculated value of the logarithm of the determinant. For a singular matrix, log_det is negative infinity.
Return Value
The matrix determinant, as if calculated by the Det method. In case of an error, 0 is returned.
Note
The determinant is calculated by the Gaussian method by reducing the matrix to an upper triangular form. The determinant of an upper triangular matrix is equal to the product of the main diagonal elements. The logarithm of a product is equal to the sum of the logarithms. Therefore, in case of an overflow when calculating the determinant, you can use the SLogDet method.
The determinant value can be reconstructed using the formula det=sign*exp(log_det).
MQL5 example:
void OnStart()
|
Expert log output
det=(-13.10918456377537,2.055678770471468)
|