⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 exm1_mex.c

📁 《精通Matlab6.5版》张志勇等编著
💻 C
字号:
/*
 * MATLAB Compiler: 2.2
 * Date: Tue Jun 25 12:31:25 2002
 * Arguments: "-B" "macro_default" "-O" "all" "-O" "fold_scalar_mxarrays:on"
 * "-O" "fold_non_scalar_mxarrays:on" "-O" "optimize_integer_for_loops:on" "-O"
 * "array_indexing:on" "-O" "optimize_conditionals:on" "-x" "-W" "mex" "-L" "C"
 * "-t" "-T" "link:mexlibrary" "libmatlbmx.mlib" "exm1" 
 */

#ifndef MLF_V2
#define MLF_V2 1
#endif

#include "libmatlb.h"
#include "exm1.h"
#include "rank.h"

static mexFunctionTableEntry function_table[1]
  = { { "exm1", mlxExm1, 1, 1, &_local_function_table_exm1 } };

static _mexInitTermTableEntry init_term_table[1]
  = { { InitializeModule_exm1, TerminateModule_exm1 } };

static _mex_information _mex_info
  = { 1, 1, function_table, 0, NULL, 0, NULL, 1, init_term_table };

/*
 * The function "Mrank" is the MATLAB callback version of the "rank" function
 * from file "d:\MATLAB6p1\toolbox\matlab\matfun\rank.m". It performs a
 * callback to MATLAB to run the "rank" function, and passes any resulting
 * output arguments back to its calling function.
 */
static mxArray * Mrank(int nargout_, mxArray * A, mxArray * tol) {
    mxArray * r = mclGetUninitializedArray();
    mclFevalCallMATLAB(
      mclNVarargout(nargout_, 0, &r, NULL), "rank", A, tol, NULL);
    return r;
}

/*
 * The function "mexLibrary" is a Compiler-generated mex wrapper, suitable for
 * building a MEX-function. It initializes any persistent variables as well as
 * a function table for use by the feval function. It then calls the function
 * "mlxExm1". Finally, it clears the feval table and exits.
 */
mex_information mexLibrary(void) {
    mclMexLibraryInit();
    return &_mex_info;
}

/*
 * The function "mlfRank" contains the normal interface for the "rank"
 * M-function from file "d:\MATLAB6p1\toolbox\matlab\matfun\rank.m" (lines
 * 0-0). This function processes any input arguments and passes them to the
 * implementation version of the function, appearing above.
 */
mxArray * mlfRank(mxArray * A, mxArray * tol) {
    int nargout = 1;
    mxArray * r = mclGetUninitializedArray();
    mlfEnterNewContext(0, 2, A, tol);
    r = Mrank(nargout, A, tol);
    mlfRestorePreviousContext(0, 2, A, tol);
    return mlfReturnValue(r);
}

/*
 * The function "mlxRank" contains the feval interface for the "rank"
 * M-function from file "d:\MATLAB6p1\toolbox\matlab\matfun\rank.m" (lines
 * 0-0). The feval function calls the implementation version of rank through
 * this function. This function processes any input arguments and passes them
 * to the implementation version of the function, appearing above.
 */
void mlxRank(int nlhs, mxArray * plhs[], int nrhs, mxArray * prhs[]) {
    mxArray * mprhs[2];
    mxArray * mplhs[1];
    int i;
    if (nlhs > 1) {
        mlfError(
          mxCreateString(
            "Run-time Error: File: rank Line: 1 Column: 1 The function \"rank\""
            " was called with more than the declared number of outputs (1)."));
    }
    if (nrhs > 2) {
        mlfError(
          mxCreateString(
            "Run-time Error: File: rank Line: 1 Column: 1 The function \"rank\""
            " was called with more than the declared number of inputs (2)."));
    }
    for (i = 0; i < 1; ++i) {
        mplhs[i] = mclGetUninitializedArray();
    }
    for (i = 0; i < 2 && i < nrhs; ++i) {
        mprhs[i] = prhs[i];
    }
    for (; i < 2; ++i) {
        mprhs[i] = NULL;
    }
    mlfEnterNewContext(0, 2, mprhs[0], mprhs[1]);
    mplhs[0] = Mrank(nlhs, mprhs[0], mprhs[1]);
    mlfRestorePreviousContext(0, 2, mprhs[0], mprhs[1]);
    plhs[0] = mplhs[0];
}

⌨️ 快捷键说明

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