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

📄 optim_private_xtrack.c

📁 ASUFIT-Matlab-全局拟合程序
💻 C
📖 第 1 页 / 共 2 页
字号:
              NULL,
              mlfScalar(15.0),
              mlfRound(
                mlfMrdivide(
                  mlfMtimes(
                    mlfScalar(3.0), mlfIndexRef(pos, "(?)", mlfScalar(3.0))),
                  n)),
              NULL),
            NULL));
        /*
         * set(gca,'units',units);
         */
        mclAssignAns(
          &ans, mlfNSet(0, mlfGca(NULL), mxCreateString("units"), units, NULL));
        /*
         * 
         * % Upper Plot
         * currsubplot = subplot(2,1,1) ;
         */
        mlfAssign(
          &currsubplot,
          mlfNSubplot(1, mlfScalar(2.0), mlfScalar(1.0), mlfScalar(1.0)));
        /*
         * lin(1)=plot(index,newx, 'b.','markersize',marksize,'tag','blueline');
         */
        mlfIndexAssign(
          &lin,
          "(?)",
          mlfScalar(1.0),
          mlfNPlot(
            1,
            index,
            newx,
            mxCreateString("b."),
            mxCreateString("markersize"),
            marksize,
            mxCreateString("tag"),
            mxCreateString("blueline"),
            NULL));
        /*
         * 
         * hold on;
         */
        mlfHold(mxCreateString("on"));
        /*
         * lin(2)=plot([-1;index(activel);index(activeu)],[0;newx(activel);newx(activeu)],'r.','markersize',marksize,'tag','redline');
         */
        mlfIndexAssign(
          &lin,
          "(?)",
          mlfScalar(2.0),
          mlfNPlot(
            1,
            mlfVertcat(
              mlfDoubleMatrix(1, 1, __Array0_r, NULL),
              mlfHorzcat(mlfIndexRef(index, "(?)", activel), NULL),
              mlfHorzcat(mlfIndexRef(index, "(?)", activeu), NULL),
              NULL),
            mlfVertcat(
              mlfDoubleMatrix(1, 1, __Array1_r, NULL),
              mlfHorzcat(mlfIndexRef(newx, "(?)", activel), NULL),
              mlfHorzcat(mlfIndexRef(newx, "(?)", activeu), NULL),
              NULL),
            mxCreateString("r."),
            mxCreateString("markersize"),
            marksize,
            mxCreateString("tag"),
            mxCreateString("redline"),
            NULL));
        /*
         * set(currsubplot,'YTick',[-1 1]);
         */
        mclAssignAns(
          &ans,
          mlfNSet(
            0,
            currsubplot,
            mxCreateString("YTick"),
            mlfDoubleMatrix(1, 2, __Array2_r, NULL),
            NULL));
        /*
         * if n < 10
         */
        if (mlfTobool(mlfLt(n, mlfScalar(10.0)))) {
            /*
             * set(currsubplot,'XTick',1:n);
             */
            mclAssignAns(
              &ans,
              mlfNSet(
                0,
                currsubplot,
                mxCreateString("XTick"),
                mlfColon(mlfScalar(1.0), n, NULL),
                NULL));
        /*
         * end
         */
        }
        /*
         * set(currsubplot,'YTickLabel',{'lower';'upper'});
         */
        mclAssignAns(
          &ans,
          mlfNSet(
            0,
            currsubplot,
            mxCreateString("YTickLabel"),
            mlfVertcat(
              mlfCellhcat(mxCreateString("lower"), NULL),
              mlfCellhcat(mxCreateString("upper"), NULL),
              NULL),
            NULL));
        /*
         * axis([1, n, -1, 1]) 
         */
        mclPrintAns(
          &ans,
          mlfNAxis(
            0,
            NULL,
            NULL,
            mlfHorzcat(
              mlfScalar(1.0), n, mlfScalar(-1.0), mlfScalar(1.0), NULL),
            NULL));
        /*
         * title('Relative position of x(i) to upper and lower bounds (log-scale)');
         */
        mclAssignAns(
          &ans,
          mlfNTitle(
            0,
            mxCreateString(
              "Relative position of x(i) to uppe"
              "r and lower bounds (log-scale)"),
            NULL));
        /*
         * ylabel('x(i)')
         */
        mclPrintAns(&ans, mlfNYlabel(0, mxCreateString("x(i)"), NULL));
        /*
         * hold off;
         */
        mlfHold(mxCreateString("off"));
        /*
         * 
         * [leg,objh]=legend(lin,'Free Variables','Variables at bounds');
         */
        mlfAssign(
          &leg,
          mlfNLegend(
            2,
            &objh,
            lin,
            mxCreateString("Free Variables"),
            mxCreateString("Variables at bounds"),
            NULL));
        /*
         * set(findobj(objh,'type','line'),'MarkerSize',15);
         */
        mclAssignAns(
          &ans,
          mlfNSet(
            0,
            mlfFindobj(
              objh, mxCreateString("type"), mxCreateString("line"), NULL),
            mxCreateString("MarkerSize"),
            mlfScalar(15.0),
            NULL));
        /*
         * set(leg,'Position',[.5 .23 .19 .08]) ;
         */
        mclAssignAns(
          &ans,
          mlfNSet(
            0,
            leg,
            mxCreateString("Position"),
            mlfDoubleMatrix(1, 4, __Array3_r, NULL),
            NULL));
        /*
         * uicontrol('Style','text', 'Units','normalized', ...
         */
        mclAssignAns(
          &ans,
          mlfNUicontrol(
            0,
            mxCreateString("Style"),
            mxCreateString("text"),
            mxCreateString("Units"),
            mxCreateString("normalized"),
            mxCreateString("Position"),
            mlfDoubleMatrix(1, 4, __Array4_r, NULL),
            mxCreateString("String"),
            mxCreateString("UPPER PLOT"),
            NULL));
        /*
         * 'Position',[.5 .315 .19 .05], 'String', 'UPPER PLOT'); 
         * 
         * % Lower Plot
         * currsubplot = subplot(2,1,2);
         */
        mlfAssign(
          &currsubplot,
          mlfNSubplot(1, mlfScalar(2.0), mlfScalar(1.0), mlfScalar(2.0)));
        /*
         * lin(1)=plot([0;index],[-1;newg],'b.','tag','blueline','markersize',marksize);
         */
        mlfIndexAssign(
          &lin,
          "(?)",
          mlfScalar(1.0),
          mlfNPlot(
            1,
            mlfVertcat(
              mlfDoubleMatrix(1, 1, __Array5_r, NULL),
              mlfHorzcat(index, NULL),
              NULL),
            mlfVertcat(
              mlfDoubleMatrix(1, 1, __Array6_r, NULL),
              mlfHorzcat(newg, NULL),
              NULL),
            mxCreateString("b."),
            mxCreateString("tag"),
            mxCreateString("blueline"),
            mxCreateString("markersize"),
            marksize,
            NULL));
        /*
         * hold on;
         */
        mlfHold(mxCreateString("on"));
        /*
         * lin(2)=plot([0;index(activeg)],[-1;newg(activeg)],'r.','tag','redline','markersize',marksize);
         */
        mlfIndexAssign(
          &lin,
          "(?)",
          mlfScalar(2.0),
          mlfNPlot(
            1,
            mlfVertcat(
              mlfDoubleMatrix(1, 1, __Array7_r, NULL),
              mlfHorzcat(mlfIndexRef(index, "(?)", activeg), NULL),
              NULL),
            mlfVertcat(
              mlfDoubleMatrix(1, 1, __Array8_r, NULL),
              mlfHorzcat(mlfIndexRef(newg, "(?)", activeg), NULL),
              NULL),
            mxCreateString("r."),
            mxCreateString("tag"),
            mxCreateString("redline"),
            mxCreateString("markersize"),
            marksize,
            NULL));
        /*
         * set(currsubplot,'YTick',[-1 0 1]);
         */
        mclAssignAns(
          &ans,
          mlfNSet(
            0,
            currsubplot,
            mxCreateString("YTick"),
            mlfDoubleMatrix(1, 3, __Array9_r, NULL),
            NULL));
        /*
         * if n < 10
         */
        if (mlfTobool(mlfLt(n, mlfScalar(10.0)))) {
            /*
             * set(currsubplot,'XTick',1:n);
             */
            mclAssignAns(
              &ans,
              mlfNSet(
                0,
                currsubplot,
                mxCreateString("XTick"),
                mlfColon(mlfScalar(1.0), n, NULL),
                NULL));
        /*
         * end
         */
        }
        /*
         * axis([1, n, -1, 1]) ;
         */
        mclAssignAns(
          &ans,
          mlfNAxis(
            0,
            NULL,
            NULL,
            mlfHorzcat(
              mlfScalar(1.0), n, mlfScalar(-1.0), mlfScalar(1.0), NULL),
            NULL));
        /*
         * xlabel('i^{th} component')
         */
        mclPrintAns(
          &ans, mlfNXlabel(0, mxCreateString("i^{th} component"), NULL));
        /*
         * ylabel('gradient')
         */
        mclPrintAns(&ans, mlfNYlabel(0, mxCreateString("gradient"), NULL));
        /*
         * title('Relative gradient scaled to the range -1 to 1')
         */
        mclPrintAns(
          &ans,
          mlfNTitle(
            0,
            mxCreateString("Relative gradient scaled to the range -1 to 1"),
            NULL));
        /*
         * hold off;
         */
        mlfHold(mxCreateString("off"));
        /*
         * 
         * [leg,objh]=legend(lin,'abs(gradient) > tol','abs(gradient) <= tol');
         */
        mlfAssign(
          &leg,
          mlfNLegend(
            2,
            &objh,
            lin,
            mxCreateString("abs(gradient) > tol"),
            mxCreateString("abs(gradient) <= tol"),
            NULL));
        /*
         * set(leg,'Position',[.5 .05 .19 .08]);
         */
        mclAssignAns(
          &ans,
          mlfNSet(
            0,
            leg,
            mxCreateString("Position"),
            mlfDoubleMatrix(1, 4, __Array10_r, NULL),
            NULL));
        /*
         * set(findobj(objh,'type','line'),'MarkerSize',15);
         */
        mclAssignAns(
          &ans,
          mlfNSet(
            0,
            mlfFindobj(
              objh, mxCreateString("type"), mxCreateString("line"), NULL),
            mxCreateString("MarkerSize"),
            mlfScalar(15.0),
            NULL));
        /*
         * uicontrol('Style','text', ...
         */
        mclPrintAns(
          &ans,
          mlfNUicontrol(
            0,
            mxCreateString("Style"),
            mxCreateString("text"),
            mxCreateString("Units"),
            mxCreateString("normalized"),
            mxCreateString("Position"),
            mlfDoubleMatrix(1, 4, __Array11_r, NULL),
            mxCreateString("String"),
            mxCreateString("LOWER PLOT"),
            NULL));
    /*
     * 'Units','normalized', ...
     * 'Position',[.5 .135 .19 .05], ...
     * 'String', 'LOWER PLOT')
     * 
     * 
     * otherwise
     */
    } else {
        /*
         * error('Invalid string used for INIT argument to XTRACK');
         */
        mlfError(
          mxCreateString("Invalid string used for INIT argument to XTRACK"));
    /*
     * end
     */
    }
    mxDestroyArray(activeg);
    mxDestroyArray(activel);
    mxDestroyArray(activeu);
    mxDestroyArray(activex);
    mxDestroyArray(ans);
    mxDestroyArray(arg1);
    mxDestroyArray(arg2);
    mxDestroyArray(arg3);
    mxDestroyArray(arg4);
    mxDestroyArray(argl);
    mxDestroyArray(argu);
    mxDestroyArray(currsubplot);
    mxDestroyArray(dist);
    mxDestroyArray(glog);
    mxDestroyArray(index);
    mxDestroyArray(init);
    mxDestroyArray(leg);
    mxDestroyArray(lin);
    mxDestroyArray(marksize);
    mxDestroyArray(maxg);
    mxDestroyArray(midpoint);
    mxDestroyArray(n);
    mxDestroyArray(nargin_);
    mxDestroyArray(newg);
    mxDestroyArray(newx);
    mxDestroyArray(objh);
    mxDestroyArray(onen);
    mxDestroyArray(pos);
    mxDestroyArray(units);
    mxDestroyArray(w);
    mxDestroyArray(xlog);
    mxDestroyArray(zeron);
}

/*
 * The function "mlfOptim_private_xtrack" contains the normal interface for the
 * "optim/private/xtrack" M-function from file
 * "C:\MATLABR11\toolbox\optim\private\xtrack.m" (lines 1-135). This function
 * processes any input arguments and passes them to the implementation version
 * of the function, appearing above.
 */
void mlfOptim_private_xtrack(mxArray * x,
                             mxArray * g,
                             mxArray * l,
                             mxArray * u,
                             mxArray * init) {
    mlfEnterNewContext(0, 5, x, g, l, u, init);
    Moptim_private_xtrack(x, g, l, u, init);
    mlfRestorePreviousContext(0, 5, x, g, l, u, init);
}

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

⌨️ 快捷键说明

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