|Re: [eigen] Memory Map a SparseMatrix|
[ Thread Index |
| More lists.tuxfamily.org/eigen Archives
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Memory Map a SparseMatrix
- From: "Gael Guennebaud" <gael.guennebaud@xxxxxxxxx>
- Date: Wed, 14 Jan 2009 23:40:22 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=YXTfAC2biTJtbZxlnbmqVbc3yy8is3SM2gDklg1RSzE=; b=W9BKervy9S2WF7D6/+UsBSWFuKtBLlbr7GB/a7hqQGsY9hmXA2Jt2hjYFNOP+mT7Y6 o8Y0998N4jjLOcF+84amn3jufKId6kFNzodLqzO1X0OWdROiTBVMBsJRXR0CoOOtuktJ 1nzV96ZsRHrEFYOnxMM2km4PEm9qMRfozHt2w=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=DLRBfRT6z9esqp8iXAyAyrYGrZYZxPOD7OX9ey4J/c39yZO3xMSOALDEr21YEpIP+i bIP3/cru22Tx8NYpNEs/v/dA5l887nhXMzMOms9XRoCqsaF9thhyihoB0J38HYe0JFJn FPBJZW5rX8mgctgNxohA/4hfZTytRkfJW9tyM=
indeed, it is currently not possible to map external data as a sparse
object but that's on the TODO list.
Unlike the Map class for dense matrix, here I think I'll simply reuse
SparseMatrix and add a flag to prevent deletion of the data, etc...
On Mon, Jan 12, 2009 at 11:01 AM, Jens Mueller <jens.k.mueller@xxxxxx> wrote:
> 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.