What\'s the easiest way to compute a 3x3 matrix inverse?
I\'m just looking for a short code snippet that\'ll do the trick for non-singular matrices, possibly using C
//Function for inverse of the input square matrix 'J' of dimension 'dim':
vector > inverseVec33(vector > J, int dim)
{
//Matrix of Minors
vector > invJ(dim,vector (dim));
for(int i=0; i > invJT(dim,vector (dim));
for(int i=0; i > Jac(3,vector (3));
Jac[0][0] = 1; Jac[0][1] = 2; Jac[0][2] = 6;
Jac[1][0] = -3; Jac[1][1] = 4; Jac[1][2] = 3;
Jac[2][0] = 5; Jac[2][1] = 1; Jac[2][2] = -4;`
//Inverse of the matrix Jac:
vector > JacI(3,vector (3));
//call function and store inverse of J as JacI:
JacI = inverseVec33(Jac,3);
}