Boost logo

Boost :

From: Larry Evans (jcampbell3_at_[hidden])
Date: 2002-01-09 19:00:51


rgarcia1771 wrote:

> Hi Larrym
>
> --- In boost_at_y..., Larry Evans <jcampbell3_at_p...> wrote:
> > Larry Evans wrote:
> >
> > >
> > > Could someone compare this method for accessing subarrays with the
> one in:
> > >
> > > _An APL Compiler_
> > > Timothy Budd
> > > Springer-Verlag(1988)
> > >
> I'm trying to locate a copy of this book, but so far I'm coming up
> empty handed. Perhaps some of the ideas in this book could lead to

What about the 1978 conference record mentioned in my email?

>
> optimizations in multi_array's implementation. If they do not affect
> the interface, though, they need not be implemented prior to
> multi_array's acceptance. I'm very open to optimizations, so long as
> they don't require all users be aware of them.
>
> >
> > The following is a short comparison between Budd's book and
> > multi_array:
>
> Thanks for the info!
>
> > t[i] == ?
> >
> > The ? above indicates I couldn not find any corresponding
> > multi_array data. t[i] in Budd's book is used when an dimension
> (or
> > axis in apl nomenclature) is "reversed", i.e. index 0 actually
> > corresponds to s[i]-1. However, the base.hpp:346 line defines
> > calculate_descending_dimension_offset, which looks like it does
> > something related, but I'm not sure.
>
> Given your description of t[i], I would say that your assessment is
> correct. You can create a [const_]multi_array[_ref] that has
> descending dimensions and a customized memory layout by passing a
> boost::general_storage_order to the constructor.
>
> > I would recommend NOT accepting into boost until some methods for
> > reversing axes and other methods for transposing axes are provided.
> > In particular, it's unclear from the code how to get a false entry
> > into ascending_.
>
> This functionality exists in the library. I am updating the
> documentation to reflect comments made here. Memory layout is one
> area I'm targeting for extended coverage.

I'd recommend providing a reverse(Axis i) for reversing each axis
individually instead of using only the general_storage_order constructor.
Also, this should be easy to do. For example, section 6.1.4 of the book says
that reverse(Axis i) results in a new "stepper" (indicated below with ' marks)
defined in terms of the old stepper as:

             t'[i] = s[i] - t[i] - 1
             d'[i] = - d[i]

Then, on p. 86, the offset of the initial value of the array is given by:

             alpha = t[0]*e[0] + t[1]*e[1] + ... + t[nrank-1]*e[nrank-1]

and the offset at arbitrary index is given with the help of gamma,
which is defined on p. 86 as:

              gamma[i] = sum_{q[j]=i}(d[j]*e[j])

(The actual nation used was the greek sigma indicating summation).
I think what Budd meant was:

               gamma[i] = d[q[i]]*e[q[i]]

Then the offset at arbitrary index, a[0]...a[nrank-1] is:

                offset = alpha + sum_{i=0}^{nrank-1}(a[i]*gamma[i])

I think the t's can be eliminated by storing the alpha with the
stepper. Anyway, the following is what I coded as Stepper::reverse(int aAxis):

            { startVar()+=(shape(aAxis)-1)*stride(aAxis)
             ; strideVar(aAxis)=-stride(aAxis)
             ;}

startVar() == alpha. The others should be self-explanatory.
Stepper::transpose(void) was coded as:

      {
      ; int j
      ; int m=rank()
      ; int* tconfig= new int[m]
     ; for(j=0; j<m; j++)
       {
       ; tconfig[m-(j+1)]=config()[j][Axis]
       ;}
     ; for(j=0; j<m; j++)
       {
       ; configVar()[j][Axis]=tconfig[j]
       ;}
      ; delete[] tconfig
      ;}

where config()[j][Axis] == q[j].


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