Are there programming languages or optimizers that simplify this kind of plumbing?
https://github.com/dzaima/CBQN/blob/v0.11.0/src/singeli/src/...
The language is oriented towards compile-time array programming instead of managing a bunch of individual vectors. So you have runtime vec_select{} (docs at [1]), mirrored by compile-time select{}, and the indices generated by pairs{} can be used in either.
[0] https://github.com/mlochbaum/Singeli/
[1] https://github.com/mlochbaum/Singeli/tree/master/include#sim...
GNU Octave if you’re on NIX or you don’t have $40k for a license