Boost logo

Boost Users :

Subject: Re: [Boost-users] multi-array and pdes
From: Larry Evans (cppljevans_at_[hidden])
Date: 2011-06-27 11:54:02


On 05/27/11 14:14, Larry Evans wrote:
[snip]
> After finding:
>
> Reference access(boost::type<Reference>,index idx,TPtr base,
> const size_type* extents,
> const index* strides,
> const index* index_bases) const {
>
> BOOST_ASSERT(idx - index_bases[0] >= 0);
> BOOST_ASSERT(size_type(idx - index_bases[0]) < extents[0]);
> // return a sub_array<T,NDims-1> proxy object
> TPtr newbase = base + idx * strides[0];
> return Reference(newbase,extents+1,strides+1,index_bases+1);
>
> in boost/multi_array/base.hpp, I'm guessing that array_dyn has
> no advantage in offset calculation since there's no test in
> that base.hpp code on general_storage_order<>::ascending.
> However, I'm still not sure how multi_array does it, unless
> it allows strides to be negative to account for a false
> ascending value and increments the base value to account for
> the negative strides, much like array_dyn's:
>
> box_domain::init_iter_strides
>
> Sorry for the noise about offset calculations.

After reading:

  http://www.boost.org/doc/libs/1_46_1/libs/multi_array
    /doc/reference.html#memory_layout

which provides an example:

Finally, both dimensions could be stored in descending order:

  int data[] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
  int *a = data + 11;
  int s[] = { -4, -1 };

which strongly suggest that multi_array *does* use negative
strides:

  int s[] = { -4, -1 };

*and* somehow performs an offset calculation to account for
those:

  int *a = data + 11;

I'm guessing that there's really no difference in the way array_dyn
implements this reversal and offset calculation. The only difference
is in the interface which uses a bool to specify whether an axis
is reversed rather than a negative length.

I just didn't see where this was done from looking at code :(

-regards
Larry


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