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

📄 nncpyi.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 "nncpyi.h"
#include "libmatlbm.h"
#include "nntobsf.h"

static mxChar _array1_[6] = { 'n', 'n', 'c', 'p', 'y', 'i' };
static mxArray * _mxarray0_;
static mxArray * _mxarray2_;
static mxArray * _mxarray3_;
static mxArray * _mxarray4_;

void InitializeModule_nncpyi(void) {
    _mxarray0_ = mclInitializeString(6, _array1_);
    _mxarray2_ = mclInitializeCharVector(0, 0, (mxChar *)NULL);
    _mxarray3_ = mclInitializeDouble(1.0);
    _mxarray4_ = mclInitializeDouble(0.0);
}

void TerminateModule_nncpyi(void) {
    mxDestroyArray(_mxarray4_);
    mxDestroyArray(_mxarray3_);
    mxDestroyArray(_mxarray2_);
    mxDestroyArray(_mxarray0_);
}

static mxArray * Mnncpyi(int nargout_, mxArray * m, mxArray * n);

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

/*
 * The function "mlfNncpyi" contains the normal interface for the "nncpyi"
 * M-function from file "d:\matlab6p5\toolbox\nnet\nnobsolete\nncpyi.m" (lines
 * 1-36). This function processes any input arguments and passes them to the
 * implementation version of the function, appearing above.
 */
mxArray * mlfNncpyi(mxArray * m, mxArray * n) {
    int nargout = 1;
    mxArray * b = NULL;
    mlfEnterNewContext(0, 2, m, n);
    b = Mnncpyi(nargout, m, n);
    mlfRestorePreviousContext(0, 2, m, n);
    return mlfReturnValue(b);
}

/*
 * The function "mlxNncpyi" contains the feval interface for the "nncpyi"
 * M-function from file "d:\matlab6p5\toolbox\nnet\nnobsolete\nncpyi.m" (lines
 * 1-36). The feval function calls the implementation version of nncpyi through
 * this function. This function processes any input arguments and passes them
 * to the implementation version of the function, appearing above.
 */
void mlxNncpyi(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: nncpyi Line: 1 Column: "
            "1 The function \"nncpyi\" was called with mor"
            "e than the declared number of outputs (1)."),
          NULL);
    }
    if (nrhs > 2) {
        mlfError(
          mxCreateString(
            "Run-time Error: File: nncpyi Line: 1 Column: "
            "1 The function \"nncpyi\" was called with mor"
            "e than the declared number of inputs (2)."),
          NULL);
    }
    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] = Mnncpyi(nlhs, mprhs[0], mprhs[1]);
    mlfRestorePreviousContext(0, 2, mprhs[0], mprhs[1]);
    plhs[0] = mplhs[0];
}

/*
 * The function "Mnncpyi" is the implementation version of the "nncpyi"
 * M-function from file "d:\matlab6p5\toolbox\nnet\nnobsolete\nncpyi.m" (lines
 * 1-36). 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 b = nncpyi(m,n)
 */
static mxArray * Mnncpyi(int nargout_, mxArray * m, mxArray * n) {
    mexLocalFunctionTable save_local_function_table_
      = mclSetCurrentLocalFunctionTable(&_local_function_table_nncpyi);
    mxArray * b = NULL;
    mxArray * i = NULL;
    mxArray * ind = NULL;
    mxArray * mc = NULL;
    mxArray * mr = NULL;
    mxArray * ans = NULL;
    mclCopyArray(&m);
    mclCopyArray(&n);
    /*
     * %NNCPYI Make interleaved copies of a matrix.
     * %  
     * %  This function is obselete.
     * 
     * nntobsf('nncpyi','')
     */
    mlfNntobsf(_mxarray0_, _mxarray2_, NULL);
    /*
     * 
     * %  
     * %  *WARNING*: This function is undocumented as it may be altered
     * %  at any time in the future without warning.
     * 
     * % NNCPYI(M,N)
     * %   M - Matrix of columns = [C1 C2 ...].
     * %   N - Number of copies to make.
     * % Returns:
     * %   Matrix = [C1 C1 ... C1 C2 C2 ... C2 ... ]
     * %   where each column in M appears N times.
     * %
     * % EXAMPLE: M = [1 2; 3 4; 5 6];
     * %          n = 3;
     * %          X = nncpyi(M,n)
     * %
     * % SEE ALSO: nncpy, nncpyd
     * 
     * % Mark Beale, 12-15-93
     * % Copyright 1992-2002 The MathWorks, Inc.
     * % $Revision: 1.11 $  $Date: 2002/03/25 16:54:00 $
     * 
     * [mr,mc] = size(m);
     */
    mlfSize(mlfVarargout(&mr, &mc, NULL), mclVa(m, "m"), NULL);
    /*
     * b = zeros(mr*n,mc);
     */
    mlfAssign(
      &b,
      mlfZeros(
        mclMtimes(mclVv(mr, "mr"), mclVa(n, "n")), mclVv(mc, "mc"), NULL));
    /*
     * ind = 1:mr;
     */
    mlfAssign(&ind, mlfColon(_mxarray3_, mclVv(mr, "mr"), NULL));
    /*
     * for i=[0:(n-1)]*mr
     */
    {
        mclForLoopIterator viter__;
        for (mclForStart(
               &viter__,
               mclMtimes(
                 mlfColon(
                   _mxarray4_, mclMinus(mclVa(n, "n"), _mxarray3_), NULL),
                 mclVv(mr, "mr")),
               NULL,
               NULL);
             mclForNext(&viter__, &i);
             ) {
            /*
             * b(ind+i,:) = m;
             */
            mclArrayAssign2(
              &b,
              mclVa(m, "m"),
              mclPlus(mclVv(ind, "ind"), mclVv(i, "i")),
              mlfCreateColonIndex());
        /*
         * end
         */
        }
        mclDestroyForLoopIterator(viter__);
    }
    /*
     * b = reshape(b,mr,n*mc);
     */
    mlfAssign(
      &b,
      mlfReshape(
        mclVv(b, "b"),
        mclVv(mr, "mr"), mclMtimes(mclVa(n, "n"), mclVv(mc, "mc")), NULL));
    mclValidateOutput(b, 1, nargout_, "b", "nncpyi");
    mxDestroyArray(ans);
    mxDestroyArray(mr);
    mxDestroyArray(mc);
    mxDestroyArray(ind);
    mxDestroyArray(i);
    mxDestroyArray(n);
    mxDestroyArray(m);
    mclSetCurrentLocalFunctionTable(save_local_function_table_);
    return b;
}

⌨️ 快捷键说明

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