MATLAB: Help with “mxGetPi is deprecated”

mexmxgetpi

Hello
I am trying to compile an old mex function. The first lines are:
void mexFunction(int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[] )
{
mxArray *blk_cell_pr, *A_cell_pr;
double *A, *B, *AI, *BI, *blksize, *Atmp, *AItmp
....
The problem is that variables AI and BI use the deprecated function MxGetPi (AI = mxGetPi(prhs[1]), for instance) and I have no idea how to modify the code to accommodate the changes. I can use a flag (-R2017b) to compile it but sooner or later I will have to change the code (I've been doing that since 93).
I try the help files but I could not find an example and to be honest I did not understand a thing on the explanation on the consequences of mxGetPi being deprecated.
Any help will be appreciated.
Cheers
Ed

Best Answer

With the R2018a release of MATLAB, complex real/imag data is stored in an interleaved fashion instead of the separate fashion of R2017b and earlier. If you compile with the -R2017b flag (the default for R2018a) then the complex data is passed into and out of your mex routine via a deep copy, which will slow you down but should still work (unless you are doing something like modifying an input variable inplace). The deep copy stuff is the penalty you pay for using the old memory model API (i.e., the -R2017b flag) in R2018a and later.
How to go about changing your code for -R2018a depends on what your code does. We can't advise you unless we see your code.