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

📄 optim_private_startx.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 "optim_private_startx.h"

/*
 * The function "Moptim_private_startx" is the implementation version of the
 * "optim/private/startx" M-function from file
 * "C:\MATLABR11\toolbox\optim\private\startx.m" (lines 1-28). 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 xstart = startx(u,l);
 */
static mxArray * Moptim_private_startx(int nargout_, mxArray * u, mxArray * l) {
    mxArray * xstart = mclGetUninitializedArray();
    mxArray * arg = mclGetUninitializedArray();
    mxArray * arg1 = mclGetUninitializedArray();
    mxArray * arg2 = mclGetUninitializedArray();
    mxArray * arg3 = mclGetUninitializedArray();
    mxArray * arg4 = mclGetUninitializedArray();
    mxArray * n = mclGetUninitializedArray();
    mxArray * onen = mclGetUninitializedArray();
    mxArray * w = mclGetUninitializedArray();
    mxArray * ww = mclGetUninitializedArray();
    mclValidateInputs("optim/private/startx", 2, &u, &l);
    mclCopyArray(&u);
    /*
     * %STARTX	Box-centered point
     * %
     * % xstart = STARTX(u,l) returns centered point.
     * 
     * %   Copyright (c) 1990-98 by The MathWorks, Inc.
     * %   $Revision: 1.1 $  $Date: 1998/03/21 16:28:57 $
     * 
     * n = length(u);
     */
    mlfAssign(&n, mlfLength(u));
    /*
     * onen = ones(n,1);
     */
    mlfAssign(&onen, mlfOnes(n, mlfScalar(1.0), NULL));
    /*
     * arg = (u > 1e12);
     */
    mlfAssign(&arg, mlfGt(u, mlfScalar(1e12)));
    /*
     * u(arg) = inf*onen(arg);
     */
    mlfIndexAssign(
      &u, "(?)", arg, mlfMtimes(mlfInf(), mlfIndexRef(onen, "(?)", arg)));
    /*
     * xstart = zeros(n,1);
     */
    mlfAssign(&xstart, mlfZeros(n, mlfScalar(1.0), NULL));
    /*
     * arg1 = (u<inf)&(l==-inf); arg2 = (u== inf)&(l > -inf);
     */
    mlfAssign(&arg1, mlfAnd(mlfLt(u, mlfInf()), mlfEq(l, mlfUminus(mlfInf()))));
    mlfAssign(&arg2, mlfAnd(mlfEq(u, mlfInf()), mlfGt(l, mlfUminus(mlfInf()))));
    /*
     * arg3 = (u<inf)&(l>-inf);  arg4 = (u==inf)&(l==-inf);
     */
    mlfAssign(&arg3, mlfAnd(mlfLt(u, mlfInf()), mlfGt(l, mlfUminus(mlfInf()))));
    mlfAssign(&arg4, mlfAnd(mlfEq(u, mlfInf()), mlfEq(l, mlfUminus(mlfInf()))));
    /*
     * %
     * w = max(abs(u),ones(n,1));
     */
    mlfAssign(
      &w, mlfMax(NULL, mlfAbs(u), mlfOnes(n, mlfScalar(1.0), NULL), NULL));
    /*
     * xstart(arg1) = u(arg1) - .5*w(arg1);
     */
    mlfIndexAssign(
      &xstart,
      "(?)",
      arg1,
      mlfMinus(
        mlfIndexRef(u, "(?)", arg1),
        mlfMtimes(mlfScalar(.5), mlfIndexRef(w, "(?)", arg1))));
    /*
     * %
     * ww = max(abs(l),ones(n,1));
     */
    mlfAssign(
      &ww, mlfMax(NULL, mlfAbs(l), mlfOnes(n, mlfScalar(1.0), NULL), NULL));
    /*
     * xstart(arg2) = l(arg2) + .5*ww(arg2);
     */
    mlfIndexAssign(
      &xstart,
      "(?)",
      arg2,
      mlfPlus(
        mlfIndexRef(l, "(?)", arg2),
        mlfMtimes(mlfScalar(.5), mlfIndexRef(ww, "(?)", arg2))));
    /*
     * %
     * xstart(arg3)=(u(arg3)+l(arg3))/2;
     */
    mlfIndexAssign(
      &xstart,
      "(?)",
      arg3,
      mlfMrdivide(
        mlfPlus(mlfIndexRef(u, "(?)", arg3), mlfIndexRef(l, "(?)", arg3)),
        mlfScalar(2.0)));
    /*
     * xstart(arg4)=ones(length(arg4(arg4>0)),1);
     */
    mlfIndexAssign(
      &xstart,
      "(?)",
      arg4,
      mlfOnes(
        mlfLength(mlfIndexRef(arg4, "(?)", mlfGt(arg4, mlfScalar(0.0)))),
        mlfScalar(1.0),
        NULL));
    mclValidateOutputs("optim/private/startx", 1, nargout_, &xstart);
    mxDestroyArray(arg);
    mxDestroyArray(arg1);
    mxDestroyArray(arg2);
    mxDestroyArray(arg3);
    mxDestroyArray(arg4);
    mxDestroyArray(n);
    mxDestroyArray(onen);
    mxDestroyArray(u);
    mxDestroyArray(w);
    mxDestroyArray(ww);
    /*
     * 
     * 
     * 
     */
    return xstart;
}

/*
 * The function "mlfOptim_private_startx" contains the normal interface for the
 * "optim/private/startx" M-function from file
 * "C:\MATLABR11\toolbox\optim\private\startx.m" (lines 1-28). This function
 * processes any input arguments and passes them to the implementation version
 * of the function, appearing above.
 */
mxArray * mlfOptim_private_startx(mxArray * u, mxArray * l) {
    int nargout = 1;
    mxArray * xstart = mclGetUninitializedArray();
    mlfEnterNewContext(0, 2, u, l);
    xstart = Moptim_private_startx(nargout, u, l);
    mlfRestorePreviousContext(0, 2, u, l);
    return mlfReturnValue(xstart);
}

/*
 * The function "mlxOptim_private_startx" contains the feval interface for the
 * "optim/private/startx" M-function from file
 * "C:\MATLABR11\toolbox\optim\private\startx.m" (lines 1-28). The feval
 * function calls the implementation version of optim/private/startx through
 * this function. This function processes any input arguments and passes them
 * to the implementation version of the function, appearing above.
 */
void mlxOptim_private_startx(int nlhs,
                             mxArray * plhs[],
                             int nrhs,
                             mxArray * prhs[]) {
    mxArray * mprhs[2];
    mxArray * mplhs[1];
    int i;
    if (nlhs > 1) {
        mlfError(
          mxCreateString(
            "Run-time Error: File: optim/private/startx Line: 1 Col"
            "umn: 0 The function \"optim/private/startx\" was calle"
            "d with more than the declared number of outputs (1)"));
    }
    if (nrhs > 2) {
        mlfError(
          mxCreateString(
            "Run-time Error: File: optim/private/startx Line: 1 Col"
            "umn: 0 The function \"optim/private/startx\" was calle"
            "d with more than the declared number of inputs (2)"));
    }
    for (i = 0; i < 1; ++i) {
        mplhs[i] = NULL;
    }
    for (i = 0; i < 2 && i < nrhs; ++i) {
        mprhs[i] = prhs[i];
    }
    for (; i < 2; ++i) {
        mprhs[i] = NULL;
    }
    mlfEnterNewContext(0, 2, mprhs[0], mprhs[1]);
    mplhs[0] = Moptim_private_startx(nlhs, mprhs[0], mprhs[1]);
    mlfRestorePreviousContext(0, 2, mprhs[0], mprhs[1]);
    plhs[0] = mplhs[0];
}

⌨️ 快捷键说明

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