00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #if defined(_MSC_VER) || __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 3)
00021 #pragma once
00022 #endif
00023
00024 #ifndef mex_h
00025 #define mex_h
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #ifndef EXTERN_C
00041
00042 #ifdef __cplusplus
00043 #define EXTERN_C extern "C"
00044 #else
00045 #define EXTERN_C extern
00046 #endif
00047
00048 #endif
00049
00050
00051
00052
00053
00054 #ifndef mex_typedefs_h
00055 #define mex_typedefs_h
00056 typedef struct impl_info_tag *MEX_impl_info;
00057
00058 #include "matrix.h"
00059
00060 typedef struct mexGlobalTableEntry_Tag
00061 {
00062 const char *name;
00063 mxArray **variable;
00064 } mexGlobalTableEntry, *mexGlobalTable;
00065
00066 #if defined(MSWIND)
00067 #define cicompare(s1,s2) utStrcmpi((s1),(s2))
00068 #else
00069 #define cicompare(s1,s2) strcmp((s1),(s2))
00070 #endif
00071 #define cscompare(s1,s2) strcmp((s1),(s2))
00072
00073 typedef struct mexFunctionTableEntry_tag {
00074 const char * name;
00075 mxFunctionPtr f;
00076 int nargin;
00077 int nargout;
00078 struct _mexLocalFunctionTable *local_function_table;
00079 } mexFunctionTableEntry, *mexFunctionTable;
00080
00081 typedef struct _mexLocalFunctionTable {
00082 size_t length;
00083 mexFunctionTable entries;
00084 } _mexLocalFunctionTable, *mexLocalFunctionTable;
00085
00086 typedef struct {
00087 void (*initialize)(void);
00088 void (*terminate)(void);
00089 } _mexInitTermTableEntry, *mexInitTermTableEntry;
00090
00091 #define MEX_INFORMATION_VERSION 1
00092
00093 typedef struct {
00094 int version;
00095 int file_function_table_length;
00096 mexFunctionTable file_function_table;
00097 int global_variable_table_length;
00098 mexGlobalTable global_variable_table;
00099 int npaths;
00100 const char ** paths;
00101 int init_term_table_length;
00102 mexInitTermTableEntry init_term_table;
00103 } _mex_information, *mex_information;
00104
00105 typedef mex_information(*fn_mex_file)(void);
00106
00107 typedef void (*fn_clean_up_after_error)(void);
00108 typedef const char *(*fn_simple_function_to_string)(mxFunctionPtr f);
00109
00110 typedef void (*fn_mex_enter_mex_library)(mex_information x);
00111 typedef fn_mex_enter_mex_library fn_mex_exit_mex_library;
00112
00113 typedef mexLocalFunctionTable (*fn_mex_get_local_function_table)(void);
00114 typedef mexLocalFunctionTable (*fn_mex_set_local_function_table)(mexLocalFunctionTable);
00115
00116 #endif
00117
00118
00119
00120
00121
00122
00123
00124
00125 #include "matrix.h"
00126
00127 #include <stdio.h>
00128
00129
00130
00131
00132
00133
00134
00135 EXTERN_C void mexFunction(
00136 int nlhs,
00137 mxArray *plhs[],
00138 int nrhs,
00139 const mxArray *prhs[]
00140 );
00141
00142
00143
00144
00145
00146 EXTERN_C void mexErrMsgTxt(
00147 const char *error_msg
00148 );
00149
00150
00151
00152
00153
00154
00155 EXTERN_C void mexErrMsgIdAndTxt(
00156 const char * identifier,
00157 const char * err_msg,
00158 ...
00159 );
00160
00161
00162
00163
00164
00165
00166 EXTERN_C void mexWarnMsgTxt(
00167 const char *warn_msg
00168 );
00169
00170
00171
00172
00173
00174
00175
00176
00177 EXTERN_C void mexWarnMsgIdAndTxt(
00178 const char * identifier,
00179 const char * warn_msg,
00180 ...
00181 );
00182
00183
00184
00185
00186
00187 EXTERN_C int mexPrintf(
00188 const char *fmt,
00189 ...
00190 );
00191
00192
00193 #define printf mexPrintf
00194
00195
00196
00197
00198
00199
00200
00201
00202 EXTERN_C void mexMakeArrayPersistent(
00203 mxArray *pa
00204 );
00205
00206
00207
00208
00209
00210
00211
00212 EXTERN_C void mexMakeMemoryPersistent(void *ptr);
00213
00214
00215
00216
00217
00218 EXTERN_C int mexSet(double handle, const char *property, mxArray *value);
00219
00220
00221
00222 EXTERN_C const mxArray *mexGet(double handle, const char *property);
00223
00224
00225
00226
00227
00228 EXTERN_C int mexCallMATLAB(
00229 int nlhs,
00230 mxArray *plhs[],
00231 int nrhs,
00232 mxArray *prhs[],
00233 const char *fcn_name
00234 );
00235
00236
00237
00238
00239
00240
00241
00242 EXTERN_C void mexSetTrapFlag(int flag);
00243
00244
00245
00246
00247
00248
00249 EXTERN_C void mexPrintAssertion(
00250 const char *test,
00251 const char *fname,
00252 int linenum,
00253 const char *message);
00254
00255
00256
00257
00258
00259 EXTERN_C bool mexIsGlobal(const mxArray *pA);
00260
00261
00262 #define mexGetGlobal() mexGetGlobal_is_obsolete
00263 #define mxSetString() mxSetString_is_obsolete
00264 #define mxSetDispMode() mxSetDispMode_is_obsolete
00265 #define mexGetMatrixPtr() mexGetMatrixPtr_is_obsolete
00266 #define mexGetMatrix() mexGetMatrix_is_obsolete
00267 #define mexPutMatrix() mexPutMatrix_is_obsolete
00268 #define mexPutFull() mexPutFull_is_obsolete
00269 #define mexGetFull() mexGetFull_is_obsolete
00270 #define mexGetEps() mexGetEps_is_obsolete
00271 #define mexGetInf() mexGetInf_is_obsolete
00272 #define mexGetNaN() mexGetNaN_is_obsolete
00273 #define mexIsFinite() mexIsFinite_is_obsolete
00274 #define mexIsInf() mexIsInf_is_obsolete
00275 #define mexIsNaN() mexIsNaN_is_obsolete
00276
00277
00278
00279
00280
00281 #define mexAddFlops(x) mexAddFlops_is_obsolete
00282
00283 #if defined(V5_COMPAT)
00284 #define mexPutArray(parray, workspace) mexPutVariable(workspace, mxGetName(parray), parray)
00285 #define mexGetArray(name, workspace) mexGetVariable(workspace, name)
00286 #define mexGetArrayPtr(name, workspace) mexGetVariablePtr(workspace, name)
00287 #else
00288 #define mexPutArray() mexPutArray_is_obsolete
00289 #define mexGetArray() mexGetArray_is_obsolete
00290 #define mexGetArrayPtr() mexGetArrayPtr_is_obsolete
00291 #endif
00292
00293
00294
00295
00296
00297
00298 EXTERN_C int mexPutVariable(
00299 const char *workspace,
00300 const char *name,
00301 const mxArray *parray
00302 );
00303
00304
00305
00306
00307
00308
00309 EXTERN_C const mxArray *mexGetVariablePtr(
00310 const char *workspace,
00311 const char *name
00312 );
00313
00314
00315
00316
00317
00318
00319 EXTERN_C mxArray *mexGetVariable(
00320 const char *workspace,
00321 const char *name
00322 );
00323
00324
00325
00326
00327
00328 EXTERN_C void mexLock(void);
00329
00330
00331
00332
00333
00334 EXTERN_C void mexUnlock(void);
00335
00336
00337
00338
00339
00340 EXTERN_C bool mexIsLocked(void);
00341
00342
00343
00344
00345
00346 EXTERN_C const char *mexFunctionName(void);
00347
00348
00349
00350
00351
00352
00353 EXTERN_C int mexEvalString(
00354 const char *str
00355 );
00356
00357
00358
00359
00360
00361 EXTERN_C int mexAtExit(
00362 void (*exit_fcn)(void)
00363 );
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373 #if 0
00374
00375 #ifdef ARGCHECK
00376
00377 #include "mwdebug.h"
00378
00379 #define mexAtExit(exitfcn) mexAtExit_d(exitfcn, __FILE__, __LINE__)
00380 #define mexCallMATLAB(nlhs, plhs, nrhs, prhs, fcn) mexCallMATLAB_d(nlhs, plhs, nrhs, prhs, fcn, __FILE__, __LINE__)
00381 #define mexErrMsgTxt(errmsg) mexErrMsgTxt_d(errmsg, __FILE__, __LINE__)
00382 #define mexEvalString(str) mexEvalString_d(str, __FILE__, __LINE__)
00383 #define mexGet(handle, property) mexGet_d(handle, property, __FILE__, __LINE__)
00384 #define mexGetVariable(workspace, name) mexGetVariable_d(workspace, name, __FILE__, __LINE__)
00385 #define mexGetVariablePtr(workspace, name) mexGetVariablePtr_d(workspace, name, __FILE__, __LINE__)
00386 #define mexIsGlobal(pa) mexIsGlobal_d(pa, __FILE__, __LINE__)
00387 #define mexMakeArrayPersistent(pa) mexMakeArrayPersistent_d(pa, __FILE__, __LINE__)
00388 #define mexMakeMemoryPersistent(ptr) mexMakeMemoryPersistent_d(ptr, __FILE__, __LINE__)
00389 #define mexPutVariable(workspace, name, pa) mexPutVariable_d(workspace, name, pa, __FILE__, __LINE__)
00390 #define mexSet(handle, property, value) mexSet_d(handle, property, value, __FILE__, __LINE__)
00391 #define mexSetTrapFlag(value) mexSetTrapFlag_d(value, __FILE__, __LINE__)
00392 #define mexSubsAssign(plhs, sub, nsubs, rhs) mexSubsAssign_d(plhs, sub, nsubs, rhs, __FILE__, __LINE__)
00393 #define mexSubsReference(prhs, sub, nsubs) mexSubsReference_d(prhs, sub, nsubs, __FILE__, __LINE__)
00394 #define mexWarnMsgTxt(str) mexWarnMsgTxt_d(str, __FILE__, __LINE__)
00395 #endif
00396
00397 #endif
00398
00399 #endif