next up previous contents
Next: Using CUTEr from within Up: Interfacing CUTEr and Matlab Previous: MEX-Files basics   Contents


CUTEr and MEX-Files

With CUTEr, gateway interfaces to the CUTEr tools are provided in three files. The file utools.f interfaces the unconstrained optimization tools, ctools.f interfaces the constrained optimization tools and gtools.f contains general tools used by utools.f and ctools.f. These gateway files can be found in

$CUTER/common/src/tools/

while shortcut files to call the corresponding routines may be found in

$CUTER/common/src/matlab/

For example, $CUTER/common/src/matlab/ contains the file usetup.m which allows the user to simply call the usetup tools by typing

matlab% [x,bl,bu]=usetup;

at the Matlab prompt instead of

matlab% [x,bl,bu]=utools('usetup');

Note that the calling sequence from within Matlab may to some extent differ from the ``usual'' Fortran calling sequence.

Help is available from within Matlab the usual way, by typing

matlab% help toolname.

For example,

matlab% help usetup

briefly documents the usetup tool. Note that MEX-Files created from Fortran source code may only handle double precision data. As a general rule, a C or Fortran routine or function compiled and linked into a MEX-File is called using

matlab% [ $o_1, o_2, \ldots, o_n$] = function_name( $i_1, i_2, \ldots,
i_m$ );

where $o_1, o_2, \ldots, o_n$ is the output arguments list (specified within square brackets) and $i_1, i_2, \ldots,
i_m$ is the input arguments list.

The gateway interfaces use the mxCopy__ construct by default. If your C or Fortran compiler supports the %val construct, which implements calls by address instead of calls by value, it should be used so as to free memory used by (no longer necessary) temporary variables and to speed up execution. Besides being more intuitive, the %val construct also considerably eases the programming effort, shortens the code and makes better use of available memory.


next up previous contents
Next: Using CUTEr from within Up: Interfacing CUTEr and Matlab Previous: MEX-Files basics   Contents
Dominique Orban 2005-03-24