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: Carlo de Falco
Subject: Re: Octave from C++: Saving objects in binary
Date: Mon, 7 Jun 2010 10:17:11 +0200


On 7 Jun 2010, at 09:46, Chidambaram Annamalai wrote:

Thanks a lot! This is what I wanted to achieve.

Could you also tell me how I could modify the save_binary_data
function arguments so that the Matrix A is stored in single precision
in the binary file? I believe real matrices in octave are by default
in double precision. I tried float_value (A) but it didn't work.

I haven't tested it and I don't think it's the cleanest solution,
bu, maybe this works:

#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();


Thanks,
Chillu



reply via email to

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