octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: error saving empty matrix in HDF5 format


From: David Bateman
Subject: Re: error saving empty matrix in HDF5 format
Date: Tue, 2 Mar 2004 00:45:35 +0100
User-agent: Mutt/1.4.1i

Ok, here is a patch for this and the problem identified by Hans Ekkehard. It
also in passing adds Nd array support for load/save to strings. Its not
necessary the best approach, but since HDF5 doesn't support zero dimensioned
matrices I don't see another way of doing this...

Cheers
David

According to John W. Eaton <address@hidden> (on 02/27/04):
> I just noticed the following error with the current CVS sources:
> 
>   octave:1> clear
>   octave:2> x = [];
>   octave:3> save -hdf5 x.hdf5
>   HDF5-DIAG: Error detected in HDF5 library version: 1.6.1 thread 16384.  
> Back trace follows.
>     #000: ../../../src/H5S.c line 1708 in H5Screate_simple(): zero sized 
> dimension for non-unlimited dimension
>       major(01): Function arguments
>       minor(05): Bad value
>   error: save: error while writing `x' to hdf5 file
> 
> I tried to fix this, but it seems that HDF5 does not like empty arrays.
> 
> Any ideas on what the right was is to save empty arrays and preserve
> their dimensions when using HDF5?
> 
> Also, the following cod seems a bit clumsy to me
> 
>   bool
>   octave_matrix::save_hdf5 (hid_t loc_id, const char *name, bool 
> save_as_floats)
>   {
>     dim_vector d = dims ();
>     hsize_t hdims[d.length () > 2 ? d.length () : 3];
>     hid_t space_hid = -1, data_hid = -1;
>     int rank = ( (d (0) == 1) && (d.length () == 2) ? 1 : d.length ());
>     bool retval = true;
>     NDArray m = array_value ();
> 
>     // Octave uses column-major, while HDF5 uses row-major ordering
>     for (int i = 0, j = d.length() - 1; i < d.length (); i++, j--)
>       hdims[i] = d (j);
> 
>     space_hid = H5Screate_simple (rank, hdims, (hsize_t*) 0);
> 
> Why not just
> 
>     dim_vector d = dims ();
>     int rank = d.length ();
>     hsize_t hdims[rank];
>     hid_t space_hid = -1, data_hid = -1;
>     bool retval = true;
>     NDArray m = array_value ();
> 
>     // Octave uses column-major, while HDF5 uses row-major ordering
>     for (int i = 0; < rank; i++)
>       hdims[i] = d (rank-i-1);
> 
>     space_hid = H5Screate_simple (rank, hdims, (hsize_t*) 0);
> 
> Finally, I suspect that there is very little difference in the code
> for various matrix types.  It would be nice to implement this in the
> base class (though that might not be possible) or as a template
> function to avoid repeated code.
> 
> jwe

-- 
David Bateman                                address@hidden
Motorola CRM                                 +33 1 69 35 48 04 (Ph) 
Parc Les Algorithmes, Commune de St Aubin    +33 1 69 35 77 01 (Fax) 
91193 Gif-Sur-Yvette FRANCE

The information contained in this communication has been classified as: 

[x] General Business Information 
[ ] Motorola Internal Use Only 
[ ] Motorola Confidential Proprietary

Attachment: patch
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]