00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef _mexhead_h_
00017 #define _mexhead_h_
00018
00019
00020
00021
00022 #define max(a,b) (((a) > (b)) ? (a) : (b))
00023 #define min(a,b) (((a) < (b)) ? (a) : (b))
00024
00025
00026
00027
00028
00029 typedef void (mexfn_t)(int, mxArray **, int , const mxArray **);
00030
00031 typedef char * (mexfn_lib_t)(int, mxArray **, int , mxArray **);
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #ifndef _mexargcheck_h_
00042 #define _mexargcheck_h_
00043
00044 #ifdef __cplusplus
00045 extern "C" {
00046 #endif
00047
00048
00049 #define IsFullRealArray(pm) (mxIsDouble(pm) && \
00050 !mxIsComplex(pm) && \
00051 !mxIsSparse(pm))
00052 #define IsFullRealMatrix(pm) (IsFullRealArray(pm) && \
00053 (mxGetNumberOfDimensions(pm) <= 2))
00054 #define IsRealVector(pm) (IsFullRealMatrix(pm) && \
00055 (mxGetM(pm) == 1 || \
00056 mxGetN(pm) == 1))
00057
00058 #define IsRealLooseVector(pm) (IsFullRealMatrix(pm) && \
00059 (mxGetM(pm) <= 1 || \
00060 mxGetN(pm) <= 1))
00061 #define IsLooseVector(pm) (mxGetM(pm) <= 1 || \
00062 mxGetN(pm) <= 1)
00063 #define IsRealScalar(pm) (IsFullRealMatrix(pm) && \
00064 mxGetNumberOfElements(pm) == 1)
00065
00066 #define IsRealLooseScalar(pm) (IsFullRealMatrix(pm) && \
00067 mxGetNumberOfElements(pm) <= 1)
00068 #define IsLooseScalar(pm) (mxGetNumberOfElements(pm) <= 1)
00069 #define IsEmpty(pm) (mxGetNumberOfElements(pm) == 0)
00070
00071
00072
00073
00074
00075 int
00076 mexargparse(int narg,
00077 const mxArray **args,
00078 const char **names, const char **specs, const char **msgs, const char *gen_msg);
00079 int start_sizechecking();
00080 int sizeinit(const mxArray *pm);
00081 int sizecheck(const char *msg, int num);
00082 int sizecheck_msg(const char *msg, const char **argnames, int num);
00083 int sizeagree(const mxArray *pm);
00084 int sizeagreeM(const mxArray *pm);
00085 int sizeagreeN(const mxArray *pm);
00086 int sizeagreeMN(const mxArray *pm);
00087 int sizesare(int *s, int d);
00088 int sizeis(int m, int n);
00089 int sizeis3(int m, int n, int p);
00090 int sizeisM(int m);
00091 int sizeisN(int n);
00092 int sizeisMN(int m, int n);
00093
00094 #ifdef __cplusplus
00095 }
00096 #endif
00097
00098 #endif
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108 #ifndef _mextool_h_
00109 #define _mextool_h_
00110
00111 #ifdef __cplusplus
00112 extern "C" {
00113 #endif
00114 #ifdef NOT_DEFINED
00115 }
00116 #endif
00117
00118
00119
00120
00121
00122
00123
00124 #ifdef MATLAB_MEX_FILE
00125
00126 #define MX_COMPAT_32
00127
00128 #ifdef MX_COMPAT_32
00129 typedef int mwSize;
00130 typedef int mwIndex;
00131 typedef int mwSignedIndex;
00132 #else
00133 typedef size_t mwSize;
00134 typedef size_t mwIndex;
00135 typedef ptrdiff_t mwSignedIndex;
00136 #endif
00137 #endif
00138
00139
00140
00141
00142
00143
00144
00145 typedef enum {
00146 mxt_SignatureNARG = 1,
00147 mxt_SignatureDocstring,
00148 mxt_SignatureInNames,
00149 mxt_SignatureInSpecs,
00150 mxt_SignatureOutNames
00151 } mxt_Signature;
00152
00153 mxArray *
00154 mxt_PackSignature(mxt_Signature index,
00155 int in_lo, int in_hi, int out_lo, int out_hi,
00156 const char **in_names,
00157 const char **in_specs,
00158 const char **out_names,
00159 const char *docstring);
00160
00161 char **
00162 mxt_ArrayToStrings(const mxArray *a);
00163
00164 int
00165 mxt_put_matrix(char *name,
00166 int inx,
00167 double *dat,
00168 mwSize m,
00169 mwSize n);
00170 double
00171 mxt_make_scalar(
00172 const mxArray *pm,
00173 double default_val);
00174 double *
00175 mxt_make_vector(
00176 const mxArray *pm,
00177 mwSignedIndex M,
00178 double *default_val,
00179 mwSize default_len);
00180 double **
00181 mxt_make_matrix1(
00182 const mxArray *pm,
00183 mwSignedIndex M,
00184 mwSignedIndex N,
00185 double default_val);
00186 double **
00187 mxt_make_matrix2(
00188 const mxArray *pm,
00189 mwSignedIndex M,
00190 mwSignedIndex N,
00191 double default_val);
00192
00193 double **
00194 mxt_matrix_index(double *data, mwSize m, mwSize n);
00195 double ***
00196 mxt_matrix3_index(double *data, mwSize m, mwSize n, mwSize p);
00197 double **
00198 mxt_matrix_alloc(double *data, mwSize m, mwSize n);
00199 double ***
00200 mxt_matrix3_alloc(double *data, mwSize m, mwSize n, mwSize p);
00201
00202 int
00203 mxt_transpose_double_mxArray(mxArray *pa);
00204
00205 #ifdef __cplusplus
00206 }
00207 #endif
00208
00209 #endif
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237 #ifndef _mex_api_extras_h_
00238 #define _mex_api_extras_h_
00239
00240 #ifdef __cplusplus
00241 extern "C" {
00242 #endif
00243
00244
00245
00246
00247
00248 char *
00249 mxt_mexDispatcher(mexfn_t *mexfn,
00250 const char *progname,
00251 int verbosity,
00252 int nlhs, mxArray **plhs, int nrhs, const mxArray **prhs);
00253
00254
00255
00256
00257
00258 extern
00259 void
00260 setrange(mxArray *pm, double datamin, double datamax);
00261
00262 extern
00263 void
00264 getrange(const mxArray *pm, double *datamin, double *datamax);
00265
00266 #ifdef __cplusplus
00267 }
00268 #endif
00269
00270 #endif
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281 #ifndef _ieee_consts_h_
00282 #define _ieee_consts_h_
00283
00284 #ifdef __cplusplus
00285 extern "C" {
00286 #endif
00287
00288 float mxt_getnanf(void);
00289 double mxt_getnand(void);
00290 double mxt_getinfd(void);
00291
00292 #ifdef __cplusplus
00293 }
00294 #endif
00295
00296 #endif
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310 #ifndef _num_strings_h_
00311 #define _num_strings_h_
00312
00313
00314
00315
00316
00317
00318
00319
00320 #define MXT_IO_UBRACK 0x100
00321 #define MXT_IO_TBAD 0
00322 #define MXT_IO_TSHORT 1
00323 #define MXT_IO_TINT 2
00324 #define MXT_IO_TFLOAT 3
00325 #define MXT_IO_TDOUBLE 4
00326 #define MXT_IO_TSTRING 5
00327 #define MXT_IO_TMATRIX 6
00328 #define MXT_IO_TMATRIX_MAX 100
00329
00330 #define MXT_IO_TMATRIX_STRLEN (MXT_IO_TMATRIX_MAX*30)
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341 int
00342 do_transpose(double *x,
00343 double *y,
00344 mwSize D,
00345 mwSize *By);
00346
00347 mwSize *
00348 string_to_array(mwSize datamax,
00349 char *s,
00350 mwSize *dimP,
00351 double *data);
00352 int
00353 string_to_matrix(mwSize datamax,
00354 char *s,
00355 mwSize *Mp,
00356 mwSize *Np,
00357 double *data,
00358 int raw);
00359 int
00360 string_to_matrix_ints(int datamax,
00361 char *s,
00362 int *Mp,
00363 int *Np,
00364 double *data,
00365 int raw);
00366 void
00367 matrix_to_string(double *data,
00368 mwSize M,
00369 mwSize N,
00370 int bracketed,
00371 char *s);
00372 void
00373 matrix_to_string_ints(double *data,
00374 int M,
00375 int N,
00376 int bracketed,
00377 char *s);
00378 int
00379 mxt_io_convert_string_to_type(const char *type);
00380
00381 #endif
00382
00383
00384
00385 #endif
00386