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

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

static mxChar _array1_[5] = { 'n', 'n', 'c', 'p', 'y' };
static mxArray * _mxarray0_;

static mxChar _array3_[16] = { 'U', 's', 'e', ' ', 'N', 'N', 'C', 'O',
                               'P', 'Y', '(', 'M', ',', '1', ')', '.' };
static mxArray * _mxarray2_;
static mxArray * _mxarray4_;
static mxArray * _mxarray5_;

void InitializeModule_nncpy(void) {
    _mxarray0_ = mclInitializeString(5, _array1_);
    _mxarray2_ = mclInitializeString(16, _array3_);
    _mxarray4_ = mclInitializeDouble(1.0);
    _mxarray5_ = mclInitializeDouble(0.0);
}

void TerminateModule_nncpy(void) {
    mxDestroyArray(_mxarray5_);
    mxDestroyArray(_mxarray4_);
    mxDestroyArray(_mxarray2_);
    mxDestroyArray(_mxarray0_);
}

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

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

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

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

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