[eigen] Memory Map a SparseMatrix |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
Hi,
I'm using the current SVN revision 909800 trying to use of the started
sparse matrix implementation in Eigen.
Because I will reuse the data of some sparse matrices very often, I want
to store it inside a file. I already have some C code that uses memory
mapped files. I came across the Map function in SparseArray. I suppose
there should also be a Map function passing a pointer to the outer
indices and a SparseArray for the values with its appropriate indices
and the needed sizes.
The trouble is you can't pass pointers that weren't allocated using
new[] because SparseArray/SparseMatrix uses delete[]. Suppose I pass a
pointer not allocated using new[] I run into troubles. I suppose this is
also the case for normal matrices.
In my case I'm using Boost.Interprocess to do like this:
// mmap file
file_mapping m_file(filename.c_str(), read_write);
mapped_region region(m_file, read_write);
and now I like to use the Map function with pointers pointing as needed
to memory mapped region like this:
MappedMatrix m = MappedMatrix::Map(region.get_address(), ...)
I'm very unsure whether this is a proper way to achieve storing and
reading matrices to/from files. Maybe other ways to do this are more
appropriate, e.g. object serialization. My approach is to store the data
in a memory mapped file.
How do you elegantly store an Eigen matrix in a file? Maybe I'm misusing
the Map function for this purpose.
Regards,
Jens