New user self-registration is disabled due to spam. Please email eigen-core-team @ if you need an account.
Before reporting a bug, please make sure that your Eigen version is up-to-date!
Bug 710 - SparseMatrix< shared_ptr<X> > is not working (patch attached)
Summary: SparseMatrix< shared_ptr<X> > is not working (patch attached)
Status: NEW
Alias: None
Product: Eigen
Classification: Unclassified
Component: Sparse (show other bugs)
Version: 3.2
Hardware: All All
: Normal Unknown
Assignee: Nobody
Depends on:
Reported: 2013-12-06 16:26 UTC by Takaki Makino
Modified: 2013-12-06 16:26 UTC (History)
0 users

Proposed patch file for 3.2.0 (8.00 KB, text/plain)
2013-12-06 16:26 UTC, Takaki Makino
no flags Details

Description Takaki Makino 2013-12-06 16:26:17 UTC
Created attachment 404 [details]
Proposed patch file for 3.2.0

When we use a custom Scalar type that require initialization
(like std::shared_ptr), the sparse matrix classes do not work correctly.
The problem is that some classes in SparseCore use memcpy() and memmove() functions, which breaks the C++ object semantics.
I found smart_copy function in Core/Memory.h, which seems currently abandoned, but perfectly suitable for replacing these memcpy()s. As a replacement of memmove(), I make an extension to smart_copy, which detects overlapping region and uses C++11 move semantics if applicable.
Attached please find a proposed patch that replaces all memcpy() into smart_copy.

Note You need to log in before you can comment on or make changes to this bug.