mex.h

来自「Finite Volume Poisson PDE Solver」· C头文件 代码 · 共 427 行

H
427
字号
/*
 * @(#)mex.h    generated by: makeheader    Fri Mar 28 13:37:25 1997
 *
 *		built from:	copyright.h
 *				../../src/mex/mexapiv4.c
 *				../../src/mex/mexapi.c
 *				../../src/mex/mexintrf.c
 *				../../src/mex/mexdbg.h
 */

#ifndef mex_h
#define mex_h


/* $Revision: 1.2 $ */
/*
 * Copyright (c) 1984-1997 by The MathWorks, Inc.
 * All Rights Reserved.
 */


#ifdef __cplusplus
    extern "C" {
#endif


/*
 * This header file "mex.h" declares all the types, macros and
 * functions necessary to interface mex files with the current
 * version of MATLAB.  See the release notes for information on 
 * supporting syntax from earlier versions.
 */  
#include "matrix.h"


#if defined(V4_COMPAT)


/*
 * return pointer to named global matrix or NULL if it doesn't exist
 * OBSOLETE: use mexGetArrayPtr(name, "global") instead
 */
extern Matrix *mexGetGlobal(
    char *name		/* name of variable in question */
    );


#ifdef __WATCOMC__
#ifndef __cplusplus
#pragma aux mexGetEps value [8087];
#pragma aux mexGetInf value [8087];
#pragma aux mexGetNaN value [8087];
#endif
#endif


/*
 * return pointer to named matrix
 * Obsolete: use mexGetArrayPtr(name, "caller") instead 
 */
extern Matrix *mexGetMatrixPtr(
    char	*name		/* name of variable in question */
    );


/*
 * Get a copy of the matrix from the local workspace 
 * Obsolete: use mexGetArray(name, "caller") instead
 */
extern Matrix *mexGetMatrix(
    char	*name		/* name of variable in question */
    );


/*
 * Put a copy of the matrix in the local workspace 
 * Obsolete: use mexPutArray(pm, "caller") instead
 */
extern int mexPutMatrix(
    Matrix	*pm		/* pointer to matrix */
    );


/*
 * Easy put copy of the matrix in the local workspace
 * Obsolete: use mxCreateDoubleMatrix() and mexPutArray(parray, "caller")
 * instead
 */
extern int mexPutFull(
    char	*name,		/* name of variable in question */
    int		m,		/* number of rows */
    int		n,		/* number of columns */
    double	*pr,		/* real part */
    double	*pi		/* imaginary part */
    );


/*
 * Easy get copy of the matrix from the local workspace
 * Obsolete: use mexGetArray(name, "caller") and mxGet
 * routines instead
 */
extern int mexGetFull(
    char	*name,		/* name of variable in question */
    int		*m,		/* number of rows */
    int		*n,		/* number of columns */
    double	**pr,		/* real part */
    double	**pi		/* imaginary part */
    );


#define mexGetEps   mxGetEps
#define mexGetInf   mxGetInf
#define mexGetNaN   mxGetNaN
#define mexIsFinite mxIsFinite
#define mexIsInf    mxIsInf
#define mexIsNaN    mxIsNaN
#else
#define mexGetGlobal()    mexGetGlobal_is_obsolete
#define mxSetString()     mxSetString_is_obsolete
#define mxSetDispMode()   mxSetDispMode_is_obsolete
#define mexGetMatrixPtr() mexGetMatrixPtr_is_obsolete
#define mexGetMatrix()    mexGetMatrix_is_obsolete
#define mexPutMatrix()    mexPutMatrix_is_obsolete
#define mexPutFull()      mexPutFull_is_obsolete
#define mexGetFull()      mexGetFull_is_obsolete
#define mexGetEps()       mexGetEps_is_obsolete
#define mexGetInf()       mexGetInf_is_obsolete
#define mexGetNaN()       mexGetNaN_is_obsolete
#define mexIsFinite()     mexIsFinite_is_obsolete
#define mexIsInf()        mexIsInf_is_obsolete
#define mexIsNaN()        mexIsNaN_is_obsolete
#endif /* V4_COMPAT */


#include <stdio.h>

#if defined(applec)
/* MATLAB is compiled with Metrowerks CodeWarrior C.  
   File I/O functions in MPW SC MEX-files are mapped back to MATLAB
   to avoid Data-to-Code Reference link errors from IntEnv.o.
   So, the macros defined in SC's stdio.h which make direct reference
   to the elements of a FILE structure need to be redefined as 
   callbacks to MATLAB.
 */
#undef getc
#undef putc
#undef clearerr
#undef feof
#undef ferror
#endif



/*
 * Parse and execute MATLAB syntax in string.  Returns zero if successful,
 * and a non zero value if an error occurs.
 */
extern int mexEvalString(
   const char *str	   /* matlab command string */
);


/*
 * mexFunction is the user defined C routine which is called upon invocation
 * of a mex function.
 */
void mexFunction(
    int           nlhs,           /* number of expected outputs */
    mxArray       *plhs[],        /* array of pointers to output arguments */
    int           nrhs,           /* number of inputs */
#if !defined(V4_COMPAT)
    const mxArray *prhs[]         /* array of pointers to input arguments */
#else
    mxArray *prhs[]         /* array of pointers to input arguments */
#endif
);

#if defined (powerc) && defined(__MWERKS__) && defined(MATLAB_MEX_FILE)
#pragma export list mexFunction
#endif


/*
 * Issue error message and return to MATLAB prompt
 */
extern void mexErrMsgTxt(
    const char	*error_msg	/* string with error message */
    );


/*
 * Issue error message if warnings enabled in MATLAB
 */
extern void mexWarnMsgTxt(
    const char	*error_msg	/* string with error message */
    );


/*
 * mex equivalent to MATLAB's "disp" function
 */
extern int mexPrintf(
    const char	*fmt,	/* printf style format */
    ...				/* any additional arguments */
    );


#define printf mexPrintf


/*
 * Remove all components of an array plus the array header itself
 * from MATLAB's memory allocation list.  The array will now
 * persist between calls to the mex function.  To destroy this
 * array, you will need to explicitly call mxDestroyArray().
 */
extern void mexMakeArrayPersistent(
    mxArray *pa              /* pointer to array */
    );


/*
 * Remove memory previously allocated via mxCalloc from MATLAB's
 * memory allocation list.  To free this memory, you will need to
 * explicitly call mxFree().
 */
extern void mexMakeMemoryPersistent(void *ptr);


/*
 * Lock a MEX-function so that it cannot be cleared from memory.
 */
extern void mexLock(void);


/*
 * Unlock a locked MEX-function so that it can be cleared from memory.
 */
extern void mexUnlock(void);


/*
 * Return the name of a the MEXfunction currently executing.
 */
extern const char *mexFunctionName(void);


/*
 * Return true if the MEX-function is currently locked, false otherwise.
 */
extern bool mexIsLocked(void);


/*
 * Look up a function and return an opaque handle for use with
 * mexCallMATLABFunction.
 */
extern void mexGetFunctionHandle(void);


/*
 * Call a function whose handle was determined by mexGetFunctionHandle.
 */
extern void mexCallMATLABFunction(void);


/*
 * Register a function pointer as a MATLAB-callable function.
 */
extern void mexRegisterFunction(void);


/*
 * mex equivalent to MATLAB's "set" function
 */
extern int mexSet(double handle, const char *property, mxArray *value); 


/* API interface which mimics the "get" function */
extern const mxArray *mexGet(double handle, const char *property);


/*
 * Place a copy of the named array into the specified workspace
 */
extern int mexPutArray(
    mxArray	*parray,		/* matrix to copy */
    const char *workspace
    );


/*
 * return a pointer to the named array from the specified workspace
 */
extern const mxArray *mexGetArrayPtr(
    const char *name,		/* name of symbol */
    const char *workspace
    );


/*
 * return a copy of the named array from the specified workspace
 */
extern mxArray *mexGetArray(
    const char	*name,		/* name of variable in question */
    const char *workspace
    );


/*
 * call MATLAB function
 */
extern int mexCallMATLAB(
    int		nlhs,			/* number of expected outputs */
    mxArray	*plhs[],		/* pointer array to outputs */
    int		nrhs,			/* number of inputs */
    mxArray	*prhs[],		/* pointer array to inputs */
    const char	*fcn_name		/* name of function to execute */
    );


/*
 * set or clear mexCallMATLAB trap flag (if set then an error in  
 * mexCallMATLAB is caught and mexCallMATLAB will return a status value, 
 * if not set an error will cause control to revert to MATLAB)
 */
extern void mexSetTrapFlag(int flag);


/*
 * Unlink the data part of an array (possibly creating copies).
 * Return a non-const array pointer that can be used with mxSetPr.
 */
extern mxArray *mexUnlink(const mxArray *a);


/*
 * Perform in-place subscript assignment.
 */
extern void mexSubsAssign(
      mxArray *plhs, /* pointer to lhs, to be modified in-place */
      const mxArray *sub[], /* array of subscripts for lhs */
      int nsubs,     /* number os subscripts */
      const mxArray *prhs /* pointer to rhs */
      );


/*
 * Retrieve a specified subset of an array.
 */
extern mxArray *mexSubsReference(
      const mxArray *prhs, /* pointer to rhs */
      const mxArray *subs[], /* array of subscripts for rhs */
    int nsubs /* number of subscripts */
      );


/*
 * Print an assertion-style error message and return control to the
 * MATLAB command line.
 */ 
extern void mexPrintAssertion(
		const char *test, 
		const char *fname, 
		int linenum, 
		const char *message);


/*
 * To accurately reflect flops (floating point operations count), mex
 * users must update this to reflect calculations done in a mex file. 
 */
extern void mexAddFlops(int count);


/*
 * Tell whether or not a mxArray is in MATLAB's global workspace.
 */
extern bool mexIsGlobal(const mxArray *pA);


/*
 * Register a function to be called by MATLAB in the event the Mex-file is to
 * be cleared or MATLAB is about to exit.  A non-zero value is returned if 
 * registeration fails.  Only one function may be registered per Mex-file.
 */
extern int mexAtExit(
    void	(*exit_fcn)(void)
    );


#if defined(MEXSUN4)
#include "mexsun4.h"
#endif /* defined(MEXSUN4) */


/* $Revision: 1.6 $ */
#ifdef ARGCHECK

#include "mwdebug.h" /* Prototype _d versions of API functions */

#define mexAddFlops(flops) 				mexAddFlops_d(flops, __FILE__, __LINE__)
#define mexAtExit(exitfcn) 				mexAtExit_d(exitfcn, __FILE__, __LINE__)
#define mexCallMATLAB(nlhs, plhs, nrhs, prhs, fcn) mexCallMATLAB_d(nlhs, plhs, nrhs, prhs, fcn, __FILE__, __LINE__)
#define mexErrMsgTxt(errmsg)			mexErrMsgTxt_d(errmsg, __FILE__, __LINE__)
#define mexEvalString(str) 				mexEvalString_d(str, __FILE__, __LINE__)
#define mexGet(handle, property) 		mexGet_d(handle, property, __FILE__, __LINE__)
#define mexGetArray(name, workspace) 	mexGetArray_d(name, workspace, __FILE__, __LINE__)
#define mexGetArrayPtr(name, workspace) mexGetArrayPtr_d(name, workspace, __FILE__, __LINE__)
#define mexIsGlobal(pa)                 mexIsGlobal_d(pa, __FILE__, __LINE__)
#define mexMakeArrayPersistent(pa) 		mexMakeArrayPersistent_d(pa, __FILE__, __LINE__)              
#define mexMakeMemoryPersistent(ptr) 	mexMakeMemoryPersistent_d(ptr, __FILE__, __LINE__)
#define mexPutArray(pa, workspace) 		mexPutArray_d(pa, workspace, __FILE__, __LINE__)
#define mexSet(handle, property, value) mexSet_d(handle, property, value, __FILE__, __LINE__)
#define mexSetTrapFlag(value)           mexSetTrapFlag_d(value, __FILE__, __LINE__)
#define mexSubsAssign(plhs, sub, nsubs, rhs)    mexSubsAssign_d(plhs, sub, nsubs, rhs, __FILE__, __LINE__)
#define mexSubsReference(prhs, sub, nsubs)    mexSubsReference_d(prhs, sub, nsubs, __FILE__, __LINE__)
#define mexWarnMsgTxt(str)		 		mexWarnMsgTxt_d(str, __FILE__, __LINE__)
#endif

#ifdef __cplusplus
    }	/* extern "C" */
#endif

#endif /* mex_h */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?