You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
1.0 KiB

  1. // This file is part of Eigen, a lightweight C++ template library
  2. // for linear algebra.
  3. //
  4. // Copyright (C) 2011 Jitse Niesen <jitse@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. #include "matrix_functions.h"
  10. template<typename MatrixType>
  11. void testMatrixSqrt(const MatrixType& m)
  12. {
  13. MatrixType A;
  14. generateTestMatrix<MatrixType>::run(A, m.rows());
  15. MatrixType sqrtA = A.sqrt();
  16. VERIFY_IS_APPROX(sqrtA * sqrtA, A);
  17. }
  18. void test_matrix_square_root()
  19. {
  20. for (int i = 0; i < g_repeat; i++) {
  21. CALL_SUBTEST_1(testMatrixSqrt(Matrix3cf()));
  22. CALL_SUBTEST_2(testMatrixSqrt(MatrixXcd(12,12)));
  23. CALL_SUBTEST_3(testMatrixSqrt(Matrix4f()));
  24. CALL_SUBTEST_4(testMatrixSqrt(Matrix<double,Dynamic,Dynamic,RowMajor>(9, 9)));
  25. CALL_SUBTEST_5(testMatrixSqrt(Matrix<float,1,1>()));
  26. CALL_SUBTEST_5(testMatrixSqrt(Matrix<std::complex<float>,1,1>()));
  27. }
  28. }