commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject svn commit: r1540155 - in /commons/proper/math/trunk/src: main/java/org/apache/commons/math3/complex/Complex.java test/java/org/apache/commons/math3/analysis/FunctionUtilsTest.java
Date Fri, 08 Nov 2013 19:08:22 GMT
Author: tn
Date: Fri Nov  8 19:08:22 2013
New Revision: 1540155

URL: http://svn.apache.org/r1540155
Log:
[MATH-1059] Replace Math with FastMath.

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/complex/Complex.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/FunctionUtilsTest.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/complex/Complex.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/complex/Complex.java?rev=1540155&r1=1540154&r2=1540155&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/complex/Complex.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/complex/Complex.java
Fri Nov  8 19:08:22 2013
@@ -634,7 +634,7 @@ public class Complex implements FieldEle
      *  </code>
      * </pre>
      * where the (real) functions on the right-hand side are
-     * {@link java.lang.Math#sin}, {@link java.lang.Math#cos},
+     * {@link FastMath#sin}, {@link FastMath#cos},
      * {@link FastMath#cosh} and {@link FastMath#sinh}.
      * <br/>
      * Returns {@link Complex#NaN} if either real or imaginary part of the
@@ -674,7 +674,7 @@ public class Complex implements FieldEle
      *  </code>
      * </pre>
      * where the (real) functions on the right-hand side are
-     * {@link java.lang.Math#sin}, {@link java.lang.Math#cos},
+     * {@link FastMath#sin}, {@link FastMath#cos},
      * {@link FastMath#cosh} and {@link FastMath#sinh}.
      * <br/>
      * Returns {@link Complex#NaN} if either real or imaginary part of the
@@ -714,8 +714,8 @@ public class Complex implements FieldEle
      *  </code>
      * </pre>
      * where the (real) functions on the right-hand side are
-     * {@link java.lang.Math#exp}, {@link java.lang.Math#cos}, and
-     * {@link java.lang.Math#sin}.
+     * {@link FastMath#exp}, {@link FastMath#cos}, and
+     * {@link FastMath#sin}.
      * <br/>
      * Returns {@link Complex#NaN} if either real or imaginary part of the
      * input argument is {@code NaN}.
@@ -755,9 +755,9 @@ public class Complex implements FieldEle
      *   log(a + bi) = ln(|a + bi|) + arg(a + bi)i
      *  </code>
      * </pre>
-     * where ln on the right hand side is {@link java.lang.Math#log},
+     * where ln on the right hand side is {@link FastMath#log},
      * {@code |a + bi|} is the modulus, {@link Complex#abs},  and
-     * {@code arg(a + bi) = }{@link java.lang.Math#atan2}(b, a).
+     * {@code arg(a + bi) = }{@link FastMath#atan2}(b, a).
      * <br/>
      * Returns {@link Complex#NaN} if either real or imaginary part of the
      * input argument is {@code NaN}.
@@ -838,7 +838,7 @@ public class Complex implements FieldEle
      *  </code>
      * </pre>
      * where the (real) functions on the right-hand side are
-     * {@link java.lang.Math#sin}, {@link java.lang.Math#cos},
+     * {@link FastMath#sin}, {@link FastMath#cos},
      * {@link FastMath#cosh} and {@link FastMath#sinh}.
      * <br/>
      * Returns {@link Complex#NaN} if either real or imaginary part of the
@@ -878,7 +878,7 @@ public class Complex implements FieldEle
      *  </code>
      * </pre>
      * where the (real) functions on the right-hand side are
-     * {@link java.lang.Math#sin}, {@link java.lang.Math#cos},
+     * {@link FastMath#sin}, {@link FastMath#cos},
      * {@link FastMath#cosh} and {@link FastMath#sinh}.
      * <br/>
      * Returns {@link Complex#NaN} if either real or imaginary part of the
@@ -917,7 +917,7 @@ public class Complex implements FieldEle
      *  else return {@code |b|/2t + sign(b)t i }</pre></li>
      * </ol>
      * where <ul>
-     * <li>{@code |a| = }{@link Math#abs}(a)</li>
+     * <li>{@code |a| = }{@link FastMath#abs}(a)</li>
      * <li>{@code |a + bi| = }{@link Complex#abs}(a + bi)</li>
      * <li>{@code sign(b) =  }{@link FastMath#copySign(double,double) copySign(1d,
b)}
      * </ul>

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/FunctionUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/FunctionUtilsTest.java?rev=1540155&r1=1540154&r2=1540155&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/FunctionUtilsTest.java
(original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/FunctionUtilsTest.java
Fri Nov  8 19:08:22 2013
@@ -46,7 +46,7 @@ import org.junit.Test;
  * Test for {@link FunctionUtils}.
  */
 public class FunctionUtilsTest {
-    private final double EPS = Math.ulp(1d);
+    private final double EPS = FastMath.ulp(1d);
 
     @Test
     public void testCompose() {
@@ -113,7 +113,7 @@ public class FunctionUtilsTest {
         UnivariateDifferentiableFunction inv = new Inverse();
 
         final double a = 123.456;
-        Assert.assertEquals(- 1 / (a * a) -1 + Math.cos(a),
+        Assert.assertEquals(- 1 / (a * a) -1 + FastMath.cos(a),
                             FunctionUtils.add(inv, m, c, sin).value(new DerivativeStructure(1,
1, 0, a)).getPartialDerivative(1),
                             EPS);
     }
@@ -138,11 +138,11 @@ public class FunctionUtilsTest {
         UnivariateDifferentiableFunction inv = new Inverse();
         UnivariateDifferentiableFunction pow = new Power(2.5);
         UnivariateDifferentiableFunction cos = new Cos();
-        Assert.assertEquals(1.5 * Math.sqrt(a) * Math.cos(a) - Math.pow(a, 1.5) * Math.sin(a),
+        Assert.assertEquals(1.5 * FastMath.sqrt(a) * FastMath.cos(a) - FastMath.pow(a, 1.5)
* FastMath.sin(a),
                             FunctionUtils.multiply(inv, pow, cos).value(new DerivativeStructure(1,
1, 0, a)).getPartialDerivative(1), EPS);
 
         UnivariateDifferentiableFunction cosh = new Cosh();
-        Assert.assertEquals(1.5 * Math.sqrt(a) * Math.cosh(a) + Math.pow(a, 1.5) * Math.sinh(a),
+        Assert.assertEquals(1.5 * FastMath.sqrt(a) * FastMath.cosh(a) + FastMath.pow(a, 1.5)
* FastMath.sinh(a),
                             FunctionUtils.multiply(inv, pow, cosh).value(new DerivativeStructure(1,
1, 0, a)).getPartialDerivative(1), 8 * EPS);
     }
 
@@ -188,7 +188,7 @@ public class FunctionUtilsTest {
         UnivariateFunction sinc2 = new Sinc();
 
         for (int i = 0; i < 10; i++) {
-            double x = Math.random();
+            double x = FastMath.random();
             Assert.assertEquals(sinc1.value(x), sinc2.value(x), EPS);
         }
     }
@@ -202,31 +202,31 @@ public class FunctionUtilsTest {
         UnivariateFunction pow2 = FunctionUtils.fix2ndArgument(new Pow(), 2);
 
         for (int i = 0; i < 10; i++) {
-            double x = Math.random() * 10;
+            double x = FastMath.random() * 10;
             Assert.assertEquals(pow1.value(x), pow2.value(x), 0);
         }
     }
 
     @Test(expected = NumberIsTooLargeException.class)
     public void testSampleWrongBounds(){
-        FunctionUtils.sample(new Sin(), Math.PI, 0.0, 10);
+        FunctionUtils.sample(new Sin(), FastMath.PI, 0.0, 10);
     }
 
     @Test(expected = NotStrictlyPositiveException.class)
     public void testSampleNegativeNumberOfPoints(){
-        FunctionUtils.sample(new Sin(), 0.0, Math.PI, -1);
+        FunctionUtils.sample(new Sin(), 0.0, FastMath.PI, -1);
     }
 
     @Test(expected = NotStrictlyPositiveException.class)
     public void testSampleNullNumberOfPoints(){
-        FunctionUtils.sample(new Sin(), 0.0, Math.PI, 0);
+        FunctionUtils.sample(new Sin(), 0.0, FastMath.PI, 0);
     }
 
     @Test
     public void testSample() {
         final int n = 11;
         final double min = 0.0;
-        final double max = Math.PI;
+        final double max = FastMath.PI;
         final double[] actual = FunctionUtils.sample(new Sin(), min, max, n);
         for (int i = 0; i < n; i++) {
             final double x = min + (max - min) / n * i;



Mime
View raw message