Gan_Bool gan_mat34_fprint ( FILE *fp, Gan_Matrix34 *p, const char *prefix, int indent, const char *fmt );prefix is a prefix string to print before the matrix itself, indent is the number of spaces to indent the matrix by, and fmt is a format string to use when printing the matrix, e.g. "%f". So for example
FILE *pfFile; pfFile = fopen ( "/tmp/matrices", "w" ); gan_mat34_fill_q ( &m34A, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ); gan_mat34_fprint ( pfFile, &m34A, "Example matrix", 3, "%f" );will print the output
Example matrix 1.000000 2.000000 3.000000 4.000000 5.000000 6.000000 7.000000 8.000000 9.000000 10.000000 11.000000 12.000000to the file "/tmp/matrices". There is also a version gan_mat34_print() for printing to standard output:
Gan_Bool gan_mat34_print ( Gan_Matrix34 *p, const char *prefix, int indent, const char *fmt );The corresponding input function is
Gan_Bool gan_mat34_fscanf ( FILE *fp, Gan_Matrix34 *p, char *prefix, int prefix_len )which reads the matrix from the file stream fp into the matrix pointer p. It also reads the prefix string (up to the specified maximum length prefix_len), which can be compared with the expected prefix string to check for consistency.
Binary file I/O is handled by the functions gan_mat34_fwrite() and gan_mat34_fread(). To write a matrix in binary format use
Gan_Bool gan_mat34_fwrite ( FILE *fp, Gan_Matrix34 *p, gan_ui32 magic_number );The magic_number takes the same role as the prefix string in gan_mat34_fprint(), and is written into the file so that it can be used later to identify the matrix when it is read back using
Gan_Bool gan_mat34_fread ( FILE *fp, Gan_Matrix34 *p, gan_ui32 *magic_number );
There are similar functions gan_mat33_fprint(), gan_mat33_print(), gan_mat33_fscanf() for ASCII I/O of matrices, and gan_mat33_fwrite(), gan_mat33_fread() for binary I/O of matrices. Functions for symmetric and triangular matrices follow the same pattern.
Error detection: The I/O routines return a boolean value, returning GAN_TRUE on success, GAN_FALSE on failure, invoking the Gandalf error handle in the latter case.