2009/9/28 Joel Falcou <joel.falcou@lri.fr>
Oliver Fochler wrote:
Hi,

I'm trying to write some dimension independent routine that makes use of Boost.MultiArray containers. The thing is that I would need several such MultiArrays within this routine with the number of MultiArrays depending on the overall number of dimensions.
And here is where it becomes complicated (at least for me). Let N be the overall number of dimensions the routine works with. Then I would a collection of N MultiArrays - but not with fixed dimensions but rather with varying (internal) dimension. That is, a collection like this:

boost::multi_array<int, N> A
boost::multi_array<int, N-1> B
boost::multi_array<int, N-2> C
...

However, since N may vary when the routine is called I cannot hardcode the array as above. I was thinking of a vector of multi_array or something like that. But then I don't know how to treat the second template parameter in defining the type of the vector (array, ...).

Is there a simple and efficient way to do this?

If you know N at compile why not using a fusion::vector of multi_array ?
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users

Well, I don't really know N at compile time. Eventually I'd like to have a routine that can be called with varying N.
BTW: The algorithm is meant for interpolating values from higher dimensional grids (N=4 or N=8 for example). Is anyone aware of easy-to-integrate, solid, fast library solutions to this problem? Linear interpolation would be fine for starters.

If I was to write the code with fixed N known at compile time (which would be sort of ok as a first step), how would I instantiate the fusion::vector?

vector< boost::multi_array<int, 3>, boost::multi_array<int,2>, boost::multi_array<int,1> > test

wouldn't make that much sense, since it would not be flexible at all.


Oliver