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

📄 optim_private_pcgr.c

📁 ASUFIT-Matlab-全局拟合程序
💻 C
📖 第 1 页 / 共 2 页
字号:
 * "C:\MATLABR11\toolbox\optim\private\pcgr.m" (lines 1-74). This function
 * processes any input arguments and passes them to the implementation version
 * of the function, appearing above.
 */
mxArray * mlfOptim_private_pcgr(mxArray * * posdef,
                                mxArray * * k,
                                mxArray * DM,
                                mxArray * DG,
                                mxArray * g,
                                mxArray * kmax,
                                mxArray * tol,
                                mxArray * mtxmpy,
                                mxArray * fdata,
                                mxArray * H,
                                mxArray * R,
                                mxArray * pR) {
    int nargout = 1;
    mxArray * p = mclGetUninitializedArray();
    mxArray * posdef__ = mclGetUninitializedArray();
    mxArray * k__ = mclGetUninitializedArray();
    mlfEnterNewContext(
      2, 10, posdef, k, DM, DG, g, kmax, tol, mtxmpy, fdata, H, R, pR);
    if (posdef != NULL) {
        ++nargout;
    }
    if (k != NULL) {
        ++nargout;
    }
    p
      = Moptim_private_pcgr(
          &posdef__,
          &k__,
          nargout,
          DM,
          DG,
          g,
          kmax,
          tol,
          mtxmpy,
          fdata,
          H,
          R,
          pR);
    mlfRestorePreviousContext(
      2, 10, posdef, k, DM, DG, g, kmax, tol, mtxmpy, fdata, H, R, pR);
    if (posdef != NULL) {
        mclCopyOutputArg(posdef, posdef__);
    } else {
        mxDestroyArray(posdef__);
    }
    if (k != NULL) {
        mclCopyOutputArg(k, k__);
    } else {
        mxDestroyArray(k__);
    }
    return mlfReturnValue(p);
}

/*
 * The function "mlxOptim_private_pcgr" contains the feval interface for the
 * "optim/private/pcgr" M-function from file
 * "C:\MATLABR11\toolbox\optim\private\pcgr.m" (lines 1-74). The feval function
 * calls the implementation version of optim/private/pcgr through this
 * function. This function processes any input arguments and passes them to the
 * implementation version of the function, appearing above.
 */
void mlxOptim_private_pcgr(int nlhs,
                           mxArray * plhs[],
                           int nrhs,
                           mxArray * prhs[]) {
    mxArray * mprhs[10];
    mxArray * mplhs[3];
    int i;
    if (nlhs > 3) {
        mlfError(
          mxCreateString(
            "Run-time Error: File: optim/private/pcgr Line: 1 Colu"
            "mn: 0 The function \"optim/private/pcgr\" was called "
            "with more than the declared number of outputs (3)"));
    }
    if (nrhs > 10) {
        mlfError(
          mxCreateString(
            "Run-time Error: File: optim/private/pcgr Line: 1 Colu"
            "mn: 0 The function \"optim/private/pcgr\" was called "
            "with more than the declared number of inputs (10)"));
    }
    for (i = 0; i < 3; ++i) {
        mplhs[i] = NULL;
    }
    for (i = 0; i < 10 && i < nrhs; ++i) {
        mprhs[i] = prhs[i];
    }
    for (; i < 10; ++i) {
        mprhs[i] = NULL;
    }
    mlfEnterNewContext(
      0,
      10,
      mprhs[0],
      mprhs[1],
      mprhs[2],
      mprhs[3],
      mprhs[4],
      mprhs[5],
      mprhs[6],
      mprhs[7],
      mprhs[8],
      mprhs[9]);
    mplhs[0]
      = Moptim_private_pcgr(
          &mplhs[1],
          &mplhs[2],
          nlhs,
          mprhs[0],
          mprhs[1],
          mprhs[2],
          mprhs[3],
          mprhs[4],
          mprhs[5],
          mprhs[6],
          mprhs[7],
          mprhs[8],
          mprhs[9]);
    mlfRestorePreviousContext(
      0,
      10,
      mprhs[0],
      mprhs[1],
      mprhs[2],
      mprhs[3],
      mprhs[4],
      mprhs[5],
      mprhs[6],
      mprhs[7],
      mprhs[8],
      mprhs[9]);
    plhs[0] = mplhs[0];
    for (i = 1; i < 3 && i < nlhs; ++i) {
        plhs[i] = mplhs[i];
    }
    for (; i < 3; ++i) {
        mxDestroyArray(mplhs[i]);
    }
}

/*
 * The function "Mpcgr_preproj" is the implementation version of the
 * "pcgr/preproj" M-function from file
 * "C:\MATLABR11\toolbox\optim\private\pcgr.m" (lines 74-100). 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 w = preproj(r,RPCMTX,ppvec);
 */
static mxArray * Mpcgr_preproj(int nargout_,
                               mxArray * r,
                               mxArray * RPCMTX,
                               mxArray * ppvec) {
    mxArray * w = mclGetUninitializedArray();
    mxArray * n = mclGetUninitializedArray();
    mxArray * nargin_ = mclGetUninitializedArray();
    mxArray * one = mclGetUninitializedArray();
    mxArray * vtol = mclGetUninitializedArray();
    mxArray * wbar = mclGetUninitializedArray();
    mlfAssign(&nargin_, mlfNargin(0, r, RPCMTX, ppvec, NULL));
    mclValidateInputs("pcgr/preproj", 3, &r, &RPCMTX, &ppvec);
    mclCopyArray(&RPCMTX);
    mclCopyArray(&ppvec);
    /*
     * %PREPROJ Apply preconditioner
     * %
     * % w = preproj(r,RPCMTX,ppvec) Apply a preconditioner to vector r.
     * % The conceptual preconditioner is H(ppvec,ppvec) = RPCMTX'*RPCMTX
     * 
     * 
     * % Initialization
     * n = length(r);
     */
    mlfAssign(&n, mlfLength(r));
    /*
     * one = ones(n,1); 
     */
    mlfAssign(&one, mlfOnes(n, mlfScalar(1.0), NULL));
    /*
     * vtol = 100*eps*one; 
     */
    mlfAssign(&vtol, mlfMtimes(mlfMtimes(mlfScalar(100.0), mlfEps()), one));
    /*
     * 
     * if nargin < 3 | isempty(ppvec)
     */
    {
        mxArray * a_ = mclInitialize(mlfLt(nargin_, mlfScalar(3.0)));
        if (mlfTobool(a_) || mlfTobool(mlfOr(a_, mlfIsempty(ppvec)))) {
            mxDestroyArray(a_);
            /*
             * ppvec = (1:n); 
             */
            mlfAssign(&ppvec, mlfColon(mlfScalar(1.0), n, NULL));
            /*
             * if nargin < 2 | isempty(RPCMTX) 
             */
            {
                mxArray * a_ = mclInitialize(mlfLt(nargin_, mlfScalar(2.0)));
                if (mlfTobool(a_) || mlfTobool(mlfOr(a_, mlfIsempty(RPCMTX)))) {
                    mxDestroyArray(a_);
                    /*
                     * RPCMTX = speye(n); 
                     */
                    mlfAssign(&RPCMTX, mlfSpeye(n, NULL));
                } else {
                    mxDestroyArray(a_);
                }
            /*
             * end
             */
            }
        } else {
            mxDestroyArray(a_);
        }
    /*
     * end 
     */
    }
    /*
     * 
     * %  Precondition
     * wbar = RPCMTX'\r(ppvec);
     */
    mlfAssign(
      &wbar, mlfMldivide(mlfCtranspose(RPCMTX), mlfIndexRef(r, "(?)", ppvec)));
    /*
     * w(ppvec,1) = RPCMTX\wbar;
     */
    mlfIndexAssign(
      &w, "(?,?)", ppvec, mlfScalar(1.0), mlfMldivide(RPCMTX, wbar));
    mclValidateOutputs("pcgr/preproj", 1, nargout_, &w);
    mxDestroyArray(RPCMTX);
    mxDestroyArray(n);
    mxDestroyArray(nargin_);
    mxDestroyArray(one);
    mxDestroyArray(ppvec);
    mxDestroyArray(vtol);
    mxDestroyArray(wbar);
    /*
     * 
     * 
     * 
     * 
     */
    return w;
}

/*
 * The function "mlfPcgr_preproj" contains the normal interface for the
 * "pcgr/preproj" M-function from file
 * "C:\MATLABR11\toolbox\optim\private\pcgr.m" (lines 74-100). This function
 * processes any input arguments and passes them to the implementation version
 * of the function, appearing above.
 */
static mxArray * mlfPcgr_preproj(mxArray * r,
                                 mxArray * RPCMTX,
                                 mxArray * ppvec) {
    int nargout = 1;
    mxArray * w = mclGetUninitializedArray();
    mlfEnterNewContext(0, 3, r, RPCMTX, ppvec);
    w = Mpcgr_preproj(nargout, r, RPCMTX, ppvec);
    mlfRestorePreviousContext(0, 3, r, RPCMTX, ppvec);
    return mlfReturnValue(w);
}

/*
 * The function "mlxPcgr_preproj" contains the feval interface for the
 * "pcgr/preproj" M-function from file
 * "C:\MATLABR11\toolbox\optim\private\pcgr.m" (lines 74-100). The feval
 * function calls the implementation version of pcgr/preproj through this
 * function. This function processes any input arguments and passes them to the
 * implementation version of the function, appearing above.
 */
static void mlxPcgr_preproj(int nlhs,
                            mxArray * plhs[],
                            int nrhs,
                            mxArray * prhs[]) {
    mxArray * mprhs[3];
    mxArray * mplhs[1];
    int i;
    if (nlhs > 1) {
        mlfError(
          mxCreateString(
            "Run-time Error: File: pcgr/preproj Line: 74 Colum"
            "n: 0 The function \"pcgr/preproj\" was called wit"
            "h more than the declared number of outputs (1)"));
    }
    if (nrhs > 3) {
        mlfError(
          mxCreateString(
            "Run-time Error: File: pcgr/preproj Line: 74 Colum"
            "n: 0 The function \"pcgr/preproj\" was called wit"
            "h more than the declared number of inputs (3)"));
    }
    for (i = 0; i < 1; ++i) {
        mplhs[i] = NULL;
    }
    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] = Mpcgr_preproj(nlhs, mprhs[0], mprhs[1], mprhs[2]);
    mlfRestorePreviousContext(0, 3, mprhs[0], mprhs[1], mprhs[2]);
    plhs[0] = mplhs[0];
}

⌨️ 快捷键说明

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