I'm porting some MATLAB code to Numpy. This task includes stripping the MEX out of some C++ code and replacing it with equivalent calls to Numpy's C-API. One problem is that the MEX code treats the incoming data as Fortran-ordered because that's how MATLAB orders its arrays. Numpy, on the other hand, uses a C ordering by default.
Short of completely re-writing the MEX code for C ordering, I can:
- (A) Reorder the arrays that go into the C code with
.copy('F')
and reorder those that come out with.copy('C')
- (B) Figure out how to get numpy to "emulate" MATLAB by doing everything in Fortran order from the get-go.
Option A -- currently implemented -- works just fine but is terribly inefficient. Anybody know how to make option B work?