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

📄 qrdecomp.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 "qrdecomp.hpp"
#include "libmatlbm.hpp"

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

void InitializeModule_qrdecomp() {
}

void TerminateModule_qrdecomp() {
}

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

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

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

//
// The function "mlxQrdecomp" contains the feval interface for the "qrdecomp"
// M-function from file "d:\matlab1\qrdecomp.m" (lines 1-8). The feval function
// calls the implementation version of qrdecomp through this function. This
// function processes any input arguments and passes them to the implementation
// version of the function, appearing above.
//
void mlxQrdecomp(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: qrdecomp Line: 1 Column: "
                  "1 The function \"qrdecomp\" was called with mor"
                  "e than the declared number of outputs (2).")));
        }
        if (nrhs > 0) {
            error(
              mwVarargin(
                mwArray(
                  "Run-time Error: File: qrdecomp Line: 1 Column: "
                  "1 The function \"qrdecomp\" was called with mor"
                  "e than the declared number of inputs (0).")));
        }
        mplhs[0] = Mqrdecomp(&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 "Mqrdecomp" is the implementation version of the "qrdecomp"
// M-function from file "d:\matlab1\qrdecomp.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]=QRDecomp()
//
static mwArray Mqrdecomp(mwArray * U, int nargout_) {
    mwLocalFunctionTable save_local_function_table_
      = &_local_function_table_qrdecomp;
    mwArray L = mwArray::UNDEFINED;
    mwArray R = mwArray::UNDEFINED;
    mwArray Q = mwArray::UNDEFINED;
    mwArray ans = mwArray::UNDEFINED;
    //
    // global A;
    // if(isempty(A))
    //
    if (tobool(isempty(mwVv(A, "A")))) {
        //
        // Q=[];
        //
        Q = _mxarray0_;
        //
        // R=[];
        //
        R = _mxarray0_;
        //
        // return;
        //
        goto return_;
    //
    // end
    //
    }
    //
    // [Q,R]=qr(A);
    //
    Q = qr(&R, mwVv(A, "A"));
    return_:
    mwValidateOutput(L, 1, nargout_, "L", "qrdecomp");
    mwValidateOutput(*U, 2, nargout_, "U", "qrdecomp");
    return L;
}

⌨️ 快捷键说明

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