Created
October 18, 2015 02:53
-
-
Save daeyun/9b6877ac8ee8675f1c27 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Inverse33(const double a[3][3], double inv[3][3]) { | |
int i, j; | |
double determinant = 0; | |
for (i = 0; i < 3; i++) | |
determinant = | |
determinant + (a[0][i] * (a[1][(i + 1) % 3] * a[2][(i + 2) % 3] - | |
a[1][(i + 2) % 3] * a[2][(i + 1) % 3])); | |
for (i = 0; i < 3; i++) { | |
for (j = 0; j < 3; j++) | |
inv[j][i] = | |
((a[(i + 1) % 3][(j + 1) % 3] * a[(i + 2) % 3][(j + 2) % 3]) - | |
(a[(i + 1) % 3][(j + 2) % 3] * a[(i + 2) % 3][(j + 1) % 3])) / | |
determinant; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment