Author: erans Date: Thu Oct 13 21:58:30 2011 New Revision: 1183128 URL: http://svn.apache.org/viewvc?rev=1183128&view=rev Log: MATH-690 Removed "sinh" and "cosh" from "MathUtils"; replaced uses with calls to equivalent in "FastMath".
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/complex/Complex.java commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MathUtils.java commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/MathUtilsTest.java Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/complex/Complex.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/complex/Complex.java?rev=1183128&r1=1183127&r2=1183128&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/complex/Complex.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/complex/Complex.java Thu Oct 13 21:58:30 2011 @@ -661,8 +661,8 @@ public class Complex implements FieldEle return NaN; } - return createComplex(FastMath.cos(real) * MathUtils.cosh(imaginary), - -FastMath.sin(real) * MathUtils.sinh(imaginary)); + return createComplex(FastMath.cos(real) * FastMath.cosh(imaginary), + -FastMath.sin(real) * FastMath.sinh(imaginary)); } /** @@ -701,8 +701,8 @@ public class Complex implements FieldEle return NaN; } - return createComplex(MathUtils.cosh(real) * FastMath.cos(imaginary), - MathUtils.sinh(real) * FastMath.sin(imaginary)); + return createComplex(FastMath.cosh(real) * FastMath.cos(imaginary), + FastMath.sinh(real) * FastMath.sin(imaginary)); } /** @@ -865,8 +865,8 @@ public class Complex implements FieldEle return NaN; } - return createComplex(FastMath.sin(real) * MathUtils.cosh(imaginary), - FastMath.cos(real) * MathUtils.sinh(imaginary)); + return createComplex(FastMath.sin(real) * FastMath.cosh(imaginary), + FastMath.cos(real) * FastMath.sinh(imaginary)); } /** @@ -905,8 +905,8 @@ public class Complex implements FieldEle return NaN; } - return createComplex(MathUtils.sinh(real) * FastMath.cos(imaginary), - MathUtils.cosh(real) * FastMath.sin(imaginary)); + return createComplex(FastMath.sinh(real) * FastMath.cos(imaginary), + FastMath.cosh(real) * FastMath.sin(imaginary)); } /** @@ -1021,10 +1021,10 @@ public class Complex implements FieldEle double real2 = 2.0 * real; double imaginary2 = 2.0 * imaginary; - double d = FastMath.cos(real2) + MathUtils.cosh(imaginary2); + double d = FastMath.cos(real2) + FastMath.cosh(imaginary2); return createComplex(FastMath.sin(real2) / d, - MathUtils.sinh(imaginary2) / d); + FastMath.sinh(imaginary2) / d); } /** @@ -1066,9 +1066,9 @@ public class Complex implements FieldEle double real2 = 2.0 * real; double imaginary2 = 2.0 * imaginary; - double d = MathUtils.cosh(real2) + FastMath.cos(imaginary2); + double d = FastMath.cosh(real2) + FastMath.cos(imaginary2); - return createComplex(MathUtils.sinh(real2) / d, + return createComplex(FastMath.sinh(real2) / d, FastMath.sin(imaginary2) / d); } Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MathUtils.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MathUtils.java?rev=1183128&r1=1183127&r2=1183128&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MathUtils.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MathUtils.java Thu Oct 13 21:58:30 2011 @@ -76,17 +76,6 @@ public final class MathUtils { } /** - * Returns the <a href="http://mathworld.wolfram.com/HyperbolicCosine.html"> - * hyperbolic cosine</a> of x. - * - * @param x double value for which to find the hyperbolic cosine - * @return hyperbolic cosine of x - */ - public static double cosh(double x) { - return (FastMath.exp(x) + FastMath.exp(-x)) / 2.0; - } - - /** * Returns an integer hash code representing the given double value. * * @param value the value to be hashed @@ -506,17 +495,6 @@ public final class MathUtils { } /** - * Compute the <a href="http://mathworld.wolfram.com/HyperbolicSine.html"> - * hyperbolic sine</a> of the argument. - * - * @param x Value for which to find the hyperbolic sine. - * @return hyperbolic sine of {@code x}. - */ - public static double sinh(double x) { - return (FastMath.exp(x) - FastMath.exp(-x)) / 2.0; - } - - /** * Raise an int to an int power. * * @param k Number to raise. Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/MathUtilsTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/MathUtilsTest.java?rev=1183128&r1=1183127&r2=1183128&view=diff ============================================================================== --- commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/MathUtilsTest.java (original) +++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/MathUtilsTest.java Thu Oct 13 21:58:30 2011 @@ -34,18 +34,6 @@ import org.junit.Test; */ public final class MathUtilsTest { @Test - public void testCosh() { - double x = 3.0; - double expected = 10.06766; - Assert.assertEquals(expected, MathUtils.cosh(x), 1.0e-5); - } - - @Test - public void testCoshNaN() { - Assert.assertTrue(Double.isNaN(MathUtils.cosh(Double.NaN))); - } - - @Test public void testHash() { double[] testArray = { Double.NaN, @@ -506,18 +494,6 @@ public final class MathUtilsTest { } @Test - public void testSinh() { - double x = 3.0; - double expected = 10.01787; - Assert.assertEquals(expected, MathUtils.sinh(x), 1.0e-5); - } - - @Test - public void testSinhNaN() { - Assert.assertTrue(Double.isNaN(MathUtils.sinh(Double.NaN))); - } - - @Test public void testPow() { Assert.assertEquals(1801088541, MathUtils.pow(21, 7));