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

📄 ludecomp.cpp

📁 该程序是一个matlab与visual c++ 混合编程的例子
💻 CPP
字号:
//
// MATLAB Compiler: 3.0
// Date: Fri Aug 26 16:33:02 2005
// 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" "-M" "-silentsetup" "-d"
// "D:/mymatrix/src" "-B" "cppsglcom:mymatrix,myfactor,1.0" "-B"
// "csglcom:mymatrix,myfactor,1.0" "-B" "sgl" "-m" "-W" "main" "-L" "C" "-t"
// "-T" "link:exe" "-h" "libmmfile.mlib" "-W" "mainhg" "libmwsglm.mlib" "-t"
// "-W" "comhg:mymatrix,myfactor,1.0" "-T" "link:lib" "-h" "libmmfile.mlib"
// "-i" "-L" "cpp" "-i" "D:/matlab1/Cholesky.m" "D:/matlab1/LUDecomp.m"
// "D:/matlab1/QRDecomp.m" 
//
#include "ludecomp.hpp"
#include "libmatlbm.hpp"

extern mwArray A;
static mwArray _mxarray0_ = mclInitializeDoubleVector(0, 0, (double *)NULL);

void InitializeModule_ludecomp() {
}

void TerminateModule_ludecomp() {
}

static mwArray Mludecomp(mwArray * U, int nargout_);

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

//
// The function "ludecomp" contains the normal interface for the "ludecomp"
// M-function from file "d:\matlab1\ludecomp.m" (lines 1-8). This function
// processes any input arguments and passes them to the implementation version
// of the function, appearing above.
//
mwArray ludecomp(mwArray * U) {
    int nargout = 1;
    mwArray L = mwArray::UNDEFINED;
    mwArray U__ = mwArray::UNDEFINED;
    if (U != NULL) {
        ++nargout;
    }
    L = Mludecomp(&U__, nargout);
    if (U != NULL) {
        *U = U__;
    }
    return L;
}

//
// The function "mlxLudecomp" contains the feval interface for the "ludecomp"
// M-function from file "d:\matlab1\ludecomp.m" (lines 1-8). The feval function
// calls the implementation version of ludecomp through this function. This
// function processes any input arguments and passes them to the implementation
// version of the function, appearing above.
//
void mlxLudecomp(int nlhs, mxArray * plhs[], int nrhs, mxArray * prhs[]) {
    MW_BEGIN_MLX();
    {
        mwArray mplhs[2];
        int i;
        mclCppUndefineArrays(2, mplhs);
        if (nlhs > 2) {
            error(
              mwVarargin(
                mwArray(
                  "Run-time Error: File: ludecomp Line: 1 Column: "
                  "1 The function \"ludecomp\" was called with mor"
                  "e than the declared number of outputs (2).")));
        }
        if (nrhs > 0) {
            error(
              mwVarargin(
                mwArray(
                  "Run-time Error: File: ludecomp Line: 1 Column: "
                  "1 The function \"ludecomp\" was called with mor"
                  "e than the declared number of inputs (0).")));
        }
        mplhs[0] = Mludecomp(&mplhs[1], nlhs);
        plhs[0] = mplhs[0].FreezeData();
        for (i = 1; i < 2 && i < nlhs; ++i) {
            plhs[i] = mplhs[i].FreezeData();
        }
    }
    MW_END_MLX();
}

//
// The function "Mludecomp" is the implementation version of the "ludecomp"
// M-function from file "d:\matlab1\ludecomp.m" (lines 1-8). 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[L,U]=LUDecomp()
//
static mwArray Mludecomp(mwArray * U, int nargout_) {
    mwLocalFunctionTable save_local_function_table_
      = &_local_function_table_ludecomp;
    mwArray L = mwArray::UNDEFINED;
    mwArray ans = mwArray::UNDEFINED;
    //
    // global A;
    // if(isempty(A))
    //
    if (tobool(isempty(mwVv(A, "A")))) {
        //
        // L=[];
        //
        L = _mxarray0_;
        //
        // U=[];
        //
        *U = _mxarray0_;
        //
        // return;
        //
        goto return_;
    //
    // end
    //
    }
    //
    // [L,U]=lu(A);
    //
    L = lu(U, mwVv(A, "A"));
    return_:
    mwValidateOutput(L, 1, nargout_, "L", "ludecomp");
    mwValidateOutput(*U, 2, nargout_, "U", "ludecomp");
    return L;
}

⌨️ 快捷键说明

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