Skip to content

Instantly share code, notes, and snippets.

@jmbr
Created November 8, 2010 18:48
Show Gist options
  • Save jmbr/668067 to your computer and use it in GitHub Desktop.
Save jmbr/668067 to your computer and use it in GitHub Desktop.
Print a GSL matrix.
#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;
}
@dgutier2
Copy link

Hi
I would like to know the format specifiers for the complex elements of a complex matrix. Thanks!
@tt
Diego

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment