1 /* matrix/file_source.c
3 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or (at
8 * your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 FUNCTION (gsl_matrix, fread) (FILE * stream, TYPE (gsl_matrix) * m)
25 const size_t size1 = m->size1;
26 const size_t size2 = m->size2;
28 const size_t tda = m->tda;
30 if (tda == size2) /* the rows are contiguous */
32 status = FUNCTION (gsl_block, raw_fread) (stream,
40 for (i = 0 ; i < size1 ; i++) /* read each row separately */
42 status = FUNCTION (gsl_block, raw_fread) (stream,
54 FUNCTION (gsl_matrix, fwrite) (FILE * stream, const TYPE (gsl_matrix) * m)
58 const size_t size1 = m->size1;
59 const size_t size2 = m->size2;
61 const size_t tda = m->tda;
63 if (tda == size2) /* the rows are contiguous */
65 status = FUNCTION (gsl_block, raw_fwrite) (stream,
73 for (i = 0 ; i < size1 ; i++) /* write each row separately */
75 status = FUNCTION (gsl_block, raw_fwrite) (stream,
87 #if !(USES_LONGDOUBLE && !HAVE_PRINTF_LONGDOUBLE)
89 FUNCTION (gsl_matrix, fprintf) (FILE * stream, const TYPE (gsl_matrix) * m,
94 const size_t size1 = m->size1;
95 const size_t size2 = m->size2;
97 const size_t tda = m->tda;
99 if (tda == size2) /* the rows are contiguous */
101 status = FUNCTION (gsl_block, raw_fprintf) (stream,
110 for (i = 0 ; i < size1 ; i++) /* print each row separately */
112 status = FUNCTION (gsl_block, raw_fprintf) (stream,
125 FUNCTION (gsl_matrix, fscanf) (FILE * stream, TYPE (gsl_matrix) * m)
129 const size_t size1 = m->size1;
130 const size_t size2 = m->size2;
132 const size_t tda = m->tda;
134 if (tda == size2) /* the rows are contiguous */
136 status = FUNCTION (gsl_block, raw_fscanf) (stream,
144 for (i = 0 ; i < size1 ; i++) /* scan each row separately */
146 status = FUNCTION (gsl_block, raw_fscanf) (stream,