| 1 | /* matrix/file_source.c |
| 2 | * |
| 3 | * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough |
| 4 | * |
| 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. |
| 9 | * |
| 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. |
| 14 | * |
| 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. |
| 18 | */ |
| 19 | |
| 20 | int |
| 21 | FUNCTIONcxx . . $ `./templates_on.h:233:9`! (gsl_matrix, fread) (FILEcxx . . $ FILE# * stream, TYPEcxx . . $ `./templates_on.h:234:9`! (gsl_matrix) * m) |
| 22 | { |
| 23 | int status = 0; |
| 24 | |
| 25 | const size_t size1 = m->size1cxx . . $ $anonymous_type_76f4ec40ad1923db_0#size1.; |
| 26 | const size_t size2 = m->size2cxx . . $ $anonymous_type_76f4ec40ad1923db_0#size2.; |
| 27 | |
| 28 | const size_t tda = m->tdacxx . . $ $anonymous_type_76f4ec40ad1923db_0#tda.; |
| 29 | |
| 30 | if (tda == size2) /* the rows are contiguous */ |
| 31 | { |
| 32 | status = FUNCTIONcxx . . $ `./templates_on.h:233:9`! (gsl_block, raw_fread) (stream, |
| 33 | m->datacxx . . $ $anonymous_type_76f4ec40ad1923db_0#data., |
| 34 | size1 * size2, 1); |
| 35 | } |
| 36 | else |
| 37 | { |
| 38 | size_t i; |
| 39 | |
| 40 | for (i = 0 ; i < size1 ; i++) /* read each row separately */ |
| 41 | { |
| 42 | status = FUNCTIONcxx . . $ `./templates_on.h:233:9`! (gsl_block, raw_fread) (stream, |
| 43 | m->datacxx . . $ $anonymous_type_76f4ec40ad1923db_0#data. + i * tda, |
| 44 | size2, 1); |
| 45 | if (status) |
| 46 | break; |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | return status; |
| 51 | } |
| 52 | |
| 53 | int |
| 54 | FUNCTIONcxx . . $ `./templates_on.h:233:9`! (gsl_matrix, fwrite) (FILEcxx . . $ FILE# * stream, const TYPEcxx . . $ `./templates_on.h:234:9`! (gsl_matrix) * m) |
| 55 | { |
| 56 | int status = 0; |
| 57 | |
| 58 | const size_t size1 = m->size1cxx . . $ $anonymous_type_76f4ec40ad1923db_0#size1.; |
| 59 | const size_t size2 = m->size2cxx . . $ $anonymous_type_76f4ec40ad1923db_0#size2.; |
| 60 | |
| 61 | const size_t tda = m->tdacxx . . $ $anonymous_type_76f4ec40ad1923db_0#tda.; |
| 62 | |
| 63 | if (tda == size2) /* the rows are contiguous */ |
| 64 | { |
| 65 | status = FUNCTIONcxx . . $ `./templates_on.h:233:9`! (gsl_block, raw_fwrite) (stream, |
| 66 | m->datacxx . . $ $anonymous_type_76f4ec40ad1923db_0#data., |
| 67 | size1 * size2, 1); |
| 68 | } |
| 69 | else |
| 70 | { |
| 71 | size_t i; |
| 72 | |
| 73 | for (i = 0 ; i < size1 ; i++) /* write each row separately */ |
| 74 | { |
| 75 | status = FUNCTIONcxx . . $ `./templates_on.h:233:9`! (gsl_block, raw_fwrite) (stream, |
| 76 | m->datacxx . . $ $anonymous_type_76f4ec40ad1923db_0#data. + i * tda, |
| 77 | size2, 1); |
| 78 | if (status) |
| 79 | break; |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | return status; |
| 84 | |
| 85 | } |
| 86 | |
| 87 | #if !(USES_LONGDOUBLE && !HAVE_PRINTF_LONGDOUBLEcxx . . $ `external/gsl/gsl__config.h:120:9`!) |
| 88 | int |
| 89 | FUNCTIONcxx . . $ `./templates_on.h:233:9`! (gsl_matrix, fprintf) (FILEcxx . . $ FILE# * stream, const TYPEcxx . . $ `./templates_on.h:234:9`! (gsl_matrix) * m, |
| 90 | const char *format) |
| 91 | { |
| 92 | int status = 0; |
| 93 | |
| 94 | const size_t size1 = m->size1cxx . . $ $anonymous_type_76f4ec40ad1923db_0#size1.; |
| 95 | const size_t size2 = m->size2cxx . . $ $anonymous_type_76f4ec40ad1923db_0#size2.; |
| 96 | |
| 97 | const size_t tda = m->tdacxx . . $ $anonymous_type_76f4ec40ad1923db_0#tda.; |
| 98 | |
| 99 | if (tda == size2) /* the rows are contiguous */ |
| 100 | { |
| 101 | status = FUNCTIONcxx . . $ `./templates_on.h:233:9`! (gsl_block, raw_fprintf) (stream, |
| 102 | m->datacxx . . $ $anonymous_type_76f4ec40ad1923db_0#data., |
| 103 | size1 * size2, 1, |
| 104 | format); |
| 105 | } |
| 106 | else |
| 107 | { |
| 108 | size_t i; |
| 109 | |
| 110 | for (i = 0 ; i < size1 ; i++) /* print each row separately */ |
| 111 | { |
| 112 | status = FUNCTIONcxx . . $ `./templates_on.h:233:9`! (gsl_block, raw_fprintf) (stream, |
| 113 | m->datacxx . . $ $anonymous_type_76f4ec40ad1923db_0#data. + i * tda, |
| 114 | size2, 1, |
| 115 | format); |
| 116 | if (status) |
| 117 | break; |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | return status; |
| 122 | } |
| 123 | |
| 124 | int |
| 125 | FUNCTIONcxx . . $ `./templates_on.h:233:9`! (gsl_matrix, fscanf) (FILEcxx . . $ FILE# * stream, TYPEcxx . . $ `./templates_on.h:234:9`! (gsl_matrix) * m) |
| 126 | { |
| 127 | int status = 0; |
| 128 | |
| 129 | const size_t size1 = m->size1cxx . . $ $anonymous_type_76f4ec40ad1923db_0#size1.; |
| 130 | const size_t size2 = m->size2cxx . . $ $anonymous_type_76f4ec40ad1923db_0#size2.; |
| 131 | |
| 132 | const size_t tda = m->tdacxx . . $ $anonymous_type_76f4ec40ad1923db_0#tda.; |
| 133 | |
| 134 | if (tda == size2) /* the rows are contiguous */ |
| 135 | { |
| 136 | status = FUNCTIONcxx . . $ `./templates_on.h:233:9`! (gsl_block, raw_fscanf) (stream, |
| 137 | m->datacxx . . $ $anonymous_type_76f4ec40ad1923db_0#data., |
| 138 | size1 * size2, 1); |
| 139 | } |
| 140 | else |
| 141 | { |
| 142 | size_t i; |
| 143 | |
| 144 | for (i = 0 ; i < size1 ; i++) /* scan each row separately */ |
| 145 | { |
| 146 | status = FUNCTIONcxx . . $ `./templates_on.h:233:9`! (gsl_block, raw_fscanf) (stream, |
| 147 | m->datacxx . . $ $anonymous_type_76f4ec40ad1923db_0#data. + i * tda, |
| 148 | size2, 1); |
| 149 | if (status) |
| 150 | break; |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | return status; |
| 155 | } |
| 156 | #endif |
| 157 |