This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Do I Need to Upgrade My MEX Files to Use Interleaved Complex API?

You do not need to update your MEX source code to continue to build your MEX files. The mex command uses the -R2017b API by default. However, in a future version of MATLAB®, mex will use the interleaved complex API -R2018a by default and then you need to modify your build command. Therefore, to ensure the desired behavior across versions of MATLAB, add the compatibility flag -R2017b to your build scripts.

Can I Run Existing MEX Functions?

You can run existing binary MEX files without upgrading the files for use with the interleaved complex API. However, other incompatibilities might prevent execution of an existing MEX function. If your function does not execute properly, search for mex in the relevant MATLAB release notes and review the Compatibility Considerations topics.

Must I Update My Source MEX Files?

State of Your Source CodeNext Action
My MEX functions do not use complex numbers.

Check that your functions properly handle any complex data input. Calls to the mxGetPr (C)/mxGetPr (Fortran) and mxGetData (C)/mxGetData (Fortran) are not recommended for complex arrays.

MathWorks recommends that you build using the -R2017b flag to ensure the desired behavior across versions of MATLAB.

If you use mxGetData or mxSetData, consider replacing them with typed data access functions. For more information, see Using the interleaved complex API.

I do not plan to update my code.

If your MEX functions use complex numbers, then you have chosen to opt out. MathWorks recommends that you build using the compatibility flag -R2017b.

If your code processes complex numbers, you might notice a performance impact as MATLAB accesses the compatibility interface.

I want to update my code. Where do I start?

To update source code, see Upgrade MEX Files to Use Interleaved Complex API.

I use complex numbers in MEX functions, but do not have access to the source code.

Ask the owner of the source code to follow the steps in Upgrade MEX Files to Use Interleaved Complex API.

I use complex numbers with third-party libraries. My MEX code is responsible for transforming the MATLAB representation of complex numbers to the library's representation of complex numbers.

Identify the library's representation of complex numbers. Sometimes the representation might be closer to the interleaved representation used in MATLAB.

In other cases, libraries have options for representing complex numbers in memory. If this is so, refer to the vendor documentation and choose the representation that most closely matches the MATLAB interleaved representation.

My MEX function generates errors.

You must recompile the MEX file from the source code. If using the -R2017b flag does not resolve the issue, then there might be incompatibilities in your source code. For information about incompatibilities, see Can I Run Existing MEX Functions? MathWorks recommends that you update your MEX source code to use the interleaved complex API.

Related Topics