[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Octave binary file format specification
From: |
David Bateman |
Subject: |
Re: Octave binary file format specification |
Date: |
Wed, 10 Nov 2004 14:35:30 +0100 |
User-agent: |
Mutt/1.4.1i |
Hate to respond to my own e-mails, but I see my previous mail was
wrong... You are in fact useing the new format. The type flag of "255"
is specific for the new binary file format...
The save_binary function in ov-re-mat.cc tells you what the missing bytes
are in your format. The first four bytes are the number of dimensions in
the matrix. This is stored as a negative value to distinguish it from the
old binary format. Thus a 2-D matrix the four bytes represent -2, ie
0xFEFFFFFF in little endian as you found out. Note if the file is big
endian the magic keyword isn't "Octave-1-L" but rather "Octave-1-B".
Also note that vectors are assumed to have 2 dimensions, and not one.
As previously mentioned the other missing bytes comes from the save_type
enum in data-conv.h that denotes the save type of the data.
You really need to read all of the octave_value save_binary functions for
the types that interest though, since the formats are particular to each
type. For example, you've figured out the "matrix" format but the "scalar"
format just has a single byte for the save_type (usually LS_DOUBLE) and
then the data itself.
Regards
David
According to David Bateman <address@hidden> (on 11/10/04):
> Paul,
>
> I notice the code you are writing is for the old binary format. The
> new format explicitly save the type name, as a 4-byte integer telling
> the length of the typename and then a string with the type name. This
> replaces the value "6" for the matrix type in your code. That being
> said the old format should work for backward compatiability reasons,
> at least with the basic data types.
>
> One of the 5 bytes you have that is unexplained is the type of the data.
> This byte includes information on whether it is float/double/char, etc.
> It is of type save_type which is an enum
>
> enum save_type
> {
> LS_U_CHAR = 0,
> LS_U_SHORT = 1,
> LS_U_INT = 2,
> LS_CHAR = 3,
> LS_SHORT = 4,
> LS_INT = 5,
> LS_FLOAT = 6,
> LS_DOUBLE = 7,
> LS_U_LONG = 8,
> LS_LONG = 9
> };
>
> Information on this byte can be found in the function write_doubles, in
> data-conv.cc. I'm not sure what the other bytes are.
>
> The new binary load/save code is split into the part in ls-oct-binary.cc
> that save the variable, its name, whether its global or not and its
> documentation. The actually saving of the variables is then handled in
> the save_binary function of each of the octave_value class.
>
> If you don't want to rely on Matlabs format, then use the HDF5 format,
> that can easily be used for matrix, complex matrix, structures, without
> doing anything that is octave specific.. There was some sample HDF5
> code on the bugs list from Claude a few weeks ago to save a structure
> of matrices. The bug associated with this is fixed in 2.1.61 and so
> it might be used as an example code for exchange in the hdf5 format.
>
> Regards
> David
>
> --
> 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
--
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
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------