📄 purelin.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 "purelin.h"
#include "libmatlbm.h"
#include "nntobsu.h"
static mxChar _array1_[21] = { 'N', 'o', 't', ' ', 'e', 'n', 'o',
'u', 'g', 'h', ' ', 'a', 'r', 'g',
'u', 'm', 'e', 'n', 't', 's', '.' };
static mxArray * _mxarray0_;
static mxChar _array3_[5] = { 'd', 'e', 'r', 'i', 'v' };
static mxArray * _mxarray2_;
static mxChar _array5_[8] = { 'd', 'p', 'u', 'r', 'e', 'l', 'i', 'n' };
static mxArray * _mxarray4_;
static mxChar _array7_[4] = { 'n', 'a', 'm', 'e' };
static mxArray * _mxarray6_;
static mxChar _array9_[6] = { 'L', 'i', 'n', 'e', 'a', 'r' };
static mxArray * _mxarray8_;
static mxChar _array11_[6] = { 'o', 'u', 't', 'p', 'u', 't' };
static mxArray * _mxarray10_;
static double _ieee_minusinf_;
static double _ieee_plusinf_;
static double _array13_[2] = { 0.0 /*_ieee_minusinf_*/,
0.0 /*_ieee_plusinf_*/ };
static mxArray * _mxarray12_;
static mxChar _array15_[6] = { 'a', 'c', 't', 'i', 'v', 'e' };
static mxArray * _mxarray14_;
static mxChar _array17_[4] = { 't', 'y', 'p', 'e' };
static mxArray * _mxarray16_;
static mxArray * _mxarray18_;
static mxChar _array20_[5] = { 'd', 'e', 'l', 't', 'a' };
static mxArray * _mxarray19_;
static mxChar _array22_[8] = { 'd', 'e', 'l', 't', 'a', 'l', 'i', 'n' };
static mxArray * _mxarray21_;
static mxChar _array24_[7] = { 'p', 'u', 'r', 'e', 'l', 'i', 'n' };
static mxArray * _mxarray23_;
static mxChar _array26_[49] = { 'U', 's', 'e', ' ', 'P', 'U', 'R', 'E', 'L',
'I', 'N', '(', 0x0027, 'd', 'e', 'r', 'i',
'v', 0x0027, ')', ' ', 'i', 'n', 's', 't',
'e', 'a', 'd', ' ', 'o', 'f', ' ', 'P', 'U',
'R', 'E', 'L', 'I', 'N', '(', 0x0027, 'd',
'e', 'l', 't', 'a', 0x0027, ')', '.' };
static mxArray * _mxarray25_;
static mxChar _array28_[4] = { 'i', 'n', 'i', 't' };
static mxArray * _mxarray27_;
static mxChar _array30_[5] = { 'r', 'a', 'n', 'd', 's' };
static mxArray * _mxarray29_;
static mxChar _array32_[53] = { 'U', 's', 'e', ' ', 'n', 'e', 't', 'w', 'o',
'r', 'k', ' ', 'p', 'r', 'o', 'p', 'r', 'e',
't', 'i', 'e', 's', ' ', 't', 'o', ' ', 'o',
'b', 't', 'a', 'i', 'n', ' ', 'i', 'n', 'i',
't', 'i', 'a', 'l', 'i', 'z', 'a', 't', 'i',
'o', 'n', ' ', 'i', 'n', 'f', 'o', '.' };
static mxArray * _mxarray31_;
static mxChar _array34_[18] = { 'U', 'n', 'r', 'e', 'c', 'o', 'g', 'n', 'i',
'z', 'e', 'd', ' ', 'c', 'o', 'd', 'e', '.' };
static mxArray * _mxarray33_;
static mxChar _array36_[59] = { 'U', 's', 'e', ' ', 'P', 'U', 'R', 'E', 'L',
'I', 'N', '(', 'N', 'E', 'T', 'S', 'U', 'M',
'(', 'Z', ',', 'B', '*', 'o', 'n', 'e', 's',
'(', '1', ',', 'Q', ')', ')', ')', ' ', 'i',
'n', 's', 't', 'e', 'a', 'd', ' ', 'o', 'f',
' ', 'P', 'U', 'R', 'E', 'L', 'I', 'N', '(',
'Z', ',', 'B', ')', '.' };
static mxArray * _mxarray35_;
static mxArray * _mxarray37_;
void InitializeModule_purelin(void) {
_mxarray0_ = mclInitializeString(21, _array1_);
_mxarray2_ = mclInitializeString(5, _array3_);
_mxarray4_ = mclInitializeString(8, _array5_);
_mxarray6_ = mclInitializeString(4, _array7_);
_mxarray8_ = mclInitializeString(6, _array9_);
_mxarray10_ = mclInitializeString(6, _array11_);
_ieee_minusinf_ = mclGetMinusInf();
_array13_[0] = _ieee_minusinf_;
_ieee_plusinf_ = mclGetInf();
_array13_[1] = _ieee_plusinf_;
_mxarray12_ = mclInitializeDoubleVector(1, 2, _array13_);
_mxarray14_ = mclInitializeString(6, _array15_);
_mxarray16_ = mclInitializeString(4, _array17_);
_mxarray18_ = mclInitializeDouble(1.0);
_mxarray19_ = mclInitializeString(5, _array20_);
_mxarray21_ = mclInitializeString(8, _array22_);
_mxarray23_ = mclInitializeString(7, _array24_);
_mxarray25_ = mclInitializeString(49, _array26_);
_mxarray27_ = mclInitializeString(4, _array28_);
_mxarray29_ = mclInitializeString(5, _array30_);
_mxarray31_ = mclInitializeString(53, _array32_);
_mxarray33_ = mclInitializeString(18, _array34_);
_mxarray35_ = mclInitializeString(59, _array36_);
_mxarray37_ = mclInitializeDouble(2.0);
}
void TerminateModule_purelin(void) {
mxDestroyArray(_mxarray37_);
mxDestroyArray(_mxarray35_);
mxDestroyArray(_mxarray33_);
mxDestroyArray(_mxarray31_);
mxDestroyArray(_mxarray29_);
mxDestroyArray(_mxarray27_);
mxDestroyArray(_mxarray25_);
mxDestroyArray(_mxarray23_);
mxDestroyArray(_mxarray21_);
mxDestroyArray(_mxarray19_);
mxDestroyArray(_mxarray18_);
mxDestroyArray(_mxarray16_);
mxDestroyArray(_mxarray14_);
mxDestroyArray(_mxarray12_);
mxDestroyArray(_mxarray10_);
mxDestroyArray(_mxarray8_);
mxDestroyArray(_mxarray6_);
mxDestroyArray(_mxarray4_);
mxDestroyArray(_mxarray2_);
mxDestroyArray(_mxarray0_);
}
static mxArray * Mpurelin(int nargout_, mxArray * n, mxArray * b);
_mexLocalFunctionTable _local_function_table_purelin
= { 0, (mexFunctionTableEntry *)NULL };
/*
* The function "mlfPurelin" contains the normal interface for the "purelin"
* M-function from file "d:\matlab6p5\toolbox\nnet\nnet\purelin.m" (lines
* 1-94). This function processes any input arguments and passes them to the
* implementation version of the function, appearing above.
*/
mxArray * mlfPurelin(mxArray * n, mxArray * b) {
int nargout = 1;
mxArray * a = NULL;
mlfEnterNewContext(0, 2, n, b);
a = Mpurelin(nargout, n, b);
mlfRestorePreviousContext(0, 2, n, b);
return mlfReturnValue(a);
}
/*
* The function "mlxPurelin" contains the feval interface for the "purelin"
* M-function from file "d:\matlab6p5\toolbox\nnet\nnet\purelin.m" (lines
* 1-94). The feval function calls the implementation version of purelin
* through this function. This function processes any input arguments and
* passes them to the implementation version of the function, appearing above.
*/
void mlxPurelin(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: purelin Line: 1 Column: "
"1 The function \"purelin\" was called with mor"
"e than the declared number of outputs (1)."),
NULL);
}
if (nrhs > 2) {
mlfError(
mxCreateString(
"Run-time Error: File: purelin Line: 1 Column:"
" 1 The function \"purelin\" was called with m"
"ore 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] = Mpurelin(nlhs, mprhs[0], mprhs[1]);
mlfRestorePreviousContext(0, 2, mprhs[0], mprhs[1]);
plhs[0] = mplhs[0];
}
/*
* The function "Mpurelin" is the implementation version of the "purelin"
* M-function from file "d:\matlab6p5\toolbox\nnet\nnet\purelin.m" (lines
* 1-94). 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 = purelin(n,b)
*/
static mxArray * Mpurelin(int nargout_, mxArray * n, mxArray * b) {
mexLocalFunctionTable save_local_function_table_
= mclSetCurrentLocalFunctionTable(&_local_function_table_purelin);
int nargin_ = mclNargin(2, n, b, NULL);
mxArray * a = NULL;
mxArray * ans = NULL;
mclCopyArray(&n);
mclCopyArray(&b);
/*
* %PURELIN Linear transfer function.
* %
* % Syntax
* %
* % A = purelin(N)
* % info = purelin(code)
* %
* % Description
* %
* % PURELIN is a transfer function. Transfer functions
* % calculate a layer's output from its net input.
* %
* % PURELIN(N) takes one input,
* % N - SxQ matrix of net input (column) vectors.
* % and returns N.
* %
* % PURELIN(CODE) returns useful information for each CODE string:
* % 'deriv' - Returns name of derivative function.
* % 'name' - Returns full name.
* % 'output' - Returns output range.
* % 'active' - Returns active input range.
* %
* % Examples
* %
* % Here is the code to create a plot of the PURELIN transfer function.
* %
* % n = -5:0.1:5;
* % a = purelin(n);
* % plot(n,a)
* %
* % Network Use
* %
* % You can create a standard network that uses PURELIN
* % by calling NEWLIN or NEWLIND.
* %
* % To change a network so a layer uses PURELIN, set
* % NET.layers{i}.transferFcn to 'purelin'.
* %
* % In either case, call SIM to simulate the network with PURELIN.
* % See NEWLIN or NEWLIND for simulation examples.
* %
* % Algorithm
* %
* % purelin(n) = n
* %
* % See also SIM, DPURELIN, SATLIN, SATLINS.
*
* % Mark Beale, 1-31-92
* % Revised 12-15-93, MB
* % Revised 11-31-97, MB
* % Copyright 1992-2002 The MathWorks, Inc.
* % $Revision: 1.11 $ $Date: 2002/03/25 16:53:19 $
*
* if nargin < 1, error('Not enough arguments.'); end
*/
if (nargin_ < 1) {
mlfError(_mxarray0_, NULL);
}
/*
*
* % FUNCTION INFO
* if isstr(n)
*/
if (mlfTobool(mlfIsstr(mclVa(n, "n")))) {
/*
* switch (n)
*/
mxArray * v_ = mclInitialize(mclVa(n, "n"));
if (mclSwitchCompare(v_, _mxarray2_)) {
/*
* case 'deriv',
* a = 'dpurelin';
*/
mlfAssign(&a, _mxarray4_);
/*
* case 'name',
*/
} else if (mclSwitchCompare(v_, _mxarray6_)) {
/*
* a = 'Linear';
*/
mlfAssign(&a, _mxarray8_);
/*
* case 'output',
*/
} else if (mclSwitchCompare(v_, _mxarray10_)) {
/*
* a = [-inf +inf];
*/
mlfAssign(&a, _mxarray12_);
/*
* case 'active',
*/
} else if (mclSwitchCompare(v_, _mxarray14_)) {
/*
* a = [-inf +inf];
*/
mlfAssign(&a, _mxarray12_);
/*
* case 'type',
*/
} else if (mclSwitchCompare(v_, _mxarray16_)) {
/*
* a = 1;
*/
mlfAssign(&a, _mxarray18_);
/*
*
* % **[ NNT2 Support ]**
* case 'delta',
*/
} else if (mclSwitchCompare(v_, _mxarray19_)) {
/*
* a = 'deltalin';
*/
mlfAssign(&a, _mxarray21_);
/*
* nntobsu('purelin','Use PURELIN(''deriv'') instead of PURELIN(''delta'').')
*/
mlfNntobsu(_mxarray23_, _mxarray25_, NULL);
/*
* case 'init',
*/
} else if (mclSwitchCompare(v_, _mxarray27_)) {
/*
* a = 'rands';
*/
mlfAssign(&a, _mxarray29_);
/*
* nntobsu('purelin','Use network propreties to obtain initialization info.')
*/
mlfNntobsu(_mxarray23_, _mxarray31_, NULL);
/*
*
* otherwise
*/
} else {
/*
* error('Unrecognized code.')
*/
mlfError(_mxarray33_, NULL);
/*
* end
*/
}
mxDestroyArray(v_);
/*
* return
*/
goto return_;
/*
* end
*/
}
/*
*
* % CALCULATION
*
* % **[ NNT2 Support ]**
* if nargin == 2
*/
if (nargin_ == 2) {
/*
* nntobsu('purelin','Use PURELIN(NETSUM(Z,B*ones(1,Q))) instead of PURELIN(Z,B).')
*/
mlfNntobsu(_mxarray23_, _mxarray35_, NULL);
/*
* n = n + b(:,ones(1,size(n,2)));
*/
mlfAssign(
&n,
mclPlus(
mclVa(n, "n"),
mclArrayRef2(
mclVa(b, "b"),
mlfCreateColonIndex(),
mlfOnes(
_mxarray18_,
mlfSize(mclValueVarargout(), mclVa(n, "n"), _mxarray37_),
NULL))));
/*
* end
*/
}
/*
*
* a = n;
*/
mlfAssign(&a, mclVa(n, "n"));
return_:
mclValidateOutput(a, 1, nargout_, "a", "purelin");
mxDestroyArray(ans);
mxDestroyArray(b);
mxDestroyArray(n);
mclSetCurrentLocalFunctionTable(save_local_function_table_);
return a;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -