From 1e9664b14737d016fabbdb72327aeda6a06bf623 Mon Sep 17 00:00:00 2001 From: Christoph Hertzberg Date: Fri, 20 Dec 2019 18:10:22 +0100 Subject: Bug #1796: Make matrix squareroot usable for Map and Ref types --- unsupported/test/matrix_function.cpp | 38 ++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'unsupported/test') diff --git a/unsupported/test/matrix_function.cpp b/unsupported/test/matrix_function.cpp index 2049b8ba0..6d753737d 100644 --- a/unsupported/test/matrix_function.cpp +++ b/unsupported/test/matrix_function.cpp @@ -177,6 +177,39 @@ void testMatrixType(const MatrixType& m) } } +template +void testMapRef(const MatrixType& A) +{ + // Test if passing Ref and Map objects is possible + // (Regression test for Bug #1796) + Index size = A.rows(); + MatrixType X; X.setRandom(size, size); + MatrixType Y(size,size); + Ref< MatrixType> R(Y); + Ref Rc(X); + Map< MatrixType> M(Y.data(), size, size); + Map Mc(X.data(), size, size); + + X = X*X; // make sure sqrt is possible + Y = X.sqrt(); + R = Rc.sqrt(); + M = Mc.sqrt(); + Y = X.exp(); + R = Rc.exp(); + M = Mc.exp(); + X = Y; // make sure log is possible + Y = X.log(); + R = Rc.log(); + M = Mc.log(); + + Y = X.cos() + Rc.cos() + Mc.cos(); + Y = X.sin() + Rc.sin() + Mc.sin(); + + Y = X.cosh() + Rc.cosh() + Mc.cosh(); + Y = X.sinh() + Rc.sinh() + Mc.sinh(); +} + + EIGEN_DECLARE_TEST(matrix_function) { CALL_SUBTEST_1(testMatrixType(Matrix())); @@ -186,4 +219,9 @@ EIGEN_DECLARE_TEST(matrix_function) CALL_SUBTEST_5(testMatrixType(Matrix())); CALL_SUBTEST_6(testMatrixType(Matrix4cd())); CALL_SUBTEST_7(testMatrixType(MatrixXd(13,13))); + + CALL_SUBTEST_1(testMapRef(Matrix())); + CALL_SUBTEST_2(testMapRef(Matrix3cf())); + CALL_SUBTEST_3(testMapRef(MatrixXf(8,8))); + CALL_SUBTEST_7(testMapRef(MatrixXd(13,13))); } -- cgit v1.2.3