?? normrnd.c
字號:
/*
* MATLAB Compiler: 3.0
* Date: Fri Mar 24 11:31:36 2006
* 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" "-W" "main" "-L"
* "C" "-t" "-T" "link:exe" "-h" "libmmfile.mlib"
* "adptive_bitpow_allocate_systems"
*/
#include "normrnd.h"
#include "libmatlbm.h"
#include "rndcheck.h"
static mxArray * _mxarray0_;
static mxArray * _mxarray1_;
static mxArray * _mxarray2_;
static mxChar _array4_[38] = { 'R', 'e', 'q', 'u', 'i', 'r', 'e', 's', ' ', 'a',
't', ' ', 'l', 'e', 'a', 's', 't', ' ', 't', 'w',
'o', ' ', 'i', 'n', 'p', 'u', 't', ' ', 'a', 'r',
'g', 'u', 'm', 'e', 'n', 't', 's', '.' };
static mxArray * _mxarray3_;
static mxArray * _mxarray5_;
static mxChar _array7_[33] = { 'S', 'i', 'z', 'e', ' ', 'i', 'n', 'f', 'o',
'r', 'm', 'a', 't', 'i', 'o', 'n', ' ', 'i',
's', ' ', 'i', 'n', 'c', 'o', 'n', 's', 'i',
's', 't', 'e', 'n', 't', '.' };
static mxArray * _mxarray6_;
static mxArray * _mxarray8_;
static double _ieee_nan_;
static mxArray * _mxarray9_;
void InitializeModule_normrnd(void) {
_mxarray0_ = mclInitializeDouble(2.0);
_mxarray1_ = mclInitializeDouble(3.0);
_mxarray2_ = mclInitializeDouble(4.0);
_mxarray3_ = mclInitializeString(38, _array4_);
_mxarray5_ = mclInitializeDouble(0.0);
_mxarray6_ = mclInitializeString(33, _array7_);
_mxarray8_ = mclInitializeDouble(1.0);
_ieee_nan_ = mclGetNaN();
_mxarray9_ = mclInitializeDouble(_ieee_nan_);
}
void TerminateModule_normrnd(void) {
mxDestroyArray(_mxarray9_);
mxDestroyArray(_mxarray8_);
mxDestroyArray(_mxarray6_);
mxDestroyArray(_mxarray5_);
mxDestroyArray(_mxarray3_);
mxDestroyArray(_mxarray2_);
mxDestroyArray(_mxarray1_);
mxDestroyArray(_mxarray0_);
}
static mxArray * Mnormrnd(int nargout_,
mxArray * mu,
mxArray * sigma,
mxArray * m,
mxArray * n);
_mexLocalFunctionTable _local_function_table_normrnd
= { 0, (mexFunctionTableEntry *)NULL };
/*
* The function "mlfNormrnd" contains the normal interface for the "normrnd"
* M-function from file "c:\matlab6p5\toolbox\stats\normrnd.m" (lines 1-36).
* This function processes any input arguments and passes them to the
* implementation version of the function, appearing above.
*/
mxArray * mlfNormrnd(mxArray * mu, mxArray * sigma, mxArray * m, mxArray * n) {
int nargout = 1;
mxArray * r = NULL;
mlfEnterNewContext(0, 4, mu, sigma, m, n);
r = Mnormrnd(nargout, mu, sigma, m, n);
mlfRestorePreviousContext(0, 4, mu, sigma, m, n);
return mlfReturnValue(r);
}
/*
* The function "mlxNormrnd" contains the feval interface for the "normrnd"
* M-function from file "c:\matlab6p5\toolbox\stats\normrnd.m" (lines 1-36).
* The feval function calls the implementation version of normrnd through this
* function. This function processes any input arguments and passes them to the
* implementation version of the function, appearing above.
*/
void mlxNormrnd(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: normrnd Line: 1 Column: "
"1 The function \"normrnd\" was called with mor"
"e than the declared number of outputs (1)."),
NULL);
}
if (nrhs > 4) {
mlfError(
mxCreateString(
"Run-time Error: File: normrnd Line: 1 Column:"
" 1 The function \"normrnd\" was called with m"
"ore 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] = Mnormrnd(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 "Mnormrnd" is the implementation version of the "normrnd"
* M-function from file "c:\matlab6p5\toolbox\stats\normrnd.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 r = normrnd(mu,sigma,m,n);
*/
static mxArray * Mnormrnd(int nargout_,
mxArray * mu,
mxArray * sigma,
mxArray * m,
mxArray * n) {
mexLocalFunctionTable save_local_function_table_
= mclSetCurrentLocalFunctionTable(&_local_function_table_normrnd);
int nargin_ = mclNargin(4, mu, sigma, m, n, NULL);
mxArray * r = NULL;
mxArray * ans = NULL;
mxArray * columns = NULL;
mxArray * rows = NULL;
mxArray * errorcode = NULL;
mclCopyArray(&mu);
mclCopyArray(&sigma);
mclCopyArray(&m);
mclCopyArray(&n);
/*
* %NORMRND Random matrices from normal distribution.
* % R = NORMRND(MU,SIGMA) returns a matrix of random numbers chosen
* % from the normal distribution with parameters MU and SIGMA.
* %
* % The size of R is the common size of MU and SIGMA if both are matrices.
* % If either parameter is a scalar, the size of R is the size of the other
* % parameter. Alternatively, R = NORMRND(MU,SIGMA,M,N) returns an M by N
* % matrix.
*
* % Copyright 1993-2002 The MathWorks, Inc.
* % $Revision: 2.11 $ $Date: 2002/03/31 22:26:56 $
*
* if nargin == 2
*/
if (nargin_ == 2) {
/*
* [errorcode rows columns] = rndcheck(2,2,mu,sigma);
*/
mlfAssign(
&errorcode,
mlfRndcheck(
&rows,
&columns,
_mxarray0_,
_mxarray0_,
mclVa(mu, "mu"),
mclVa(sigma, "sigma"),
NULL,
NULL,
NULL));
/*
* elseif nargin == 3
*/
} else if (nargin_ == 3) {
/*
* [errorcode rows columns] = rndcheck(3,2,mu,sigma,m);
*/
mlfAssign(
&errorcode,
mlfRndcheck(
&rows,
&columns,
_mxarray1_,
_mxarray0_,
mclVa(mu, "mu"),
mclVa(sigma, "sigma"),
mclVa(m, "m"),
NULL,
NULL));
/*
* elseif nargin == 4
*/
} else if (nargin_ == 4) {
/*
* [errorcode rows columns] = rndcheck(4,2,mu,sigma,m,n);
*/
mlfAssign(
&errorcode,
mlfRndcheck(
&rows,
&columns,
_mxarray2_,
_mxarray0_,
mclVa(mu, "mu"),
mclVa(sigma, "sigma"),
mclVa(m, "m"),
mclVa(n, "n"),
NULL));
/*
* else
*/
} else {
/*
* error('Requires at least two input arguments.');
*/
mlfError(_mxarray3_, NULL);
/*
* end
*/
}
/*
*
* if errorcode > 0
*/
if (mclGtBool(mclVv(errorcode, "errorcode"), _mxarray5_)) {
/*
* error('Size information is inconsistent.');
*/
mlfError(_mxarray6_, NULL);
/*
* end
*/
}
/*
*
* r = randn(rows,columns) .* sigma + mu;
*/
mlfAssign(
&r,
mclPlus(
mclTimes(
mlfNRandn(1, mclVv(rows, "rows"), mclVv(columns, "columns"), NULL),
mclVa(sigma, "sigma")),
mclVa(mu, "mu")));
/*
*
* % Fill in elements corresponding to illegal parameter values
* if prod(size(sigma)) > 1
*/
if (mclGtBool(
mlfProd(
mlfSize(mclValueVarargout(), mclVa(sigma, "sigma"), NULL), NULL),
_mxarray8_)) {
/*
* r(sigma < 0) = NaN;
*/
mclArrayAssign1(
&r, _mxarray9_, mclLt(mclVa(sigma, "sigma"), _mxarray5_));
/*
* elseif sigma < 0
*/
} else if (mclLtBool(mclVa(sigma, "sigma"), _mxarray5_)) {
/*
* r(:) = NaN;
*/
mclArrayAssign1(&r, _mxarray9_, mlfCreateColonIndex());
/*
* end
*/
}
mclValidateOutput(r, 1, nargout_, "r", "normrnd");
mxDestroyArray(errorcode);
mxDestroyArray(rows);
mxDestroyArray(columns);
mxDestroyArray(ans);
mxDestroyArray(n);
mxDestroyArray(m);
mxDestroyArray(sigma);
mxDestroyArray(mu);
mclSetCurrentLocalFunctionTable(save_local_function_table_);
return r;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -