You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by GitBox <gi...@apache.org> on 2022/10/20 21:09:21 UTC

[GitHub] [commons-math] aherbert commented on a diff in pull request #217: java 8 improvements.

aherbert commented on code in PR #217:
URL: https://github.com/apache/commons-math/pull/217#discussion_r1001111243


##########
commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/ode/nonstiff/AdamsNordsieckFieldTransformer.java:
##########
@@ -170,10 +170,8 @@ private AdamsNordsieckFieldTransformer(final Field<T> field, final int n) {
         // Nordsieck to multistep, then shifting rows to represent step advance
         // then applying inverse transform
         T[][] shiftedP = bigP.getData();
-        for (int i = shiftedP.length - 1; i > 0; --i) {
-            // shift rows
-            shiftedP[i] = shiftedP[i - 1];
-        }
+        // shift rows
+        if (shiftedP.length - 1 >= 0) System.arraycopy(shiftedP, 0, shiftedP, 1, shiftedP.length - 1);

Review Comment:
   Should this be `if (shiftedP.length -1 > 0)` (since we cannot copy length=0).
   
   Please add enclosing braces.



##########
commons-math-transform/src/main/java/org/apache/commons/math4/transform/FastCosineTransform.java:
##########
@@ -181,7 +181,7 @@ private UnaryOperator<double[]> create(final Norm normalization,
         } else {
             return normalization == Norm.ORTHO ?
                 f -> TransformUtils.scaleInPlace(fct(f), Math.sqrt(2d / (f.length - 1))) :
-                f -> fct(f);
+                    this::fct;

Review Comment:
   Whitespace indentation



##########
commons-math-transform/src/main/java/org/apache/commons/math4/transform/FastSineTransform.java:
##########
@@ -188,7 +188,7 @@ private UnaryOperator<double[]> create(final Norm normalization,
         } else {
             return normalization == Norm.ORTHO ?
                 f -> TransformUtils.scaleInPlace(fst(f), Math.sqrt(2d / f.length)) :
-                f -> fst(f);
+                    this::fst;

Review Comment:
   Indentation again



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org