aboutsummaryrefslogtreecommitdiffhomepage
path: root/unsupported/test/matrix_power.cpp
diff options
context:
space:
mode:
authorGravatar Chen-Pang He <jdh8@ms63.hinet.net>2013-07-10 02:59:16 +0800
committerGravatar Chen-Pang He <jdh8@ms63.hinet.net>2013-07-10 02:59:16 +0800
commit4466875d544c7a279b84fabb3b67a73da6b15487 (patch)
treefaa9119481b3bcba9b21d20a5dcf267d076405fe /unsupported/test/matrix_power.cpp
parent5c95892b83f9c1b2fb7f5a236cfb965bf8e55c3f (diff)
The only(?) way to test complex matrix power.
Diffstat (limited to 'unsupported/test/matrix_power.cpp')
-rw-r--r--unsupported/test/matrix_power.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/unsupported/test/matrix_power.cpp b/unsupported/test/matrix_power.cpp
index a3055c81e..b9b72b528 100644
--- a/unsupported/test/matrix_power.cpp
+++ b/unsupported/test/matrix_power.cpp
@@ -142,6 +142,19 @@ void testSingular(MatrixType m, double tol)
}
}
+template<typename MatrixType>
+void testLogThenExp(MatrixType m, double tol)
+{
+ typedef typename MatrixType::Scalar Scalar;
+ Scalar x;
+
+ for (int i=0; i < g_repeat; ++i) {
+ generateTestMatrix<MatrixType>::run(m, m.rows());
+ x = internal::random<Scalar>();
+ VERIFY(m.pow(x).isApprox((x * m.log()).exp(), tol));
+ }
+}
+
typedef Matrix<double,3,3,RowMajor> Matrix3dRowMajor;
typedef Matrix<long double,Dynamic,Dynamic> MatrixXe;
@@ -173,4 +186,14 @@ void test_matrix_power()
CALL_SUBTEST_8(testSingular(Matrix4f(), 1e-4));
CALL_SUBTEST_6(testSingular(MatrixXf(2,2), 1e-3));
CALL_SUBTEST_9(testSingular(MatrixXe(7,7), 1e-13));
+
+ CALL_SUBTEST_2(testLogThenExp(Matrix2d(), 1e-13));
+ CALL_SUBTEST_7(testLogThenExp(Matrix3dRowMajor(), 1e-13));
+ CALL_SUBTEST_3(testLogThenExp(Matrix4cd(), 1e-13));
+ CALL_SUBTEST_4(testLogThenExp(MatrixXd(8,8), 2e-12));
+ CALL_SUBTEST_1(testLogThenExp(Matrix2f(), 1e-4));
+ CALL_SUBTEST_5(testLogThenExp(Matrix3cf(), 1e-4));
+ CALL_SUBTEST_8(testLogThenExp(Matrix4f(), 1e-4));
+ CALL_SUBTEST_6(testLogThenExp(MatrixXf(2,2), 1e-3));
+ CALL_SUBTEST_9(testLogThenExp(MatrixXe(7,7), 1e-13));
}