Boost logo

Boost :

Subject: Re: [boost] different matrix library?
From: Rutger ter Borg (rutger_at_[hidden])
Date: 2009-08-18 06:37:37


Edward Grace wrote:
>
> Hi Rutger,
>
> I'm not sure I understand. Perhaps because, I'm guessing, you don't
> understand what the
>
> B(tgt{:}) = A(src{:})
>
> is doing -- it took me a while to figure out when I first saw it.
> Can you confirm that you are happy with the following - src on the
> left tgt on the right?

I think I understood. Although the statement looks powerful, I think it is a
bit of "cheating" because setting up the index vectors tgt and src is done
in a loop, by dimension.

> How would *you* do this, elegantly, in C++? That's a genuine
> question -- I'm curious because, quite frankly, it's foxed me for
> ages and I would like to do this in C++! ;-)

I would say this is a typical example that I would solve by recursion. For
the case of a nested std::vector, please see attached. Uncomment lines in
main for other dimensions, to see that working. Add some more goodies for
sizes and stuff and you're done for any arbitrary nesting and/or dimension
of data. Not sure if it is the the most elegant solution, though.

Cheers,

Rutger




Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk