Mercurial > hg > octave-lojdl
changeset 4815:2eb844b27953
[project @ 2004-03-04 00:14:44 by jwe]
author | jwe |
---|---|
date | Thu, 04 Mar 2004 00:14:44 +0000 |
parents | 495e9df75836 |
children | 4908c82cd1a1 |
files | src/ChangeLog src/ov-bool-mat.cc src/ov-bool.cc src/ov-cell.cc src/ov-complex.cc src/ov-cx-mat.cc src/ov-range.cc src/ov-re-mat.cc src/ov-scalar.cc src/ov-str-mat.cc |
diffstat | 10 files changed, 79 insertions(+), 42 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,24 @@ +2004-03-03 John W. Eaton <jwe@bevo.che.wisc.edu> + + * ov-bool.cc (octave_bool::load_hdf5, octave_bool::save_hdf5): + Avoid unnecessary casts. + * ov-bool-mat.cc (octave_bool_matrix::load_hdf5, + octave_bool_matrix::save_hdf5): Likewise. + * ov-cell.cc (octave_cell::load_hdf5, octave_cell::save_hdf5): + Likewise. + * ov-complex.cc (octave_complex::load_hdf5, + octave_complex::save_hdf5): Likewise. + * ov-cx-mat.cc (octave_complex_matrix::load_hdf5, + octave_complex_matrix::save_hdf5): Likewise. + * ov-range.cc (octave_range::load_hdf5, octave_range::save_hdf5): + Likewise. + * ov-re-mat.cc (octave_matrix::load_hdf5, octave_matrix::save_hdf5): + Likewise. + * ov-scalar.cc (octave_scalar::load_hdf5, octave_scalar::save_hdf5): + Likewise. + * ov-str-mat.cc (octave_char_matrix_str::load_hdf5, + octave_char_matrix_str::save_hdf5): Likewise. + 2004-03-03 David Bateman <dbateman@free.fr> * ov-cell.cc (octave_cell::save_hdf5, octave_cell::load_hdf5):
--- a/src/ov-bool-mat.cc +++ b/src/ov-bool-mat.cc @@ -359,7 +359,7 @@ for (int i = 0; i < rank; i++) hdims[i] = d (rank-i-1); - space_hid = H5Screate_simple (rank, hdims, (hsize_t*) 0); + space_hid = H5Screate_simple (rank, hdims, 0); if (space_hid < 0) return false; data_hid = H5Dcreate (loc_id, name, H5T_NATIVE_HBOOL, space_hid, @@ -378,7 +378,7 @@ htmp[i] = mtmp[i]; retval = H5Dwrite (data_hid, H5T_NATIVE_HBOOL, H5S_ALL, H5S_ALL, - H5P_DEFAULT, (void*) htmp) >= 0; + H5P_DEFAULT, htmp) >= 0; H5Dclose (data_hid); H5Sclose (space_hid); @@ -423,14 +423,14 @@ else { dv.resize (rank); - for (int i = 0, j = rank - 1; i < (int)rank; i++, j--) + for (hsize_t i = 0, j = rank - 1; i < rank; i++, j--) dv(j) = hdims[i]; } int nel = dv.numel (); hbool_t htmp[nel]; if (H5Dread (data_hid, H5T_NATIVE_HBOOL, H5S_ALL, H5S_ALL, - H5P_DEFAULT, (void *) htmp) >= 0) + H5P_DEFAULT, htmp) >= 0) { retval = true;
--- a/src/ov-bool.cc +++ b/src/ov-bool.cc @@ -170,7 +170,7 @@ hid_t space_hid = -1, data_hid = -1; bool retval = true; - space_hid = H5Screate_simple (0, dimens, (hsize_t*) 0); + space_hid = H5Screate_simple (0, dimens, 0); if (space_hid < 0) return false; data_hid = H5Dcreate (loc_id, name, H5T_NATIVE_DOUBLE, space_hid, @@ -183,7 +183,7 @@ double tmp = double_value (); retval = H5Dwrite (data_hid, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, - H5P_DEFAULT, (void*) &tmp) >= 0; + H5P_DEFAULT, &tmp) >= 0; H5Dclose (data_hid); H5Sclose (space_hid); @@ -207,7 +207,7 @@ double dtmp; if (H5Dread (data_hid, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, - H5P_DEFAULT, (void *) &dtmp) < 0) + H5P_DEFAULT, &dtmp) < 0) { H5Dclose (data_hid); return false;
--- a/src/ov-cell.cc +++ b/src/ov-cell.cc @@ -687,19 +687,24 @@ } #if defined (HAVE_HDF5) + bool octave_cell::save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats) { dim_vector dv = dims (); - hsize_t rank = dv.length(); + hsize_t rank = dv.length (); hid_t space_hid = -1, data_hid = -1, size_hid = -1; data_hid = H5Gcreate (loc_id, name, 0); - if (data_hid < 0) return false; + + if (data_hid < 0) + return false; // Have to save cell array shape, since can't have a // dataset of groups.... - space_hid = H5Screate_simple (1, &rank, (hsize_t*) 0); + + space_hid = H5Screate_simple (1, &rank, 0); + if (space_hid < 0) { H5Gclose (data_hid); @@ -709,8 +714,8 @@ OCTAVE_LOCAL_BUFFER (int, hdims, rank); // Octave uses column-major, while HDF5 uses row-major ordering - for (int i = 0; i < (int)rank; i++) - hdims[i] = dv (rank-i-1); + for (int i = 0; i < rank; i++) + hdims[i] = dv(rank-i-1); size_hid = H5Dcreate (data_hid, "dims", H5T_NATIVE_INT, space_hid, H5P_DEFAULT); @@ -722,17 +727,19 @@ } if (! H5Dwrite (size_hid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - H5P_DEFAULT, (void*) hdims) < 0) + H5P_DEFAULT, hdims) < 0) { H5Dclose (size_hid); H5Sclose (space_hid); H5Gclose (data_hid); return false; } + H5Dclose (size_hid); H5Sclose (space_hid); - // recursively add each element of the cell to this group + // Recursively add each element of the cell to this group. + Cell tmp = cell_value (); for (int i = 0; i < dv.numel (); i++) @@ -749,6 +756,7 @@ } H5Gclose (data_hid); + return true; } @@ -774,33 +782,40 @@ OCTAVE_LOCAL_BUFFER (hsize_t, hdims, rank); OCTAVE_LOCAL_BUFFER (hsize_t, maxdims, rank); + H5Sget_simple_extent_dims (space_hid, hdims, maxdims); - // Octave uses column-major, while HDF5 uses row-major ordering + // Octave uses column-major, while HDF5 uses row-major ordering. + dim_vector dv; dv.resize (hdims[0]); + OCTAVE_LOCAL_BUFFER (int, tmp, hdims[0]); if (H5Dread (data_hid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - H5P_DEFAULT, (void *) tmp) < 0) + H5P_DEFAULT, tmp) < 0) { H5Dclose(data_hid); H5Gclose(group_id); return false; } + H5Dclose (data_hid); H5Gclose (group_id); - for (int i = 0, j = hdims[0] - 1; i < (int)hdims[0]; i++, j--) + for (hsize_t i = 0, j = hdims[0] - 1; i < hdims[0]; i++, j--) dv(j) = tmp[i]; hdf5_callback_data dsub; herr_t retval2 = -1; + Cell m (dv); + int current_item = 0; + if (have_h5giterate_bug) - current_item = 1; // Skip dims items in group + current_item = 1; // Skip dims items in group. #ifdef HAVE_H5GGET_NUM_OBJS hsize_t num_obj = 0; @@ -825,7 +840,7 @@ m.elem (i) = ov; if (have_h5giterate_bug) - current_item++; // H5Giterate returned the last index processed + current_item++; // H5Giterate returned the last index processed. } @@ -837,6 +852,7 @@ return retval; } + #endif DEFUN (iscell, args, ,
--- a/src/ov-complex.cc +++ b/src/ov-complex.cc @@ -244,7 +244,7 @@ hid_t space_hid = -1, type_hid = -1, data_hid = -1; bool retval = true; - space_hid = H5Screate_simple (0, dimens, (hsize_t*) 0); + space_hid = H5Screate_simple (0, dimens, 0); if (space_hid < 0) return false; type_hid = hdf5_make_complex_type (H5T_NATIVE_DOUBLE); @@ -264,7 +264,7 @@ Complex tmp = complex_value (); retval = H5Dwrite (data_hid, type_hid, H5S_ALL, H5S_ALL, H5P_DEFAULT, - (void*) X_CAST (double*, &tmp)) >= 0; + &tmp) >= 0; H5Dclose (data_hid); H5Tclose (type_hid); @@ -303,7 +303,7 @@ // complex scalar: Complex ctmp; if (H5Dread (data_hid, complex_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, - (void *) X_CAST (double *, &ctmp)) >= 0) + &ctmp) >= 0) { retval = true; scalar = ctmp;
--- a/src/ov-cx-mat.cc +++ b/src/ov-cx-mat.cc @@ -461,7 +461,7 @@ for (int i = 0; i < rank; i++) hdims[i] = d (rank-i-1); - space_hid = H5Screate_simple (rank, hdims, (hsize_t*) 0); + space_hid = H5Screate_simple (rank, hdims, 0); if (space_hid < 0) return false; hid_t save_type_hid = H5T_NATIVE_DOUBLE; @@ -510,7 +510,7 @@ { Complex *mtmp = m.fortran_vec (); if (H5Dwrite (data_hid, complex_type_hid, H5S_ALL, H5S_ALL, H5P_DEFAULT, - (void*) X_CAST (double *, mtmp)) < 0) + mtmp) < 0) { H5Tclose (complex_type_hid); retval = false; @@ -575,14 +575,14 @@ else { dv.resize (rank); - for (int i = 0, j = rank - 1; i < (int)rank; i++, j--) + for (hsize_t i = 0, j = rank - 1; i < rank; i++, j--) dv(j) = hdims[i]; } ComplexNDArray m (dv); Complex *reim = m.fortran_vec (); - if (H5Dread (data_hid, complex_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, - (void *) X_CAST (double *, reim)) >= 0) + if (H5Dread (data_hid, complex_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, + reim) >= 0) { retval = true; matrix = m;
--- a/src/ov-range.cc +++ b/src/ov-range.cc @@ -383,7 +383,7 @@ hid_t space_hid = -1, type_hid = -1, data_hid = -1; bool retval = true; - space_hid = H5Screate_simple (0, dimens, (hsize_t*) 0); + space_hid = H5Screate_simple (0, dimens, 0); if (space_hid < 0) return false; type_hid = hdf5_make_range_type (H5T_NATIVE_DOUBLE); @@ -408,7 +408,7 @@ range_vals[2] = r.inc (); retval = H5Dwrite (data_hid, type_hid, H5S_ALL, H5S_ALL, H5P_DEFAULT, - (void*) range_vals) >= 0; + range_vals) >= 0; H5Dclose (data_hid); H5Tclose (type_hid); @@ -446,7 +446,7 @@ double rangevals[3]; if (H5Dread (data_hid, range_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, - (void *) rangevals) >= 0) + rangevals) >= 0) { retval = true; Range r (rangevals[0], rangevals[1], rangevals[2]);
--- a/src/ov-re-mat.cc +++ b/src/ov-re-mat.cc @@ -524,7 +524,7 @@ for (int i = 0; i < rank; i++) hdims[i] = d (rank-i-1); - space_hid = H5Screate_simple (rank, hdims, (hsize_t *)0); + space_hid = H5Screate_simple (rank, hdims, 0); if (space_hid < 0) return false; @@ -562,7 +562,7 @@ double *mtmp = m.fortran_vec (); retval = H5Dwrite (data_hid, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, - H5P_DEFAULT, (void*) mtmp) >= 0; + H5P_DEFAULT, mtmp) >= 0; H5Dclose (data_hid); H5Sclose (space_hid); @@ -608,14 +608,14 @@ else { dv.resize (rank); - for (int i = 0, j = rank - 1; i < (int)rank; i++, j--) + for (hsize_t i = 0, j = rank - 1; i < rank; i++, j--) dv(j) = hdims[i]; } NDArray m (dv); double *re = m.fortran_vec (); if (H5Dread (data_hid, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, - H5P_DEFAULT, (void *) re) >= 0) + H5P_DEFAULT, re) >= 0) { retval = true; matrix = m;
--- a/src/ov-scalar.cc +++ b/src/ov-scalar.cc @@ -192,7 +192,7 @@ bool octave_scalar::load_binary (std::istream& is, bool swap, - oct_mach_info::float_format fmt) + oct_mach_info::float_format fmt) { char tmp; if (! is.read (X_CAST (char *, &tmp), 1)) @@ -216,7 +216,7 @@ hid_t space_hid = -1, data_hid = -1; bool retval = true; - space_hid = H5Screate_simple (0, dimens, (hsize_t*) 0); + space_hid = H5Screate_simple (0, dimens, 0); if (space_hid < 0) return false; data_hid = H5Dcreate (loc_id, name, H5T_NATIVE_DOUBLE, space_hid, @@ -229,7 +229,7 @@ double tmp = double_value (); retval = H5Dwrite (data_hid, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, - H5P_DEFAULT, (void*) &tmp) >= 0; + H5P_DEFAULT, &tmp) >= 0; H5Dclose (data_hid); H5Sclose (space_hid); @@ -253,7 +253,7 @@ double dtmp; if (H5Dread (data_hid, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, - H5P_DEFAULT, (void *) &dtmp) < 0) + H5P_DEFAULT, &dtmp) < 0) { H5Dclose (data_hid); return false;
--- a/src/ov-str-mat.cc +++ b/src/ov-str-mat.cc @@ -512,7 +512,7 @@ for (int i = 0; i < rank; i++) hdims[i] = d (rank-i-1); - space_hid = H5Screate_simple (rank, hdims, (hsize_t *)0); + space_hid = H5Screate_simple (rank, hdims, 0); if (space_hid < 0) return false; @@ -530,7 +530,7 @@ s[i] = m(i); retval = H5Dwrite (data_hid, H5T_NATIVE_CHAR, H5S_ALL, H5S_ALL, - H5P_DEFAULT, (void*) s) >= 0; + H5P_DEFAULT, s) >= 0; H5Dclose (data_hid); H5Sclose (space_hid); @@ -580,14 +580,14 @@ else { dv.resize (rank); - for (int i = 0, j = rank - 1; i < (int)rank; i++, j--) + for (hsize_t i = 0, j = rank - 1; i < rank; i++, j--) dv(j) = hdims[i]; } charNDArray m (dv); char *str = m.fortran_vec (); if (H5Dread (data_hid, H5T_NATIVE_CHAR, H5S_ALL, H5S_ALL, - H5P_DEFAULT, (void *) str) >= 0) + H5P_DEFAULT, str) >= 0) { retval = true; matrix = m;