Ideas for future array SRFIs: procedures for numerical arrays
John Cowan 12 Apr 2026 03:41 UTC
Numerical arrays:
Except insofar as the storage class constrains the elements of an
array, the operations of SRFI 231 do not care what type the values
have, so operations that depend on numerical elements aren't
available. Here are a few ideas for suitable procedures:
Matrix addition, subtraction, and {Hadamard, cross, dot} products are
trivial to do with array-map, array-inner-product and
array-outer-product, but we could have wrappers for them with more
obvious names: as in Racket, these could be macros.
(make-identity-array storage-class dimensions size) returns an
n-dimensional hypercube of real numbers where every dimension has a
lower bound of 0 and an upper bound of size, and every element on the
principal diagonal is 1 and every other element is zero. I suppose
this would normally be used with a non-generic storage-class, but
there might be some way to specify if the values are exact or inexact
for use with generic-storage-class.(array-determinant array) returns
the determinant of a matrix. I don't know how this generalizes, if at
all, to higher dimensions.
(array-divide array1 array2) returns the matrix divide of array1 and
array2. I don't know how this generalizes, if at all, to higher
dimensions.
(array-invert array1) is the result of dividing an appropriately sized
identity array by array1. Again, I don't know if this generalizes.
How about FFTs? Racket supports FFT over a specified dimension or all
dimensions, plus their inverses.