You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ah...@apache.org on 2019/12/20 17:58:13 UTC
[commons-numbers] 22/30: Added edge case tests for asin.
This is an automated email from the ASF dual-hosted git repository.
aherbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-numbers.git
commit e1ad2a0e9c6f05b38d26d6484c3a3509b6a5935a
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Thu Dec 19 23:09:58 2019 +0000
Added edge case tests for asin.
---
.../numbers/complex/ComplexEdgeCaseTest.java | 40 +++++++++++++++++-----
1 file changed, 31 insertions(+), 9 deletions(-)
diff --git a/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/ComplexEdgeCaseTest.java b/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/ComplexEdgeCaseTest.java
index 42ca2cb..fd163e8 100644
--- a/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/ComplexEdgeCaseTest.java
+++ b/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/ComplexEdgeCaseTest.java
@@ -161,19 +161,41 @@ public class ComplexEdgeCaseTest {
assertComplex(1.00000002785941, 5.72464869028403e-200, name, operation, 2.4252018043912224e-196, -0.00023604834149293664);
}
- @Test
- public void testAcosh() {
- // Defined by acos() so edge cases are the same
- // TODO
- }
+ // acosh is defined by acos so is not tested
@Test
- public void testAsinh() {
- // asinh(z) = ln(z + sqrt(1 + z^2))
- // Odd function: negative real cases defined by positive real cases
- // TODO
+ public void testAsin() {
+ // asin(z) = -i (ln(iz + sqrt(1 - z^2)))
+ final String name = "asin";
+ final UnaryOperator<Complex> operation = Complex::asin;
+
+ // This method is essentially the same as acos and the edge cases are the same.
+ // The results have been generated using g++ -std=c++11 asin.
+ double huge = Math.sqrt(Double.MAX_VALUE) * 2;
+ double big = Math.sqrt(Double.MAX_VALUE) / 8;
+ double medium = 100;
+ double small = Math.sqrt(Double.MIN_NORMAL) * 4;
+ assertComplex(huge, big, name, operation, 1.5083775167989393, 356.27960012801969);
+ assertComplex(huge, medium, name, operation, 1.5707963267948966, 356.27765080781188);
+ assertComplex(huge, small, name, operation, 1.5707963267948966, 356.27765080781188);
+ assertComplex(big, big, name, operation, 0.78539816339744828, 353.85163567585209);
+ assertComplex(big, medium, name, operation, 1.5707963267948966, 353.50506208557209);
+ assertComplex(big, small, name, operation, 1.5707963267948966, 353.50506208557209);
+ assertComplex(medium, big, name, operation, 5.9666725849601662e-152, 353.50506208557209);
+ assertComplex(medium, medium, name, operation, 0.78538566339745486, 5.6448909570623842);
+ assertComplex(medium, small, name, operation, 1.5707963267948966, 5.298292365610485);
+ assertComplex(small, big, name, operation, 3.560118173611523e-307, 353.50506208557209);
+ assertComplex(small, medium, name, operation, 5.9663742737040751e-156, 5.2983423656105888);
+ assertComplex(small, small, name, operation, 5.9666725849601654e-154, 5.9666725849601654e-154);
+ // Additional cases to achieve full coverage
+ // xm1 = 0
+ assertComplex(1, small, name, operation, 1.5707963267948966, 2.4426773395109241e-77);
+ // https://svn.boost.org/trac10/ticket/7290
+ assertComplex(1.00000002785941, 5.72464869028403e-200, name, operation, 1.5707963267948966, 0.00023604834149293664);
}
+ // asinh is defined by asin so is not tested
+
@Test
public void testAtanh() {
// atanh(z) = (1/2) ln((1 + z) / (1 - z))