aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/array_cwise.cpp
diff options
context:
space:
mode:
authorGravatar Srinivas Vasudevan <srvasude@gmail.com>2019-12-12 01:56:54 +0000
committerGravatar Rasmus Munk Larsen <rmlarsen@google.com>2019-12-12 01:56:54 +0000
commit88062b7feddcf3e8354c6857753523c2a80d864f (patch)
tree39a2b3928922d35946a324bd4828040ce6237709 /test/array_cwise.cpp
parent381f8f3139533739c4a428843e2495b442989fcc (diff)
Fix implementation of complex expm1. Add tests that fail with previous implementation, but pass with the current one.
Diffstat (limited to 'test/array_cwise.cpp')
-rw-r--r--test/array_cwise.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/test/array_cwise.cpp b/test/array_cwise.cpp
index ae0f9f97c..48ebcc88b 100644
--- a/test/array_cwise.cpp
+++ b/test/array_cwise.cpp
@@ -429,6 +429,11 @@ template<typename ArrayType> void array_complex(const ArrayType& m)
VERIFY_IS_APPROX(m1.exp(), exp(m1));
VERIFY_IS_APPROX(m1.exp() / m2.exp(),(m1-m2).exp());
+ VERIFY_IS_APPROX(m1.expm1(), expm1(m1));
+ VERIFY_IS_APPROX(expm1(m1), exp(m1) - 1.);
+ // Check for larger magnitude complex numbers that expm1 matches exp - 1.
+ VERIFY_IS_APPROX(expm1(10. * m1), exp(10. * m1) - 1.);
+
VERIFY_IS_APPROX(sinh(m1), 0.5*(exp(m1)-exp(-m1)));
VERIFY_IS_APPROX(cosh(m1), 0.5*(exp(m1)+exp(-m1)));
VERIFY_IS_APPROX(tanh(m1), (0.5*(exp(m1)-exp(-m1)))/(0.5*(exp(m1)+exp(-m1))));