Mercurial > hg > octave-lyh
comparison src/ls-mat5.cc @ 5164:57077d0ddc8e
[project @ 2005-02-25 19:55:24 by jwe]
author | jwe |
---|---|
date | Fri, 25 Feb 2005 19:55:28 +0000 |
parents | 3db2b2762491 |
children | 90a9058de7e8 |
comparison
equal
deleted
inserted
replaced
5163:9f3299378193 | 5164:57077d0ddc8e |
---|---|
162 } | 162 } |
163 } | 163 } |
164 | 164 |
165 template <class T> | 165 template <class T> |
166 void | 166 void |
167 read_mat5_integer_data (std::istream& is, T &m, int count, bool swap, | 167 read_mat5_integer_data (std::istream& is, T *m, int count, bool swap, |
168 mat5_data_type type) | 168 mat5_data_type type) |
169 { | 169 { |
170 | 170 |
171 #define READ_INTEGER_DATA(TYPE, swap, data, size, len, stream) \ | 171 #define READ_INTEGER_DATA(TYPE, swap, data, size, len, stream) \ |
172 do \ | 172 do \ |
186 while (0) | 186 while (0) |
187 | 187 |
188 switch (type) | 188 switch (type) |
189 { | 189 { |
190 case miINT8: | 190 case miINT8: |
191 READ_INTEGER_DATA (signed char, swap, m.fortran_vec (), 1, | 191 READ_INTEGER_DATA (signed char, swap, m, 1, count, is); |
192 count, is); | |
193 break; | 192 break; |
194 | 193 |
195 case miUINT8: | 194 case miUINT8: |
196 READ_INTEGER_DATA (unsigned char, swap, m.fortran_vec (), 1, | 195 READ_INTEGER_DATA (unsigned char, swap, m, 1, count, is); |
197 count, is); | |
198 break; | 196 break; |
199 | 197 |
200 case miINT16: | 198 case miINT16: |
201 READ_INTEGER_DATA (signed TWO_BYTE_INT, swap, m.fortran_vec (), 2, | 199 READ_INTEGER_DATA (signed TWO_BYTE_INT, swap, m, 2, count, is); |
202 count, is); | |
203 break; | 200 break; |
204 | 201 |
205 case miUINT16: | 202 case miUINT16: |
206 READ_INTEGER_DATA (unsigned TWO_BYTE_INT, swap, m.fortran_vec (), 2, | 203 READ_INTEGER_DATA (unsigned TWO_BYTE_INT, swap, m, 2, count, is); |
207 count, is); | |
208 break; | 204 break; |
209 | 205 |
210 case miINT32: | 206 case miINT32: |
211 READ_INTEGER_DATA (signed FOUR_BYTE_INT, swap, m.fortran_vec (), 4, | 207 READ_INTEGER_DATA (signed FOUR_BYTE_INT, swap, m, 4, count, is); |
212 count, is); | |
213 break; | 208 break; |
214 | 209 |
215 case miUINT32: | 210 case miUINT32: |
216 READ_INTEGER_DATA (unsigned FOUR_BYTE_INT, swap, m.fortran_vec (), 4, | 211 READ_INTEGER_DATA (unsigned FOUR_BYTE_INT, swap, m, 4, count, is); |
217 count, is); | |
218 break; | 212 break; |
219 | 213 |
220 case miSINGLE: | 214 case miSINGLE: |
221 case miRESERVE1: | 215 case miRESERVE1: |
222 case miDOUBLE: | 216 case miDOUBLE: |
224 case miRESERVE3: | 218 case miRESERVE3: |
225 break; | 219 break; |
226 | 220 |
227 case miINT64: | 221 case miINT64: |
228 #ifdef EIGHT_BYTE_INT | 222 #ifdef EIGHT_BYTE_INT |
229 READ_INTEGER_DATA (signed EIGHT_BYTE_INT, swap, m.fortran_vec (), 8, | 223 READ_INTEGER_DATA (signed EIGHT_BYTE_INT, swap, m, 8, count, is); |
230 count, is); | |
231 #endif | 224 #endif |
232 break; | 225 break; |
233 | 226 |
234 case miUINT64: | 227 case miUINT64: |
235 #ifdef EIGHT_BYTE_INT | 228 #ifdef EIGHT_BYTE_INT |
236 READ_INTEGER_DATA (unsigned EIGHT_BYTE_INT, swap, m.fortran_vec (), 8, | 229 READ_INTEGER_DATA (unsigned EIGHT_BYTE_INT, swap, m, 8, count, is); |
237 count, is); | |
238 #endif | 230 #endif |
239 break; | 231 break; |
240 | 232 |
241 case miMATRIX: | 233 case miMATRIX: |
242 default: | 234 default: |
245 | 237 |
246 #undef READ_INTEGER_DATA | 238 #undef READ_INTEGER_DATA |
247 | 239 |
248 } | 240 } |
249 | 241 |
250 template void read_mat5_integer_data (std::istream& is, int8NDArray &m, | 242 template void read_mat5_integer_data (std::istream& is, octave_int8 *m, |
251 int count, bool swap, | 243 int count, bool swap, |
252 mat5_data_type type); | 244 mat5_data_type type); |
253 template void read_mat5_integer_data (std::istream& is, int16NDArray &m, | 245 template void read_mat5_integer_data (std::istream& is, octave_int16 *m, |
254 int count, bool swap, | 246 int count, bool swap, |
255 mat5_data_type type); | 247 mat5_data_type type); |
256 template void read_mat5_integer_data (std::istream& is, int32NDArray &m, | 248 template void read_mat5_integer_data (std::istream& is, octave_int32 *m, |
257 int count, bool swap, | 249 int count, bool swap, |
258 mat5_data_type type); | 250 mat5_data_type type); |
259 template void read_mat5_integer_data (std::istream& is, int64NDArray &m, | 251 template void read_mat5_integer_data (std::istream& is, octave_int64 *m, |
260 int count, bool swap, | 252 int count, bool swap, |
261 mat5_data_type type); | 253 mat5_data_type type); |
262 template void read_mat5_integer_data (std::istream& is, uint8NDArray &m, | 254 template void read_mat5_integer_data (std::istream& is, octave_uint8 *m, |
263 int count, bool swap, | 255 int count, bool swap, |
264 mat5_data_type type); | 256 mat5_data_type type); |
265 template void read_mat5_integer_data (std::istream& is, uint16NDArray &m, | 257 template void read_mat5_integer_data (std::istream& is, octave_uint16 *m, |
266 int count, bool swap, | 258 int count, bool swap, |
267 mat5_data_type type); | 259 mat5_data_type type); |
268 template void read_mat5_integer_data (std::istream& is, uint32NDArray &m, | 260 template void read_mat5_integer_data (std::istream& is, octave_uint32 *m, |
269 int count, bool swap, | 261 int count, bool swap, |
270 mat5_data_type type); | 262 mat5_data_type type); |
271 template void read_mat5_integer_data (std::istream& is, uint64NDArray &m, | 263 template void read_mat5_integer_data (std::istream& is, octave_uint64 *m, |
264 int count, bool swap, | |
265 mat5_data_type type); | |
266 | |
267 template void read_mat5_integer_data (std::istream& is, int *m, | |
272 int count, bool swap, | 268 int count, bool swap, |
273 mat5_data_type type); | 269 mat5_data_type type); |
274 | 270 |
275 #define OCTAVE_MAT5_INTEGER_READ(TYP) \ | 271 #define OCTAVE_MAT5_INTEGER_READ(TYP) \ |
276 { \ | 272 { \ |
284 goto data_read_error; \ | 280 goto data_read_error; \ |
285 } \ | 281 } \ |
286 \ | 282 \ |
287 int n = re.length (); \ | 283 int n = re.length (); \ |
288 tmp_pos = is.tellg (); \ | 284 tmp_pos = is.tellg (); \ |
289 read_mat5_integer_data (is, re, n, swap, \ | 285 read_mat5_integer_data (is, re.fortran_vec (), n, swap, \ |
290 (enum mat5_data_type) type); \ | 286 (enum mat5_data_type) type); \ |
291 \ | 287 \ |
292 if (! is || error_state) \ | 288 if (! is || error_state) \ |
293 { \ | 289 { \ |
294 error ("load: reading matrix data for `%s'", retval.c_str ()); \ | 290 error ("load: reading matrix data for `%s'", retval.c_str ()); \ |
399 oct_mach_info::float_format flt_fmt = oct_mach_info::flt_fmt_unknown; | 395 oct_mach_info::float_format flt_fmt = oct_mach_info::flt_fmt_unknown; |
400 int type = 0; | 396 int type = 0; |
401 bool imag; | 397 bool imag; |
402 bool logicalvar; | 398 bool logicalvar; |
403 enum arrayclasstype arrayclass; | 399 enum arrayclasstype arrayclass; |
404 FOUR_BYTE_INT junk; | 400 FOUR_BYTE_INT nnz; |
405 FOUR_BYTE_INT flags; | 401 FOUR_BYTE_INT flags; |
406 dim_vector dims; | 402 dim_vector dims; |
407 int len; | 403 int len; |
408 int element_length; | 404 int element_length; |
409 std::streampos pos; | 405 std::streampos pos; |
446 read_int (is, swap, flags); | 442 read_int (is, swap, flags); |
447 imag = (flags & 0x0800) != 0; // has an imaginary part? | 443 imag = (flags & 0x0800) != 0; // has an imaginary part? |
448 global = (flags & 0x0400) != 0; // global variable? | 444 global = (flags & 0x0400) != 0; // global variable? |
449 logicalvar = (flags & 0x0200) != 0; // we don't use this yet | 445 logicalvar = (flags & 0x0200) != 0; // we don't use this yet |
450 arrayclass = (arrayclasstype)(flags & 0xff); | 446 arrayclass = (arrayclasstype)(flags & 0xff); |
451 read_int (is, swap, junk); // an "undefined" entry | 447 read_int (is, swap, nnz); // number of non-zero in sparse |
452 | 448 |
453 // dimensions array subelement | 449 // dimensions array subelement |
454 { | 450 { |
455 FOUR_BYTE_INT dim_len; | 451 FOUR_BYTE_INT dim_len; |
456 | 452 |
529 case mxOBJECT_CLASS: | 525 case mxOBJECT_CLASS: |
530 warning ("load: objects are not implemented"); | 526 warning ("load: objects are not implemented"); |
531 goto skip_ahead; | 527 goto skip_ahead; |
532 | 528 |
533 case mxSPARSE_CLASS: | 529 case mxSPARSE_CLASS: |
534 warning ("load: sparse arrays are not implemented"); | 530 { |
535 goto skip_ahead; | 531 int nr = dims(0); |
532 int nc = dims(1); | |
533 SparseMatrix sm; | |
534 SparseComplexMatrix scm; | |
535 NDArray re; | |
536 int *ridx; | |
537 int *cidx; | |
538 double *data; | |
539 | |
540 // Setup return value | |
541 if (imag) | |
542 { | |
543 scm = SparseComplexMatrix (nr, nc, nnz); | |
544 ridx = scm.ridx (); | |
545 cidx = scm.cidx (); | |
546 re = NDArray (dim_vector (static_cast<int> (nnz))); | |
547 data = re.fortran_vec (); | |
548 } | |
549 else | |
550 { | |
551 sm = SparseMatrix (nr, nc, nnz); | |
552 ridx = sm.ridx (); | |
553 cidx = sm.cidx (); | |
554 data = sm.data (); | |
555 } | |
556 | |
557 // row indices | |
558 std::streampos tmp_pos; | |
559 | |
560 if (read_mat5_tag (is, swap, type, len)) | |
561 { | |
562 error ("load: reading sparse row data for `%s'", retval.c_str ()); | |
563 goto data_read_error; | |
564 } | |
565 | |
566 tmp_pos = is.tellg (); | |
567 | |
568 read_mat5_integer_data (is, ridx, nnz, swap, | |
569 (enum mat5_data_type) type); | |
570 | |
571 if (! is || error_state) | |
572 { | |
573 error ("load: reading sparse row data for `%s'", retval.c_str ()); | |
574 goto data_read_error; | |
575 } | |
576 | |
577 is.seekg (tmp_pos + static_cast<std::streamoff> (PAD (len))); | |
578 | |
579 // col indices | |
580 if (read_mat5_tag (is, swap, type, len)) | |
581 { | |
582 error ("load: reading sparse column data for `%s'", retval.c_str ()); | |
583 goto data_read_error; | |
584 } | |
585 | |
586 tmp_pos = is.tellg (); | |
587 | |
588 read_mat5_integer_data (is, cidx, nc + 1, swap, | |
589 (enum mat5_data_type) type); | |
590 | |
591 if (! is || error_state) | |
592 { | |
593 error ("load: reading sparse column data for `%s'", retval.c_str ()); | |
594 goto data_read_error; | |
595 } | |
596 | |
597 is.seekg (tmp_pos + static_cast<std::streamoff> (PAD (len))); | |
598 | |
599 // real data subelement | |
600 if (read_mat5_tag (is, swap, type, len)) | |
601 { | |
602 error ("load: reading sparse matrix data for `%s'", retval.c_str ()); | |
603 goto data_read_error; | |
604 } | |
605 | |
606 tmp_pos = is.tellg (); | |
607 read_mat5_binary_data (is, data, nnz, swap, | |
608 (enum mat5_data_type) type, flt_fmt); | |
609 | |
610 if (! is || error_state) | |
611 { | |
612 error ("load: reading sparse matrix data for `%s'", retval.c_str ()); | |
613 goto data_read_error; | |
614 } | |
615 | |
616 is.seekg (tmp_pos + static_cast<std::streamoff> (PAD (len))); | |
617 | |
618 // imaginary data subelement | |
619 if (imag) | |
620 { | |
621 NDArray im (dim_vector (static_cast<int> (nnz))); | |
622 | |
623 if (read_mat5_tag (is, swap, type, len)) | |
624 { | |
625 error ("load: reading sparse matrix data for `%s'", retval.c_str ()); | |
626 goto data_read_error; | |
627 } | |
628 | |
629 read_mat5_binary_data (is, im.fortran_vec (), nnz, swap, | |
630 (enum mat5_data_type) type, flt_fmt); | |
631 | |
632 if (! is || error_state) | |
633 { | |
634 error ("load: reading imaginary sparse matrix data for `%s'", | |
635 retval.c_str ()); | |
636 goto data_read_error; | |
637 } | |
638 | |
639 for (int i = 0; i < nnz; i++) | |
640 scm.xdata (i) = Complex (re (i), im (i)); | |
641 | |
642 tc = scm; | |
643 } | |
644 else | |
645 tc = sm; | |
646 } | |
647 break; | |
536 | 648 |
537 case mxFUNCTION_CLASS: | 649 case mxFUNCTION_CLASS: |
538 warning ("load: function handles are not implemented"); | 650 warning ("load: function handles are not implemented"); |
539 goto skip_ahead; | 651 goto skip_ahead; |
540 | 652 |
911 } | 1023 } |
912 } | 1024 } |
913 | 1025 |
914 template <class T> | 1026 template <class T> |
915 void | 1027 void |
916 write_mat5_integer_data (std::ostream& os, const T& m, int size) | 1028 write_mat5_integer_data (std::ostream& os, const T *m, int size, int nel) |
917 { | 1029 { |
918 int nel = m.nelem (); | |
919 mat5_data_type mst; | 1030 mat5_data_type mst; |
920 unsigned len; | 1031 unsigned len; |
921 | 1032 |
922 switch (size) | 1033 switch (size) |
923 { | 1034 { |
925 mst = miUINT8; | 1036 mst = miUINT8; |
926 break; | 1037 break; |
927 case 2: | 1038 case 2: |
928 mst = miUINT16; | 1039 mst = miUINT16; |
929 break; | 1040 break; |
930 case 3: | 1041 case 4: |
931 mst = miUINT32; | 1042 mst = miUINT32; |
932 break; | 1043 break; |
933 case 4: | 1044 case 8: |
934 mst = miUINT64; | 1045 mst = miUINT64; |
935 break; | 1046 break; |
936 case -1: | 1047 case -1: |
937 mst = miINT8; | 1048 mst = miINT8; |
938 size = - size; | 1049 size = - size; |
939 break; | 1050 break; |
940 case -2: | 1051 case -2: |
941 mst = miINT16; | 1052 mst = miINT16; |
942 size = - size; | 1053 size = - size; |
943 break; | 1054 break; |
944 case -3: | 1055 case -4: |
945 mst = miINT32; | 1056 mst = miINT32; |
946 size = - size; | 1057 size = - size; |
947 break; | 1058 break; |
948 case -4: | 1059 case -8: |
949 default: | 1060 default: |
950 mst = miINT64; | 1061 mst = miINT64; |
951 size = - size; | 1062 size = - size; |
952 break; | 1063 break; |
953 } | 1064 } |
954 | 1065 |
955 len = nel*size; | 1066 len = nel*size; |
956 write_mat5_tag (os, mst, len); | 1067 write_mat5_tag (os, mst, len); |
957 | 1068 |
958 os.write (X_CAST(char *, m.data ()), len); | 1069 os.write (X_CAST(char *, m), len); |
959 | 1070 |
960 if (PAD (len) > len) | 1071 if (PAD (len) > len) |
961 { | 1072 { |
962 static char buf[9]="\x00\x00\x00\x00\x00\x00\x00\x00"; | 1073 static char buf[9]="\x00\x00\x00\x00\x00\x00\x00\x00"; |
963 os.write (buf, PAD (len) - len); | 1074 os.write (buf, PAD (len) - len); |
964 } | 1075 } |
965 } | 1076 } |
966 | 1077 |
967 template void write_mat5_integer_data (std::ostream& os, | 1078 template void write_mat5_integer_data (std::ostream& os, const octave_int8 *m, |
968 const int8NDArray &m, int size); | 1079 int size, int nel); |
969 template void write_mat5_integer_data (std::ostream& os, | 1080 template void write_mat5_integer_data (std::ostream& os, const octave_int16 *m, |
970 const int16NDArray &m, int size); | 1081 int size, int nel); |
971 template void write_mat5_integer_data (std::ostream& os, | 1082 template void write_mat5_integer_data (std::ostream& os, const octave_int32 *m, |
972 const int32NDArray &m, int size); | 1083 int size, int nel); |
973 template void write_mat5_integer_data (std::ostream& os, | 1084 template void write_mat5_integer_data (std::ostream& os, const octave_int64 *m, |
974 const int64NDArray &m, int size); | 1085 int size, int nel); |
975 template void write_mat5_integer_data (std::ostream& os, | 1086 template void write_mat5_integer_data (std::ostream& os, const octave_uint8 *m, |
976 const uint8NDArray &m, int size); | 1087 int size, int nel); |
977 template void write_mat5_integer_data (std::ostream& os, | 1088 template void write_mat5_integer_data (std::ostream& os, const octave_uint16 *m, |
978 const uint16NDArray &m, int size); | 1089 int size, int nel); |
979 template void write_mat5_integer_data (std::ostream& os, | 1090 template void write_mat5_integer_data (std::ostream& os, const octave_uint32 *m, |
980 const uint32NDArray &m, int size); | 1091 int size, int nel); |
981 template void write_mat5_integer_data (std::ostream& os, | 1092 template void write_mat5_integer_data (std::ostream& os, const octave_uint64 *m, |
982 const uint64NDArray &m, int size); | 1093 int size, int nel); |
1094 template void write_mat5_integer_data (std::ostream& os, const int *m, | |
1095 int size, int nel); | |
983 | 1096 |
984 // Write out cell element values in the cell array to OS, preceded by | 1097 // Write out cell element values in the cell array to OS, preceded by |
985 // the appropriate tag. | 1098 // the appropriate tag. |
986 | 1099 |
987 static bool | 1100 static bool |
1009 save_mat5_binary_element (std::ostream& os, | 1122 save_mat5_binary_element (std::ostream& os, |
1010 const octave_value& tc, const std::string& name, | 1123 const octave_value& tc, const std::string& name, |
1011 bool mark_as_global, bool save_as_floats) | 1124 bool mark_as_global, bool save_as_floats) |
1012 { | 1125 { |
1013 FOUR_BYTE_INT flags=0; | 1126 FOUR_BYTE_INT flags=0; |
1014 FOUR_BYTE_INT junk=0; | 1127 FOUR_BYTE_INT nnz=0; |
1015 std::streampos fixup, contin; | 1128 std::streampos fixup, contin; |
1016 std::string cname = tc.class_name (); | 1129 std::string cname = tc.class_name (); |
1017 | 1130 |
1018 // element type and length | 1131 // element type and length |
1019 fixup = os.tellp (); | 1132 fixup = os.tellp (); |
1044 flags |= mxUINT16_CLASS; | 1157 flags |= mxUINT16_CLASS; |
1045 else if (cname == "uint32") | 1158 else if (cname == "uint32") |
1046 flags |= mxUINT32_CLASS; | 1159 flags |= mxUINT32_CLASS; |
1047 else if (cname == "uint64") | 1160 else if (cname == "uint64") |
1048 flags |= mxUINT64_CLASS; | 1161 flags |= mxUINT64_CLASS; |
1162 else if (cname == "sparse") | |
1163 { | |
1164 flags |= mxSPARSE_CLASS; | |
1165 if (tc.is_complex_type ()) | |
1166 { | |
1167 SparseComplexMatrix scm = tc.sparse_complex_matrix_value (); | |
1168 nnz = scm.nnz (); | |
1169 } | |
1170 else | |
1171 { | |
1172 SparseMatrix sm = tc.sparse_matrix_value (); | |
1173 nnz = sm.nnz (); | |
1174 } | |
1175 } | |
1049 else if (tc.is_real_scalar ()) | 1176 else if (tc.is_real_scalar ()) |
1050 flags |= mxDOUBLE_CLASS; | 1177 flags |= mxDOUBLE_CLASS; |
1051 else if (tc.is_real_matrix () || tc.is_range ()) | 1178 else if (tc.is_real_matrix () || tc.is_range ()) |
1052 flags |= mxDOUBLE_CLASS; | 1179 flags |= mxDOUBLE_CLASS; |
1053 else if (tc.is_complex_scalar ()) | 1180 else if (tc.is_complex_scalar ()) |
1063 gripe_wrong_type_arg ("save", tc, false); | 1190 gripe_wrong_type_arg ("save", tc, false); |
1064 goto error_cleanup; | 1191 goto error_cleanup; |
1065 } | 1192 } |
1066 | 1193 |
1067 os.write ((char *)&flags, 4); | 1194 os.write ((char *)&flags, 4); |
1068 os.write ((char *)&junk, 4); | 1195 os.write ((char *)&nnz, 4); |
1069 | 1196 |
1070 { | 1197 { |
1071 dim_vector dv = tc.dims (); | 1198 dim_vector dv = tc.dims (); |
1072 int nd = tc.ndims (); | 1199 int nd = tc.ndims (); |
1073 int dim_len = 4*nd; | 1200 int dim_len = 4*nd; |
1126 os.write ((char *)buf, nr*nc*2); | 1253 os.write ((char *)buf, nr*nc*2); |
1127 | 1254 |
1128 if (paddedlength > len) | 1255 if (paddedlength > len) |
1129 os.write ((char *)buf, paddedlength - len); | 1256 os.write ((char *)buf, paddedlength - len); |
1130 } | 1257 } |
1258 else if (cname == "sparse") | |
1259 { | |
1260 if (tc.is_complex_type ()) | |
1261 { | |
1262 SparseComplexMatrix m = tc.sparse_complex_matrix_value (); | |
1263 int nc = m.cols (); | |
1264 | |
1265 write_mat5_integer_data (os, m.ridx (), - sizeof(int), nnz); | |
1266 write_mat5_integer_data (os, m.cidx (), - sizeof(int), nc + 1); | |
1267 | |
1268 NDArray buf (dim_vector (nnz, 1)); | |
1269 | |
1270 for (int i = 0; i < nnz; i++) | |
1271 buf (i) = ::real (m.data (i)); | |
1272 | |
1273 write_mat5_array (os, buf, save_as_floats); | |
1274 | |
1275 for (int i = 0; i < nnz; i++) | |
1276 buf (i) = ::imag (m.data (i)); | |
1277 | |
1278 write_mat5_array (os, buf, save_as_floats); | |
1279 } | |
1280 else | |
1281 { | |
1282 SparseMatrix m = tc.sparse_matrix_value (); | |
1283 int nc = m.cols (); | |
1284 | |
1285 write_mat5_integer_data (os, m.ridx (), - sizeof(int), nnz); | |
1286 write_mat5_integer_data (os, m.cidx (), - sizeof(int), nc + 1); | |
1287 | |
1288 // XXX FIXME XXX | |
1289 // Is there a way to easily do without this buffer | |
1290 NDArray buf (dim_vector (nnz, 1)); | |
1291 | |
1292 for (int i = 0; i < nnz; i++) | |
1293 buf (i) = m.data (i); | |
1294 | |
1295 write_mat5_array (os, buf, save_as_floats); | |
1296 } | |
1297 } | |
1131 else if (cname == "int8") | 1298 else if (cname == "int8") |
1132 { | 1299 { |
1133 int8NDArray m = tc.int8_array_value (); | 1300 int8NDArray m = tc.int8_array_value (); |
1134 | 1301 |
1135 write_mat5_integer_data (os, m, -1); | 1302 write_mat5_integer_data (os, m.fortran_vec (), -1, m.nelem ()); |
1136 } | 1303 } |
1137 else if (cname == "int16") | 1304 else if (cname == "int16") |
1138 { | 1305 { |
1139 int16NDArray m = tc.int16_array_value (); | 1306 int16NDArray m = tc.int16_array_value (); |
1140 | 1307 |
1141 write_mat5_integer_data (os, m, -2); | 1308 write_mat5_integer_data (os, m.fortran_vec (), -2, m.nelem ()); |
1142 } | 1309 } |
1143 else if (cname == "int32") | 1310 else if (cname == "int32") |
1144 { | 1311 { |
1145 int32NDArray m = tc.int32_array_value (); | 1312 int32NDArray m = tc.int32_array_value (); |
1146 | 1313 |
1147 write_mat5_integer_data (os, m, -4); | 1314 write_mat5_integer_data (os, m.fortran_vec (), -4, m.nelem ()); |
1148 } | 1315 } |
1149 else if (cname == "int64") | 1316 else if (cname == "int64") |
1150 { | 1317 { |
1151 int64NDArray m = tc.int64_array_value (); | 1318 int64NDArray m = tc.int64_array_value (); |
1152 | 1319 |
1153 write_mat5_integer_data (os, m, -8); | 1320 write_mat5_integer_data (os, m.fortran_vec (), -8, m.nelem ()); |
1154 } | 1321 } |
1155 else if (cname == "uint8") | 1322 else if (cname == "uint8") |
1156 { | 1323 { |
1157 uint8NDArray m = tc.uint8_array_value (); | 1324 uint8NDArray m = tc.uint8_array_value (); |
1158 | 1325 |
1159 write_mat5_integer_data (os, m, 1); | 1326 write_mat5_integer_data (os, m.fortran_vec (), 1, m.nelem ()); |
1160 } | 1327 } |
1161 else if (cname == "uint16") | 1328 else if (cname == "uint16") |
1162 { | 1329 { |
1163 uint16NDArray m = tc.uint16_array_value (); | 1330 uint16NDArray m = tc.uint16_array_value (); |
1164 | 1331 |
1165 write_mat5_integer_data (os, m, 2); | 1332 write_mat5_integer_data (os, m.fortran_vec (), 2, m.nelem ()); |
1166 } | 1333 } |
1167 else if (cname == "uint32") | 1334 else if (cname == "uint32") |
1168 { | 1335 { |
1169 uint32NDArray m = tc.uint32_array_value (); | 1336 uint32NDArray m = tc.uint32_array_value (); |
1170 | 1337 |
1171 write_mat5_integer_data (os, m, 4); | 1338 write_mat5_integer_data (os, m.fortran_vec (), 4, m.nelem ()); |
1172 } | 1339 } |
1173 else if (cname == "uint64") | 1340 else if (cname == "uint64") |
1174 { | 1341 { |
1175 uint64NDArray m = tc.uint64_array_value (); | 1342 uint64NDArray m = tc.uint64_array_value (); |
1176 | 1343 |
1177 write_mat5_integer_data (os, m, 8); | 1344 write_mat5_integer_data (os, m.fortran_vec (), 8, m.nelem ()); |
1178 } | 1345 } |
1179 else if (tc.is_real_scalar () || tc.is_real_matrix () || tc.is_range ()) | 1346 else if (tc.is_real_scalar () || tc.is_real_matrix () || tc.is_range ()) |
1180 { | 1347 { |
1181 NDArray m = tc.array_value (); | 1348 NDArray m = tc.array_value (); |
1182 | 1349 |