84 if (
sqr(vd)<0.9999*vv*dd)
86 double a=
dhd*vd-dd*dd,
92 double tmp2=
sqrt(b*b-a*c)/
a, dd1, dd2, dhd1, dhd2;
106 else { D=D2; dd=dd2;
dhd=dhd2; }
122 i=
n;
while (i--) v[
i]=
d[
i]-temp*
g[
i];
125 if ((normG*dd)<(0.5-2*rho*
condorAbs(dhd))||(vv/dd<1e-4))
128 VMAX=
condorAbs(scale*(gd+0.5*scale*dhd));
141 double theta, cosTheta, sinTheta;
149 theta=0.5*atan(0.5*vhg/(vhv-ghg));
156 d[
i]= cosTheta*g[
i]+ sinTheta*v[
i];
157 v[
i]=-sinTheta*g[
i]+ cosTheta*v[
i];
167 dhd=(ghg*
sqr(cosTheta)+vhv*
sqr(sinTheta))*
sqr(norm);
171 vhv=(ghg*
sqr(sinTheta)+vhv*
sqr(cosTheta)*
sqr(norm));
173 double halfRootTwo=
sqrt(0.5),
174 t1=normG*cosTheta*
rho,
175 t2=normG*sinTheta*
rho,
183 if ((q4>
q3)&&(q4>
q2)&&(q4>
q1))
185 double st1=
sign(t1*t3), st2=
sign(t2*t3);
186 i=
n;
while (i--)
d[
i]=halfRootTwo*(st1*
d[
i]-st2*v[
i]);
192 double st1=
sign(t1*t3), st2=
sign(t2*t3);
193 i=
n;
while (i--)
d[
i]=halfRootTwo*(st1*
d[
i]+st2*v[
i]);
void sqrt(Image< double > &op)
Matrix multiply(Matrix B)
T norm(const std::vector< T > &v)
void gradientHessian(Vector P, Vector G, Matrix H)
double scalarProduct(Vector v)
static Vector emptyVector
Vector LAGMAXModified(Vector G, Matrix H, double rho, double &VMAX)