Re: [eigen] Eigen with Boost::smart_ptr

[ Thread Index | Date Index | More Archives ]

On Tue, Nov 8, 2011 at 9:50 PM, Jim Bosch <talljimbo@xxxxxxxxx> wrote:
> On 11/08/2011 08:44 AM, Christoph Hertzberg wrote:
>> Hi,
>> On 08.11.2011 13:07, Sathishkumar Duraisamy wrote:
>>> Hi all,
>>> 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.

Thanks for pointing me, "why need to dynamically allocate?".  This
helps me change the model.

As per the present model, I have  a class called ADC driver class
which actually fills the row matrix  and send to another class called
rawsamples that holds these matrices.  Now I have been changing the
model in which ADC class requests the matrices to be filled from the
rawsamples. ( for  reference I have attached some diagrams!)

>> 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
>>> week ptr?
>> 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.
As per the first model, I have to manage large no of pointer to
dynamically allocated matrices. To hold these matrices I planned to
use pointer container.

> Jim

With thanks,
Sathishkumar D

Attachment: RawSamples_Model _A.jpeg
Description: JPEG image

Attachment: RawSamples_Model_B.jpeg
Description: JPEG image

Mail converted by MHonArc 2.6.19+