23.07.2012 Views

MATLAB C++ Math Library Reference

MATLAB C++ Math Library Reference

MATLAB C++ Math Library Reference

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

mwArray svd(mwArray *S, mwArray *V, const mwArray &X,<br />

const mwArray &Zero);<br />

Note Contrastthedatatypeforanoutputargumentwiththedatatypeforan<br />

input argument. The type for an output argument is a pointer to an mwArray.<br />

The type for an input argument is an mwArray. Theconst mwArray & in the<br />

prototype improves the efficiency of the function, but you can ignore the const<br />

and & and just pass in an mwArray.)<br />

Translating <strong>MATLAB</strong> Syntax into <strong>C++</strong> Syntax<br />

This procedure translates the <strong>MATLAB</strong> call [U,S,V] = svd(X,0) into a <strong>C++</strong><br />

call. The procedure applies to library functions in general.<br />

Note that within a call to a <strong>MATLAB</strong> <strong>C++</strong> <strong>Math</strong> <strong>Library</strong> function, an output<br />

argument is preceded by &; an input argument is not.<br />

1 Declare input, output, and return variables as mwArray variables, and<br />

assign values to the input variables.<br />

2 Make the first <strong>MATLAB</strong> output argument the return value from the<br />

function.<br />

U =<br />

3 Pass any other output arguments as the first arguments to the function.<br />

U = svd(&S,&V,<br />

4 Pass the input arguments to the <strong>C++</strong> function, following the output<br />

arguments.<br />

U = svd(&S,&V,X,0);<br />

The translation is complete.<br />

Note that if you see [] as a <strong>MATLAB</strong> input argument, you should pass<br />

mwArray() as the <strong>C++</strong> argument. For example,<br />

B = cplxpair(A,[],dim)<br />

becomes<br />

B = cplxpair(A,mwArray(),dim);<br />

4

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!