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

📄 cubici1.c

📁 ASUFIT-Matlab-全局拟合程序
💻 C
字号:
/*
 * MATLAB Compiler: 2.0.1
 * Date: Tue May 08 21:28:22 2001
 * Arguments: "-B" "sgl" "-m" "-W" "mainhg" "-L" "C" "asufit.m" "absfun.m"
 * "absfunfree.m" "absfunshift.m" "absfunwidth.m" "dispfit.m" "dispfitdisp.m"
 * "dispfitfree.m" "dispfitwidth.m" "seqmodfree.m" "spcfun.m" "spcfun1.m"
 * "atamult.m" "aprecon.m" 
 */
#include "cubici1.h"

/*
 * The function "Mcubici1" is the implementation version of the "cubici1"
 * M-function from file "C:\MATLABR11\toolbox\optim\cubici1.m" (lines 1-17). 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 r=cubici1(fnew,fold,graddnew,graddold,stepsize)
 */
static mxArray * Mcubici1(int nargout_,
                          mxArray * fnew,
                          mxArray * fold,
                          mxArray * graddnew,
                          mxArray * graddold,
                          mxArray * stepsize) {
    mxArray * r = mclGetUninitializedArray();
    mxArray * w = mclGetUninitializedArray();
    mxArray * z = mclGetUninitializedArray();
    mclValidateInputs(
      "cubici1", 5, &fnew, &fold, &graddnew, &graddold, &stepsize);
    mclCopyArray(&fnew);
    /*
     * %CUBICI1 Cubicly interpolates 2 points and gradients to estimate minimum.
     * %
     * %   This function uses cubic interpolation and the values of two 
     * %   points and their gradients in order to estimate the minimum of a 
     * %   a function along a line.
     * 
     * %   Copyright (c) 1990-98 by The MathWorks, Inc.
     * %   $Revision: 1.9 $  $Date: 1997/11/29 01:23:01 $
     * %   Andy Grace 7-9-90.
     * 
     * if isinf(fnew), fnew=1/eps; end
     */
    if (mlfTobool(mlfIsinf(fnew))) {
        mlfAssign(&fnew, mlfMrdivide(mlfScalar(1.0), mlfEps()));
    }
    /*
     * z=3*(fold-fnew)/stepsize+graddold+graddnew;
     */
    mlfAssign(
      &z,
      mlfPlus(
        mlfPlus(
          mlfMrdivide(
            mlfMtimes(mlfScalar(3.0), mlfMinus(fold, fnew)), stepsize),
          graddold),
        graddnew));
    /*
     * w=real(sqrt(z*z-graddold*graddnew));
     */
    mlfAssign(
      &w,
      mlfReal(
        mlfSqrt(mlfMinus(mlfMtimes(z, z), mlfMtimes(graddold, graddnew)))));
    /*
     * r=stepsize*((z+w-graddold)/(graddnew-graddold+2*w));
     */
    mlfAssign(
      &r,
      mlfMtimes(
        stepsize,
        mlfMrdivide(
          mlfMinus(mlfPlus(z, w), graddold),
          mlfPlus(
            mlfMinus(graddnew, graddold), mlfMtimes(mlfScalar(2.0), w)))));
    mclValidateOutputs("cubici1", 1, nargout_, &r);
    mxDestroyArray(fnew);
    mxDestroyArray(w);
    mxDestroyArray(z);
    /*
     * 
     */
    return r;
}

/*
 * The function "mlfCubici1" contains the normal interface for the "cubici1"
 * M-function from file "C:\MATLABR11\toolbox\optim\cubici1.m" (lines 1-17).
 * This function processes any input arguments and passes them to the
 * implementation version of the function, appearing above.
 */
mxArray * mlfCubici1(mxArray * fnew,
                     mxArray * fold,
                     mxArray * graddnew,
                     mxArray * graddold,
                     mxArray * stepsize) {
    int nargout = 1;
    mxArray * r = mclGetUninitializedArray();
    mlfEnterNewContext(0, 5, fnew, fold, graddnew, graddold, stepsize);
    r = Mcubici1(nargout, fnew, fold, graddnew, graddold, stepsize);
    mlfRestorePreviousContext(0, 5, fnew, fold, graddnew, graddold, stepsize);
    return mlfReturnValue(r);
}

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

⌨️ 快捷键说明

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