Is your feature request related to a problem? Please describe.
Too many 3d loops in the code. It is irritating and there is a need to differentiate the 3d-to-1d look-up between the magnetic and geographic grids, which adds if statements.
Describe the solution you'd like
Need to eliminate loops, and armadillo code does this. Armadillo also takes care of different grids.
Describe alternatives you've considered
Might think of using templates, but I don't know how to do this.
Additional context
Qusai suggested using armadillo, and this is a good solution.