home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l460 / 2.ddi / INCLUDE.DI$ / MX3MEX.H < prev   
Encoding:
C/C++ Source or Header  |  1993-02-15  |  5.2 KB  |  221 lines

  1. /*
  2.  * @(#)mex.h    generated by: makeheader    Fri Feb 12 12:06:48 1993
  3.  *
  4.  *        built from:    /rel/bld/matlab4/sun4/prod/sandbox4/src/cmex/cmex1.c
  5.  *                /rel/bld/matlab4/sun4/prod/sandbox4/src/fmex/fmex.c
  6.  */
  7.  
  8. #ifndef mex_h
  9. #define mex_h
  10.  
  11.  
  12. /*
  13.  * These are needed because the symbols for these functions clash with the
  14.  * FORTRAN ones with the same names.  The VMS linker makes all symbols
  15.  * uppercase in the end.
  16.  */
  17. #ifdef VMS
  18. #define mexFunction        CmexFunction
  19. #define mexGetMatrixPtr        CmexGetMatrixPtr
  20. #define mexCallMATLAB        CmexCallMATLAB
  21. #define mexSetTrapFlag        CmexSetTrapFlag
  22. #define mexErrMsgTxt        CmexErrMsgTxt
  23. #define mexPrintf        CmexPrintf
  24. #define mexAtExit        CmexAtExit
  25. #define mexGetMatrix        CmexGetMatrix
  26. #define mexPutMatrix        CmexPutMatrix
  27. #define mexGetFull        CmexGetFull
  28. #define mexPutFull        CmexPutFull
  29. #define mexEvalString        CmexEvalString
  30. #define mexEvaluateBlock     CmexEvaluateBlock 
  31. #define __STDC__
  32. #endif /* VMS */
  33.  
  34.  
  35. #include "matrix.h"
  36.  
  37.  
  38. /*
  39.  * return pointer to named matrix 
  40.  */
  41. #ifdef __STDC__
  42. extern    Matrix *mexGetMatrixPtr(
  43.     char    *name        /* name of variable in question */
  44.     );
  45. #else
  46. extern    Matrix *mexGetMatrixPtr();
  47. #endif /* __STDC__ */
  48.  
  49.  
  50. /*
  51.  * call MATLAB function
  52.  */
  53. #ifdef __STDC__
  54. extern    int mexCallMATLAB(
  55.     int        nlhs,        /* number of expected outputs */
  56.     Matrix    *plhs[],    /* matrix pointer array returning outputs */
  57.     int        nrhs,        /* number of inputs */
  58.     Matrix    *prhs[],    /* matrix pointer array for inputs */
  59.     char    *name        /* name of function */
  60.     );
  61. #else
  62. extern    int mexCallMATLAB();
  63. #endif /* __STDC__ */
  64.  
  65.  
  66. /*
  67.  * set or clear mexCallMATLAB trap flag (if set then an error in  
  68.  * mexCallMATLAB is caught and mexCallMATLAB will return a status value, 
  69.  * if not set an error will cause control to revert to MATLAB)
  70.  */
  71. #ifdef __STDC__
  72. extern    void mexSetTrapFlag(
  73.     int        trap_flag    /* trap flag 0 - off, 1 - on) */
  74.     );
  75. #else
  76. extern    mexSetTrapFlag();
  77. #endif /* __STDC__ */
  78.  
  79.  
  80. /*
  81.  * error return function
  82.  */
  83. #ifdef __STDC__
  84. extern    void mexErrMsgTxt(
  85.     const char    *error_msg    /* string with error message */
  86.     );
  87. #else
  88. extern    mexErrMsgTxt();
  89. #endif /* __STDC__ */
  90.  
  91.  
  92. /*
  93.  * MATLAB pprintf (print to stdout and possibly to diary file)
  94.  */
  95. #ifdef __STDC__
  96. extern    int mexPrintf(
  97.     char    *format,    /* printf style format */
  98.     ...                /* any additional arguments */
  99.     );
  100. #else
  101. extern    int mexPrintf();
  102. #endif /* __STDC__ */
  103.  
  104.  
  105. /*
  106.  * Register a function to be called by MATLAB in the event the Mex-file is to
  107.  * be cleared or MATLAB is about to exit.  A non-zero value is returned if 
  108.  * registeration fails.  Only one function may be registered per Mex-file.
  109.  */
  110. #ifdef __STDC__
  111. extern    int mexAtExit(
  112.     void    (*fcn)(void)
  113.     );
  114. #else
  115. extern    int mexAtExit();
  116. #endif /* __STDC__ */
  117.  
  118.  
  119. /*
  120.  * Get a copy of the matrix from the local workspace 
  121.  */
  122. #ifdef __STDC__
  123. extern    Matrix *mexGetMatrix(
  124.     char    *name        /* name of variable in question */
  125.     );
  126. #else
  127. extern    Matrix *mexGetMatrix();
  128. #endif /* __STDC__ */
  129.  
  130.  
  131. /*
  132.  * Put a copy of the matrix in the local workspace 
  133.  */
  134. #ifdef __STDC__
  135. extern    int mexPutMatrix(
  136.     Matrix    *pm        /* pointer to matrix */
  137.     );
  138. #else
  139. extern    int mexPutMatrix();
  140. #endif /* __STDC__ */
  141.  
  142.  
  143. /*
  144.  * Easy get copy of the matrix from the local workspace
  145.  */
  146. #ifdef __STDC__
  147. extern    int mexGetFull(
  148.     char    *name,        /* name of variable in question */
  149.     int        *m,        /* number of rows */
  150.     int        *n,        /* number of columns */
  151.     Real    **pr,        /* real part */
  152.     Real    **pi        /* imaginary part */
  153.     );
  154. #else
  155. extern    int mexGetFull();
  156. #endif /* __STDC__ */
  157.  
  158.  
  159. /*
  160.  * Easy put copy of the matrix in the local workspace
  161.  */
  162. #ifdef __STDC__
  163. extern    int mexPutFull(
  164.     char    *name,        /* name of variable in question */
  165.     int        m,        /* number of rows */
  166.     int        n,        /* number of columns */
  167.     Real    *pr,        /* real part */
  168.     Real    *pi        /* imaginary part */
  169.     );
  170. #else
  171. extern    int mexPutFull();
  172. #endif /* __STDC__ */
  173.  
  174.  
  175. /*
  176.  * Execute a matlab command string in the local workspace
  177.  */
  178. #ifdef __STDC__
  179. extern    int mexEvalString(
  180.    char        *str        /* matlab command string */
  181.     );
  182. #else
  183. extern    int mexEvalString();
  184. #endif /* __STDC__ */
  185.  
  186.  
  187. /*
  188.  * definitions which may be helpful
  189.  */
  190. #define printf              mexPrintf
  191.  
  192. #define create_real_array(N)    (double *) mxCalloc((N),sizeof(double))
  193. #define create_int_array(N)     (int *) mxCalloc((N),sizeof(int))
  194. #define user_fcn                mexFunction
  195. #define free_matrix             mxFreeMatrix
  196. #define mex_calloc              mxCalloc
  197. #define mex_free                mxFree
  198. #define get_global              mexGetMatrixPtr
  199. #define matlab_fcn              mexCallMATLAB
  200. #define matlab_trap             mexSetTrapFlag
  201. #define mex_error               mexErrMsgTxt
  202. #define mex_printf              mexPrintf
  203. #define create_matrix       mxCreateFull
  204.  
  205.  
  206. /*
  207.  * prototype of user-defined function
  208.  */
  209. #ifdef __STDC__
  210. extern    void mexFunction(
  211.     int        nlhs,        /* number of expected outputs */
  212.     Matrix    *plhs[],    /* matrix pointer array returning outputs */
  213.     int        nrhs,        /* number of inputs */
  214.     Matrix    *prhs[]        /* matrix pointer array for inputs */
  215.     );
  216. #else
  217. extern    mexFunction();
  218. #endif /* __STDC__ */
  219.  
  220. #endif /* mex_h */
  221.