Mercurial > octave-nkf
comparison src/ov-cx-mat.cc @ 4805:b0d6da24caeb
[project @ 2004-03-02 03:43:15 by jwe]
author | jwe |
---|---|
date | Tue, 02 Mar 2004 03:43:15 +0000 |
parents | 14dc2267c343 |
children | 2eb844b27953 |
comparison
equal
deleted
inserted
replaced
4804:6202d9b75f83 | 4805:b0d6da24caeb |
---|---|
444 bool | 444 bool |
445 octave_complex_matrix::save_hdf5 (hid_t loc_id, const char *name, | 445 octave_complex_matrix::save_hdf5 (hid_t loc_id, const char *name, |
446 bool save_as_floats) | 446 bool save_as_floats) |
447 { | 447 { |
448 dim_vector d = dims (); | 448 dim_vector d = dims (); |
449 hsize_t hdims[d.length () > 2 ? d.length () : 3]; | 449 int empty = save_hdf5_empty (loc_id, name, d); |
450 hid_t space_hid = -1, type_hid = -1, data_hid = -1; | 450 if (empty != 0) |
451 int rank = ( (d (0) == 1) && (d.length () == 2) ? 1 : d.length ()); | 451 return (empty > 0); |
452 | |
453 int rank = d.length (); | |
454 hid_t space_hid = -1, data_hid = -1, type_hid = -1; | |
452 bool retval = true; | 455 bool retval = true; |
453 ComplexNDArray m = complex_array_value (); | 456 ComplexNDArray m = complex_array_value (); |
454 | 457 |
458 OCTAVE_LOCAL_BUFFER (hsize_t, hdims, rank); | |
459 | |
455 // Octave uses column-major, while HDF5 uses row-major ordering | 460 // Octave uses column-major, while HDF5 uses row-major ordering |
456 for (int i = 0, j = d.length() - 1; i < d.length (); i++, j--) | 461 for (int i = 0; i < rank; i++) |
457 hdims[i] = d (j); | 462 hdims[i] = d (rank-i-1); |
458 | 463 |
459 space_hid = H5Screate_simple (rank, hdims, (hsize_t*) 0); | 464 space_hid = H5Screate_simple (rank, hdims, (hsize_t*) 0); |
460 if (space_hid < 0) return false; | 465 if (space_hid < 0) return false; |
461 | 466 |
462 hid_t save_type_hid = H5T_NATIVE_DOUBLE; | 467 hid_t save_type_hid = H5T_NATIVE_DOUBLE; |
463 | 468 |
521 | 526 |
522 bool | 527 bool |
523 octave_complex_matrix::load_hdf5 (hid_t loc_id, const char *name, | 528 octave_complex_matrix::load_hdf5 (hid_t loc_id, const char *name, |
524 bool /* have_h5giterate_bug */) | 529 bool /* have_h5giterate_bug */) |
525 { | 530 { |
531 dim_vector dv; | |
532 int empty = load_hdf5_empty (loc_id, name, dv); | |
533 if (empty > 0) | |
534 matrix.resize(dv); | |
535 if (empty != 0) | |
536 return (empty > 0); | |
537 | |
526 bool retval = false; | 538 bool retval = false; |
527 hid_t data_hid = H5Dopen (loc_id, name); | 539 hid_t data_hid = H5Dopen (loc_id, name); |
528 hid_t type_hid = H5Dget_type (data_hid); | 540 hid_t type_hid = H5Dget_type (data_hid); |
529 | 541 |
530 hid_t complex_type = hdf5_make_complex_type (H5T_NATIVE_DOUBLE); | 542 hid_t complex_type = hdf5_make_complex_type (H5T_NATIVE_DOUBLE); |
550 | 562 |
551 OCTAVE_LOCAL_BUFFER (hsize_t, hdims, rank); | 563 OCTAVE_LOCAL_BUFFER (hsize_t, hdims, rank); |
552 OCTAVE_LOCAL_BUFFER (hsize_t, maxdims, rank); | 564 OCTAVE_LOCAL_BUFFER (hsize_t, maxdims, rank); |
553 | 565 |
554 H5Sget_simple_extent_dims (space_id, hdims, maxdims); | 566 H5Sget_simple_extent_dims (space_id, hdims, maxdims); |
555 | |
556 dim_vector dv; | |
557 | 567 |
558 // Octave uses column-major, while HDF5 uses row-major ordering | 568 // Octave uses column-major, while HDF5 uses row-major ordering |
559 if (rank == 1) | 569 if (rank == 1) |
560 { | 570 { |
561 dv.resize (2); | 571 dv.resize (2); |