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

📄 minmax.c

📁 nnToolKit 神经网络工具包是基于 MATLAB 神经网络工具箱自行开发的一组神经网络算法函数库
💻 C
字号:
/*
 * MATLAB Compiler: 3.0
 * Date: Sun May 13 16:47:41 2007
 * Arguments: "-B" "macro_default" "-O" "all" "-O" "fold_scalar_mxarrays:on"
 * "-O" "fold_non_scalar_mxarrays:on" "-O" "optimize_integer_for_loops:on" "-O"
 * "array_indexing:on" "-O" "optimize_conditionals:on" "-M" "-silentsetup" "-d"
 * "d:/MATLAB6p5/work/nnToolKit/src" "-B" "csglcom:nnToolKit,nnToolKit,2.0"
 * "-B" "sgl" "-m" "-W" "main" "-L" "C" "-t" "-T" "link:exe" "-h"
 * "libmmfile.mlib" "-W" "mainhg" "libmwsglm.mlib" "-t" "-W"
 * "comhg:nnToolKit,nnToolKit,2.0" "-T" "link:lib" "-h" "libmmfile.mlib" "-i"
 * "-i" "D:/MATLAB6p5/work/nnToolKit/lmnet/LmSimu.m"
 * "D:/MATLAB6p5/work/nnToolKit/lmnet/LmTrain.m"
 * "D:/MATLAB6p5/work/nnToolKit/sofm/SofmSimu.m"
 * "D:/MATLAB6p5/work/nnToolKit/sofm/SofmTrain.m" 
 */
#include "minmax.h"
#include "libmatlbm.h"
#include "libmmfile.h"
static mxArray * _mxarray0_;
static mxArray * _mxarray1_;

static mxChar _array3_[6] = { 'd', 'o', 'u', 'b', 'l', 'e' };
static mxArray * _mxarray2_;
static mxArray * _mxarray4_;

static mxChar _array6_[26] = { 'A', 'r', 'g', 'u', 'm', 'e', 'n', 't', ' ',
                               'h', 'a', 's', ' ', 'i', 'l', 'l', 'e', 'g',
                               'a', 'l', ' ', 't', 'y', 'p', 'e', '.' };
static mxArray * _mxarray5_;

void InitializeModule_minmax(void) {
    _mxarray0_ = mclInitializeDouble(1.0);
    _mxarray1_ = mclInitializeDoubleVector(0, 0, (double *)NULL);
    _mxarray2_ = mclInitializeString(6, _array3_);
    _mxarray4_ = mclInitializeDouble(2.0);
    _mxarray5_ = mclInitializeString(26, _array6_);
}

void TerminateModule_minmax(void) {
    mxDestroyArray(_mxarray5_);
    mxDestroyArray(_mxarray4_);
    mxDestroyArray(_mxarray2_);
    mxDestroyArray(_mxarray1_);
    mxDestroyArray(_mxarray0_);
}

static mxArray * Mminmax(int nargout_, mxArray * p);

_mexLocalFunctionTable _local_function_table_minmax
  = { 0, (mexFunctionTableEntry *)NULL };

/*
 * The function "mlfMinmax" contains the normal interface for the "minmax"
 * M-function from file "d:\matlab6p5\toolbox\nnet\nnet\minmax.m" (lines 1-45).
 * This function processes any input arguments and passes them to the
 * implementation version of the function, appearing above.
 */
mxArray * mlfMinmax(mxArray * p) {
    int nargout = 1;
    mxArray * pr = NULL;
    mlfEnterNewContext(0, 1, p);
    pr = Mminmax(nargout, p);
    mlfRestorePreviousContext(0, 1, p);
    return mlfReturnValue(pr);
}

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

/*
 * The function "Mminmax" is the implementation version of the "minmax"
 * M-function from file "d:\matlab6p5\toolbox\nnet\nnet\minmax.m" (lines 1-45).
 * 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 pr=minmax(p)
 */
static mxArray * Mminmax(int nargout_, mxArray * p) {
    mexLocalFunctionTable save_local_function_table_
      = mclSetCurrentLocalFunctionTable(&_local_function_table_minmax);
    mxArray * pr = NULL;
    mxArray * ans = NULL;
    mxArray * i = NULL;
    mxArray * n = NULL;
    mxArray * m = NULL;
    mclCopyArray(&p);
    /*
     * %MINMAX Ranges of matrix rows.
     * %
     * %  Syntax
     * %
     * %    pr = minmax(p)
     * %
     * %  Description
     * %
     * %    MINMAX(P) takes one argument,
     * %      P - RxQ matrix.
     * %    and returns the Rx2 matrix PR of minimum and maximum values
     * %    for each row of P.
     * %
     * %    Alternately, P can be an MxN cell array of matrices.  Each matrix
     * %    P{i,j} should Ri rows and Q columns.  In this case, MINMAX returns
     * %    an Mx1 cell array where the mth matrix is an Rix2 matrix of the
     * %    minimum and maximum values of elements for the matrics on the
     * %    ith row of P.
     * %
     * %  Examples
     * %
     * %    p = [0 1 2; -1 -2 -0.5]
     * %    pr = minmax(p)
     * %
     * %    p = {[0 1; -1 -2] [2 3 -2; 8 0 2]; [1 -2] [9 7 3]};
     * %    pr = minmax(p)
     * 
     * % Mark Beale, 11-31-97
     * % Copyright 1992-2002 The MathWorks, Inc.
     * % $Revision: 1.11 $
     * 
     * 
     * if iscell(p)
     */
    if (mlfTobool(mlfIscell(mclVa(p, "p")))) {
        /*
         * [m,n] = size(p);
         */
        mlfSize(mlfVarargout(&m, &n, NULL), mclVa(p, "p"), NULL);
        /*
         * pr = cell(m,1);
         */
        mlfAssign(&pr, mlfCell(mclVv(m, "m"), _mxarray0_, NULL));
        /*
         * for i=1:m
         */
        {
            int v_ = mclForIntStart(1);
            int e_ = mclForIntEnd(mclVv(m, "m"));
            if (v_ > e_) {
                mlfAssign(&i, _mxarray1_);
            } else {
                /*
                 * pr{i} = minmax([p{i,:}]);
                 * end
                 */
                for (; ; ) {
                    mlfIndexAssign(
                      &pr,
                      "{?}",
                      mlfScalar(v_),
                      mlfMinmax(
                        mlfHorzcat(
                          mlfIndexRef(
                            mclVa(p, "p"),
                            "{?,?}",
                            mlfScalar(v_),
                            mlfCreateColonIndex()),
                          NULL)));
                    if (v_ == e_) {
                        break;
                    }
                    ++v_;
                }
                mlfAssign(&i, mlfScalar(v_));
            }
        }
    /*
     * elseif isa(p,'double')
     */
    } else if (mlfTobool(mlfIsa(mclVa(p, "p"), _mxarray2_))) {
        /*
         * pr = [min(p,[],2) max(p,[],2)];
         */
        mlfAssign(
          &pr,
          mlfHorzcat(
            mlfMin(NULL, mclVa(p, "p"), _mxarray1_, _mxarray4_),
            mlfMax(NULL, mclVa(p, "p"), _mxarray1_, _mxarray4_),
            NULL));
    /*
     * else
     */
    } else {
        /*
         * error('Argument has illegal type.')
         */
        mlfError(_mxarray5_, NULL);
    /*
     * end
     */
    }
    mclValidateOutput(pr, 1, nargout_, "pr", "minmax");
    mxDestroyArray(m);
    mxDestroyArray(n);
    mxDestroyArray(i);
    mxDestroyArray(ans);
    mxDestroyArray(p);
    mclSetCurrentLocalFunctionTable(save_local_function_table_);
    return pr;
}

⌨️ 快捷键说明

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