On 8/28/24 2:10 PM, Bradley Lucier wrote:
I now understand that array broadcasting (or at least array-lift as described below) can be framed as a "Bawden-style" array transformation.
This statement is incorrect in an interesting way---array-lift as defined in the previous email employs an affine mapping of the multi-index argument, but that mapping is not one-to-one on the new domain to the old domain, it is necessarily many-to-one.
The SRFI document states that the multi-index mapping argument to specialized-array-share must be one-to-one.
The motivation is that you don't want a value stored in one location to change the value in a "different" location.
But this motivation doesn't hold if the result is an immutable specialized array.
So for example one could "broadcast" a one-dimensional specialized array to all the rows of an *immutable* two-dimensional specialized array, while keeping the one-dimensional array as the entire backing store of the result. Then one could apply other array transforms (permuting, extracting, etc.) while keeping O(1)-time accesses.
I'd have to check the details to see if this would work. Then it may be more efficient than the NumPy implementation. (The NumPy documentation explicitly suggests using loops rather than array operations if the broadcast arrays get too big.)
Brad
