Removed "sinh" and "cosh" from "MathUtils"; replaced uses with calls to
equivalent in "FastMath".


git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1183128 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gilles Sadowski 2011-10-13 21:58:30 +00:00
parent 54364e6b57
commit 41c29f826d
3 changed files with 12 additions and 58 deletions

View File

@ -661,8 +661,8 @@ public class Complex implements FieldElement<Complex>, Serializable {
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 FieldElement<Complex>, Serializable {
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 FieldElement<Complex>, Serializable {
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 FieldElement<Complex>, Serializable {
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 FieldElement<Complex>, Serializable {
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 FieldElement<Complex>, Serializable {
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);
}

View File

@ -75,17 +75,6 @@ public final class MathUtils {
super();
}
/**
* 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.
*
@ -505,17 +494,6 @@ public final class MathUtils {
return (x == ZS) ? ZS : (x > ZS) ? PS : NS;
}
/**
* 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.
*

View File

@ -33,18 +33,6 @@ import org.junit.Test;
* 2007) $
*/
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 = {
@ -505,18 +493,6 @@ public final class MathUtilsTest {
Assert.assertEquals((short) (-1), MathUtils.sign((short) (-2)));
}
@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() {