00001 /* 00002 * mex2matlab 00003 * 00004 * library for interoperability in calling mex code from matlab, 00005 * and from the command line or other interpreters. 00006 * 00007 * these routines are not in the matlab C API, but had to be added 00008 * to get certain useful functionality. 00009 * 00010 */ 00011 00012 #include <stdio.h> 00013 #include "mex.h" /* must be present, but its contents are unused */ 00014 #include "mexhead.h" 00015 00016 00017 00018 /************************************************************************ 00019 * 00020 * dispatcher shell 00021 * 00022 * (for compatibility with pure C library dispatcher) 00023 * 00024 * In contrast to the C dispatcher, calls within a library mexfunction 00025 * that is called from Matlab will route thru the Mathworks version 00026 * of mexErrMsgTxt. This will generate an immediate return to the 00027 * matlab prompt. So, there's no need for error handling here. 00028 * 00029 ***********************************************************************/ 00030 00031 00032 char * 00033 mxt_mexDispatcher(mexfn_t *mexfn, 00034 const char *progname, 00035 int verbosity, 00036 int nlhs, mxArray **plhs, int nrhs, const mxArray **prhs) 00037 { 00038 #ifdef DEBUG 00039 printf(" calling library mexfunction...\n"); 00040 #endif 00041 (*mexfn)(nlhs, plhs, nrhs, prhs); 00042 #ifdef DEBUG 00043 printf(" returned normally from library mexfunction.\n"); 00044 #endif 00045 return NULL; /* successful return */ 00046 } 00047 00048 00049 /************************************************************************ 00050 * 00051 * RANGE SETTING 00052 * this is un-used by matlab -- hence not in the Matlab API as formulated 00053 * by Mathworks -- but required for some aspects of the command-line API. 00054 * 00055 ***********************************************************************/ 00056 00057 00058 /* 00059 * set the range of the Matrix structure to [datamin,datamax]. 00060 */ 00061 void 00062 setrange(mxArray *pm, double datamin, double datamax) 00063 { } 00064 00065 /* 00066 * get the range, [datamin,datamax], of the Matrix structure 00067 * here datamin > datamax so the caller knows not to bother adjusting it; 00068 * if called from Matlab this will have no function 00069 */ 00070 void 00071 getrange(const mxArray *pm, double *datamin, double *datamax) 00072 { *datamin = 1.0; *datamax = -1.0; } 00073