📄 simusm.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 "simusm.h"
#include "compet.h"
#include "dist.h"
#include "libmatlbm.h"
#include "nntobsf.h"
static mxChar _array1_[6] = { 's', 'i', 'm', 'u', 's', 'm' };
static mxArray * _mxarray0_;
static mxChar _array3_[56] = { 'U', 's', 'e', ' ', 'N', 'N', 'T', '2', 'S', 'O',
'M', ' ', 'a', 'n', 'd', ' ', 'S', 'I', 'M', ' ',
't', 'o', ' ', 'u', 'p', 'd', 'a', 't', 'e', ' ',
'a', 'n', 'd', ' ', 's', 'i', 'm', 'u', 'l', 'a',
't', 'e', ' ', 'y', 'o', 'u', 'r', ' ', 'n', 'e',
't', 'w', 'o', 'r', 'k', '.' };
static mxArray * _mxarray2_;
static mxChar _array5_[21] = { 'N', 'o', 't', ' ', 'e', 'n', 'o',
'u', 'g', 'h', ' ', 'a', 'r', 'g',
'u', 'm', 'e', 'n', 't', 's', '.' };
static mxArray * _mxarray4_;
static mxArray * _mxarray6_;
static mxArray * _mxarray7_;
void InitializeModule_simusm(void) {
_mxarray0_ = mclInitializeString(6, _array1_);
_mxarray2_ = mclInitializeString(56, _array3_);
_mxarray4_ = mclInitializeString(21, _array5_);
_mxarray6_ = mclInitializeDouble(1.0);
_mxarray7_ = mclInitializeDouble(.5);
}
void TerminateModule_simusm(void) {
mxDestroyArray(_mxarray7_);
mxDestroyArray(_mxarray6_);
mxDestroyArray(_mxarray4_);
mxDestroyArray(_mxarray2_);
mxDestroyArray(_mxarray0_);
}
static mxArray * Msimusm(int nargout_,
mxArray * p,
mxArray * w,
mxArray * m,
mxArray * n);
_mexLocalFunctionTable _local_function_table_simusm
= { 0, (mexFunctionTableEntry *)NULL };
/*
* The function "mlfSimusm" contains the normal interface for the "simusm"
* M-function from file "d:\matlab6p5\toolbox\nnet\nnobsolete\simusm.m" (lines
* 1-32). This function processes any input arguments and passes them to the
* implementation version of the function, appearing above.
*/
mxArray * mlfSimusm(mxArray * p, mxArray * w, mxArray * m, mxArray * n) {
int nargout = 1;
mxArray * a = NULL;
mlfEnterNewContext(0, 4, p, w, m, n);
a = Msimusm(nargout, p, w, m, n);
mlfRestorePreviousContext(0, 4, p, w, m, n);
return mlfReturnValue(a);
}
/*
* The function "mlxSimusm" contains the feval interface for the "simusm"
* M-function from file "d:\matlab6p5\toolbox\nnet\nnobsolete\simusm.m" (lines
* 1-32). The feval function calls the implementation version of simusm through
* this function. This function processes any input arguments and passes them
* to the implementation version of the function, appearing above.
*/
void mlxSimusm(int nlhs, mxArray * plhs[], int nrhs, mxArray * prhs[]) {
mxArray * mprhs[4];
mxArray * mplhs[1];
int i;
if (nlhs > 1) {
mlfError(
mxCreateString(
"Run-time Error: File: simusm Line: 1 Column: "
"1 The function \"simusm\" was called with mor"
"e than the declared number of outputs (1)."),
NULL);
}
if (nrhs > 4) {
mlfError(
mxCreateString(
"Run-time Error: File: simusm Line: 1 Column: "
"1 The function \"simusm\" was called with mor"
"e than the declared number of inputs (4)."),
NULL);
}
for (i = 0; i < 1; ++i) {
mplhs[i] = NULL;
}
for (i = 0; i < 4 && i < nrhs; ++i) {
mprhs[i] = prhs[i];
}
for (; i < 4; ++i) {
mprhs[i] = NULL;
}
mlfEnterNewContext(0, 4, mprhs[0], mprhs[1], mprhs[2], mprhs[3]);
mplhs[0] = Msimusm(nlhs, mprhs[0], mprhs[1], mprhs[2], mprhs[3]);
mlfRestorePreviousContext(0, 4, mprhs[0], mprhs[1], mprhs[2], mprhs[3]);
plhs[0] = mplhs[0];
}
/*
* The function "Msimusm" is the implementation version of the "simusm"
* M-function from file "d:\matlab6p5\toolbox\nnet\nnobsolete\simusm.m" (lines
* 1-32). 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 a = simusm(p,w,m,n)
*/
static mxArray * Msimusm(int nargout_,
mxArray * p,
mxArray * w,
mxArray * m,
mxArray * n) {
mexLocalFunctionTable save_local_function_table_
= mclSetCurrentLocalFunctionTable(&_local_function_table_simusm);
int nargin_ = mclNargin(4, p, w, m, n, NULL);
mxArray * a = NULL;
mxArray * ans = NULL;
mclCopyArray(&p);
mclCopyArray(&w);
mclCopyArray(&m);
mclCopyArray(&n);
/*
* %SIMUSM Simulates a self-organizing map.
* %
* % This function is obselete.
* % Use NNT2SOM and SIM to update and simulate your network.
*
* nntobsf('simusm','Use NNT2SOM and SIM to update and simulate your network.')
*/
mlfNntobsf(_mxarray0_, _mxarray2_, NULL);
/*
*
* % SIMUSM(P,W,B,M,N)
* % P - RxQ matrix of input (column) vectors.
* % W - SxR weight matrix.
* % M - Neighborhood matrix.
* % N - Neighborhood size, default = 1.
* % Returns outputs of the self-organizing map.
* %
* % EXAMPLE: w = initsm([-2 2;0 5],6);
* % m = nbman(2,3);
* % p = [1; 2];
* % a = simusm(p,w,m)
* %
* % See also NNSIM, SELFORG, INITSM, TRAINSM.
*
* % Mark Beale, 12-15-93
* % Copyright 1992-2002 The MathWorks, Inc.
* % $Revision: 1.11 $ $Date: 2002/03/25 16:54:16 $
*
* if nargin < 3,error('Not enough arguments.'),end
*/
if (nargin_ < 3) {
mlfError(_mxarray4_, NULL);
}
/*
* if nargin ==3, n = 1; end
*/
if (nargin_ == 3) {
mlfAssign(&n, _mxarray6_);
}
/*
*
* a = compet(-dist(w,p));
*/
mlfAssign(
&a, mlfCompet(mclUminus(mlfDist(mclVa(w, "w"), mclVa(p, "p"))), NULL));
/*
* a = 0.5*(a + sparse(m <= n)*a);
*/
mlfAssign(
&a,
mclMtimes(
_mxarray7_,
mclPlus(
mclVv(a, "a"),
mclMtimes(
mlfSparse(
mclLe(mclVa(m, "m"), mclVa(n, "n")),
NULL,
NULL,
NULL,
NULL,
NULL),
mclVv(a, "a")))));
mclValidateOutput(a, 1, nargout_, "a", "simusm");
mxDestroyArray(ans);
mxDestroyArray(n);
mxDestroyArray(m);
mxDestroyArray(w);
mxDestroyArray(p);
mclSetCurrentLocalFunctionTable(save_local_function_table_);
return a;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -