Boost logo

Boost Users :

Subject: Re: [Boost-users] Boost MultiArray and Boost uBLAS - Designed to be used together?
From: Jesse Perla (jesseperla_at_[hidden])
Date: 2010-01-14 14:08:05


On Jan 14, 7:40 am, "Bilokon, Paul " <paul.bilo..._at_[hidden]> wrote:
> Hi all,
>
> Were Boost MultiArray and Boost uBLAS designed to be used together?
> I.e. can I apply linear algebra operations to Boost MultiArrays and get Boost MultiArrays back?
> If this is impossible / impractical / inefficient, what's the right approach (conversion?).

If this is a one-off problem, you could order the dimensions of the
multi_array (fortran vs. C ordering) so that the matrix data you need
is contiguous, get the underlying data pointer, go to the right offset
by looking at the extents() variable, then use ublas data adaptors to
turn the pointer into. Of course, this is a horrible hack and not
generally useful.

As far as I can tell, the right way to do this is: Create ublas
adaptors for multi_array references of dimension 1 and 2. I am not
entirely sure how to do this, but I was told before that looking at
the undocumented ublas::shallow_array_adaptor in \boost\numeric\ublas
\storage.hpp might give a template for the 1d version at least.

The other thing I thought about was that the matrix_range class and
equivalent for vectors (which is returned from subrange, and is in
matrix_proxy.cpp) would provide a great template for the iterators,
typedefs, etc. necessary for the adaptor. I imagine most of the code
will just be proxying iterators to the underlying multi_array
iterators, etc.

I haven't had a pressing need for this, so might never get around to
playing with it. But if you write it, I am sure everyone on the ublas
list would love to have it.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net