aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorGravatar Jitse Niesen <jitse@maths.leeds.ac.uk>2011-05-09 10:17:41 +0100
committerGravatar Jitse Niesen <jitse@maths.leeds.ac.uk>2011-05-09 10:17:41 +0100
commit837db08cbd41a3975b893fb231c28cdc88d4c606 (patch)
tree730d37e62724c068e5553b2581b424f61f47d649 /test
parent6e1573f66a60511a00f6c7a54cf0918d23007c3e (diff)
Add test for sqrt() on complex Arrays.
From Gael's dashboard output of matrix_square_root test, I suspect the test committed here may fail on old gcc.
Diffstat (limited to 'test')
-rw-r--r--test/array.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/array.cpp b/test/array.cpp
index 6964075ea..fad835cb4 100644
--- a/test/array.cpp
+++ b/test/array.cpp
@@ -208,6 +208,25 @@ template<typename ArrayType> void array_real(const ArrayType& m)
VERIFY_IS_APPROX(std::pow(m3,RealScalar(0.5)), m3.sqrt());
}
+template<typename ArrayType> void array_complex(const ArrayType& m)
+{
+ typedef typename ArrayType::Index Index;
+
+ Index rows = m.rows();
+ Index cols = m.cols();
+
+ ArrayType m1 = ArrayType::Random(rows, cols),
+ m2(rows, cols);
+
+ for (Index i = 0; i < m.rows(); ++i)
+ for (Index j = 0; j < m.cols(); ++j)
+ m2(i,j) = std::sqrt(m1(i,j));
+
+ VERIFY_IS_APPROX(m1.sqrt(), m2);
+ VERIFY_IS_APPROX(m1.sqrt(), std::sqrt(m1));
+ VERIFY_IS_APPROX(m1.sqrt(), internal::sqrt(m1));
+}
+
void test_array()
{
for(int i = 0; i < g_repeat; i++) {
@@ -231,6 +250,9 @@ void test_array()
CALL_SUBTEST_3( array_real(Array44d()) );
CALL_SUBTEST_5( array_real(ArrayXXf(8, 12)) );
}
+ for(int i = 0; i < g_repeat; i++) {
+ CALL_SUBTEST_4( array_complex(ArrayXXcf(3, 3)) );
+ }
VERIFY((internal::is_same< internal::global_math_functions_filtering_base<int>::type, int >::value));
VERIFY((internal::is_same< internal::global_math_functions_filtering_base<float>::type, float >::value));