Home | History | Annotate | Download | only in test
      1 // This file is part of Eigen, a lightweight C++ template library
      2 // for linear algebra.
      3 //
      4 // Copyright (C) 2011 Jitse Niesen <jitse (at) maths.leeds.ac.uk>
      5 //
      6 // This Source Code Form is subject to the terms of the Mozilla
      7 // Public License v. 2.0. If a copy of the MPL was not distributed
      8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
      9 
     10 #include "matrix_functions.h"
     11 
     12 template<typename MatrixType>
     13 void testMatrixSqrt(const MatrixType& m)
     14 {
     15   MatrixType A;
     16   generateTestMatrix<MatrixType>::run(A, m.rows());
     17   MatrixType sqrtA = A.sqrt();
     18   VERIFY_IS_APPROX(sqrtA * sqrtA, A);
     19 }
     20 
     21 void test_matrix_square_root()
     22 {
     23   for (int i = 0; i < g_repeat; i++) {
     24     CALL_SUBTEST_1(testMatrixSqrt(Matrix3cf()));
     25     CALL_SUBTEST_2(testMatrixSqrt(MatrixXcd(12,12)));
     26     CALL_SUBTEST_3(testMatrixSqrt(Matrix4f()));
     27     CALL_SUBTEST_4(testMatrixSqrt(Matrix<double,Dynamic,Dynamic,RowMajor>(9, 9)));
     28     CALL_SUBTEST_5(testMatrixSqrt(Matrix<float,1,1>()));
     29     CALL_SUBTEST_5(testMatrixSqrt(Matrix<std::complex<float>,1,1>()));
     30   }
     31 }
     32