Fix multi-dimensional indexing bug, add tests, and some convenience r… by tmrn411 · Pull Request #9 · diffplug/matfilerw

Fantastic work, thanks very much! I didn't believe that a bug this horrific could possibly have survived undetected for so long, but there's an overload for getIndex(int m, int n) which has the correct column-major behavior. Which leads to this catastrophe:

int arg2 = array.getIndex(3, 2);
int arr = array.getIndex(new int[]{3, 2});

Obviously these should give the same result, but they do not. They do give the same result if the array happens to be square - and most of the test cases use square or cubic arrays, which has helped mask this.

This means that if we just fixed this behavior (no CM methods, just fix the actual methods), then all users of 1D and 2D matrices will be unaffected, as well as users of "square" N-D matrices.

I think this calls for a major-version bump which calls out the error in the previous versions, and making the CM methods be the real methods. I'll merge your change, make these adjustments, and publish as 3.0.0.

I'd like to credit you in the acknowledgements, would you like to be tmrn411 or something else? Any profile you'd like me to link to?