owlbarn / owl

Owl - OCaml Scientific Computing @ https://ocaml.xyz
MIT License
1.2k stars 120 forks source link

Map a fancy/basic index list into a list of array coordinates? #670

Closed zoj613 closed 2 weeks ago

zoj613 commented 1 month ago

Does the library expose a function to map a list of index constructors into a list of the resulting array coordinates? Something like [L [0; 2]; R [1;3]; I 4] getting mapped to [[0; 1; 4]; [0; 2; 4]; [0; 3; 4]; [2; 1; 4]; [2; 2; 4]; [2; 3; 4]]?

zoj613 commented 2 weeks ago

I figured out how to do this using a combination of Owl_base_slicing.check_slice_definition, a custom range and cartesian_product functions