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

📄 initsm.c

📁 nnToolKit 神经网络工具包是基于 MATLAB 神经网络工具箱自行开发的一组神经网络算法函数库
💻 C
字号:
/*
 * MATLAB Compiler: 3.0
 * Date: Sun May 13 16:47:40 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 "initsm.h"
#include "libmatlbm.h"
#include "midpoint.h"
#include "nntobsf.h"

static mxChar _array1_[6] = { 'i', 'n', 'i', 't', 's', 'm' };
static mxArray * _mxarray0_;

static mxChar _array3_[59] = { 'U', 's', 'e', ' ', 'N', 'N', 'T', '2', 'S', 'O',
                               'M', ' ', 'a', 'n', 'd', ' ', 'I', 'N', 'I', 'T',
                               ' ', 't', 'o', ' ', 'u', 'p', 'd', 'a', 't', 'e',
                               ' ', 'a', 'n', 'd', ' ', 'i', 'n', 'i', 't', 'i',
                               'a', 'l', 'i', 'z', 'e', ' ', 'y', 'o', 'u', 'r',
                               ' ', 'n', 'e', 't', 'w', 'o', 'r', 'k', '.' };
static mxArray * _mxarray2_;
static mxArray * _mxarray4_;

static mxChar _array6_[34] = { 'M', 'a', 't', 'r', 'i', 'x', ' ', 'e', 'x',
                               'p', 'e', 'c', 't', 'e', 'd', ' ', 'a', 's',
                               ' ', 'f', 'i', 'r', 's', 't', ' ', 'a', 'r',
                               'g', 'u', 'm', 'e', 'n', 't', '.' };
static mxArray * _mxarray5_;
static mxArray * _mxarray7_;

void InitializeModule_initsm(void) {
    _mxarray0_ = mclInitializeString(6, _array1_);
    _mxarray2_ = mclInitializeString(59, _array3_);
    _mxarray4_ = mclInitializeDouble(2.0);
    _mxarray5_ = mclInitializeString(34, _array6_);
    _mxarray7_ = mclInitializeDoubleVector(0, 0, (double *)NULL);
}

void TerminateModule_initsm(void) {
    mxDestroyArray(_mxarray7_);
    mxDestroyArray(_mxarray5_);
    mxDestroyArray(_mxarray4_);
    mxDestroyArray(_mxarray2_);
    mxDestroyArray(_mxarray0_);
}

static mxArray * Minitsm(int nargout_, mxArray * p, mxArray * s);

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

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

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

/*
 * The function "Minitsm" is the implementation version of the "initsm"
 * M-function from file "d:\matlab6p5\toolbox\nnet\nnobsolete\initsm.m" (lines
 * 1-34). 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 w = initsm(p,s)
 */
static mxArray * Minitsm(int nargout_, mxArray * p, mxArray * s) {
    mexLocalFunctionTable save_local_function_table_
      = mclSetCurrentLocalFunctionTable(&_local_function_table_initsm);
    mxArray * w = NULL;
    mxArray * Q = NULL;
    mxArray * R = NULL;
    mxArray * ans = NULL;
    mclCopyArray(&p);
    mclCopyArray(&s);
    /*
     * %INITSM Inititialize self-organizing map.
     * %  
     * %  This function is obselete.
     * %  Use NNT2SOM and INIT to update and initialize your network.
     * 
     * nntobsf('initsm','Use NNT2SOM and INIT to update and initialize your network.')
     */
    mlfNntobsf(_mxarray0_, _mxarray2_, NULL);
    /*
     * 
     * %  INITSM(P,S)
     * %    P - Rx2 matrix of input vectors.
     * %    S - Number of neurons in layer.
     * %  Returns:
     * %    W - SxR weight matrix.
     * %  
     * %  IMPORTANT: Each ith row of P must contain expected
     * %    min and max values for the ith input.
     * %  
     * %  EXAMPLE: w = initsm([-2 2;0 5],6);
     * %           m = nbgrid(2,3);
     * %           p = [1; 2];
     * %           a = simusm(p,w,m)
     * %  
     * %  See also NNINIT, SELFORG, SIMUSM, TRAINSM.
     * 
     * % Mark Beale, 12-15-93
     * % Copyright 1992-2002 The MathWorks, Inc.
     * % $Revision: 1.11 $  $Date: 2002/03/25 16:53:52 $
     * 
     * % INPUTS
     * [R,Q] = size(p);
     */
    mlfSize(mlfVarargout(&R, &Q, NULL), mclVa(p, "p"), NULL);
    /*
     * if Q < 2,error('Matrix expected as first argument.'),end
     */
    if (mclLtBool(mclVv(Q, "Q"), _mxarray4_)) {
        mlfError(_mxarray5_, NULL);
    }
    /*
     * 
     * w = midpoint(s,[min(p,[],2) max(p,[],2)]);
     */
    mlfAssign(
      &w,
      mlfNMidpoint(
        1,
        NULL,
        mclVa(s, "s"),
        mlfHorzcat(
          mlfMin(NULL, mclVa(p, "p"), _mxarray7_, _mxarray4_),
          mlfMax(NULL, mclVa(p, "p"), _mxarray7_, _mxarray4_),
          NULL)));
    mclValidateOutput(w, 1, nargout_, "w", "initsm");
    mxDestroyArray(ans);
    mxDestroyArray(R);
    mxDestroyArray(Q);
    mxDestroyArray(s);
    mxDestroyArray(p);
    mclSetCurrentLocalFunctionTable(save_local_function_table_);
    return w;
}

⌨️ 快捷键说明

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