C++ Math Library Reference    

Constructing a C++ Prototype

A complete set of C++ prototypes appears on the reference page for each function. You can reconstruct the C++ prototypes for a library function by examining the MATLAB syntax for a function. In C++ an overloaded version of the function exists for each different way of calling the MATLAB function.

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

To construct the C++ prototypes, follow this procedure.

  1. Use the first return value, U, as the return value from the function. C++ routines can only return a single value. The data type for the return value is mwArray.
  2. Add the remaining return values, S and V, as the first, second, etc., output arguments to the function. The data type for an output argument is mwArray *.
  3. Add the number of input arguments to the prototype, X and Zero, one after another following the output arguments. The data type for an input argument is mwArray.

Here is the complete C++ prototype for the svd routine.

Note Contrast the data type for an output argument with the data type for an input argument. The type for an output argument is a pointer to an mwArray. The type for an input argument is an mwArray. The const mwArray & in the prototype improves the efficiency of the function, but you can ignore the const and & and just pass in an mwArray.)


 Calling Conventions Translating MATLAB Syntax into C++ Syntax