From bug-request at octave dot org Tue Feb 22 14:59:07 2005 Subject: [2.1.65] 1-D Matrices in Binary Data Files From: "jason cipriani" To: bug at octave dot org Date: Tue, 22 Feb 2005 16:04:46 -0500 Hi. In writing an application (in C) that writes out Octave binary data files, = I believe I have uncovered a bug. When saving a variable of type "matrix", = binary data files store the number of dimensions, and then the length in ea= ch dimension. I have found that I can write binary files with only 1 dimension of length = N (using the "new" binary format). These files can be loaded into Octave an= d the data in them can be handled just fine (i.e. I can perform basic math = operations on it, and assign other variables to the data). However, AFAIK, = it is impossible to create 1D data from within Octave, meaning that I can l= oad data from a binary file that I can't possibly create by hand from withi= n Octave. If I load a "1D matrix" from my binary data file, and then save i= t in Octave ASCII format, "ndims" is 1, and "columns" is set to -1 in the o= utput file: ---------- # Created by Octave 2.1.65, Tue Feb 22 15:53:59 2005 EST <> # name: sigma_for # type: global matrix # rows: 1 # columns: -1 0.157966644730402 ---------- Octave then fails when I try to load the data back in from the saved ASCII = file, with: ---------- error: load: failed to extract number of rows and columns error: load: trouble reading ascii file `test' error: load: reading file test ---------- The size() results for this kind of matrix look like: ---------- octave:2> size(sigma_for) ans =3D 1 ---------- Note that there is only one dimension reported, as opposed to the normal "1= 1" when you just declare scalars. Additionally, and more mysterious: ---------- octave:3> isscalar(sigma_for) ans =3D 0 octave:4> ismatrix(sigma_for) ans =3D 0 octave:5> isvector(sigma_for) ans =3D 0 octave:6> isnumeric(sigma_for) ans =3D 1 ---------- I am not extremely familiar with Octave. If this is not a bug, then I would= like to know how to declare such 1D matrices from within Octave itself. Ho= wever, the fact that saving these types of data to ASCII files creates corr= upt ASCII files, and the fact that Octave believes that my data is not a sc= alar, a matrix, or a vector, lead me to believe that this is not correct be= havior. I will be happy to post an example of this type of binary file if necessary. Thanks, Jason Cipriani ------------------------------------------------------------- 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 -------------------------------------------------------------