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

📄 quadi.c

📁 ASUFIT-Matlab-全局拟合程序
💻 C
字号:
/*
 * MATLAB Compiler: 2.0.1
 * Date: Tue May 08 21:28:23 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 "quadi.h"

/*
 * The function "Mquadi" is the implementation version of the "quadi"
 * M-function from file "C:\MATLABR11\toolbox\optim\quadi.m" (lines 1-20). 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 [stepmin]=quadi(steps,matf)
 */
static mxArray * Mquadi(int nargout_, mxArray * steps, mxArray * matf) {
    mxArray * stepmin = mclGetUninitializedArray();
    mxArray * abc = mclGetUninitializedArray();
    mxArray * amat = mclGetUninitializedArray();
    mclValidateInputs("quadi", 2, &steps, &matf);
    mclCopyArray(&steps);
    /*
     * %QUADI  Quadraticly interpolates three points to estimate minimum.
     * %         This function uses QUADRATIC interpolation and
     * %         the values of three unevenly spaced points 
     * %         in order estimate the minimum of a 
     * %         a function along a line.
     * %    syntax: [stepmin]=quadi(steps,matf)
     * %    where steps is a matrix constraining the spacing of the points.
     * %          matf is a vector which contains the corresponding elements of f 
     * %          stepmin is the step to the minimum.
     * 
     * %   Copyright (c) 1990-98 by The MathWorks, Inc.
     * %   $Revision: 1.9 $  $Date: 1997/11/29 01:23:25 $
     * %   Andy Grace 7-9-90.
     * steps=steps(:);
     */
    mlfAssign(&steps, mlfIndexRef(steps, "(?)", mlfCreateColonIndex()));
    /*
     * % Solve simultaneous equations:
     * amat=[0.5*steps.*steps, steps, ones(3,1)];
     */
    mlfAssign(
      &amat,
      mlfHorzcat(
        mlfTimes(mlfMtimes(mlfScalar(0.5), steps), steps),
        steps,
        mlfOnes(mlfScalar(3.0), mlfScalar(1.0), NULL),
        NULL));
    /*
     * abc=amat\matf(:);
     */
    mlfAssign(
      &abc, mlfMldivide(amat, mlfIndexRef(matf, "(?)", mlfCreateColonIndex())));
    /*
     * stepmin=-abc(2)/abc(1);
     */
    mlfAssign(
      &stepmin,
      mlfMrdivide(
        mlfUminus(mlfIndexRef(abc, "(?)", mlfScalar(2.0))),
        mlfIndexRef(abc, "(?)", mlfScalar(1.0))));
    mclValidateOutputs("quadi", 1, nargout_, &stepmin);
    mxDestroyArray(abc);
    mxDestroyArray(amat);
    mxDestroyArray(steps);
    return stepmin;
}

/*
 * The function "mlfQuadi" contains the normal interface for the "quadi"
 * M-function from file "C:\MATLABR11\toolbox\optim\quadi.m" (lines 1-20). This
 * function processes any input arguments and passes them to the implementation
 * version of the function, appearing above.
 */
mxArray * mlfQuadi(mxArray * steps, mxArray * matf) {
    int nargout = 1;
    mxArray * stepmin = mclGetUninitializedArray();
    mlfEnterNewContext(0, 2, steps, matf);
    stepmin = Mquadi(nargout, steps, matf);
    mlfRestorePreviousContext(0, 2, steps, matf);
    return mlfReturnValue(stepmin);
}

/*
 * The function "mlxQuadi" contains the feval interface for the "quadi"
 * M-function from file "C:\MATLABR11\toolbox\optim\quadi.m" (lines 1-20). The
 * feval function calls the implementation version of quadi through this
 * function. This function processes any input arguments and passes them to the
 * implementation version of the function, appearing above.
 */
void mlxQuadi(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: quadi Line: 1 Column: 0 The function \"quadi"
            "\" was called with more than the declared number of outputs (1)"));
    }
    if (nrhs > 2) {
        mlfError(
          mxCreateString(
            "Run-time Error: File: quadi Line: 1 Column: 0 The function \"quadi"
            "\" was called 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] = Mquadi(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 + -