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.
s = svd(X) [U,S,V] = svd(X) [U,S,V] = svd(X,0)
To construct the C++ prototypes, follow this procedure.
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
.
S
and V
, as the first, second, etc., output arguments to the function. The data type for an output argument is mwArray *
.
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.
mwArray svd(mwArray *S, mwArray *V, const mwArray &X, const mwArray &Zero);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 | ![]() |