Advertisement
cd62131

GSL Matrix Read and Write

Nov 27th, 2013
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.58 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <gsl/gsl_matrix.h>
  4. #define N 8
  5.  
  6. int main(int argc, char **argv) {
  7.   gsl_matrix *e = gsl_matrix_alloc(N, N);
  8.   gsl_matrix *f = gsl_matrix_alloc(N, N);
  9.   FILE *in;
  10.   if (argc > 1) in = fopen(argv[1], "r");
  11.   else in = stdin;
  12.   gsl_matrix_fscanf(in, e);
  13.   gsl_matrix_fscanf(in, f);
  14.   fclose(in);
  15.   //
  16.   // some operation
  17.   //
  18.   FILE *out = fopen("output.dat", "w");
  19.   gsl_matrix_fprintf(out, e, "%e");
  20.   gsl_matrix_fprintf(out, f, "%e");
  21.   fclose(out);
  22.   gsl_matrix_free(e);
  23.   gsl_matrix_free(f);
  24.   return EXIT_SUCCESS;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement