Feature complete? SRFI 231 and NumPy.
Bradley Lucier 19 Mar 2022 18:59 UTC
After I went through NumPy's array manipulation procedures here:
https://srfi-email.schemers.org/srfi-231/msg/19031902/
I added array-block and generalized array-tile to this SRFI. (I also
fixed a long-standing bug in the sample implementation code to move data
from one array to another that occurred (a) in more than four
dimensions, (b) when moving data to a specialized array, (c) when
checking was needed to see whether the data could be manipulated by the
result array's storage class, (d) when the result array is a subarray of
a larger array, (e) whose first element is not the first element of the
larger array, and (f) whose elements are, nonetheless, stored in
adjacent cells in the body of the array. I missed testing this case
until I tested array-block. I wanted to get that off my chest.)
I don't feel a real need to add anything more from NumPy. That email
has a short implementation of numpy.squeeze and an example about how to
interpret the elements of the body in Fortran, column-major, order. The
CLAPACK library can work with data in row-major order, so I don't see
this as much of a problem for interfacing with LAPACK. NumPy also has
many specialized routines for 2- and 3-dimensional arrays, but they're
special cases.
The only other thing that has been brought up is SRFI 42-style
comprehensions. This SRFI has interval-for-each and array-for-each for
stepping through the multi-indices in an interval or the elements of an
array, and read-pgm in the SRFI document provides an example of building
an array from a stream of data.
I haven't figured out how to do SRFI 42-style comprehensions in a way I
like. A problem (for me) is that the sample implementation seems to
assume stepping through linear data structures (vectors, lists, strings,
ports, ...) and what seems natural in this SRFI are multi-dimensional
data structures; I don't see how to adapt do-ec:do to this situation.
Anyway, I invite further commentary.
Brad