[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: doc make-shared-array

From: Marius Vollmer
Subject: Re: doc make-shared-array
Date: Mon, 28 Feb 2005 03:25:58 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/21.3.50 (gnu/linux)

Kevin Ryde <address@hidden> writes:

> Expanded words about make-shared-array, trying to clarify what linear
> means, and adding lots of example usages.

Nice, thanks!

> [...] and perhaps enclose-array too (if anyone can explain what it
> actually does :-).

Yeah, strange critters, those enclosed arrays.  Enclosing an array is
like creating a new array where each element is a shared array created
from the original array.  An enclosed array is different from this in
that the shared arrays are created 'on-demand' during array-ref.

> The quotient/remainder example flattening two dims to one works I
> think, but I'm not sure it obeys a strict reading of what's described
> for a "linear" mapfunc.

It is not linear (and not affine) and make-shared array only works by
accident in this case, I think.  For example, bounds checking is not
done independently for each dimension, but only for the start and end
points in the lexical ordering of all possible indices, or something
like that.

Also, the map function is not really linear, it is affine (because of
the offset).

>      An array can be flattened from say two dimensions to one by having
>      the MAPFUNC translate portions of the new array to rows in the old,
>           (make-shared-array #2((a b c d) (e f g h) (i j k l))
>                              (lambda (i) (list (quotient i 4)
>                                                (remainder i 4)))
>                              12)
>           => #(a b c d e f g h i j k l)

This should be removed.  An array can be flattened with

>      The opposite is possible too, taking say a one dimensional array
>      and considering portions of it as rows,
>           (make-shared-array #1(a b c d e f g h i j k l)
>                              (lambda (i j) (list (+ (* i 3) j)))
>                              4 3)
>           => #2((a b c) (d e f) (g h i) (j k l))

But this is OK, of course.

>      With a negation on an index, the order that elements appear can be
>      reversed.  This is the sort of thing `array-transpose' below does.

Hmm, transpose-array (not array-transpose) permutes the indices, it
does not reverse the direction within one dimension.

GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3  331E FAF8 226A D5D4 E405

reply via email to

[Prev in Thread] Current Thread [Next in Thread]