What is the method of calculating the matrix determinant?

John Carmack uses this approach to calculate the determinant of a 4x4 matrix. From my research, I determined that it begins as a Laplace expansion theorem, and then continues to calculate the 3x3 determinants, which seem to be inconsistent with any work that I read.

    // 2x2 sub-determinants
    float det2_01_01 = mat[0][0] * mat[1][1] - mat[0][1] * mat[1][0];
    float det2_01_02 = mat[0][0] * mat[1][2] - mat[0][2] * mat[1][0];
    float det2_01_03 = mat[0][0] * mat[1][3] - mat[0][3] * mat[1][0];
    float det2_01_12 = mat[0][1] * mat[1][2] - mat[0][2] * mat[1][1];
    float det2_01_13 = mat[0][1] * mat[1][3] - mat[0][3] * mat[1][1];
    float det2_01_23 = mat[0][2] * mat[1][3] - mat[0][3] * mat[1][2];

    // 3x3 sub-determinants
    float det3_201_012 = mat[2][0] * det2_01_12 - mat[2][1] * det2_01_02 + mat[2][2] * det2_01_01;
    float det3_201_013 = mat[2][0] * det2_01_13 - mat[2][1] * det2_01_03 + mat[2][3] * det2_01_01;
    float det3_201_023 = mat[2][0] * det2_01_23 - mat[2][2] * det2_01_03 + mat[2][3] * det2_01_02;
    float det3_201_123 = mat[2][1] * det2_01_23 - mat[2][2] * det2_01_13 + mat[2][3] * det2_01_12;

    return ( - det3_201_123 * mat[3][0] + det3_201_023 * mat[3][1] - det3_201_013 * mat[3][2] + det3_201_012 * mat[3][3] );

Can someone explain to me how this approach works, or tell me a good record that uses the same approach?

Note
If it matters, this matrix has a number of basic meanings.

+3
source share
2 answers

This seems to be a method that involves the use of minors. The mathematical aspect can be found on Wikipedia in

http://en.wikipedia.org/wiki/Determinant#Properties_characterizing_the_determinant

- ( (-1) , ).

+5

,

det(M) = sum(M[0, i] * det(M.minor[0, i]) * (-1)^i)

minor[0, i] - , , 0 - i - , (-1)*i i - -1.

( ) , . , det , . , 2-:

det(M) = M[0, 0] * M[1, 1] * (+1) + M[0, 1] * M[1, 0] * (-1)

, 1, 0,

-det(M) = M[1, 0] * M[0, 1] * (+1) + M[1, 1] * M[0, 0] * (-1)

- 2x2.

, 3-, N = [[a, b, c], [d, e, f], [g, h, i]],

det(N) = a * det([[e, f], [h, i]]) - b * det([[d, f], [g, i]]) + c * det([[d, e], [g, h]])

, ,

a*e*i + b*f*g +  c*d*h - c*e*g - a*f*h - b*d*i

, 2x2.

, 4- X, , det(X) 4- , 3x3; , 6 2x2 . , 3x3 .

+2

Source: https://habr.com/ru/post/1715154/


All Articles