|Re: [eigen] Eigen with Boost::smart_ptr|
[ Thread Index |
| More lists.tuxfamily.org/eigen Archives
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Eigen with Boost::smart_ptr
- From: Jim Bosch <talljimbo@xxxxxxxxx>
- Date: Tue, 08 Nov 2011 11:20:02 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=fehaMzJRhMrElbSea1N/FxYduPfLoNxFXFY8K+/6dvY=; b=rR96vvIuSSC1F2viuW2EeBDgvUpntCT5FEzGjSI89sbzAW9drDZsVmSjnP05B5xuuV fy/3PhIQi0qyOmOhuDebndTaYxtBh4jlen/k7lL+n68SWq5Dt6QdmQfn/5o+6cOm7cBE m3GRsg63SMuKW6eotTxku4ZuISZSWR9euC1Ls=
On 11/08/2011 08:44 AM, Christoph Hertzberg wrote:
On 08.11.2011 13:07, Sathishkumar Duraisamy wrote:
I am in some kind of signal processing application. To manage and
manipulate data, I have been using Eigen Matrix.
Can you please give me some recommendation for using pointers for
dynamically allocated eigen matrix?
I guess you need to be a bit more specific for that ...
Maybe you don't need to dynamically allocate your matrices at all, since
Eigen::MatrixXd already dynamically allocate their memory.
Side note: That might actually be a nice feature, having kind-of a
shared matrix, i.e. multiple instances of the same matrix share the same
memory until the matrix is modified, in which case it allocates new
memory (unless of course it is the last instance using that memory).
I've actually been working on shared Eigen matrices as part of an Eigen
interface to another project, and I'd be happy to contribute code to
that effect, but it's not as straightforward as one might expect. For
instance, when one gets a block of a shared matrix, does the block share
memory with the original? That would make it a lot harder for the
compiler to optimize away the block, but it would make it a lot more
sensible when you want to return the block from a function where the
matrix is a local variable.
Is it possible to use boost::smart_ptr and boost::pointer_container
with Eigen Matrix. In case, which is good smart_ptr, shared_ptr or
I can't see a reason why it is not possible.
smart_ptr is just the name of the library, isn't it?
W.r.t shared_ptr vs weak_ptr: you can construct weak_ptr only from
shared_ptr, so you need at least one shared_ptr per matrix anyways.
What's better afterwards depends on what you are planning to do.
I agree, and I'd also say that I can think of very few situations in
which one would gain anything by using pointer container with Eigen,
though it is possible. Pointer container is mainly intended for holding
hierarchies of polymorphic classes.