You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by er...@apache.org on 2020/08/26 23:26:05 UTC
[commons-math] branch master updated: Avoid redundant array
accesses (unit tests).
This is an automated email from the ASF dual-hosted git repository.
erans pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-math.git
The following commit(s) were added to refs/heads/master by this push:
new 450dadf Avoid redundant array accesses (unit tests).
450dadf is described below
commit 450dadfd59a442eed6db0080ff30727836fdf97c
Author: Gilles Sadowski <gi...@gmail.com>
AuthorDate: Mon Aug 10 20:17:06 2020 +0200
Avoid redundant array accesses (unit tests).
---
.../math4/optim/nonlinear/scalar/noderiv/OptimTestUtils.java | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/test/java/org/apache/commons/math4/optim/nonlinear/scalar/noderiv/OptimTestUtils.java b/src/test/java/org/apache/commons/math4/optim/nonlinear/scalar/noderiv/OptimTestUtils.java
index df6cd1f..d759e4b 100644
--- a/src/test/java/org/apache/commons/math4/optim/nonlinear/scalar/noderiv/OptimTestUtils.java
+++ b/src/test/java/org/apache/commons/math4/optim/nonlinear/scalar/noderiv/OptimTestUtils.java
@@ -203,9 +203,10 @@ class OptimTestUtils {
@Override
public double value(double[] x) {
double f = 0;
- for (int i = 0; i < x.length - 1; ++i) {
- f += 1e2 * (x[i] * x[i] - x[i + 1]) * (x[i] * x[i] - x[i + 1])
- + (x[i] - 1.) * (x[i] - 1.);
+ for (int i = 0; i < x.length - 1; i++) {
+ final double a = x[i] * x[i] - x[i + 1];
+ final double b = x[i] - 1;
+ f += 1e2 * a * a + b * b;
}
return f;
}