User`s manual

Advanced Topics
2-41
This section explains how to write and build MEX-files that call LAPACK and
BLAS functions. It provides information on:
Specifying the Function Name
Passing Arguments to Fortran from C
Handling Complex Numbers
Building the MEX-File
It also provides a symmetric indefinite factorization example that uses
functions from LAPACK.
Specifying the Function Name
When calling an LAPACK or BLAS function, some platforms require an
underscore character following the function name in the call statement.
On the PC, IBM_RS, and HP platforms, use the function name alone, with no
trailing underscore. For example, to call the LAPACK
dgemm function, use
dgemm (arg1, arg2, ..., argn);
On the SGI, LINUX, Solaris, and Alpha platforms, add the underscore after the
function name. For example, to call
dgemm on any of these platforms, use
dgemm_ (arg1, arg2, ..., argn);
Passing Arguments to Fortran from C
Since the LAPACK and BLAS functions are written in Fortran, arguments
passed to and from these functions must be passed by reference. The following
example calls
dgemm, passing all arguments by reference. An ampersand (&)
precedes each argument unless that argument is already a reference.
#include "mex.h"
void mexFunction( int nlhs, mxArray *plhs[], int nrhs, mxArray
*prhs[] )
{
double *A, *B, *C, one = 1.0, zero = 0.0;
int m,n,p;
char *chn = "N";
A = mxGetPr(prhs[0]);