Created
November 8, 2010 18:48
-
-
Save jmbr/668067 to your computer and use it in GitHub Desktop.
Print a GSL matrix.
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
#include <stdio.h> | |
#include <stddef.h> | |
#include <gsl/gsl_matrix.h> | |
int print_matrix(FILE *f, const gsl_matrix *m) | |
{ | |
int status, n = 0; | |
for (size_t i = 0; i < m->size1; i++) { | |
for (size_t j = 0; j < m->size2; j++) { | |
if ((status = fprintf(f, "%g ", gsl_matrix_get(m, i, j))) < 0) | |
return -1; | |
n += status; | |
} | |
if ((status = fprintf(f, "\n")) < 0) | |
return -1; | |
n += status; | |
} | |
return n; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi
I would like to know the format specifiers for the complex elements of a complex matrix. Thanks!
@tt
Diego