Re:Yorick is an interpreted programming language for scienti...
by imurray on Saturday November 04, 2023 @12:08PM
(#38142343)
> Although length-1 axes already being in the data sounds worrying: you have an array that doesn't depend on an axis, but there's an axis anyway to show where it would go if it did?
Example:
A / A.sum(axis=3, keepdims=True)
Make all of the vectors along axis=3 sum up to one. There are other ways of doing it, but this way seems fairly clear to me. Unfortunately for this example (and several others!) keepdims=True isn't the default. keepdims=True is the behavior in Matlab/Octave, so the example becomes A / sum(A, 4)
with 4=3+1 because Matlab is 1-based like Fortran.
Named axis systems like einops are much better regarded. I've seen some implementations of similar functionality in APL, and various discussions of how it could be built into an array language (I have my own design where that's a core idea, but not using APL syntax).