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

📄 matsum.cpp

📁 C++下的乘法 阶乘 fft运算
💻 CPP
字号:
/*
 * MATLAB Compiler: 3.0
 * Date: Tue Dec 11 16:11:23 2007
 * 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" "-t" "-L" "C" "matsum.m" 
 */
#include "matsum.h"
#include "libmatlbm.h"
static mxArray * _mxarray0_;
static mxArray * _mxarray1_;

void InitializeModule_matsum(void) {
    _mxarray0_ = mclInitializeDouble(3.0);
    _mxarray1_ = mclInitializeDouble(4.0);
}

void TerminateModule_matsum(void) {
    mxDestroyArray(_mxarray1_);
    mxDestroyArray(_mxarray0_);
}

static mxArray * Mmatsum(int nargout_, mxArray * a, mxArray * b);

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

/*
 * The function "mlfMatsum" contains the normal interface for the "matsum"
 * M-function from file "d:\matlab6p5\work\exercise_signal and system\matsum.m"
 * (lines 1-6). This function processes any input arguments and passes them to
 * the implementation version of the function, appearing above.
 */
mxArray * mlfMatsum(mxArray * a, mxArray * b) {
    int nargout = 1;
    mxArray * sum = NULL;
    mlfEnterNewContext(0, 2, a, b);
    sum = Mmatsum(nargout, a, b);
    mlfRestorePreviousContext(0, 2, a, b);
    return mlfReturnValue(sum);
}

/*
 * The function "mlxMatsum" contains the feval interface for the "matsum"
 * M-function from file "d:\matlab6p5\work\exercise_signal and system\matsum.m"
 * (lines 1-6). The feval function calls the implementation version of matsum
 * through this function. This function processes any input arguments and
 * passes them to the implementation version of the function, appearing above.
 */
void mlxMatsum(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: matsum Line: 1 Column: "
            "1 The function \"matsum\" was called with mor"
            "e than the declared number of outputs (1)."),
          NULL);
    }
    if (nrhs > 2) {
        mlfError(
          mxCreateString(
            "Run-time Error: File: matsum Line: 1 Column: "
            "1 The function \"matsum\" was called with mor"
            "e than the declared number of inputs (2)."),
          NULL);
    }
    for (i = 0; i < 1; ++i) {
        mplhs[i] = NULL;
    }
    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] = Mmatsum(nlhs, mprhs[0], mprhs[1]);
    mlfRestorePreviousContext(0, 2, mprhs[0], mprhs[1]);
    plhs[0] = mplhs[0];
}

/*
 * The function "Mmatsum" is the implementation version of the "matsum"
 * M-function from file "d:\matlab6p5\work\exercise_signal and system\matsum.m"
 * (lines 1-6). 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 sum = matbs( a, b )
 */
static mxArray * Mmatsum(int nargout_, mxArray * a, mxArray * b) {
    mexLocalFunctionTable save_local_function_table_
      = mclSetCurrentLocalFunctionTable(&_local_function_table_matsum);
    mxArray * sum = NULL;
    mclCopyArray(&a);
    mclCopyArray(&b);
    /*
     * % sum
     * a=3
     */
    mlfAssign(&a, _mxarray0_);
    mclPrintArray(mclVa(a, "a"), "a");
    /*
     * b=4
     */
    mlfAssign(&b, _mxarray1_);
    mclPrintArray(mclVa(b, "b"), "b");
    /*
     * sum = a + b;
     */
    mlfAssign(&sum, mclPlus(mclVa(a, "a"), mclVa(b, "b")));
    mclValidateOutput(sum, 1, nargout_, "sum", "matsum");
    mxDestroyArray(b);
    mxDestroyArray(a);
    mclSetCurrentLocalFunctionTable(save_local_function_table_);
    return sum;
}

⌨️ 快捷键说明

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