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

📄 searchq.c

📁 ASUFIT-Matlab-全局拟合程序
💻 C
📖 第 1 页 / 共 2 页
字号:
                 * elseif pcnt==2 & fnew>=matl(2)
                 */
                } else {
                    mxDestroyArray(a_);
                    {
                        mxArray * a_ = mclInitialize(
                                         mlfEq(pcnt, mlfScalar(2.0)));
                        if (mlfTobool(a_)
                            && mlfTobool(
                                 mlfAnd(
                                   a_,
                                   mlfGe(
                                     *fnew,
                                     mlfIndexRef(
                                       *matl, "(?)", mlfScalar(2.0)))))) {
                            mxDestroyArray(a_);
                            /*
                             * matx(3)=stepsize;
                             */
                            mlfIndexAssign(
                              matx, "(?)", mlfScalar(3.0), *stepsize);
                            /*
                             * matl(3)=fnew;
                             */
                            mlfIndexAssign(matl, "(?)", mlfScalar(3.0), *fnew);
                            /*
                             * [stepsize]=cubici2(gdold,matl,matx);
                             */
                            mlfAssign(
                              stepsize, mlfCubici2(gdold, *matl, *matx));
                            /*
                             * pcnt=4;
                             */
                            mlfAssign(&pcnt, mlfScalar(4.0));
                        /*
                         * % ...  having just reduced step.
                         * elseif  pcnt==3  & fnew<matl(1)
                         */
                        } else {
                            mxDestroyArray(a_);
                            {
                                mxArray * a_ = mclInitialize(
                                                 mlfEq(pcnt, mlfScalar(3.0)));
                                if (mlfTobool(a_)
                                    && mlfTobool(
                                         mlfAnd(
                                           a_,
                                           mlfLt(
                                             *fnew,
                                             mlfIndexRef(
                                               *matl,
                                               "(?)",
                                               mlfScalar(1.0)))))) {
                                    mxDestroyArray(a_);
                                    /*
                                     * matx(2)=stepsize;
                                     */
                                    mlfIndexAssign(
                                      matx, "(?)", mlfScalar(2.0), *stepsize);
                                    /*
                                     * matl(2)=fnew;
                                     */
                                    mlfIndexAssign(
                                      matl, "(?)", mlfScalar(2.0), *fnew);
                                    /*
                                     * [stepsize]=cubici2(gdold,matl,matx);
                                     */
                                    mlfAssign(
                                      stepsize,
                                      mlfCubici2(gdold, *matl, *matx));
                                    /*
                                     * pcnt=4;
                                     */
                                    mlfAssign(&pcnt, mlfScalar(4.0));
                                /*
                                 * % Have just interpolated - Check to see whether function is any better 
                                 * % - if not replace.
                                 * elseif pcnt==4 
                                 */
                                } else {
                                    mxDestroyArray(a_);
                                    if (mlfTobool(
                                          mlfEq(pcnt, mlfScalar(4.0)))) {
                                        /*
                                         * pcnt=0;
                                         */
                                        mlfAssign(&pcnt, mlfScalar(0.0));
                                        /*
                                         * stepsize=abs(stepsize);
                                         */
                                        mlfAssign(stepsize, mlfAbs(*stepsize));
                                        /*
                                         * % If interpolation failed use old point.
                                         * if fnew>matl(2),
                                         */
                                        if (mlfTobool(
                                              mlfGt(
                                                *fnew,
                                                mlfIndexRef(
                                                  *matl,
                                                  "(?)",
                                                  mlfScalar(2.0))))) {
                                            /*
                                             * fnew=matl(2);
                                             */
                                            mlfAssign(
                                              fnew,
                                              mlfIndexRef(
                                                *matl, "(?)", mlfScalar(2.0)));
                                            /*
                                             * how='f';
                                             */
                                            mlfAssign(how, mxCreateString("f"));
                                            /*
                                             * stepsize=matx(2);       
                                             */
                                            mlfAssign(
                                              stepsize,
                                              mlfIndexRef(
                                                *matx, "(?)", mlfScalar(2.0)));
                                        /*
                                         * end
                                         */
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    /*
     * end %if pcnt==1
     */
    }
    mclValidateOutputs(
      "searchq", 6, nargout_, &pcnt, matl, matx, stepsize, fnew, how);
    mxDestroyArray(newstep);
    /*
     * 
     */
    return pcnt;
}

/*
 * The function "mlfSearchq" contains the normal interface for the "searchq"
 * M-function from file "C:\MATLABR11\toolbox\optim\searchq.m" (lines 1-86).
 * This function processes any input arguments and passes them to the
 * implementation version of the function, appearing above.
 */
mxArray * mlfSearchq(mxArray * * matl,
                     mxArray * * matx,
                     mxArray * * stepsize,
                     mxArray * * fnew,
                     mxArray * * how,
                     mxArray * pcnt_,
                     mxArray * fnew_,
                     mxArray * oldx,
                     mxArray * matl_,
                     mxArray * matx_,
                     mxArray * sd,
                     mxArray * gdold,
                     mxArray * stepsize_,
                     mxArray * how_) {
    int nargout = 1;
    mxArray * pcnt = mclGetUninitializedArray();
    mxArray * matl__ = mclGetUninitializedArray();
    mxArray * matx__ = mclGetUninitializedArray();
    mxArray * stepsize__ = mclGetUninitializedArray();
    mxArray * fnew__ = mclGetUninitializedArray();
    mxArray * how__ = mclGetUninitializedArray();
    mlfEnterNewContext(
      5,
      9,
      matl,
      matx,
      stepsize,
      fnew,
      how,
      pcnt_,
      fnew_,
      oldx,
      matl_,
      matx_,
      sd,
      gdold,
      stepsize_,
      how_);
    if (matl != NULL) {
        ++nargout;
    }
    if (matx != NULL) {
        ++nargout;
    }
    if (stepsize != NULL) {
        ++nargout;
    }
    if (fnew != NULL) {
        ++nargout;
    }
    if (how != NULL) {
        ++nargout;
    }
    pcnt
      = Msearchq(
          &matl__,
          &matx__,
          &stepsize__,
          &fnew__,
          &how__,
          nargout,
          pcnt_,
          fnew_,
          oldx,
          matl_,
          matx_,
          sd,
          gdold,
          stepsize_,
          how_);
    mlfRestorePreviousContext(
      5,
      9,
      matl,
      matx,
      stepsize,
      fnew,
      how,
      pcnt_,
      fnew_,
      oldx,
      matl_,
      matx_,
      sd,
      gdold,
      stepsize_,
      how_);
    if (matl != NULL) {
        mclCopyOutputArg(matl, matl__);
    } else {
        mxDestroyArray(matl__);
    }
    if (matx != NULL) {
        mclCopyOutputArg(matx, matx__);
    } else {
        mxDestroyArray(matx__);
    }
    if (stepsize != NULL) {
        mclCopyOutputArg(stepsize, stepsize__);
    } else {
        mxDestroyArray(stepsize__);
    }
    if (fnew != NULL) {
        mclCopyOutputArg(fnew, fnew__);
    } else {
        mxDestroyArray(fnew__);
    }
    if (how != NULL) {
        mclCopyOutputArg(how, how__);
    } else {
        mxDestroyArray(how__);
    }
    return mlfReturnValue(pcnt);
}

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

⌨️ 快捷键说明

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