It now seems to be working properly.
No test in place.
Need short-circuits for 1D case, to match performance of the old function.