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

📄 test2.c

📁 《精通Matlab6.5版》张志勇等编著
💻 C
字号:
/*
 * MATLAB Compiler: 2.2
 * Date: Tue Jun 25 10:51:47 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" "-O" "none" "-O"
 * "fold_scalar_mxarrays:off" "-O" "fold_non_scalar_mxarrays:off" "-O"
 * "optimize_integer_for_loops:off" "-O" "array_indexing:off" "-O"
 * "optimize_conditionals:off" "-O" "fold_non_scalar_mxarrays:on" "-x" "-W"
 * "mex" "-L" "C" "-t" "-T" "link:mexlibrary" "libmatlbmx.mlib" "test2" 
 */
#include "test2.h"
#include "libmatlbm.h"

static mxChar _array1_[128] = { 'R', 'u', 'n', '-', 't', 'i', 'm', 'e', ' ',
                                'E', 'r', 'r', 'o', 'r', ':', ' ', 'F', 'i',
                                'l', 'e', ':', ' ', 't', 'e', 's', 't', '2',
                                ' ', 'L', 'i', 'n', 'e', ':', ' ', '1', ' ',
                                'C', 'o', 'l', 'u', 'm', 'n', ':', ' ', '1',
                                ' ', 'T', 'h', 'e', ' ', 'f', 'u', 'n', 'c',
                                't', 'i', 'o', 'n', ' ', '"', 't', 'e', 's',
                                't', '2', '"', ' ', 'w', 'a', 's', ' ', 'c',
                                'a', 'l', 'l', 'e', 'd', ' ', 'w', 'i', 't',
                                'h', ' ', 'm', 'o', 'r', 'e', ' ', 't', 'h',
                                'a', 'n', ' ', 't', 'h', 'e', ' ', 'd', 'e',
                                'c', 'l', 'a', 'r', 'e', 'd', ' ', 'n', 'u',
                                'm', 'b', 'e', 'r', ' ', 'o', 'f', ' ', 'o',
                                'u', 't', 'p', 'u', 't', 's', ' ', '(', '1',
                                ')', '.' };
static mxArray * _mxarray0_;

static mxChar _array3_[127] = { 'R', 'u', 'n', '-', 't', 'i', 'm', 'e', ' ',
                                'E', 'r', 'r', 'o', 'r', ':', ' ', 'F', 'i',
                                'l', 'e', ':', ' ', 't', 'e', 's', 't', '2',
                                ' ', 'L', 'i', 'n', 'e', ':', ' ', '1', ' ',
                                'C', 'o', 'l', 'u', 'm', 'n', ':', ' ', '1',
                                ' ', 'T', 'h', 'e', ' ', 'f', 'u', 'n', 'c',
                                't', 'i', 'o', 'n', ' ', '"', 't', 'e', 's',
                                't', '2', '"', ' ', 'w', 'a', 's', ' ', 'c',
                                'a', 'l', 'l', 'e', 'd', ' ', 'w', 'i', 't',
                                'h', ' ', 'm', 'o', 'r', 'e', ' ', 't', 'h',
                                'a', 'n', ' ', 't', 'h', 'e', ' ', 'd', 'e',
                                'c', 'l', 'a', 'r', 'e', 'd', ' ', 'n', 'u',
                                'm', 'b', 'e', 'r', ' ', 'o', 'f', ' ', 'i',
                                'n', 'p', 'u', 't', 's', ' ', '(', '3', ')',
                                '.' };
static mxArray * _mxarray2_;

void InitializeModule_test2(void) {
    _mxarray0_ = mclInitializeString(128, _array1_);
    _mxarray2_ = mclInitializeString(127, _array3_);
}

void TerminateModule_test2(void) {
    mxDestroyArray(_mxarray2_);
    mxDestroyArray(_mxarray0_);
}

static mxArray * Mtest2(int nargout_, mxArray * x, mxArray * i1, mxArray * i2);

_mexLocalFunctionTable _local_function_table_test2
  = { 0, (mexFunctionTableEntry *)NULL };

/*
 * The function "mlfTest2" contains the normal interface for the "test2"
 * M-function from file "D:\mywork\test2.m" (lines 1-3). This function
 * processes any input arguments and passes them to the implementation version
 * of the function, appearing above.
 */
mxArray * mlfTest2(mxArray * x, mxArray * i1, mxArray * i2) {
    int nargout = 1;
    mxArray * y = mclGetUninitializedArray();
    mlfEnterNewContext(0, 3, x, i1, i2);
    y = Mtest2(nargout, x, i1, i2);
    mlfRestorePreviousContext(0, 3, x, i1, i2);
    return mlfReturnValue(y);
}

/*
 * The function "mlxTest2" contains the feval interface for the "test2"
 * M-function from file "D:\mywork\test2.m" (lines 1-3). The feval function
 * calls the implementation version of test2 through this function. This
 * function processes any input arguments and passes them to the implementation
 * version of the function, appearing above.
 */
void mlxTest2(int nlhs, mxArray * plhs[], int nrhs, mxArray * prhs[]) {
    mxArray * mprhs[3];
    mxArray * mplhs[1];
    int i;
    if (nlhs > 1) {
        mlfError(_mxarray0_);
    }
    if (nrhs > 3) {
        mlfError(_mxarray2_);
    }
    for (i = 0; i < 1; ++i) {
        mplhs[i] = mclGetUninitializedArray();
    }
    for (i = 0; i < 3 && i < nrhs; ++i) {
        mprhs[i] = prhs[i];
    }
    for (; i < 3; ++i) {
        mprhs[i] = NULL;
    }
    mlfEnterNewContext(0, 3, mprhs[0], mprhs[1], mprhs[2]);
    mplhs[0] = Mtest2(nlhs, mprhs[0], mprhs[1], mprhs[2]);
    mlfRestorePreviousContext(0, 3, mprhs[0], mprhs[1], mprhs[2]);
    plhs[0] = mplhs[0];
}

/*
 * The function "Mtest2" is the implementation version of the "test2"
 * M-function from file "D:\mywork\test2.m" (lines 1-3). It contains the actual
 * compiled code for that M-function. It is a static function and must only be
 * called from one of the interface functions, appearing below.
 */
/*
 * function y = test2(x,i1,i2);
 */
static mxArray * Mtest2(int nargout_, mxArray * x, mxArray * i1, mxArray * i2) {
    mexLocalFunctionTable save_local_function_table_
      = mclSetCurrentLocalFunctionTable(&_local_function_table_test2);
    mxArray * y = mclGetUninitializedArray();
    mclCopyArray(&x);
    mclCopyArray(&i1);
    mclCopyArray(&i2);
    /*
     * y = x(i1,i2);
     */
    mlfAssign(
      &y,
      mlfIndexRef(mclVsa(x, "x"), "(?,?)", mclVsa(i1, "i1"), mclVsa(i2, "i2")));
    mclValidateOutput(y, 1, nargout_, "y", "test2");
    mxDestroyArray(i2);
    mxDestroyArray(i1);
    mxDestroyArray(x);
    mclSetCurrentLocalFunctionTable(save_local_function_table_);
    return y;
}

⌨️ 快捷键说明

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