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

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

/*
 * The function "Moptim_private_definev" is the implementation version of the
 * "optim/private/definev" M-function from file
 * "C:\MATLABR11\toolbox\optim\private\definev.m" (lines 1-29). 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 [v,dv]= definev(g,x,l,u);
 */
static mxArray * Moptim_private_definev(mxArray * * dv,
                                        int nargout_,
                                        mxArray * g,
                                        mxArray * x,
                                        mxArray * l,
                                        mxArray * u) {
    mxArray * v = mclGetUninitializedArray();
    mxArray * arg1 = mclGetUninitializedArray();
    mxArray * arg2 = mclGetUninitializedArray();
    mxArray * arg3 = mclGetUninitializedArray();
    mxArray * arg4 = mclGetUninitializedArray();
    mxArray * n = mclGetUninitializedArray();
    mclValidateInputs("optim/private/definev", 4, &g, &x, &l, &u);
    /*
     * %DEFINEV Scaling vector and derivative
     * %
     * %	[v,dv]= DEFINEV(g,x,l,u) returns v, distances to the
     * %   bounds corresponding to the sign of the gradient g, where
     * %   l is the vector of lower bounds, u is the vector of upper 
     * %   bounds. Vector dv is 0-1 sign vector (See ?? for more detail.)
     * %
     * 
     * %   Copyright (c) 1990-98 by The MathWorks, Inc.
     * %   $Revision: 1.2 $  $Date: 1998/03/21 16:29:10 $
     * 
     * n = length(x); 
     */
    mlfAssign(&n, mlfLength(x));
    /*
     * v = zeros(n,1); 
     */
    mlfAssign(&v, mlfZeros(n, mlfScalar(1.0), NULL));
    /*
     * dv=zeros(n,1);
     */
    mlfAssign(dv, mlfZeros(n, mlfScalar(1.0), NULL));
    /*
     * arg1 = (g < 0)  & (u <  inf ); 
     */
    mlfAssign(&arg1, mlfAnd(mlfLt(g, mlfScalar(0.0)), mlfLt(u, mlfInf())));
    /*
     * arg2 = (g >= 0) & (l > -inf);
     */
    mlfAssign(
      &arg2, mlfAnd(mlfGe(g, mlfScalar(0.0)), mlfGt(l, mlfUminus(mlfInf()))));
    /*
     * arg3 = (g < 0)  & (u == inf); 
     */
    mlfAssign(&arg3, mlfAnd(mlfLt(g, mlfScalar(0.0)), mlfEq(u, mlfInf())));
    /*
     * arg4 = (g >= 0) & (l == -inf);
     */
    mlfAssign(
      &arg4, mlfAnd(mlfGe(g, mlfScalar(0.0)), mlfEq(l, mlfUminus(mlfInf()))));
    /*
     * v(arg1)  = (x(arg1) - u(arg1)); 
     */
    mlfIndexAssign(
      &v,
      "(?)",
      arg1,
      mlfMinus(mlfIndexRef(x, "(?)", arg1), mlfIndexRef(u, "(?)", arg1)));
    /*
     * dv(arg1) = 1;
     */
    mlfIndexAssign(dv, "(?)", arg1, mlfScalar(1.0));
    /*
     * v(arg2)  = (x(arg2) - l(arg2)); 
     */
    mlfIndexAssign(
      &v,
      "(?)",
      arg2,
      mlfMinus(mlfIndexRef(x, "(?)", arg2), mlfIndexRef(l, "(?)", arg2)));
    /*
     * dv(arg2) = 1;
     */
    mlfIndexAssign(dv, "(?)", arg2, mlfScalar(1.0));
    /*
     * v(arg3)  = -1;
     */
    mlfIndexAssign(&v, "(?)", arg3, mlfScalar(-1.0));
    /*
     * dv(arg3) = 0;
     */
    mlfIndexAssign(dv, "(?)", arg3, mlfScalar(0.0));
    /*
     * v(arg4)  = 1;
     */
    mlfIndexAssign(&v, "(?)", arg4, mlfScalar(1.0));
    /*
     * dv(arg4) = 0;
     */
    mlfIndexAssign(dv, "(?)", arg4, mlfScalar(0.0));
    mclValidateOutputs("optim/private/definev", 2, nargout_, &v, dv);
    mxDestroyArray(arg1);
    mxDestroyArray(arg2);
    mxDestroyArray(arg3);
    mxDestroyArray(arg4);
    mxDestroyArray(n);
    /*
     * 
     */
    return v;
}

/*
 * The function "mlfOptim_private_definev" contains the normal interface for
 * the "optim/private/definev" M-function from file
 * "C:\MATLABR11\toolbox\optim\private\definev.m" (lines 1-29). This function
 * processes any input arguments and passes them to the implementation version
 * of the function, appearing above.
 */
mxArray * mlfOptim_private_definev(mxArray * * dv,
                                   mxArray * g,
                                   mxArray * x,
                                   mxArray * l,
                                   mxArray * u) {
    int nargout = 1;
    mxArray * v = mclGetUninitializedArray();
    mxArray * dv__ = mclGetUninitializedArray();
    mlfEnterNewContext(1, 4, dv, g, x, l, u);
    if (dv != NULL) {
        ++nargout;
    }
    v = Moptim_private_definev(&dv__, nargout, g, x, l, u);
    mlfRestorePreviousContext(1, 4, dv, g, x, l, u);
    if (dv != NULL) {
        mclCopyOutputArg(dv, dv__);
    } else {
        mxDestroyArray(dv__);
    }
    return mlfReturnValue(v);
}

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

⌨️ 快捷键说明

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