Numpy's array manipulation routines compared to this SRFI. Bradley Lucier (25 Feb 2022 20:17 UTC)
Re: Numpy's array manipulation routines compared to this SRFI. Bradley Lucier (28 Aug 2024 18:10 UTC)

Re: Numpy's array manipulation routines compared to this SRFI. Bradley Lucier 28 Aug 2024 18:10 UTC

On 8/28/24 9:09 AM, Alex Shinn wrote:
>
> FYI I just added array-broadcast to (chibi math linalg):
Thank you for this note.

I now understand that array broadcasting (or at least array-lift as
described below) can be framed as a "Bawden-style" array transformation.
  I guess I found the description and usage examples of NumPy's array
broadcasting to combine a number of concepts (adding axes to the left of
a domain, expanding axes of length one, ...) in a way that confused me.

If there is a followup document to SRFI 231, I'd add

(array-lift I A)

which returns for each interval I and array A a new immutable
generalized array B with domain

(interval-cartesian-product I (array-domain A))

whose getter satisfies

(apply (array-getter B) multi-index)
==
(apply (array-getter A) (drop multi-index (interval-dimension I))

Combining array-lift with array-permute gives the same functionality as
NumPy's broadcast rules (with different notational conventions).

For convenience, to match NumPy's broadcast rules one could add

(array-broadcast A B)

which takes as arguments two arrays A and B (probably not allowing
scalars) and returns two immutable generalized arrays A-prime and
B-prime with the same domains that satisfy NumPy's broadcast rules.  I
suppose if one array argument didn't need to be changed to match the
other, then that argument could be returned unchanged (whether or not it
is specialized or mutable).

Brad