On Sat, Sep 2, 2023 at 11:51 PM Lucier, Bradley J <
[email protected]> wrote:

I’m sorry, but I don’t totally understand your comment "231 doesn't
> directly support arbitrary affine transforms”.  SRFI 231 has
> specialized-array-share, which does allow arbitrary (one-to-one) affine
> transforms on array domains, new-domain -> old-domain.
>

Specialized-array-share returns a specialized-array, so if you convert an
array into a one-dimensional array it gets copied, which is no better than
invoking array->vector.  For the special case of row-major-aref you need to
do flooring division to figure out how to convert the single index to the
multi-index (which then gets converted back to the single-index internally
to array-ref).  You can also pull out the data with `storage-class-data->body`
and then use that to construct a one-dimensional array from it, though I
don't quite see how.


>
> What is needed is a mapping taking
>
> [0, (interval-volume (array-domain A))
>
> to valid consecutive multi-indices in (array-domain A).  One can compute
> this with a series of quotient and remainders of n with partial products of
> the widths of the interval, which are then added to the lower bounds of the
> interval.
>

Of course, having done that you then need to convert the interval back the
other way inside array-ref.   Perhaps you can do something with
`storage-class-data->body, but then you have to index into the body, and
I'm not sure how you do that.  Do storage-class-ref and storage-class-set!
have the right behaviors?

Reply via email to