C Math Library Reference    

Constructing a C Prototype

One C prototype supports all the possible ways to call a particular MATLAB C Math Library function. You can reconstruct the C prototype by examining the MATLAB syntax for a function.

For example, the MATLAB function svd() has the following syntax:

To construct the C prototype for mlfSvd(), follow this procedure.

  1. Find the MATLAB syntax that includes the largest number of return values and input arguments.
  2. Use the first return value, U, as the return value from the C version of the function. (C routines can only have one return value.) The data type for the return value is mxArray *.
  3. Add the remaining return values, S and V, as output arguments to the C function. Output arguments appear before any input arguments in the argument list. The second return value becomes the first output argument, as so on. The data type for the C output arguments is mxArray **.
  4. Specify the maximum number of input arguments in the C routine prototype. The data type for input arguments is mxArray *.

Here is the complete C prototype for the svd function. Compare it to the original MATLAB syntax.


 C Math Library Calling Conventions Translating MATLAB Syntax into C Syntax