Guile Mailing List Archive

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

Re: Guile numerical work and uniform arrays



> My impression is that there is also an array of pointers to one-dim
> D-arrays.

I would hope not!

> Otherwise, I think, it would be impossible to work with shared arrays.

Er, no.  A shared array is (or should be) a pointer to a one-dimensional
base array, plus a descriptor (containing offset from the start of the
base vector, plus length and stride of each dimension).  The descriptor
defines a linear transformation of the array indexes into an
index into the base array.

For generality, it makes sense that non-shared multi-dimensional arrays
should also be represented using a base vector (one-dimensional array)
plus descriptor.  It is then easy and cheap to perform various
interesting transformations on (shared) arrays.

> My suggestion was, thus: 1) to give user the possibility
> to know that a given multi-dimensional array can be treated as
> one-dimensional; 2) to have a standard procedure to get a pointer to
> this chunk.

I cannot see how this can be mathematically meaningful, in general,
nor do I see any use for it (except perhaps some optionization).

There are two "obvious" way to view a multi-dimensional array as
a one-dimensional array:

(1) As a vector of arrays.  E.g. an array of shape (3, 4, 5) may
be reasonably interpreted as a vector of size 3, each of whose
elements has shape (4, 5).  (Of course you can use some other
dimension, but it is most natural to select the first dimension
as primary - unless you're a Fortran programmer!)

(2) In row-major-order (or I guess as column-major-order, if you're
a Fortran programmer).  This is sometims useful;  unfortunately,
there is no linear transformation that maps a general (shared)
multi-dimensional array into a one-dimensional array such that
can be described using a single stride per dimension.  The
(important) exception is the case of simple multi-dimensional
arrays (with no offsetting relative to a base vector).  In other
cases, you need a more general (non-linear) mapping function.

	--Per Bothner
Cygnus Solutions     bothner@cygnus.com     http://www.cygnus.com/~bothner

Guile Home | Main Index | Thread Index