b2ac/ext/src/Eigenmethods_double.c
double matrixInverse3by3_double(double *A, double *inverse)
{
    // First row of adjugate A
    inverse[0] = (A[4] * A[8] - A[7] * A[5]);  // Det #0
    inverse[1] = -(A[1] * A[8] - A[7] * A[2]);
    inverse[2] = (A[1] * A[5] - A[4] * A[2]);

    // Second row of adjugate A
    inverse[3] = -(A[3] * A[8] - A[6] * A[5]);  // Det #1
    inverse[4] = (A[0] * A[8] - A[6] * A[2]);
    inverse[5] = -(A[0] * A[5] - A[3] * A[2]);

    // Third row of adjugate A
    inverse[6] = (A[3] * A[7] - A[6] * A[4]);  // Det #2
    inverse[7] = -(A[0] * A[7] - A[6] * A[1]);
    inverse[8] = (A[0] * A[4] - A[3] * A[1]);

    return (A[0] * inverse[0] + A[1] * inverse[3] + A[2] * inverse[6]);
}
/**
 * Inverse of a general 3 by 3 matrix.
 *
 * N.B. it returns the adjugate matrix and determinant separately
 * in order to be able to apply it only if it is needed.
 *
 */
Inverse of a general 3 by 3 matrix.
Inverse of a general 3 by 3 matrix .
double matrixInverse3by3_double(double *A, double *inverse)
{
    inverse[0] = (A[4] * A[8] - A[7] * A[5]);  
    inverse[1] = -(A[1] * A[8] - A[7] * A[2]);
    inverse[2] = (A[1] * A[5] - A[4] * A[2]);
    inverse[3] = -(A[3] * A[8] - A[6] * A[5]);  
    inverse[4] = (A[0] * A[8] - A[6] * A[2]);
    inverse[5] = -(A[0] * A[5] - A[3] * A[2]);
    inverse[6] = (A[3] * A[7] - A[6] * A[4]);  
    inverse[7] = -(A[0] * A[7] - A[6] * A[1]);
    inverse[8] = (A[0] * A[4] - A[3] * A[1]);
    return (A[0] * inverse[0] + A[1] * inverse[3] + A[2] * inverse[6]);
}
double matrixInverse3by3_double ( double * A , double * inverse ) { inverse [ 0 ] = ( A [ 4 ] * A [ 8 ] - A [ 7 ] * A [ 5 ] ) ; inverse [ 1 ] = - ( A [ 1 ] * A [ 8 ] - A [ 7 ] * A [ 2 ] ) ; inverse [ 2 ] = ( A [ 1 ] * A [ 5 ] - A [ 4 ] * A [ 2 ] ) ; inverse [ 3 ] = - ( A [ 3 ] * A [ 8 ] - A [ 6 ] * A [ 5 ] ) ; inverse [ 4 ] = ( A [ 0 ] * A [ 8 ] - A [ 6 ] * A [ 2 ] ) ; inverse [ 5 ] = - ( A [ 0 ] * A [ 5 ] - A [ 3 ] * A [ 2 ] ) ; inverse [ 6 ] = ( A [ 3 ] * A [ 7 ] - A [ 6 ] * A [ 4 ] ) ; inverse [ 7 ] = - ( A [ 0 ] * A [ 7 ] - A [ 6 ] * A [ 1 ] ) ; inverse [ 8 ] = ( A [ 0 ] * A [ 4 ] - A [ 3 ] * A [ 1 ] ) ; return ( A [ 0 ] * inverse [ 0 ] + A [ 1 ] * inverse [ 3 ] + A [ 2 ] * inverse [ 6 ] ) ; }
Inverse of a general 3 by 3 matrix.
Inverse of a general 3 by 3 matrix .
// First row of adjugate A // Det #0 // Second row of adjugate A // Det #1 // Third row of adjugate A // Det #2