sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] 03/03: Remove Formulas.pow3(int), replaced by the more generic MathFunctions.pow(long, int).
Date Tue, 11 Jun 2019 15:13:30 GMT
This is an automated email from the ASF dual-hosted git repository.

desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git

commit e36a238b801b006c6fd9ebb63271b91a8756f2ca
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Tue Jun 11 17:03:44 2019 +0200

    Remove Formulas.pow3(int), replaced by the more generic MathFunctions.pow(long, int).
---
 .../main/java/org/apache/sis/geometry/Envelopes.java |  4 ++--
 .../apache/sis/internal/referencing/Formulas.java    | 20 --------------------
 .../sis/internal/referencing/FormulasTest.java       | 12 ------------
 3 files changed, 2 insertions(+), 34 deletions(-)

diff --git a/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelopes.java b/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelopes.java
index 36177e0..13d5f86 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelopes.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelopes.java
@@ -44,7 +44,6 @@ import org.apache.sis.referencing.operation.transform.AbstractMathTransform;
 import org.apache.sis.internal.metadata.ReferencingServices;
 import org.apache.sis.internal.referencing.CoordinateOperations;
 import org.apache.sis.internal.referencing.DirectPositionView;
-import org.apache.sis.internal.referencing.Formulas;
 import org.apache.sis.internal.system.Loggers;
 import org.apache.sis.util.logging.Logging;
 import org.apache.sis.util.resources.Errors;
@@ -52,6 +51,7 @@ import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.ComparisonMode;
 import org.apache.sis.util.Utilities;
 import org.apache.sis.util.Static;
+import org.apache.sis.math.MathFunctions;
 
 import static org.apache.sis.util.StringBuilders.trimFractionalPart;
 
@@ -422,7 +422,7 @@ public final class Envelopes extends Static {
         int             pointIndex            = 0;
         boolean         isDerivativeSupported = true;
         GeneralEnvelope transformed           = null;
-        final Matrix[]  derivatives           = new Matrix[Formulas.pow3(sourceDim)];
+        final Matrix[]  derivatives           = new Matrix[Math.toIntExact(MathFunctions.pow(3,
sourceDim))];
         final double[]  coordinates           = new double[derivatives.length * targetDim];
         final double[]  sourcePt              = new double[sourceDim];
         for (int i=sourceDim; --i>=0;) {
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Formulas.java
b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Formulas.java
index 9c145a2..fe86928 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Formulas.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Formulas.java
@@ -98,26 +98,6 @@ public final class Formulas extends Static {
     }
 
     /**
-     * Returns 3ⁿ for very small (less than 10) positive values of <var>n</var>.
-     * Note that this method overflow for any value equals or greater than 20.
-     *
-     * @param  n  the exponent.
-     * @return 3ⁿ
-     *
-     * @see org.apache.sis.math.DecimalFunctions#pow10(int)
-     *
-     * @since 0.5
-     */
-    public static int pow3(int n) {
-        assert n >= 0 && n <= 19 : n;
-        int p = 1;
-        while (--n >= 0) {
-            p *= 3;
-        }
-        return p;
-    }
-
-    /**
      * Returns {@code true} if {@code ymin} is the south pole and {@code ymax} is the north
pole.
      *
      * @param  ymin  the minimal latitude to test.
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/FormulasTest.java
b/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/FormulasTest.java
index 9f0302a..46b81ff 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/FormulasTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/FormulasTest.java
@@ -52,18 +52,6 @@ public final strictfp class FormulasTest extends TestCase {
     }
 
     /**
-     * Tests {@link Formulas#pow3(int)}.
-     *
-     * @since 0.5
-     */
-    @Test
-    public void testPow3() {
-        for (int n=0; n<=8; n++) {
-            assertEquals((int) StrictMath.round(StrictMath.pow(3, n)), Formulas.pow3(n));
-        }
-    }
-
-    /**
      * Tests {@link Formulas#isPoleToPole(double, double)}.
      */
     @Test


Mime
View raw message