Registered Member
|
Hello everyone,
I'm trying to read and write a large float Eigen Matrix (size is approx 8K * 8K). Currently, my code looks like this:
The matrix my_matrix is dynamically allocated and, before writing, is correctly initialized (I made some tests). However, this code has the effect of creating a small file (1Kb) in my directory, which turns out to be unuseful, since after the read instruction all the value in the new matrix are equal to zero. Is it possible to store the matrix in some binary file? Or do I need to use only text file? Thanks for your advice! |
Registered Member
|
An object of type MatrixXf does not contain the values, but it contains a pointer to a dynamically allocated region of memory containing the values. This is the pointer returned by .data() .
I did not try it, but I think you can write and read the values with
This does not store the size of the matrix in the file. |
Registered Member
|
Should work, but serialization is really one of those things you should leave to a readily available & widely tested library. I personally prefer Boost, but any other should work. If you get the need to gain access to any inside data or add methods to Eigen (which might be the case with Boost), you can use the plugin system.
|
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]