Using the C Math Library    

Utility Routines

The MATLAB C Math Library utility routines help you perform indexing, create scalar arrays, and initialize and control the library environment.

Error Handling 
Function
Purpose
void
mlfSetErrorHandler(void (* EH)(const char *,
                   bool));
Specify pointer to external application's error handler function.

mlfFeval() Support 
Function
Purpose
void
mlfFevalTableSetup(mlfFuncTab *mlfUfuncTable);
Register a thunk function table with the MATLAB C Math Library.
Indexing 
Function
Purpose
mxArray *
mlfIndexAssign(mxArray * volatile *pa,
                const char *index, ...);
Handle assignments that include indexing.
mxArray *
mlfIndexDelete(mxArray * volatile *pa,
                const char *index, ...);
Handle deletions that include indexing.
mxArray *
mlfIndexRef(mxArray *pa,
             const char* index_string, ...);
Perform array references such as X(5,:).
mxArray *
mlfColon(mxArray *start, mxArray *step,
                mxArray *end);
Generate a sequence of indices. Use this where you'd use the colon operator (:) operator in MATLAB.
mlfColon(NULL, NULL,NULL) is equivalent to mlfCreateColonIndex().
mxArray *
mlfCreateColonIndex(void);
Create an array that acts like the colon operator (:) when passed to mlfArrayRef(), mlfArrayAssign(), and mlfArrayDelete().
mxArray *
mlfEnd(mxArray *array, mxArray *dim,
                mxArray *numindices);
Generate the last index for an array dimension. Acts like end in the MATLAB expression A(3,6:end). dim is the dimension to compute end for. Use 1 to indicate the row dimension; use 2 to indicate the column dimension. numindices is the number of indices in the subscript.

Memory Allocation 
Function
Purpose
void
mlfSetLibraryAllocFcns (calloc_proc calloc_fcn,
                free_proc free_fcn,
                realloc_proc realloc_fcn,
                malloc_proc malloc_fcn);
Set the MATLAB C Math Library's memory management functions. Gives you complete control over memory management.

Printing 
Function
Purpose
int
mlfPrintf(const char *fmt, ...);
Format output just like printf. Use the installed print handler to display the output.
void
mlfPrintMatrix(mxArray *m);
Print contents of matrix.
void
mlfSetPrintHandler(void (* PH)(const char *));
Specify pointer to external application's output function.

Scalar Array Creation 
Function
Purpose
mxArray *
mlfScalar (double v);
Create a 1-by-1 array whose contents are initialized to the value of v.
mxArray *
mlfComplexScalar(double v, double i);

Create a complex 1-by-1 array whose contents are initialized to the real part v and the imaginary part i.


 Sparse Matrix Functions MATLAB M-File Math Library