MATH-621
Function "update": All local variables defined at initialization. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1158457 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4b1377907d
commit
9c4571dd50
|
@ -1995,8 +1995,9 @@ public class BOBYQAOptimizer
|
||||||
// upper bound on the indices of the conjugate gradient iterations.
|
// upper bound on the indices of the conjugate gradient iterations.
|
||||||
|
|
||||||
int state = 20;
|
int state = 20;
|
||||||
for(;;) switch (state) {
|
for(;;) {
|
||||||
|
// System.out.println("loop in trsbox: state=" + state); // XXX
|
||||||
|
switch (state) {
|
||||||
case 20: {
|
case 20: {
|
||||||
beta = ZERO;
|
beta = ZERO;
|
||||||
}
|
}
|
||||||
|
@ -2390,6 +2391,7 @@ public class BOBYQAOptimizer
|
||||||
default: {
|
default: {
|
||||||
throw new MathIllegalStateException(LocalizedFormats.SIMPLE_MESSAGE, "trsbox");
|
throw new MathIllegalStateException(LocalizedFormats.SIMPLE_MESSAGE, "trsbox");
|
||||||
}}
|
}}
|
||||||
|
}
|
||||||
} // trsbox
|
} // trsbox
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------------
|
||||||
|
@ -2427,18 +2429,7 @@ public class BOBYQAOptimizer
|
||||||
// XXX Should probably be split into two arrays.
|
// XXX Should probably be split into two arrays.
|
||||||
final ArrayRealVector work = new ArrayRealVector(npt + n);
|
final ArrayRealVector work = new ArrayRealVector(npt + n);
|
||||||
|
|
||||||
|
double ztest = ZERO;
|
||||||
// System generated locals
|
|
||||||
double d__1, d__2, d__3;
|
|
||||||
|
|
||||||
// Local variables
|
|
||||||
int jp;
|
|
||||||
double tau, temp;
|
|
||||||
double alpha, tempa, tempb, ztest;
|
|
||||||
|
|
||||||
// Function Body
|
|
||||||
|
|
||||||
ztest = ZERO;
|
|
||||||
for (int k = 0; k < npt; k++) {
|
for (int k = 0; k < npt; k++) {
|
||||||
for (int j = 0; j < nptm; j++) {
|
for (int j = 0; j < nptm; j++) {
|
||||||
// Computing MAX
|
// Computing MAX
|
||||||
|
@ -2450,20 +2441,19 @@ public class BOBYQAOptimizer
|
||||||
// Apply the rotations that put zeros in the KNEW-th row of ZMAT.
|
// Apply the rotations that put zeros in the KNEW-th row of ZMAT.
|
||||||
|
|
||||||
for (int j = 1; j < nptm; j++) {
|
for (int j = 1; j < nptm; j++) {
|
||||||
d__1 = zmat.getEntry(knew, j);
|
final double d1 = zmat.getEntry(knew, j);
|
||||||
if (Math.abs(d__1) > ztest) {
|
if (Math.abs(d1) > ztest) {
|
||||||
// Computing 2nd power
|
// Computing 2nd power
|
||||||
d__1 = zmat.getEntry(knew, 0);
|
final double d2 = zmat.getEntry(knew, 0);
|
||||||
// Computing 2nd power
|
// Computing 2nd power
|
||||||
d__2 = zmat.getEntry(knew, j);
|
final double d3 = zmat.getEntry(knew, j);
|
||||||
temp = Math.sqrt(d__1 * d__1 + d__2 * d__2);
|
final double d4 = Math.sqrt(d2 * d2 + d3 * d3);
|
||||||
tempa = zmat.getEntry(knew, 0) / temp;
|
final double d5 = zmat.getEntry(knew, 0) / d4;
|
||||||
tempb = zmat.getEntry(knew, j) / temp;
|
final double d6 = zmat.getEntry(knew, j) / d4;
|
||||||
for (int i = 0; i < npt; i++) {
|
for (int i = 0; i < npt; i++) {
|
||||||
temp = tempa * zmat.getEntry(i, 0) + tempb * zmat.getEntry(i, j);
|
final double d7 = d5 * zmat.getEntry(i, 0) + d6 * zmat.getEntry(i, j);
|
||||||
zmat.setEntry(i, j, tempa * zmat.getEntry(i, j) -
|
zmat.setEntry(i, j, d5 * zmat.getEntry(i, j) - d6 * zmat.getEntry(i, 0));
|
||||||
tempb * zmat.getEntry(i, 0));
|
zmat.setEntry(i, 0, d7);
|
||||||
zmat.setEntry(i, 0, temp);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
zmat.setEntry(knew, j, ZERO);
|
zmat.setEntry(knew, j, ZERO);
|
||||||
|
@ -2475,30 +2465,30 @@ public class BOBYQAOptimizer
|
||||||
for (int i = 0; i < npt; i++) {
|
for (int i = 0; i < npt; i++) {
|
||||||
work.setEntry(i, zmat.getEntry(knew, 0) * zmat.getEntry(i, 0));
|
work.setEntry(i, zmat.getEntry(knew, 0) * zmat.getEntry(i, 0));
|
||||||
}
|
}
|
||||||
alpha = work.getEntry(knew);
|
final double alpha = work.getEntry(knew);
|
||||||
tau = vlag.getEntry(knew);
|
final double tau = vlag.getEntry(knew);
|
||||||
vlag.setEntry(knew, vlag.getEntry(knew) - ONE);
|
vlag.setEntry(knew, vlag.getEntry(knew) - ONE);
|
||||||
|
|
||||||
// Complete the updating of ZMAT.
|
// Complete the updating of ZMAT.
|
||||||
|
|
||||||
temp = Math.sqrt(denom);
|
final double sqrtDenom = Math.sqrt(denom);
|
||||||
tempb = zmat.getEntry(knew, 0) / temp;
|
final double d1 = tau / sqrtDenom;
|
||||||
tempa = tau / temp;
|
final double d2 = zmat.getEntry(knew, 0) / sqrtDenom;
|
||||||
for (int i = 0; i < npt; i++) {
|
for (int i = 0; i < npt; i++) {
|
||||||
zmat.setEntry(i, 0,
|
zmat.setEntry(i, 0,
|
||||||
tempa * zmat.getEntry(i, 0) - tempb * vlag.getEntry(i));
|
d1 * zmat.getEntry(i, 0) - d2 * vlag.getEntry(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finally, update the matrix BMAT.
|
// Finally, update the matrix BMAT.
|
||||||
|
|
||||||
for (int j = 0; j < n; j++) {
|
for (int j = 0; j < n; j++) {
|
||||||
jp = npt + j;
|
final int jp = npt + j;
|
||||||
work.setEntry(jp, bmat.getEntry(knew, j));
|
work.setEntry(jp, bmat.getEntry(knew, j));
|
||||||
tempa = (alpha * vlag.getEntry(jp) - tau * work.getEntry(jp)) / denom;
|
final double d3 = (alpha * vlag.getEntry(jp) - tau * work.getEntry(jp)) / denom;
|
||||||
tempb = (-beta * work.getEntry(jp) - tau * vlag.getEntry(jp)) / denom;
|
final double d4 = (-beta * work.getEntry(jp) - tau * vlag.getEntry(jp)) / denom;
|
||||||
for (int i = 0; i <= jp; i++) {
|
for (int i = 0; i <= jp; i++) {
|
||||||
bmat.setEntry(i, j, bmat.getEntry(i, j) + tempa *
|
bmat.setEntry(i, j,
|
||||||
vlag.getEntry(i) + tempb * work.getEntry(i));
|
bmat.getEntry(i, j) + d3 * vlag.getEntry(i) + d4 * work.getEntry(i));
|
||||||
if (i >= npt) {
|
if (i >= npt) {
|
||||||
bmat.setEntry(jp, (i - npt), bmat.getEntry(i, j));
|
bmat.setEntry(jp, (i - npt), bmat.getEntry(i, j));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue