mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Clang-format tests, examples, libraries, benchmarks, etc.
This commit is contained in:
committed by
Rasmus Munk Larsen
parent
3252ecc7a4
commit
46e9cdb7fe
@@ -11,8 +11,8 @@
|
||||
#include "main.h"
|
||||
#include <Eigen/LU>
|
||||
|
||||
template<typename MatrixType> void determinant(const MatrixType& m)
|
||||
{
|
||||
template <typename MatrixType>
|
||||
void determinant(const MatrixType& m) {
|
||||
/* this test covers the following files:
|
||||
Determinant.h
|
||||
*/
|
||||
@@ -24,13 +24,13 @@ template<typename MatrixType> void determinant(const MatrixType& m)
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
Scalar x = internal::random<Scalar>();
|
||||
VERIFY_IS_APPROX(MatrixType::Identity(size, size).determinant(), Scalar(1));
|
||||
VERIFY_IS_APPROX((m1*m2).eval().determinant(), m1.determinant() * m2.determinant());
|
||||
if(size==1) return;
|
||||
Index i = internal::random<Index>(0, size-1);
|
||||
VERIFY_IS_APPROX((m1 * m2).eval().determinant(), m1.determinant() * m2.determinant());
|
||||
if (size == 1) return;
|
||||
Index i = internal::random<Index>(0, size - 1);
|
||||
Index j;
|
||||
do {
|
||||
j = internal::random<Index>(0, size-1);
|
||||
} while(j==i);
|
||||
j = internal::random<Index>(0, size - 1);
|
||||
} while (j == i);
|
||||
m2 = m1;
|
||||
m2.row(i).swap(m2.row(j));
|
||||
VERIFY_IS_APPROX(m2.determinant(), -m1.determinant());
|
||||
@@ -40,27 +40,26 @@ template<typename MatrixType> void determinant(const MatrixType& m)
|
||||
VERIFY_IS_APPROX(m2.determinant(), m2.transpose().determinant());
|
||||
VERIFY_IS_APPROX(numext::conj(m2.determinant()), m2.adjoint().determinant());
|
||||
m2 = m1;
|
||||
m2.row(i) += x*m2.row(j);
|
||||
m2.row(i) += x * m2.row(j);
|
||||
VERIFY_IS_APPROX(m2.determinant(), m1.determinant());
|
||||
m2 = m1;
|
||||
m2.row(i) *= x;
|
||||
VERIFY_IS_APPROX(m2.determinant(), m1.determinant() * x);
|
||||
|
||||
|
||||
// check empty matrix
|
||||
VERIFY_IS_APPROX(m2.block(0,0,0,0).determinant(), Scalar(1));
|
||||
VERIFY_IS_APPROX(m2.block(0, 0, 0, 0).determinant(), Scalar(1));
|
||||
}
|
||||
|
||||
EIGEN_DECLARE_TEST(determinant)
|
||||
{
|
||||
for(int i = 0; i < g_repeat; i++) {
|
||||
EIGEN_DECLARE_TEST(determinant) {
|
||||
for (int i = 0; i < g_repeat; i++) {
|
||||
int s = 0;
|
||||
CALL_SUBTEST_1( determinant(Matrix<float, 1, 1>()) );
|
||||
CALL_SUBTEST_2( determinant(Matrix<double, 2, 2>()) );
|
||||
CALL_SUBTEST_3( determinant(Matrix<double, 3, 3>()) );
|
||||
CALL_SUBTEST_4( determinant(Matrix<double, 4, 4>()) );
|
||||
CALL_SUBTEST_5( determinant(Matrix<std::complex<double>, 10, 10>()) );
|
||||
s = internal::random<int>(1,EIGEN_TEST_MAX_SIZE/4);
|
||||
CALL_SUBTEST_6( determinant(MatrixXd(s, s)) );
|
||||
CALL_SUBTEST_1(determinant(Matrix<float, 1, 1>()));
|
||||
CALL_SUBTEST_2(determinant(Matrix<double, 2, 2>()));
|
||||
CALL_SUBTEST_3(determinant(Matrix<double, 3, 3>()));
|
||||
CALL_SUBTEST_4(determinant(Matrix<double, 4, 4>()));
|
||||
CALL_SUBTEST_5(determinant(Matrix<std::complex<double>, 10, 10>()));
|
||||
s = internal::random<int>(1, EIGEN_TEST_MAX_SIZE / 4);
|
||||
CALL_SUBTEST_6(determinant(MatrixXd(s, s)));
|
||||
TEST_SET_BUT_UNUSED_VARIABLE(s)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user