comparison libinterp/interp-core/ls-mat5.cc @ 15467:049e8bbff782

maint: periodic merge of stable to default
author John W. Eaton <jwe@octave.org>
date Mon, 01 Oct 2012 18:30:44 -0400
parents src/ls-mat5.cc@d174210ce1ec src/ls-mat5.cc@9ed4fc294f3f
children 39fd2ad26fb7
comparison
equal deleted inserted replaced
15465:ded4ce76ee7a 15467:049e8bbff782
372 \ 372 \
373 std::streampos tmp_pos; \ 373 std::streampos tmp_pos; \
374 \ 374 \
375 if (read_mat5_tag (is, swap, type, len)) \ 375 if (read_mat5_tag (is, swap, type, len)) \
376 { \ 376 { \
377 error ("load: reading matrix data for `%s'", retval.c_str ()); \ 377 error ("load: reading matrix data for '%s'", retval.c_str ()); \
378 goto data_read_error; \ 378 goto data_read_error; \
379 } \ 379 } \
380 \ 380 \
381 octave_idx_type n = re.numel (); \ 381 octave_idx_type n = re.numel (); \
382 tmp_pos = is.tellg (); \ 382 tmp_pos = is.tellg (); \
383 read_mat5_integer_data (is, re.fortran_vec (), n, swap, \ 383 read_mat5_integer_data (is, re.fortran_vec (), n, swap, \
384 static_cast<enum mat5_data_type> (type)); \ 384 static_cast<enum mat5_data_type> (type)); \
385 \ 385 \
386 if (! is || error_state) \ 386 if (! is || error_state) \
387 { \ 387 { \
388 error ("load: reading matrix data for `%s'", retval.c_str ()); \ 388 error ("load: reading matrix data for '%s'", retval.c_str ()); \
389 goto data_read_error; \ 389 goto data_read_error; \
390 } \ 390 } \
391 \ 391 \
392 is.seekg (tmp_pos + static_cast<std::streamoff> (PAD (len))); \ 392 is.seekg (tmp_pos + static_cast<std::streamoff> (PAD (len))); \
393 \ 393 \
396 /* We don't handle imag integer types, convert to an array */ \ 396 /* We don't handle imag integer types, convert to an array */ \
397 NDArray im (dims); \ 397 NDArray im (dims); \
398 \ 398 \
399 if (read_mat5_tag (is, swap, type, len)) \ 399 if (read_mat5_tag (is, swap, type, len)) \
400 { \ 400 { \
401 error ("load: reading matrix data for `%s'", \ 401 error ("load: reading matrix data for '%s'", \
402 retval.c_str ()); \ 402 retval.c_str ()); \
403 goto data_read_error; \ 403 goto data_read_error; \
404 } \ 404 } \
405 \ 405 \
406 n = im.numel (); \ 406 n = im.numel (); \
407 read_mat5_binary_data (is, im.fortran_vec (), n, swap, \ 407 read_mat5_binary_data (is, im.fortran_vec (), n, swap, \
408 static_cast<enum mat5_data_type> (type), flt_fmt); \ 408 static_cast<enum mat5_data_type> (type), flt_fmt); \
409 \ 409 \
410 if (! is || error_state) \ 410 if (! is || error_state) \
411 { \ 411 { \
412 error ("load: reading imaginary matrix data for `%s'", \ 412 error ("load: reading imaginary matrix data for '%s'", \
413 retval.c_str ()); \ 413 retval.c_str ()); \
414 goto data_read_error; \ 414 goto data_read_error; \
415 } \ 415 } \
416 \ 416 \
417 ComplexNDArray ctmp (dims); \ 417 ComplexNDArray ctmp (dims); \
712 std::string nm 712 std::string nm
713 = read_mat5_binary_element (is, filename, swap, global, tc2); 713 = read_mat5_binary_element (is, filename, swap, global, tc2);
714 714
715 if (! is || error_state) 715 if (! is || error_state)
716 { 716 {
717 error ("load: reading cell data for `%s'", nm.c_str ()); 717 error ("load: reading cell data for '%s'", nm.c_str ());
718 goto data_read_error; 718 goto data_read_error;
719 } 719 }
720 720
721 cell_array(i) = tc2; 721 cell_array(i) = tc2;
722 } 722 }
754 // row indices 754 // row indices
755 std::streampos tmp_pos; 755 std::streampos tmp_pos;
756 756
757 if (read_mat5_tag (is, swap, type, len)) 757 if (read_mat5_tag (is, swap, type, len))
758 { 758 {
759 error ("load: reading sparse row data for `%s'", retval.c_str ()); 759 error ("load: reading sparse row data for '%s'", retval.c_str ());
760 goto data_read_error; 760 goto data_read_error;
761 } 761 }
762 762
763 tmp_pos = is.tellg (); 763 tmp_pos = is.tellg ();
764 764
765 read_mat5_integer_data (is, ridx, nzmax, swap, 765 read_mat5_integer_data (is, ridx, nzmax, swap,
766 static_cast<enum mat5_data_type> (type)); 766 static_cast<enum mat5_data_type> (type));
767 767
768 if (! is || error_state) 768 if (! is || error_state)
769 { 769 {
770 error ("load: reading sparse row data for `%s'", retval.c_str ()); 770 error ("load: reading sparse row data for '%s'", retval.c_str ());
771 goto data_read_error; 771 goto data_read_error;
772 } 772 }
773 773
774 is.seekg (tmp_pos + static_cast<std::streamoff> (PAD (len))); 774 is.seekg (tmp_pos + static_cast<std::streamoff> (PAD (len)));
775 775
776 // col indices 776 // col indices
777 if (read_mat5_tag (is, swap, type, len)) 777 if (read_mat5_tag (is, swap, type, len))
778 { 778 {
779 error ("load: reading sparse column data for `%s'", retval.c_str ()); 779 error ("load: reading sparse column data for '%s'", retval.c_str ());
780 goto data_read_error; 780 goto data_read_error;
781 } 781 }
782 782
783 tmp_pos = is.tellg (); 783 tmp_pos = is.tellg ();
784 784
785 read_mat5_integer_data (is, cidx, nc + 1, swap, 785 read_mat5_integer_data (is, cidx, nc + 1, swap,
786 static_cast<enum mat5_data_type> (type)); 786 static_cast<enum mat5_data_type> (type));
787 787
788 if (! is || error_state) 788 if (! is || error_state)
789 { 789 {
790 error ("load: reading sparse column data for `%s'", retval.c_str ()); 790 error ("load: reading sparse column data for '%s'", retval.c_str ());
791 goto data_read_error; 791 goto data_read_error;
792 } 792 }
793 793
794 is.seekg (tmp_pos + static_cast<std::streamoff> (PAD (len))); 794 is.seekg (tmp_pos + static_cast<std::streamoff> (PAD (len)));
795 795
796 // real data subelement 796 // real data subelement
797 if (read_mat5_tag (is, swap, type, len)) 797 if (read_mat5_tag (is, swap, type, len))
798 { 798 {
799 error ("load: reading sparse matrix data for `%s'", retval.c_str ()); 799 error ("load: reading sparse matrix data for '%s'", retval.c_str ());
800 goto data_read_error; 800 goto data_read_error;
801 } 801 }
802 802
803 octave_idx_type nnz = cidx[nc]; 803 octave_idx_type nnz = cidx[nc];
804 NDArray re; 804 NDArray re;
812 read_mat5_binary_data (is, data, nnz, swap, 812 read_mat5_binary_data (is, data, nnz, swap,
813 static_cast<enum mat5_data_type> (type), flt_fmt); 813 static_cast<enum mat5_data_type> (type), flt_fmt);
814 814
815 if (! is || error_state) 815 if (! is || error_state)
816 { 816 {
817 error ("load: reading sparse matrix data for `%s'", retval.c_str ()); 817 error ("load: reading sparse matrix data for '%s'", retval.c_str ());
818 goto data_read_error; 818 goto data_read_error;
819 } 819 }
820 820
821 is.seekg (tmp_pos + static_cast<std::streamoff> (PAD (len))); 821 is.seekg (tmp_pos + static_cast<std::streamoff> (PAD (len)));
822 822
825 { 825 {
826 NDArray im (dim_vector (static_cast<int> (nnz), 1)); 826 NDArray im (dim_vector (static_cast<int> (nnz), 1));
827 827
828 if (read_mat5_tag (is, swap, type, len)) 828 if (read_mat5_tag (is, swap, type, len))
829 { 829 {
830 error ("load: reading sparse matrix data for `%s'", retval.c_str ()); 830 error ("load: reading sparse matrix data for '%s'", retval.c_str ());
831 goto data_read_error; 831 goto data_read_error;
832 } 832 }
833 833
834 read_mat5_binary_data (is, im.fortran_vec (), nnz, swap, 834 read_mat5_binary_data (is, im.fortran_vec (), nnz, swap,
835 static_cast<enum mat5_data_type> (type), flt_fmt); 835 static_cast<enum mat5_data_type> (type), flt_fmt);
836 836
837 if (! is || error_state) 837 if (! is || error_state)
838 { 838 {
839 error ("load: reading imaginary sparse matrix data for `%s'", 839 error ("load: reading imaginary sparse matrix data for '%s'",
840 retval.c_str ()); 840 retval.c_str ());
841 goto data_read_error; 841 goto data_read_error;
842 } 842 }
843 843
844 for (octave_idx_type i = 0; i < nnz; i++) 844 for (octave_idx_type i = 0; i < nnz; i++)
1317 1317
1318 std::streampos tmp_pos; 1318 std::streampos tmp_pos;
1319 1319
1320 if (read_mat5_tag (is, swap, type, len)) 1320 if (read_mat5_tag (is, swap, type, len))
1321 { 1321 {
1322 error ("load: reading matrix data for `%s'", retval.c_str ()); 1322 error ("load: reading matrix data for '%s'", retval.c_str ());
1323 goto data_read_error; 1323 goto data_read_error;
1324 } 1324 }
1325 1325
1326 octave_idx_type n = re.numel (); 1326 octave_idx_type n = re.numel ();
1327 tmp_pos = is.tellg (); 1327 tmp_pos = is.tellg ();
1328 read_mat5_binary_data (is, re.fortran_vec (), n, swap, 1328 read_mat5_binary_data (is, re.fortran_vec (), n, swap,
1329 static_cast<enum mat5_data_type> (type), flt_fmt); 1329 static_cast<enum mat5_data_type> (type), flt_fmt);
1330 1330
1331 if (! is || error_state) 1331 if (! is || error_state)
1332 { 1332 {
1333 error ("load: reading matrix data for `%s'", retval.c_str ()); 1333 error ("load: reading matrix data for '%s'", retval.c_str ());
1334 goto data_read_error; 1334 goto data_read_error;
1335 } 1335 }
1336 1336
1337 is.seekg (tmp_pos + static_cast<std::streamoff> (PAD (len))); 1337 is.seekg (tmp_pos + static_cast<std::streamoff> (PAD (len)));
1338 1338
1342 1342
1343 FloatNDArray im (dims); 1343 FloatNDArray im (dims);
1344 1344
1345 if (read_mat5_tag (is, swap, type, len)) 1345 if (read_mat5_tag (is, swap, type, len))
1346 { 1346 {
1347 error ("load: reading matrix data for `%s'", retval.c_str ()); 1347 error ("load: reading matrix data for '%s'", retval.c_str ());
1348 goto data_read_error; 1348 goto data_read_error;
1349 } 1349 }
1350 1350
1351 n = im.numel (); 1351 n = im.numel ();
1352 read_mat5_binary_data (is, im.fortran_vec (), n, swap, 1352 read_mat5_binary_data (is, im.fortran_vec (), n, swap,
1353 static_cast<enum mat5_data_type> (type), flt_fmt); 1353 static_cast<enum mat5_data_type> (type), flt_fmt);
1354 1354
1355 if (! is || error_state) 1355 if (! is || error_state)
1356 { 1356 {
1357 error ("load: reading imaginary matrix data for `%s'", 1357 error ("load: reading imaginary matrix data for '%s'",
1358 retval.c_str ()); 1358 retval.c_str ());
1359 goto data_read_error; 1359 goto data_read_error;
1360 } 1360 }
1361 1361
1362 FloatComplexNDArray ctmp (dims); 1362 FloatComplexNDArray ctmp (dims);
1383 1383
1384 std::streampos tmp_pos; 1384 std::streampos tmp_pos;
1385 1385
1386 if (read_mat5_tag (is, swap, type, len)) 1386 if (read_mat5_tag (is, swap, type, len))
1387 { 1387 {
1388 error ("load: reading matrix data for `%s'", retval.c_str ()); 1388 error ("load: reading matrix data for '%s'", retval.c_str ());
1389 goto data_read_error; 1389 goto data_read_error;
1390 } 1390 }
1391 1391
1392 octave_idx_type n = re.numel (); 1392 octave_idx_type n = re.numel ();
1393 tmp_pos = is.tellg (); 1393 tmp_pos = is.tellg ();
1394 read_mat5_binary_data (is, re.fortran_vec (), n, swap, 1394 read_mat5_binary_data (is, re.fortran_vec (), n, swap,
1395 static_cast<enum mat5_data_type> (type), flt_fmt); 1395 static_cast<enum mat5_data_type> (type), flt_fmt);
1396 1396
1397 if (! is || error_state) 1397 if (! is || error_state)
1398 { 1398 {
1399 error ("load: reading matrix data for `%s'", retval.c_str ()); 1399 error ("load: reading matrix data for '%s'", retval.c_str ());
1400 goto data_read_error; 1400 goto data_read_error;
1401 } 1401 }
1402 1402
1403 is.seekg (tmp_pos + static_cast<std::streamoff> (PAD (len))); 1403 is.seekg (tmp_pos + static_cast<std::streamoff> (PAD (len)));
1404 1404
1421 1421
1422 NDArray im (dims); 1422 NDArray im (dims);
1423 1423
1424 if (read_mat5_tag (is, swap, type, len)) 1424 if (read_mat5_tag (is, swap, type, len))
1425 { 1425 {
1426 error ("load: reading matrix data for `%s'", retval.c_str ()); 1426 error ("load: reading matrix data for '%s'", retval.c_str ());
1427 goto data_read_error; 1427 goto data_read_error;
1428 } 1428 }
1429 1429
1430 n = im.numel (); 1430 n = im.numel ();
1431 read_mat5_binary_data (is, im.fortran_vec (), n, swap, 1431 read_mat5_binary_data (is, im.fortran_vec (), n, swap,
1432 static_cast<enum mat5_data_type> (type), flt_fmt); 1432 static_cast<enum mat5_data_type> (type), flt_fmt);
1433 1433
1434 if (! is || error_state) 1434 if (! is || error_state)
1435 { 1435 {
1436 error ("load: reading imaginary matrix data for `%s'", 1436 error ("load: reading imaginary matrix data for '%s'",
1437 retval.c_str ()); 1437 retval.c_str ());
1438 goto data_read_error; 1438 goto data_read_error;
1439 } 1439 }
1440 1440
1441 ComplexNDArray ctmp (dims); 1441 ComplexNDArray ctmp (dims);
1503 1503
1504 return retval; 1504 return retval;
1505 1505
1506 data_read_error: 1506 data_read_error:
1507 early_read_error: 1507 early_read_error:
1508 error ("load: trouble reading binary file `%s'", filename.c_str ()); 1508 error ("load: trouble reading binary file '%s'", filename.c_str ());
1509 return std::string (); 1509 return std::string ();
1510 1510
1511 skip_ahead: 1511 skip_ahead:
1512 warning ("skipping over `%s'", retval.c_str ()); 1512 warning ("skipping over '%s'", retval.c_str ());
1513 is.seekg (pos + static_cast<std::streamoff> (element_length)); 1513 is.seekg (pos + static_cast<std::streamoff> (element_length));
1514 return read_mat5_binary_element (is, filename, swap, global, tc); 1514 return read_mat5_binary_element (is, filename, swap, global, tc);
1515 } 1515 }
1516 1516
1517 int 1517 int
2715 2715
2716 skip_to_next: 2716 skip_to_next:
2717 return true; 2717 return true;
2718 2718
2719 error_cleanup: 2719 error_cleanup:
2720 error ("save: error while writing `%s' to MAT file", name.c_str ()); 2720 error ("save: error while writing '%s' to MAT file", name.c_str ());
2721 2721
2722 return false; 2722 return false;
2723 } 2723 }