help-octave
[Top][All Lists]
Advanced

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

Re: Octave from C++: Saving objects in binary


From: Chidambaram Annamalai
Subject: Re: Octave from C++: Saving objects in binary
Date: Wed, 9 Jun 2010 13:52:24 +0530

On 6/7/10, Carlo de Falco <address@hidden> wrote:
>> #include <octave/load-save.h>
>> #include <octave/ls-oct-binary.h>
>>  std::ofstream os ("A.mat");
>>  bool boolvar(false);
>>  write_header (os, LS_BINARY);
>>  save_binary_data (os, octave_value (FloatMatrix (A)),
>>                    std::string("A"), std::string(""),
>>                    boolvar, boolvar);
>>  os.close();

After saving the binary data I try to read them as follows:

    /* read the problem from .dat files */
    Matrix A;
    octave_value oA(A);
    std::ifstream is;
    std::string fname;
    std::string doc;

    bool boolvar, othervar;
    oct_mach_info::float_format flt_fmt;

    /* A */
    is.open("Data/A.mat");
    read_binary_file_header (is, boolvar, flt_fmt);
    /* Segmentation fault while executing the next function */
    read_binary_data (is, false, flt_fmt, fname, boolvar, oA, doc);
    is.close();

But this code segfaults after reading the file header. Am I reading
the data properly?

Chillu


reply via email to

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