//-----------------------------------------------// // This is an example of how to invert a matrix // // by using the GNU Scientific Library. // // // // Thomas Bisig (03.2005), thomas@macapp.net // //-----------------------------------------------// #include #include #include int main (void) { // Define the dimension n of the matrix // and the signum s (for LU decomposition) int n = 2; int s; // Define all the used matrices gsl_matrix * m = gsl_matrix_alloc (n, n); gsl_matrix * inverse = gsl_matrix_alloc (n, n); gsl_permutation * perm = gsl_permutation_alloc (n); // Fill the matrix m // // // // // Make LU decomposition of matrix m gsl_linalg_LU_decomp (m, perm, &s); // Invert the matrix m gsl_linalg_LU_invert (m, perm, inverse); }