2011-05-08 05:57:46 +08:00
|
|
|
// This file is part of Eigen, a lightweight C++ template library
|
|
|
|
// for linear algebra.
|
|
|
|
//
|
|
|
|
// Copyright (C) 2011 Jitse Niesen <jitse@maths.leeds.ac.uk>
|
|
|
|
//
|
2012-07-14 02:42:47 +08:00
|
|
|
// This Source Code Form is subject to the terms of the Mozilla
|
|
|
|
// Public License v. 2.0. If a copy of the MPL was not distributed
|
|
|
|
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
2011-05-08 05:57:46 +08:00
|
|
|
|
2012-08-28 05:48:37 +08:00
|
|
|
#include "matrix_functions.h"
|
2011-05-09 05:18:37 +08:00
|
|
|
|
2011-05-08 05:57:46 +08:00
|
|
|
template<typename MatrixType>
|
|
|
|
void testMatrixSqrt(const MatrixType& m)
|
|
|
|
{
|
2011-05-09 05:18:37 +08:00
|
|
|
MatrixType A;
|
|
|
|
generateTestMatrix<MatrixType>::run(A, m.rows());
|
2011-05-10 05:20:20 +08:00
|
|
|
MatrixType sqrtA = A.sqrt();
|
2011-05-09 05:18:37 +08:00
|
|
|
VERIFY_IS_APPROX(sqrtA * sqrtA, A);
|
2011-05-08 05:57:46 +08:00
|
|
|
}
|
|
|
|
|
2018-07-17 20:46:15 +08:00
|
|
|
EIGEN_DECLARE_TEST(matrix_square_root)
|
2011-05-08 05:57:46 +08:00
|
|
|
{
|
|
|
|
for (int i = 0; i < g_repeat; i++) {
|
|
|
|
CALL_SUBTEST_1(testMatrixSqrt(Matrix3cf()));
|
|
|
|
CALL_SUBTEST_2(testMatrixSqrt(MatrixXcd(12,12)));
|
2011-05-09 05:18:37 +08:00
|
|
|
CALL_SUBTEST_3(testMatrixSqrt(Matrix4f()));
|
|
|
|
CALL_SUBTEST_4(testMatrixSqrt(Matrix<double,Dynamic,Dynamic,RowMajor>(9, 9)));
|
2011-06-07 21:32:16 +08:00
|
|
|
CALL_SUBTEST_5(testMatrixSqrt(Matrix<float,1,1>()));
|
|
|
|
CALL_SUBTEST_5(testMatrixSqrt(Matrix<std::complex<float>,1,1>()));
|
2011-05-08 05:57:46 +08:00
|
|
|
}
|
|
|
|
}
|