Combined nested if statements.

This commit is contained in:
Luc Maisonobe 2015-11-03 21:43:57 +01:00
parent 1130658baf
commit 63a179da8b
2 changed files with 9 additions and 11 deletions

View File

@ -213,10 +213,10 @@ public class EnumeratedDistribution<T> implements Serializable {
index = -index-1; index = -index-1;
} }
if (index >= 0 && index < probabilities.length) { if (index >= 0 &&
if (randomValue < cumulativeProbabilities[index]) { index < probabilities.length &&
return singletons.get(index); randomValue < cumulativeProbabilities[index]) {
} return singletons.get(index);
} }
/* This should never happen, but it ensures we will return a correct /* This should never happen, but it ensures we will return a correct

View File

@ -234,13 +234,11 @@ public class GaussNewtonOptimizer implements LeastSquaresOptimizer {
currentPoint = current.getPoint(); currentPoint = current.getPoint();
// Check convergence. // Check convergence.
if (previous != null) { if (previous != null &&
if (checker.converged(iterationCounter.getCount(), previous, current)) { checker.converged(iterationCounter.getCount(), previous, current)) {
return new OptimumImpl( return new OptimumImpl(current,
current, evaluationCounter.getCount(),
evaluationCounter.getCount(), iterationCounter.getCount());
iterationCounter.getCount());
}
} }
// solve the linearized least squares problem // solve the linearized least squares problem