What I have found typically works in this scenario (2D containers that aren’t used for matrix algebra) is to convert your wide representation to a long one. Exactly how tidyverse in R has a pivot_longer() to convert a wide representation to a long representation. In a long representation the contents of the wide are flattened to a vector and with that vector you then have one or more new indexing vectors. The SUG 1.13 example has an example of this where the array of ints jj
is an index vector for the data vector y
. Another source for vectorization inspiration is my super-optimized version of the same model that’s here.
1 Like