📄 optim_private_perturb.c
字号:
/*
* MATLAB Compiler: 2.0.1
* Date: Tue May 08 21:28:22 2001
* Arguments: "-B" "sgl" "-m" "-W" "mainhg" "-L" "C" "asufit.m" "absfun.m"
* "absfunfree.m" "absfunshift.m" "absfunwidth.m" "dispfit.m" "dispfitdisp.m"
* "dispfitfree.m" "dispfitwidth.m" "seqmodfree.m" "spcfun.m" "spcfun1.m"
* "atamult.m" "aprecon.m"
*/
#include "optim_private_perturb.h"
/*
* The function "Moptim_private_perturb" is the implementation version of the
* "optim/private/perturb" M-function from file
* "C:\MATLABR11\toolbox\optim\private\perturb.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[pert,x,y] = perturb(x,l,u,del,y,sigma)
*/
static mxArray * Moptim_private_perturb(mxArray * * x,
mxArray * * y,
int nargout_,
mxArray * x_,
mxArray * l,
mxArray * u,
mxArray * del,
mxArray * y_,
mxArray * sigma) {
mxArray * pert = mclGetUninitializedArray();
mxArray * loweri = mclGetUninitializedArray();
mxArray * nargin_ = mclGetUninitializedArray();
mxArray * upperi = mclGetUninitializedArray();
mlfAssign(&nargin_, mlfNargin(0, x_, l, u, del, y_, sigma, NULL));
mclValidateInputs(
"optim/private/perturb", 6, &x_, &l, &u, &del, &y_, &sigma);
mclCopyArray(&del);
mclCopyInputArg(x, x_);
mclCopyInputArg(y, y_);
/*
* %PERTURB Perturb point from bounds
* %
* % [PERT,X] = PERTURB(X,L,U,DEL) perturbs the current point X
* % slightly to shake it loose from tight (less than DEL away)
* % bounds U and L to be strictly feasible.
* % Called by SNLS and SFMINBX.
* %
* % [PERT,X,Y] = PERTURB(X,L,U,DEL,Y,SIGMA) also perturbs the
* % reflected point Y with respect to SIGMA,
*
* % Copyright (c) 1990-98 by The MathWorks, Inc.
* % $Revision: 1.2 $ $Date: 1998/03/21 16:29:04 $
*
* if nargin < 4
*/
if (mlfTobool(mlfLt(nargin_, mlfScalar(4.0)))) {
/*
* del = 100*eps;
*/
mlfAssign(&del, mlfMtimes(mlfScalar(100.0), mlfEps()));
/*
* end
*/
}
/*
*
* if (min(abs(u-x)) < del) | (min(abs(x-l)) < del)
*/
{
mxArray * a_ = mclInitialize(
mlfLt(
mlfMin(NULL, mlfAbs(mlfMinus(u, *x)), NULL, NULL),
del));
if (mlfTobool(a_)
|| mlfTobool(
mlfOr(
a_,
mlfLt(
mlfMin(NULL, mlfAbs(mlfMinus(*x, l)), NULL, NULL),
del)))) {
mxDestroyArray(a_);
/*
* upperi = (u-x) < del;
*/
mlfAssign(&upperi, mlfLt(mlfMinus(u, *x), del));
/*
* loweri = (x-l) < del;
*/
mlfAssign(&loweri, mlfLt(mlfMinus(*x, l), del));
/*
* x(upperi) = x(upperi) - del;
*/
mlfIndexAssign(
x, "(?)", upperi, mlfMinus(mlfIndexRef(*x, "(?)", upperi), del));
/*
* x(loweri) = x(loweri) + del;
*/
mlfIndexAssign(
x, "(?)", loweri, mlfPlus(mlfIndexRef(*x, "(?)", loweri), del));
/*
* if nargin > 4
*/
if (mlfTobool(mlfGt(nargin_, mlfScalar(4.0)))) {
/*
* y(upperi) = y(upperi) - del*sigma(upperi);
*/
mlfIndexAssign(
y,
"(?)",
upperi,
mlfMinus(
mlfIndexRef(*y, "(?)", upperi),
mlfMtimes(del, mlfIndexRef(sigma, "(?)", upperi))));
/*
* y(loweri) = y(loweri) + del*sigma(loweri);
*/
mlfIndexAssign(
y,
"(?)",
loweri,
mlfPlus(
mlfIndexRef(*y, "(?)", loweri),
mlfMtimes(del, mlfIndexRef(sigma, "(?)", loweri))));
/*
* end
*/
}
/*
* pert = 1;
*/
mlfAssign(&pert, mlfScalar(1.0));
/*
* else
*/
} else {
mxDestroyArray(a_);
/*
* pert = 0;
*/
mlfAssign(&pert, mlfScalar(0.0));
}
/*
* end
*/
}
mclValidateOutputs("optim/private/perturb", 3, nargout_, &pert, x, y);
mxDestroyArray(del);
mxDestroyArray(loweri);
mxDestroyArray(nargin_);
mxDestroyArray(upperi);
/*
*
*
*
*
*/
return pert;
}
/*
* The function "mlfOptim_private_perturb" contains the normal interface for
* the "optim/private/perturb" M-function from file
* "C:\MATLABR11\toolbox\optim\private\perturb.m" (lines 1-36). This function
* processes any input arguments and passes them to the implementation version
* of the function, appearing above.
*/
mxArray * mlfOptim_private_perturb(mxArray * * x,
mxArray * * y,
mxArray * x_,
mxArray * l,
mxArray * u,
mxArray * del,
mxArray * y_,
mxArray * sigma) {
int nargout = 1;
mxArray * pert = mclGetUninitializedArray();
mxArray * x__ = mclGetUninitializedArray();
mxArray * y__ = mclGetUninitializedArray();
mlfEnterNewContext(2, 6, x, y, x_, l, u, del, y_, sigma);
if (x != NULL) {
++nargout;
}
if (y != NULL) {
++nargout;
}
pert
= Moptim_private_perturb(&x__, &y__, nargout, x_, l, u, del, y_, sigma);
mlfRestorePreviousContext(2, 6, x, y, x_, l, u, del, y_, sigma);
if (x != NULL) {
mclCopyOutputArg(x, x__);
} else {
mxDestroyArray(x__);
}
if (y != NULL) {
mclCopyOutputArg(y, y__);
} else {
mxDestroyArray(y__);
}
return mlfReturnValue(pert);
}
/*
* The function "mlxOptim_private_perturb" contains the feval interface for the
* "optim/private/perturb" M-function from file
* "C:\MATLABR11\toolbox\optim\private\perturb.m" (lines 1-36). The feval
* function calls the implementation version of optim/private/perturb through
* this function. This function processes any input arguments and passes them
* to the implementation version of the function, appearing above.
*/
void mlxOptim_private_perturb(int nlhs,
mxArray * plhs[],
int nrhs,
mxArray * prhs[]) {
mxArray * mprhs[6];
mxArray * mplhs[3];
int i;
if (nlhs > 3) {
mlfError(
mxCreateString(
"Run-time Error: File: optim/private/perturb Line: 1 Col"
"umn: 0 The function \"optim/private/perturb\" was calle"
"d with more than the declared number of outputs (3)"));
}
if (nrhs > 6) {
mlfError(
mxCreateString(
"Run-time Error: File: optim/private/perturb Line: 1 Col"
"umn: 0 The function \"optim/private/perturb\" was calle"
"d with more than the declared number of inputs (6)"));
}
for (i = 0; i < 3; ++i) {
mplhs[i] = NULL;
}
for (i = 0; i < 6 && i < nrhs; ++i) {
mprhs[i] = prhs[i];
}
for (; i < 6; ++i) {
mprhs[i] = NULL;
}
mlfEnterNewContext(
0, 6, mprhs[0], mprhs[1], mprhs[2], mprhs[3], mprhs[4], mprhs[5]);
mplhs[0]
= Moptim_private_perturb(
&mplhs[1],
&mplhs[2],
nlhs,
mprhs[0],
mprhs[1],
mprhs[2],
mprhs[3],
mprhs[4],
mprhs[5]);
mlfRestorePreviousContext(
0, 6, mprhs[0], mprhs[1], mprhs[2], mprhs[3], mprhs[4], mprhs[5]);
plhs[0] = mplhs[0];
for (i = 1; i < 3 && i < nlhs; ++i) {
plhs[i] = mplhs[i];
}
for (; i < 3; ++i) {
mxDestroyArray(mplhs[i]);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -