diff --git a/include/eigen/test/AnnoyingScalar.h b/include/eigen/test/AnnoyingScalar.h new file mode 100644 index 0000000000000000000000000000000000000000..b621887275df49477656d23da0e31432bf65010f --- /dev/null +++ b/include/eigen/test/AnnoyingScalar.h @@ -0,0 +1,165 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2011-2018 Gael Guennebaud +// +// 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/. + +#ifndef EIGEN_TEST_ANNOYING_SCALAR_H +#define EIGEN_TEST_ANNOYING_SCALAR_H + +#include + +#if EIGEN_COMP_GNUC +#pragma GCC diagnostic ignored "-Wshadow" +#endif + +#ifndef EIGEN_TEST_ANNOYING_SCALAR_DONT_THROW +struct my_exception +{ + my_exception() {} + ~my_exception() {} +}; +#endif + +// An AnnoyingScalar is a pseudo scalar type that: +// - can randomly through an exception in operator + +// - randomly allocate on the heap or initialize a reference to itself making it non trivially copyable, nor movable, nor relocatable. + +class AnnoyingScalar +{ + public: + AnnoyingScalar() { init(); *v = 0; } + AnnoyingScalar(long double _v) { init(); *v = _v; } + AnnoyingScalar(double _v) { init(); *v = _v; } + AnnoyingScalar(float _v) { init(); *v = _v; } + AnnoyingScalar(int _v) { init(); *v = _v; } + AnnoyingScalar(long _v) { init(); *v = _v; } + #if EIGEN_HAS_CXX11 + AnnoyingScalar(long long _v) { init(); *v = _v; } + #endif + AnnoyingScalar(const AnnoyingScalar& other) { init(); *v = *(other.v); } + ~AnnoyingScalar() { + if(v!=&data) + delete v; + instances--; + } + + void init() { + if(internal::random()) + v = new float; + else + v = &data; + instances++; + } + + AnnoyingScalar operator+(const AnnoyingScalar& other) const + { + #ifndef EIGEN_TEST_ANNOYING_SCALAR_DONT_THROW + countdown--; + if(countdown<=0 && !dont_throw) + throw my_exception(); + #endif + return AnnoyingScalar(*v+*other.v); + } + + AnnoyingScalar operator-() const + { return AnnoyingScalar(-*v); } + + AnnoyingScalar operator-(const AnnoyingScalar& other) const + { return AnnoyingScalar(*v-*other.v); } + + AnnoyingScalar operator*(const AnnoyingScalar& other) const + { return AnnoyingScalar((*v)*(*other.v)); } + + AnnoyingScalar operator/(const AnnoyingScalar& other) const + { return AnnoyingScalar((*v)/(*other.v)); } + + AnnoyingScalar& operator+=(const AnnoyingScalar& other) { *v += *other.v; return *this; } + AnnoyingScalar& operator-=(const AnnoyingScalar& other) { *v -= *other.v; return *this; } + AnnoyingScalar& operator*=(const AnnoyingScalar& other) { *v *= *other.v; return *this; } + AnnoyingScalar& operator/=(const AnnoyingScalar& other) { *v /= *other.v; return *this; } + AnnoyingScalar& operator= (const AnnoyingScalar& other) { *v = *other.v; return *this; } + + bool operator==(const AnnoyingScalar& other) const { return *v == *other.v; } + bool operator!=(const AnnoyingScalar& other) const { return *v != *other.v; } + bool operator<=(const AnnoyingScalar& other) const { return *v <= *other.v; } + bool operator< (const AnnoyingScalar& other) const { return *v < *other.v; } + bool operator>=(const AnnoyingScalar& other) const { return *v >= *other.v; } + bool operator> (const AnnoyingScalar& other) const { return *v > *other.v; } + + float* v; + float data; + static int instances; +#ifndef EIGEN_TEST_ANNOYING_SCALAR_DONT_THROW + static int countdown; + static bool dont_throw; +#endif +}; + +AnnoyingScalar real(const AnnoyingScalar &x) { return x; } +AnnoyingScalar imag(const AnnoyingScalar & ) { return 0; } +AnnoyingScalar conj(const AnnoyingScalar &x) { return x; } +AnnoyingScalar sqrt(const AnnoyingScalar &x) { return std::sqrt(*x.v); } +AnnoyingScalar abs (const AnnoyingScalar &x) { return std::abs(*x.v); } +AnnoyingScalar cos (const AnnoyingScalar &x) { return std::cos(*x.v); } +AnnoyingScalar sin (const AnnoyingScalar &x) { return std::sin(*x.v); } +AnnoyingScalar acos(const AnnoyingScalar &x) { return std::acos(*x.v); } +AnnoyingScalar atan2(const AnnoyingScalar &y,const AnnoyingScalar &x) { return std::atan2(*y.v,*x.v); } + +std::ostream& operator<<(std::ostream& stream,const AnnoyingScalar& x) { + stream << (*(x.v)); + return stream; +} + +int AnnoyingScalar::instances = 0; + +#ifndef EIGEN_TEST_ANNOYING_SCALAR_DONT_THROW +int AnnoyingScalar::countdown = 0; +bool AnnoyingScalar::dont_throw = false; +#endif + +namespace Eigen { +template<> +struct NumTraits : NumTraits +{ + enum { + RequireInitialization = 1 + }; + typedef AnnoyingScalar Real; + typedef AnnoyingScalar Nested; + typedef AnnoyingScalar Literal; + typedef AnnoyingScalar NonInteger; +}; + +template<> inline AnnoyingScalar test_precision() { return test_precision(); } + +namespace numext { +template<> +EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE +bool (isfinite)(const AnnoyingScalar& x) { + return (numext::isfinite)(*x.v); +} +} + +namespace internal { + template<> EIGEN_STRONG_INLINE double cast(const AnnoyingScalar& x) { return double(*x.v); } + template<> EIGEN_STRONG_INLINE float cast(const AnnoyingScalar& x) { return *x.v; } +} +} // namespace Eigen + +AnnoyingScalar get_test_precision(const AnnoyingScalar&) +{ return Eigen::test_precision(); } + +AnnoyingScalar test_relative_error(const AnnoyingScalar &a, const AnnoyingScalar &b) +{ return test_relative_error(*a.v, *b.v); } + +inline bool test_isApprox(const AnnoyingScalar &a, const AnnoyingScalar &b) +{ return internal::isApprox(*a.v, *b.v, test_precision()); } + +inline bool test_isMuchSmallerThan(const AnnoyingScalar &a, const AnnoyingScalar &b) +{ return test_isMuchSmallerThan(*a.v, *b.v); } + +#endif // EIGEN_TEST_ANNOYING_SCALAR_H diff --git a/include/eigen/test/SafeScalar.h b/include/eigen/test/SafeScalar.h new file mode 100644 index 0000000000000000000000000000000000000000..c5cb75717c7c0131814ee98ceb840ac83b48dd26 --- /dev/null +++ b/include/eigen/test/SafeScalar.h @@ -0,0 +1,30 @@ + +// A Scalar that asserts for uninitialized access. +template +class SafeScalar { + public: + SafeScalar() : initialized_(false) {} + SafeScalar(const SafeScalar& other) { + *this = other; + } + SafeScalar& operator=(const SafeScalar& other) { + val_ = T(other); + initialized_ = true; + return *this; + } + + SafeScalar(T val) : val_(val), initialized_(true) {} + SafeScalar& operator=(T val) { + val_ = val; + initialized_ = true; + } + + operator T() const { + VERIFY(initialized_ && "Uninitialized access."); + return val_; + } + + private: + T val_; + bool initialized_; +}; diff --git a/include/eigen/test/adjoint.cpp b/include/eigen/test/adjoint.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4c4f98bb978c0277957089217caf9c21f14f4cad --- /dev/null +++ b/include/eigen/test/adjoint.cpp @@ -0,0 +1,219 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2006-2008 Benoit Jacob +// +// 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/. + +#define EIGEN_NO_STATIC_ASSERT + +#include "main.h" + +template struct adjoint_specific; + +template<> struct adjoint_specific { + template + static void run(const Vec& v1, const Vec& v2, Vec& v3, const Mat& square, Scalar s1, Scalar s2) { + VERIFY(test_isApproxWithRef((s1 * v1 + s2 * v2).dot(v3), numext::conj(s1) * v1.dot(v3) + numext::conj(s2) * v2.dot(v3), 0)); + VERIFY(test_isApproxWithRef(v3.dot(s1 * v1 + s2 * v2), s1*v3.dot(v1)+s2*v3.dot(v2), 0)); + + // check compatibility of dot and adjoint + VERIFY(test_isApproxWithRef(v1.dot(square * v2), (square.adjoint() * v1).dot(v2), 0)); + } +}; + +template<> struct adjoint_specific { + template + static void run(const Vec& v1, const Vec& v2, Vec& v3, const Mat& square, Scalar s1, Scalar s2) { + typedef typename NumTraits::Real RealScalar; + using std::abs; + + RealScalar ref = NumTraits::IsInteger ? RealScalar(0) : (std::max)((s1 * v1 + s2 * v2).norm(),v3.norm()); + VERIFY(test_isApproxWithRef((s1 * v1 + s2 * v2).dot(v3), numext::conj(s1) * v1.dot(v3) + numext::conj(s2) * v2.dot(v3), ref)); + VERIFY(test_isApproxWithRef(v3.dot(s1 * v1 + s2 * v2), s1*v3.dot(v1)+s2*v3.dot(v2), ref)); + + VERIFY_IS_APPROX(v1.squaredNorm(), v1.norm() * v1.norm()); + // check normalized() and normalize() + VERIFY_IS_APPROX(v1, v1.norm() * v1.normalized()); + v3 = v1; + v3.normalize(); + VERIFY_IS_APPROX(v1, v1.norm() * v3); + VERIFY_IS_APPROX(v3, v1.normalized()); + VERIFY_IS_APPROX(v3.norm(), RealScalar(1)); + + // check null inputs + VERIFY_IS_APPROX((v1*0).normalized(), (v1*0)); +#if (!EIGEN_ARCH_i386) || defined(EIGEN_VECTORIZE) + RealScalar very_small = (std::numeric_limits::min)(); + VERIFY( (v1*very_small).norm() == 0 ); + VERIFY_IS_APPROX((v1*very_small).normalized(), (v1*very_small)); + v3 = v1*very_small; + v3.normalize(); + VERIFY_IS_APPROX(v3, (v1*very_small)); +#endif + + // check compatibility of dot and adjoint + ref = NumTraits::IsInteger ? 0 : (std::max)((std::max)(v1.norm(),v2.norm()),(std::max)((square * v2).norm(),(square.adjoint() * v1).norm())); + VERIFY(internal::isMuchSmallerThan(abs(v1.dot(square * v2) - (square.adjoint() * v1).dot(v2)), ref, test_precision())); + + // check that Random().normalized() works: tricky as the random xpr must be evaluated by + // normalized() in order to produce a consistent result. + VERIFY_IS_APPROX(Vec::Random(v1.size()).normalized().norm(), RealScalar(1)); + } +}; + +template void adjoint(const MatrixType& m) +{ + /* this test covers the following files: + Transpose.h Conjugate.h Dot.h + */ + using std::abs; + typedef typename MatrixType::Scalar Scalar; + typedef typename NumTraits::Real RealScalar; + typedef Matrix VectorType; + typedef Matrix SquareMatrixType; + const Index PacketSize = internal::packet_traits::size; + + Index rows = m.rows(); + Index cols = m.cols(); + + MatrixType m1 = MatrixType::Random(rows, cols), + m2 = MatrixType::Random(rows, cols), + m3(rows, cols), + square = SquareMatrixType::Random(rows, rows); + VectorType v1 = VectorType::Random(rows), + v2 = VectorType::Random(rows), + v3 = VectorType::Random(rows), + vzero = VectorType::Zero(rows); + + Scalar s1 = internal::random(), + s2 = internal::random(); + + // check basic compatibility of adjoint, transpose, conjugate + VERIFY_IS_APPROX(m1.transpose().conjugate().adjoint(), m1); + VERIFY_IS_APPROX(m1.adjoint().conjugate().transpose(), m1); + + // check multiplicative behavior + VERIFY_IS_APPROX((m1.adjoint() * m2).adjoint(), m2.adjoint() * m1); + VERIFY_IS_APPROX((s1 * m1).adjoint(), numext::conj(s1) * m1.adjoint()); + + // check basic properties of dot, squaredNorm + VERIFY_IS_APPROX(numext::conj(v1.dot(v2)), v2.dot(v1)); + VERIFY_IS_APPROX(numext::real(v1.dot(v1)), v1.squaredNorm()); + + adjoint_specific::IsInteger>::run(v1, v2, v3, square, s1, s2); + + VERIFY_IS_MUCH_SMALLER_THAN(abs(vzero.dot(v1)), static_cast(1)); + + // like in testBasicStuff, test operator() to check const-qualification + Index r = internal::random(0, rows-1), + c = internal::random(0, cols-1); + VERIFY_IS_APPROX(m1.conjugate()(r,c), numext::conj(m1(r,c))); + VERIFY_IS_APPROX(m1.adjoint()(c,r), numext::conj(m1(r,c))); + + // check inplace transpose + m3 = m1; + m3.transposeInPlace(); + VERIFY_IS_APPROX(m3,m1.transpose()); + m3.transposeInPlace(); + VERIFY_IS_APPROX(m3,m1); + + if(PacketSize(0,m3.rows()-PacketSize); + Index j = internal::random(0,m3.cols()-PacketSize); + m3.template block(i,j).transposeInPlace(); + VERIFY_IS_APPROX( (m3.template block(i,j)), (m1.template block(i,j).transpose()) ); + m3.template block(i,j).transposeInPlace(); + VERIFY_IS_APPROX(m3,m1); + } + + // check inplace adjoint + m3 = m1; + m3.adjointInPlace(); + VERIFY_IS_APPROX(m3,m1.adjoint()); + m3.transposeInPlace(); + VERIFY_IS_APPROX(m3,m1.conjugate()); + + // check mixed dot product + typedef Matrix RealVectorType; + RealVectorType rv1 = RealVectorType::Random(rows); + VERIFY_IS_APPROX(v1.dot(rv1.template cast()), v1.dot(rv1)); + VERIFY_IS_APPROX(rv1.template cast().dot(v1), rv1.dot(v1)); + + VERIFY( is_same_type(m1,m1.template conjugateIf()) ); + VERIFY( is_same_type(m1.conjugate(),m1.template conjugateIf()) ); +} + +template +void adjoint_extra() +{ + MatrixXcf a(10,10), b(10,10); + VERIFY_RAISES_ASSERT(a = a.transpose()); + VERIFY_RAISES_ASSERT(a = a.transpose() + b); + VERIFY_RAISES_ASSERT(a = b + a.transpose()); + VERIFY_RAISES_ASSERT(a = a.conjugate().transpose()); + VERIFY_RAISES_ASSERT(a = a.adjoint()); + VERIFY_RAISES_ASSERT(a = a.adjoint() + b); + VERIFY_RAISES_ASSERT(a = b + a.adjoint()); + + // no assertion should be triggered for these cases: + a.transpose() = a.transpose(); + a.transpose() += a.transpose(); + a.transpose() += a.transpose() + b; + a.transpose() = a.adjoint(); + a.transpose() += a.adjoint(); + a.transpose() += a.adjoint() + b; + + // regression tests for check_for_aliasing + MatrixXd c(10,10); + c = 1.0 * MatrixXd::Ones(10,10) + c; + c = MatrixXd::Ones(10,10) * 1.0 + c; + c = c + MatrixXd::Ones(10,10) .cwiseProduct( MatrixXd::Zero(10,10) ); + c = MatrixXd::Ones(10,10) * MatrixXd::Zero(10,10); + + // regression for bug 1646 + for (int j = 0; j < 10; ++j) { + c.col(j).head(j) = c.row(j).head(j); + } + + for (int j = 0; j < 10; ++j) { + c.col(j) = c.row(j); + } + + a.conservativeResize(1,1); + a = a.transpose(); + + a.conservativeResize(0,0); + a = a.transpose(); +} + +EIGEN_DECLARE_TEST(adjoint) +{ + for(int i = 0; i < g_repeat; i++) { + CALL_SUBTEST_1( adjoint(Matrix()) ); + CALL_SUBTEST_2( adjoint(Matrix3d()) ); + CALL_SUBTEST_3( adjoint(Matrix4f()) ); + + CALL_SUBTEST_4( adjoint(MatrixXcf(internal::random(1,EIGEN_TEST_MAX_SIZE/2), internal::random(1,EIGEN_TEST_MAX_SIZE/2))) ); + CALL_SUBTEST_5( adjoint(MatrixXi(internal::random(1,EIGEN_TEST_MAX_SIZE), internal::random(1,EIGEN_TEST_MAX_SIZE))) ); + CALL_SUBTEST_6( adjoint(MatrixXf(internal::random(1,EIGEN_TEST_MAX_SIZE), internal::random(1,EIGEN_TEST_MAX_SIZE))) ); + + // Complement for 128 bits vectorization: + CALL_SUBTEST_8( adjoint(Matrix2d()) ); + CALL_SUBTEST_9( adjoint(Matrix()) ); + + // 256 bits vectorization: + CALL_SUBTEST_10( adjoint(Matrix()) ); + CALL_SUBTEST_11( adjoint(Matrix()) ); + CALL_SUBTEST_12( adjoint(Matrix()) ); + } + // test a large static matrix only once + CALL_SUBTEST_7( adjoint(Matrix()) ); + + CALL_SUBTEST_13( adjoint_extra<0>() ); +} + diff --git a/include/eigen/test/array_for_matrix.cpp b/include/eigen/test/array_for_matrix.cpp new file mode 100644 index 0000000000000000000000000000000000000000..06e04a2fa04fbd8d94c3427d04f770438538ca55 --- /dev/null +++ b/include/eigen/test/array_for_matrix.cpp @@ -0,0 +1,341 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2008-2009 Gael Guennebaud +// +// 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/. + +#include "main.h" + +template void array_for_matrix(const MatrixType& m) +{ + typedef typename MatrixType::Scalar Scalar; + typedef Matrix ColVectorType; + typedef Matrix RowVectorType; + + Index rows = m.rows(); + Index cols = m.cols(); + + MatrixType m1 = MatrixType::Random(rows, cols), + m2 = MatrixType::Random(rows, cols), + m3(rows, cols); + + ColVectorType cv1 = ColVectorType::Random(rows); + RowVectorType rv1 = RowVectorType::Random(cols); + + Scalar s1 = internal::random(), + s2 = internal::random(); + + // scalar addition + VERIFY_IS_APPROX(m1.array() + s1, s1 + m1.array()); + VERIFY_IS_APPROX((m1.array() + s1).matrix(), MatrixType::Constant(rows,cols,s1) + m1); + VERIFY_IS_APPROX(((m1*Scalar(2)).array() - s2).matrix(), (m1+m1) - MatrixType::Constant(rows,cols,s2) ); + m3 = m1; + m3.array() += s2; + VERIFY_IS_APPROX(m3, (m1.array() + s2).matrix()); + m3 = m1; + m3.array() -= s1; + VERIFY_IS_APPROX(m3, (m1.array() - s1).matrix()); + + // reductions + VERIFY_IS_MUCH_SMALLER_THAN(m1.colwise().sum().sum() - m1.sum(), m1.squaredNorm()); + VERIFY_IS_MUCH_SMALLER_THAN(m1.rowwise().sum().sum() - m1.sum(), m1.squaredNorm()); + VERIFY_IS_MUCH_SMALLER_THAN(m1.colwise().sum() + m2.colwise().sum() - (m1+m2).colwise().sum(), (m1+m2).squaredNorm()); + VERIFY_IS_MUCH_SMALLER_THAN(m1.rowwise().sum() - m2.rowwise().sum() - (m1-m2).rowwise().sum(), (m1-m2).squaredNorm()); + VERIFY_IS_APPROX(m1.colwise().sum(), m1.colwise().redux(internal::scalar_sum_op())); + + // vector-wise ops + m3 = m1; + VERIFY_IS_APPROX(m3.colwise() += cv1, m1.colwise() + cv1); + m3 = m1; + VERIFY_IS_APPROX(m3.colwise() -= cv1, m1.colwise() - cv1); + m3 = m1; + VERIFY_IS_APPROX(m3.rowwise() += rv1, m1.rowwise() + rv1); + m3 = m1; + VERIFY_IS_APPROX(m3.rowwise() -= rv1, m1.rowwise() - rv1); + + // empty objects + VERIFY_IS_APPROX((m1.template block<0,Dynamic>(0,0,0,cols).colwise().sum()), RowVectorType::Zero(cols)); + VERIFY_IS_APPROX((m1.template block(0,0,rows,0).rowwise().sum()), ColVectorType::Zero(rows)); + VERIFY_IS_APPROX((m1.template block<0,Dynamic>(0,0,0,cols).colwise().prod()), RowVectorType::Ones(cols)); + VERIFY_IS_APPROX((m1.template block(0,0,rows,0).rowwise().prod()), ColVectorType::Ones(rows)); + + VERIFY_IS_APPROX(m1.block(0,0,0,cols).colwise().sum(), RowVectorType::Zero(cols)); + VERIFY_IS_APPROX(m1.block(0,0,rows,0).rowwise().sum(), ColVectorType::Zero(rows)); + VERIFY_IS_APPROX(m1.block(0,0,0,cols).colwise().prod(), RowVectorType::Ones(cols)); + VERIFY_IS_APPROX(m1.block(0,0,rows,0).rowwise().prod(), ColVectorType::Ones(rows)); + + // verify the const accessors exist + const Scalar& ref_m1 = m.matrix().array().coeffRef(0); + const Scalar& ref_m2 = m.matrix().array().coeffRef(0,0); + const Scalar& ref_a1 = m.array().matrix().coeffRef(0); + const Scalar& ref_a2 = m.array().matrix().coeffRef(0,0); + VERIFY(&ref_a1 == &ref_m1); + VERIFY(&ref_a2 == &ref_m2); + + // Check write accessors: + m1.array().coeffRef(0,0) = 1; + VERIFY_IS_APPROX(m1(0,0),Scalar(1)); + m1.array()(0,0) = 2; + VERIFY_IS_APPROX(m1(0,0),Scalar(2)); + m1.array().matrix().coeffRef(0,0) = 3; + VERIFY_IS_APPROX(m1(0,0),Scalar(3)); + m1.array().matrix()(0,0) = 4; + VERIFY_IS_APPROX(m1(0,0),Scalar(4)); +} + +template void comparisons(const MatrixType& m) +{ + using std::abs; + typedef typename MatrixType::Scalar Scalar; + typedef typename NumTraits::Real RealScalar; + + Index rows = m.rows(); + Index cols = m.cols(); + + Index r = internal::random(0, rows-1), + c = internal::random(0, cols-1); + + MatrixType m1 = MatrixType::Random(rows, cols), + m2 = MatrixType::Random(rows, cols), + m3(rows, cols); + + VERIFY(((m1.array() + Scalar(1)) > m1.array()).all()); + VERIFY(((m1.array() - Scalar(1)) < m1.array()).all()); + if (rows*cols>1) + { + m3 = m1; + m3(r,c) += 1; + VERIFY(! (m1.array() < m3.array()).all() ); + VERIFY(! (m1.array() > m3.array()).all() ); + } + + // comparisons to scalar + VERIFY( (m1.array() != (m1(r,c)+1) ).any() ); + VERIFY( (m1.array() > (m1(r,c)-1) ).any() ); + VERIFY( (m1.array() < (m1(r,c)+1) ).any() ); + VERIFY( (m1.array() == m1(r,c) ).any() ); + VERIFY( m1.cwiseEqual(m1(r,c)).any() ); + + // test Select + VERIFY_IS_APPROX( (m1.array()m2.array()).select(m1,m2), m1.cwiseMax(m2) ); + Scalar mid = (m1.cwiseAbs().minCoeff() + m1.cwiseAbs().maxCoeff())/Scalar(2); + for (int j=0; j=MatrixType::Constant(rows,cols,mid).array()) + .select(m1,0), m3); + // even shorter version: + VERIFY_IS_APPROX( (m1.array().abs()RealScalar(0.1)).count() == rows*cols); + + // and/or + VERIFY( ((m1.array()RealScalar(0)).matrix()).count() == 0); + VERIFY( ((m1.array()=RealScalar(0)).matrix()).count() == rows*cols); + RealScalar a = m1.cwiseAbs().mean(); + VERIFY( ((m1.array()<-a).matrix() || (m1.array()>a).matrix()).count() == (m1.cwiseAbs().array()>a).count()); + + typedef Matrix VectorOfIndices; + + // TODO allows colwise/rowwise for array + VERIFY_IS_APPROX(((m1.array().abs()+1)>RealScalar(0.1)).matrix().colwise().count(), VectorOfIndices::Constant(cols,rows).transpose()); + VERIFY_IS_APPROX(((m1.array().abs()+1)>RealScalar(0.1)).matrix().rowwise().count(), VectorOfIndices::Constant(rows, cols)); +} + +template void lpNorm(const VectorType& v) +{ + using std::sqrt; + typedef typename VectorType::RealScalar RealScalar; + VectorType u = VectorType::Random(v.size()); + + if(v.size()==0) + { + VERIFY_IS_APPROX(u.template lpNorm(), RealScalar(0)); + VERIFY_IS_APPROX(u.template lpNorm<1>(), RealScalar(0)); + VERIFY_IS_APPROX(u.template lpNorm<2>(), RealScalar(0)); + VERIFY_IS_APPROX(u.template lpNorm<5>(), RealScalar(0)); + } + else + { + VERIFY_IS_APPROX(u.template lpNorm(), u.cwiseAbs().maxCoeff()); + } + + VERIFY_IS_APPROX(u.template lpNorm<1>(), u.cwiseAbs().sum()); + VERIFY_IS_APPROX(u.template lpNorm<2>(), sqrt(u.array().abs().square().sum())); + VERIFY_IS_APPROX(numext::pow(u.template lpNorm<5>(), typename VectorType::RealScalar(5)), u.array().abs().pow(5).sum()); +} + +template void cwise_min_max(const MatrixType& m) +{ + typedef typename MatrixType::Scalar Scalar; + + Index rows = m.rows(); + Index cols = m.cols(); + + MatrixType m1 = MatrixType::Random(rows, cols); + + // min/max with array + Scalar maxM1 = m1.maxCoeff(); + Scalar minM1 = m1.minCoeff(); + + VERIFY_IS_APPROX(MatrixType::Constant(rows,cols, minM1), m1.cwiseMin(MatrixType::Constant(rows,cols, minM1))); + VERIFY_IS_APPROX(m1, m1.cwiseMin(MatrixType::Constant(rows,cols, maxM1))); + + VERIFY_IS_APPROX(MatrixType::Constant(rows,cols, maxM1), m1.cwiseMax(MatrixType::Constant(rows,cols, maxM1))); + VERIFY_IS_APPROX(m1, m1.cwiseMax(MatrixType::Constant(rows,cols, minM1))); + + // min/max with scalar input + VERIFY_IS_APPROX(MatrixType::Constant(rows,cols, minM1), m1.cwiseMin( minM1)); + VERIFY_IS_APPROX(m1, m1.cwiseMin(maxM1)); + VERIFY_IS_APPROX(-m1, (-m1).cwiseMin(-minM1)); + VERIFY_IS_APPROX(-m1.array(), ((-m1).array().min)( -minM1)); + + VERIFY_IS_APPROX(MatrixType::Constant(rows,cols, maxM1), m1.cwiseMax( maxM1)); + VERIFY_IS_APPROX(m1, m1.cwiseMax(minM1)); + VERIFY_IS_APPROX(-m1, (-m1).cwiseMax(-maxM1)); + VERIFY_IS_APPROX(-m1.array(), ((-m1).array().max)(-maxM1)); + + VERIFY_IS_APPROX(MatrixType::Constant(rows,cols, minM1).array(), (m1.array().min)( minM1)); + VERIFY_IS_APPROX(m1.array(), (m1.array().min)( maxM1)); + + VERIFY_IS_APPROX(MatrixType::Constant(rows,cols, maxM1).array(), (m1.array().max)( maxM1)); + VERIFY_IS_APPROX(m1.array(), (m1.array().max)( minM1)); + + // Test NaN propagation for min/max. + if (!NumTraits::IsInteger) { + m1(0,0) = NumTraits::quiet_NaN(); + // Elementwise. + VERIFY((numext::isnan)(m1.template cwiseMax(MatrixType::Constant(rows,cols, Scalar(1)))(0,0))); + VERIFY((numext::isnan)(m1.template cwiseMin(MatrixType::Constant(rows,cols, Scalar(1)))(0,0))); + VERIFY(!(numext::isnan)(m1.template cwiseMax(MatrixType::Constant(rows,cols, Scalar(1)))(0,0))); + VERIFY(!(numext::isnan)(m1.template cwiseMin(MatrixType::Constant(rows,cols, Scalar(1)))(0,0))); + VERIFY((numext::isnan)(m1.template cwiseMax(Scalar(1))(0,0))); + VERIFY((numext::isnan)(m1.template cwiseMin(Scalar(1))(0,0))); + VERIFY(!(numext::isnan)(m1.template cwiseMax(Scalar(1))(0,0))); + VERIFY(!(numext::isnan)(m1.template cwiseMin(Scalar(1))(0,0))); + + + VERIFY((numext::isnan)(m1.array().template max(MatrixType::Constant(rows,cols, Scalar(1)).array())(0,0))); + VERIFY((numext::isnan)(m1.array().template min(MatrixType::Constant(rows,cols, Scalar(1)).array())(0,0))); + VERIFY(!(numext::isnan)(m1.array().template max(MatrixType::Constant(rows,cols, Scalar(1)).array())(0,0))); + VERIFY(!(numext::isnan)(m1.array().template min(MatrixType::Constant(rows,cols, Scalar(1)).array())(0,0))); + VERIFY((numext::isnan)(m1.array().template max(Scalar(1))(0,0))); + VERIFY((numext::isnan)(m1.array().template min(Scalar(1))(0,0))); + VERIFY(!(numext::isnan)(m1.array().template max(Scalar(1))(0,0))); + VERIFY(!(numext::isnan)(m1.array().template min(Scalar(1))(0,0))); + + // Reductions. + VERIFY((numext::isnan)(m1.template maxCoeff())); + VERIFY((numext::isnan)(m1.template minCoeff())); + if (m1.size() > 1) { + VERIFY(!(numext::isnan)(m1.template maxCoeff())); + VERIFY(!(numext::isnan)(m1.template minCoeff())); + } else { + VERIFY((numext::isnan)(m1.template maxCoeff())); + VERIFY((numext::isnan)(m1.template minCoeff())); + } + } +} + +template void resize(const MatrixTraits& t) +{ + typedef typename MatrixTraits::Scalar Scalar; + typedef Matrix MatrixType; + typedef Array Array2DType; + typedef Matrix VectorType; + typedef Array Array1DType; + + Index rows = t.rows(), cols = t.cols(); + + MatrixType m(rows,cols); + VectorType v(rows); + Array2DType a2(rows,cols); + Array1DType a1(rows); + + m.array().resize(rows+1,cols+1); + VERIFY(m.rows()==rows+1 && m.cols()==cols+1); + a2.matrix().resize(rows+1,cols+1); + VERIFY(a2.rows()==rows+1 && a2.cols()==cols+1); + v.array().resize(cols); + VERIFY(v.size()==cols); + a1.matrix().resize(cols); + VERIFY(a1.size()==cols); +} + +template +void regression_bug_654() +{ + ArrayXf a = RowVectorXf(3); + VectorXf v = Array(3); +} + +// Check propagation of LvalueBit through Array/Matrix-Wrapper +template +void regrrssion_bug_1410() +{ + const Matrix4i M; + const Array4i A; + ArrayWrapper MA = M.array(); + MA.row(0); + MatrixWrapper AM = A.matrix(); + AM.row(0); + + VERIFY((internal::traits >::Flags&LvalueBit)==0); + VERIFY((internal::traits >::Flags&LvalueBit)==0); + + VERIFY((internal::traits >::Flags&LvalueBit)==LvalueBit); + VERIFY((internal::traits >::Flags&LvalueBit)==LvalueBit); +} + +EIGEN_DECLARE_TEST(array_for_matrix) +{ + for(int i = 0; i < g_repeat; i++) { + CALL_SUBTEST_1( array_for_matrix(Matrix()) ); + CALL_SUBTEST_2( array_for_matrix(Matrix2f()) ); + CALL_SUBTEST_3( array_for_matrix(Matrix4d()) ); + CALL_SUBTEST_4( array_for_matrix(MatrixXcf(internal::random(1,EIGEN_TEST_MAX_SIZE), internal::random(1,EIGEN_TEST_MAX_SIZE))) ); + CALL_SUBTEST_5( array_for_matrix(MatrixXf(internal::random(1,EIGEN_TEST_MAX_SIZE), internal::random(1,EIGEN_TEST_MAX_SIZE))) ); + CALL_SUBTEST_6( array_for_matrix(MatrixXi(internal::random(1,EIGEN_TEST_MAX_SIZE), internal::random(1,EIGEN_TEST_MAX_SIZE))) ); + } + for(int i = 0; i < g_repeat; i++) { + CALL_SUBTEST_1( comparisons(Matrix()) ); + CALL_SUBTEST_2( comparisons(Matrix2f()) ); + CALL_SUBTEST_3( comparisons(Matrix4d()) ); + CALL_SUBTEST_5( comparisons(MatrixXf(internal::random(1,EIGEN_TEST_MAX_SIZE), internal::random(1,EIGEN_TEST_MAX_SIZE))) ); + CALL_SUBTEST_6( comparisons(MatrixXi(internal::random(1,EIGEN_TEST_MAX_SIZE), internal::random(1,EIGEN_TEST_MAX_SIZE))) ); + } + for(int i = 0; i < g_repeat; i++) { + CALL_SUBTEST_1( cwise_min_max(Matrix()) ); + CALL_SUBTEST_2( cwise_min_max(Matrix2f()) ); + CALL_SUBTEST_3( cwise_min_max(Matrix4d()) ); + CALL_SUBTEST_5( cwise_min_max(MatrixXf(internal::random(1,EIGEN_TEST_MAX_SIZE), internal::random(1,EIGEN_TEST_MAX_SIZE))) ); + CALL_SUBTEST_6( cwise_min_max(MatrixXi(internal::random(1,EIGEN_TEST_MAX_SIZE), internal::random(1,EIGEN_TEST_MAX_SIZE))) ); + } + for(int i = 0; i < g_repeat; i++) { + CALL_SUBTEST_1( lpNorm(Matrix()) ); + CALL_SUBTEST_2( lpNorm(Vector2f()) ); + CALL_SUBTEST_7( lpNorm(Vector3d()) ); + CALL_SUBTEST_8( lpNorm(Vector4f()) ); + CALL_SUBTEST_5( lpNorm(VectorXf(internal::random(1,EIGEN_TEST_MAX_SIZE))) ); + CALL_SUBTEST_4( lpNorm(VectorXcf(internal::random(1,EIGEN_TEST_MAX_SIZE))) ); + } + CALL_SUBTEST_5( lpNorm(VectorXf(0)) ); + CALL_SUBTEST_4( lpNorm(VectorXcf(0)) ); + for(int i = 0; i < g_repeat; i++) { + CALL_SUBTEST_4( resize(MatrixXcf(internal::random(1,EIGEN_TEST_MAX_SIZE), internal::random(1,EIGEN_TEST_MAX_SIZE))) ); + CALL_SUBTEST_5( resize(MatrixXf(internal::random(1,EIGEN_TEST_MAX_SIZE), internal::random(1,EIGEN_TEST_MAX_SIZE))) ); + CALL_SUBTEST_6( resize(MatrixXi(internal::random(1,EIGEN_TEST_MAX_SIZE), internal::random(1,EIGEN_TEST_MAX_SIZE))) ); + } + CALL_SUBTEST_6( regression_bug_654<0>() ); + CALL_SUBTEST_6( regrrssion_bug_1410<0>() ); +} diff --git a/include/eigen/test/array_of_string.cpp b/include/eigen/test/array_of_string.cpp new file mode 100644 index 0000000000000000000000000000000000000000..23e51529b105f2b45b807e8d6bc6fdcf7f2a7058 --- /dev/null +++ b/include/eigen/test/array_of_string.cpp @@ -0,0 +1,32 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2016 Gael Guennebaud +// +// 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/. + +#include "main.h" + +EIGEN_DECLARE_TEST(array_of_string) +{ + typedef Array ArrayXs; + ArrayXs a1(3), a2(3), a3(3), a3ref(3); + a1 << "one", "two", "three"; + a2 << "1", "2", "3"; + a3ref << "one (1)", "two (2)", "three (3)"; + std::stringstream s1; + s1 << a1; + VERIFY_IS_EQUAL(s1.str(), std::string(" one two three")); + a3 = a1 + std::string(" (") + a2 + std::string(")"); + VERIFY((a3==a3ref).all()); + + a3 = a1; + a3 += std::string(" (") + a2 + std::string(")"); + VERIFY((a3==a3ref).all()); + + a1.swap(a3); + VERIFY((a1==a3ref).all()); + VERIFY((a3!=a3ref).all()); +} diff --git a/include/eigen/test/array_replicate.cpp b/include/eigen/test/array_replicate.cpp new file mode 100644 index 0000000000000000000000000000000000000000..057c3c77b4996fbaf92d2b0fa063ac4caa33ef22 --- /dev/null +++ b/include/eigen/test/array_replicate.cpp @@ -0,0 +1,81 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2009 Gael Guennebaud +// +// 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/. + +#include "main.h" + +template void replicate(const MatrixType& m) +{ + /* this test covers the following files: + Replicate.cpp + */ + typedef typename MatrixType::Scalar Scalar; + typedef Matrix VectorType; + typedef Matrix MatrixX; + typedef Matrix VectorX; + + Index rows = m.rows(); + Index cols = m.cols(); + + MatrixType m1 = MatrixType::Random(rows, cols), + m2 = MatrixType::Random(rows, cols); + + VectorType v1 = VectorType::Random(rows); + + MatrixX x1, x2; + VectorX vx1; + + int f1 = internal::random(1,10), + f2 = internal::random(1,10); + + x1.resize(rows*f1,cols*f2); + for(int j=0; j())); + + x2.resize(rows,3*cols); + x2 << m2, m2, m2; + VERIFY_IS_APPROX(x2, (m2.template replicate<1,3>())); + + vx1.resize(3*rows,cols); + vx1 << m2, m2, m2; + VERIFY_IS_APPROX(vx1+vx1, vx1+(m2.template replicate<3,1>())); + + vx1=m2+(m2.colwise().replicate(1)); + + if(m2.cols()==1) + VERIFY_IS_APPROX(m2.coeff(0), (m2.template replicate<3,1>().coeff(m2.rows()))); + + x2.resize(rows,f1); + for (int j=0; j()) ); + CALL_SUBTEST_2( replicate(Vector2f()) ); + CALL_SUBTEST_3( replicate(Vector3d()) ); + CALL_SUBTEST_4( replicate(Vector4f()) ); + CALL_SUBTEST_5( replicate(VectorXf(16)) ); + CALL_SUBTEST_6( replicate(VectorXcd(10)) ); + } +} diff --git a/include/eigen/test/bandmatrix.cpp b/include/eigen/test/bandmatrix.cpp new file mode 100644 index 0000000000000000000000000000000000000000..66a1b0db4734e01baf0e4368a9bc2fb7f56c58f7 --- /dev/null +++ b/include/eigen/test/bandmatrix.cpp @@ -0,0 +1,71 @@ +// This file is triangularView of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2008-2009 Gael Guennebaud +// +// 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/. + +#include "main.h" + +template void bandmatrix(const MatrixType& _m) +{ + typedef typename MatrixType::Scalar Scalar; + typedef typename NumTraits::Real RealScalar; + typedef Matrix DenseMatrixType; + + Index rows = _m.rows(); + Index cols = _m.cols(); + Index supers = _m.supers(); + Index subs = _m.subs(); + + MatrixType m(rows,cols,supers,subs); + + DenseMatrixType dm1(rows,cols); + dm1.setZero(); + + m.diagonal().setConstant(123); + dm1.diagonal().setConstant(123); + for (int i=1; i<=m.supers();++i) + { + m.diagonal(i).setConstant(static_cast(i)); + dm1.diagonal(i).setConstant(static_cast(i)); + } + for (int i=1; i<=m.subs();++i) + { + m.diagonal(-i).setConstant(-static_cast(i)); + dm1.diagonal(-i).setConstant(-static_cast(i)); + } + //std::cerr << m.m_data << "\n\n" << m.toDense() << "\n\n" << dm1 << "\n\n\n\n"; + VERIFY_IS_APPROX(dm1,m.toDenseMatrix()); + + for (int i=0; i(i+1)); + dm1.col(i).setConstant(static_cast(i+1)); + } + Index d = (std::min)(rows,cols); + Index a = std::max(0,cols-d-supers); + Index b = std::max(0,rows-d-subs); + if(a>0) dm1.block(0,d+supers,rows,a).setZero(); + dm1.block(0,supers+1,cols-supers-1-a,cols-supers-1-a).template triangularView().setZero(); + dm1.block(subs+1,0,rows-subs-1-b,rows-subs-1-b).template triangularView().setZero(); + if(b>0) dm1.block(d+subs,0,b,cols).setZero(); + //std::cerr << m.m_data << "\n\n" << m.toDense() << "\n\n" << dm1 << "\n\n"; + VERIFY_IS_APPROX(dm1,m.toDenseMatrix()); + +} + +using Eigen::internal::BandMatrix; + +EIGEN_DECLARE_TEST(bandmatrix) +{ + for(int i = 0; i < 10*g_repeat ; i++) { + Index rows = internal::random(1,10); + Index cols = internal::random(1,10); + Index sups = internal::random(0,cols-1); + Index subs = internal::random(0,rows-1); + CALL_SUBTEST(bandmatrix(BandMatrix(rows,cols,sups,subs)) ); + } +} diff --git a/include/eigen/test/basicstuff.cpp b/include/eigen/test/basicstuff.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4ca607c8248d99a32efbfa53cf779177c70d3360 --- /dev/null +++ b/include/eigen/test/basicstuff.cpp @@ -0,0 +1,356 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2006-2008 Benoit Jacob +// +// 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/. + +#define EIGEN_NO_STATIC_ASSERT + +#include "main.h" +#include "random_without_cast_overflow.h" + +template void basicStuff(const MatrixType& m) +{ + typedef typename MatrixType::Scalar Scalar; + typedef Matrix VectorType; + typedef Matrix SquareMatrixType; + + Index rows = m.rows(); + Index cols = m.cols(); + + // this test relies a lot on Random.h, and there's not much more that we can do + // to test it, hence I consider that we will have tested Random.h + MatrixType m1 = MatrixType::Random(rows, cols), + m2 = MatrixType::Random(rows, cols), + m3(rows, cols), + mzero = MatrixType::Zero(rows, cols), + square = Matrix::Random(rows, rows); + VectorType v1 = VectorType::Random(rows), + vzero = VectorType::Zero(rows); + SquareMatrixType sm1 = SquareMatrixType::Random(rows,rows), sm2(rows,rows); + + Scalar x = 0; + while(x == Scalar(0)) x = internal::random(); + + Index r = internal::random(0, rows-1), + c = internal::random(0, cols-1); + + m1.coeffRef(r,c) = x; + VERIFY_IS_APPROX(x, m1.coeff(r,c)); + m1(r,c) = x; + VERIFY_IS_APPROX(x, m1(r,c)); + v1.coeffRef(r) = x; + VERIFY_IS_APPROX(x, v1.coeff(r)); + v1(r) = x; + VERIFY_IS_APPROX(x, v1(r)); + v1[r] = x; + VERIFY_IS_APPROX(x, v1[r]); + + // test fetching with various index types. + Index r1 = internal::random(0, numext::mini(Index(127),rows-1)); + x = v1(static_cast(r1)); + x = v1(static_cast(r1)); + x = v1(static_cast(r1)); + x = v1(static_cast(r1)); + x = v1(static_cast(r1)); + x = v1(static_cast(r1)); + x = v1(static_cast(r1)); + x = v1(static_cast(r1)); + x = v1(static_cast(r1)); +#if EIGEN_HAS_CXX11 + x = v1(static_cast(r1)); + x = v1(static_cast(r1)); +#endif + + VERIFY_IS_APPROX( v1, v1); + VERIFY_IS_NOT_APPROX( v1, 2*v1); + VERIFY_IS_MUCH_SMALLER_THAN( vzero, v1); + VERIFY_IS_MUCH_SMALLER_THAN( vzero, v1.squaredNorm()); + VERIFY_IS_NOT_MUCH_SMALLER_THAN(v1, v1); + VERIFY_IS_APPROX( vzero, v1-v1); + VERIFY_IS_APPROX( m1, m1); + VERIFY_IS_NOT_APPROX( m1, 2*m1); + VERIFY_IS_MUCH_SMALLER_THAN( mzero, m1); + VERIFY_IS_NOT_MUCH_SMALLER_THAN(m1, m1); + VERIFY_IS_APPROX( mzero, m1-m1); + + // always test operator() on each read-only expression class, + // in order to check const-qualifiers. + // indeed, if an expression class (here Zero) is meant to be read-only, + // hence has no _write() method, the corresponding MatrixBase method (here zero()) + // should return a const-qualified object so that it is the const-qualified + // operator() that gets called, which in turn calls _read(). + VERIFY_IS_MUCH_SMALLER_THAN(MatrixType::Zero(rows,cols)(r,c), static_cast(1)); + + // now test copying a row-vector into a (column-)vector and conversely. + square.col(r) = square.row(r).eval(); + Matrix rv(rows); + Matrix cv(rows); + rv = square.row(r); + cv = square.col(r); + + VERIFY_IS_APPROX(rv, cv.transpose()); + + if(cols!=1 && rows!=1 && MatrixType::SizeAtCompileTime!=Dynamic) + { + VERIFY_RAISES_ASSERT(m1 = (m2.block(0,0, rows-1, cols-1))); + } + + if(cols!=1 && rows!=1) + { + VERIFY_RAISES_ASSERT(m1[0]); + VERIFY_RAISES_ASSERT((m1+m1)[0]); + } + + VERIFY_IS_APPROX(m3 = m1,m1); + MatrixType m4; + VERIFY_IS_APPROX(m4 = m1,m1); + + m3.real() = m1.real(); + VERIFY_IS_APPROX(static_cast(m3).real(), static_cast(m1).real()); + VERIFY_IS_APPROX(static_cast(m3).real(), m1.real()); + + // check == / != operators + VERIFY(m1==m1); + VERIFY(m1!=m2); + VERIFY(!(m1==m2)); + VERIFY(!(m1!=m1)); + m1 = m2; + VERIFY(m1==m2); + VERIFY(!(m1!=m2)); + + // check automatic transposition + sm2.setZero(); + for(Index i=0;i(0,10)>5; + m3 = b ? m1 : m2; + if(b) VERIFY_IS_APPROX(m3,m1); + else VERIFY_IS_APPROX(m3,m2); + m3 = b ? -m1 : m2; + if(b) VERIFY_IS_APPROX(m3,-m1); + else VERIFY_IS_APPROX(m3,m2); + m3 = b ? m1 : -m2; + if(b) VERIFY_IS_APPROX(m3,m1); + else VERIFY_IS_APPROX(m3,-m2); + } +} + +template void basicStuffComplex(const MatrixType& m) +{ + typedef typename MatrixType::Scalar Scalar; + typedef typename NumTraits::Real RealScalar; + typedef Matrix RealMatrixType; + + Index rows = m.rows(); + Index cols = m.cols(); + + Scalar s1 = internal::random(), + s2 = internal::random(); + + VERIFY(numext::real(s1)==numext::real_ref(s1)); + VERIFY(numext::imag(s1)==numext::imag_ref(s1)); + numext::real_ref(s1) = numext::real(s2); + numext::imag_ref(s1) = numext::imag(s2); + VERIFY(internal::isApprox(s1, s2, NumTraits::epsilon())); + // extended precision in Intel FPUs means that s1 == s2 in the line above is not guaranteed. + + RealMatrixType rm1 = RealMatrixType::Random(rows,cols), + rm2 = RealMatrixType::Random(rows,cols); + MatrixType cm(rows,cols); + cm.real() = rm1; + cm.imag() = rm2; + VERIFY_IS_APPROX(static_cast(cm).real(), rm1); + VERIFY_IS_APPROX(static_cast(cm).imag(), rm2); + rm1.setZero(); + rm2.setZero(); + rm1 = cm.real(); + rm2 = cm.imag(); + VERIFY_IS_APPROX(static_cast(cm).real(), rm1); + VERIFY_IS_APPROX(static_cast(cm).imag(), rm2); + cm.real().setZero(); + VERIFY(static_cast(cm).real().isZero()); + VERIFY(!static_cast(cm).imag().isZero()); +} + +template +struct casting_test { + static void run() { + Matrix m; + for (int i=0; i::value(); + } + } + Matrix n = m.template cast(); + for (int i=0; i(m(i, j)))); + } + } + } +}; + +template +struct casting_test_runner { + static void run() { + casting_test::run(); + casting_test::run(); + casting_test::run(); + casting_test::run(); + casting_test::run(); + casting_test::run(); + casting_test::run(); +#if EIGEN_HAS_CXX11 + casting_test::run(); + casting_test::run(); +#endif + casting_test::run(); + casting_test::run(); + casting_test::run(); + casting_test::run(); + casting_test >::run(); + casting_test >::run(); + } +}; + +template +struct casting_test_runner::IsComplex)>::type> +{ + static void run() { + // Only a few casts from std::complex are defined. + casting_test::run(); + casting_test::run(); + casting_test >::run(); + casting_test >::run(); + } +}; + +void casting_all() { + casting_test_runner::run(); + casting_test_runner::run(); + casting_test_runner::run(); + casting_test_runner::run(); + casting_test_runner::run(); + casting_test_runner::run(); + casting_test_runner::run(); +#if EIGEN_HAS_CXX11 + casting_test_runner::run(); + casting_test_runner::run(); +#endif + casting_test_runner::run(); + casting_test_runner::run(); + casting_test_runner::run(); + casting_test_runner::run(); + casting_test_runner >::run(); + casting_test_runner >::run(); +} + +template +void fixedSizeMatrixConstruction() +{ + Scalar raw[4]; + for(int k=0; k<4; ++k) + raw[k] = internal::random(); + + { + Matrix m(raw); + Array a(raw); + for(int k=0; k<4; ++k) VERIFY(m(k) == raw[k]); + for(int k=0; k<4; ++k) VERIFY(a(k) == raw[k]); + VERIFY_IS_EQUAL(m,(Matrix(raw[0],raw[1],raw[2],raw[3]))); + VERIFY((a==(Array(raw[0],raw[1],raw[2],raw[3]))).all()); + } + { + Matrix m(raw); + Array a(raw); + for(int k=0; k<3; ++k) VERIFY(m(k) == raw[k]); + for(int k=0; k<3; ++k) VERIFY(a(k) == raw[k]); + VERIFY_IS_EQUAL(m,(Matrix(raw[0],raw[1],raw[2]))); + VERIFY((a==Array(raw[0],raw[1],raw[2])).all()); + } + { + Matrix m(raw), m2( (DenseIndex(raw[0])), (DenseIndex(raw[1])) ); + Array a(raw), a2( (DenseIndex(raw[0])), (DenseIndex(raw[1])) ); + for(int k=0; k<2; ++k) VERIFY(m(k) == raw[k]); + for(int k=0; k<2; ++k) VERIFY(a(k) == raw[k]); + VERIFY_IS_EQUAL(m,(Matrix(raw[0],raw[1]))); + VERIFY((a==Array(raw[0],raw[1])).all()); + for(int k=0; k<2; ++k) VERIFY(m2(k) == DenseIndex(raw[k])); + for(int k=0; k<2; ++k) VERIFY(a2(k) == DenseIndex(raw[k])); + } + { + Matrix m(raw), + m2( (DenseIndex(raw[0])), (DenseIndex(raw[1])) ), + m3( (int(raw[0])), (int(raw[1])) ), + m4( (float(raw[0])), (float(raw[1])) ); + Array a(raw), a2( (DenseIndex(raw[0])), (DenseIndex(raw[1])) ); + for(int k=0; k<2; ++k) VERIFY(m(k) == raw[k]); + for(int k=0; k<2; ++k) VERIFY(a(k) == raw[k]); + VERIFY_IS_EQUAL(m,(Matrix(raw[0],raw[1]))); + VERIFY((a==Array(raw[0],raw[1])).all()); + for(int k=0; k<2; ++k) VERIFY(m2(k) == DenseIndex(raw[k])); + for(int k=0; k<2; ++k) VERIFY(a2(k) == DenseIndex(raw[k])); + for(int k=0; k<2; ++k) VERIFY(m3(k) == int(raw[k])); + for(int k=0; k<2; ++k) VERIFY((m4(k)) == Scalar(float(raw[k]))); + } + { + Matrix m(raw), m1(raw[0]), m2( (DenseIndex(raw[0])) ), m3( (int(raw[0])) ); + Array a(raw), a1(raw[0]), a2( (DenseIndex(raw[0])) ); + VERIFY(m(0) == raw[0]); + VERIFY(a(0) == raw[0]); + VERIFY(m1(0) == raw[0]); + VERIFY(a1(0) == raw[0]); + VERIFY(m2(0) == DenseIndex(raw[0])); + VERIFY(a2(0) == DenseIndex(raw[0])); + VERIFY(m3(0) == int(raw[0])); + VERIFY_IS_EQUAL(m,(Matrix(raw[0]))); + VERIFY((a==Array(raw[0])).all()); + } +} + +EIGEN_DECLARE_TEST(basicstuff) +{ + for(int i = 0; i < g_repeat; i++) { + CALL_SUBTEST_1( basicStuff(Matrix()) ); + CALL_SUBTEST_2( basicStuff(Matrix4d()) ); + CALL_SUBTEST_3( basicStuff(MatrixXcf(internal::random(1,EIGEN_TEST_MAX_SIZE), internal::random(1,EIGEN_TEST_MAX_SIZE))) ); + CALL_SUBTEST_4( basicStuff(MatrixXi(internal::random(1,EIGEN_TEST_MAX_SIZE), internal::random(1,EIGEN_TEST_MAX_SIZE))) ); + CALL_SUBTEST_5( basicStuff(MatrixXcd(internal::random(1,EIGEN_TEST_MAX_SIZE), internal::random(1,EIGEN_TEST_MAX_SIZE))) ); + CALL_SUBTEST_6( basicStuff(Matrix()) ); + CALL_SUBTEST_7( basicStuff(Matrix(internal::random(1,EIGEN_TEST_MAX_SIZE),internal::random(1,EIGEN_TEST_MAX_SIZE))) ); + CALL_SUBTEST_8( casting_all() ); + + CALL_SUBTEST_3( basicStuffComplex(MatrixXcf(internal::random(1,EIGEN_TEST_MAX_SIZE), internal::random(1,EIGEN_TEST_MAX_SIZE))) ); + CALL_SUBTEST_5( basicStuffComplex(MatrixXcd(internal::random(1,EIGEN_TEST_MAX_SIZE), internal::random(1,EIGEN_TEST_MAX_SIZE))) ); + } + + CALL_SUBTEST_1(fixedSizeMatrixConstruction()); + CALL_SUBTEST_1(fixedSizeMatrixConstruction()); + CALL_SUBTEST_1(fixedSizeMatrixConstruction()); + CALL_SUBTEST_1(fixedSizeMatrixConstruction()); + CALL_SUBTEST_1(fixedSizeMatrixConstruction()); + CALL_SUBTEST_1(fixedSizeMatrixConstruction()); +} diff --git a/include/eigen/test/bicgstab.cpp b/include/eigen/test/bicgstab.cpp new file mode 100644 index 0000000000000000000000000000000000000000..59c4b501c20e6f51ec688c65c38ecfdf70a5a1ec --- /dev/null +++ b/include/eigen/test/bicgstab.cpp @@ -0,0 +1,34 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2011 Gael Guennebaud +// +// 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/. + +#include "sparse_solver.h" +#include + +template void test_bicgstab_T() +{ + BiCGSTAB, DiagonalPreconditioner > bicgstab_colmajor_diag; + BiCGSTAB, IdentityPreconditioner > bicgstab_colmajor_I; + BiCGSTAB, IncompleteLUT > bicgstab_colmajor_ilut; + //BiCGSTAB, SSORPreconditioner > bicgstab_colmajor_ssor; + + bicgstab_colmajor_diag.setTolerance(NumTraits::epsilon()*4); + bicgstab_colmajor_ilut.setTolerance(NumTraits::epsilon()*4); + + CALL_SUBTEST( check_sparse_square_solving(bicgstab_colmajor_diag) ); +// CALL_SUBTEST( check_sparse_square_solving(bicgstab_colmajor_I) ); + CALL_SUBTEST( check_sparse_square_solving(bicgstab_colmajor_ilut) ); + //CALL_SUBTEST( check_sparse_square_solving(bicgstab_colmajor_ssor) ); +} + +EIGEN_DECLARE_TEST(bicgstab) +{ + CALL_SUBTEST_1((test_bicgstab_T()) ); + CALL_SUBTEST_2((test_bicgstab_T, int>())); + CALL_SUBTEST_3((test_bicgstab_T())); +} diff --git a/include/eigen/test/blasutil.cpp b/include/eigen/test/blasutil.cpp new file mode 100644 index 0000000000000000000000000000000000000000..845a498d675f589a4a526834fd693f024392c07b --- /dev/null +++ b/include/eigen/test/blasutil.cpp @@ -0,0 +1,210 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2020 Everton Constantino +// +// 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/ + +#include "main.h" + +// Disable "ignoring attributes on template argument" +// for packet_traits +// => The only workaround would be to wrap _m128 and the likes +// within wrappers. +#if EIGEN_GNUC_AT_LEAST(6,0) + #pragma GCC diagnostic ignored "-Wignored-attributes" +#endif + +#define GET(i,j) (StorageOrder == RowMajor ? (i)*stride + (j) : (i) + (j)*stride) +#define SCATTER(i,j,k) (StorageOrder == RowMajor ? ((i)+(k))*stride + (j) : (i) + ((j)+(k))*stride) + +template +void compare(const Packet& a, const Packet& b) +{ + int pktsz = internal::packet_traits::size; + Scalar *buffA = new Scalar[pktsz]; + Scalar *buffB = new Scalar[pktsz]; + + internal::pstoreu(buffA, a); + internal::pstoreu(buffB, b); + + for(int i = 0; i < pktsz; i++) + { + VERIFY_IS_EQUAL(buffA[i], buffB[i]); + } + + delete[] buffA; + delete[] buffB; +} + +template +struct PacketBlockSet +{ + typedef typename internal::packet_traits::type Packet; + + void setPacketBlock(internal::PacketBlock& block, Scalar value) + { + for(int idx = 0; idx < n; idx++) + { + block.packet[idx] = internal::pset1(value); + } + } + + void comparePacketBlock(Scalar *data, int i, int j, int stride, internal::PacketBlock& block) + { + for(int idx = 0; idx < n; idx++) + { + Packet line = internal::ploadu(data + SCATTER(i,j,idx)); + compare(block.packet[idx], line); + } + } +}; + +template +void run_bdmp_spec_1() +{ + typedef internal::blas_data_mapper BlasDataMapper; + int packetSize = internal::packet_traits::size; + int minSize = std::max(packetSize, BlockSize); + typedef typename internal::packet_traits::type Packet; + + int szm = internal::random(minSize,500), szn = internal::random(minSize,500); + int stride = StorageOrder == RowMajor ? szn : szm; + Scalar *d = new Scalar[szn*szm]; + + // Initializing with random entries + for(int i = 0; i < szm*szn; i++) + { + d[i] = internal::random(static_cast(3), static_cast(10)); + } + + BlasDataMapper bdm(d, stride); + + // Testing operator() + for(int i = 0; i < szm; i++) + { + for(int j = 0; j < szn; j++) + { + VERIFY_IS_EQUAL(d[GET(i,j)], bdm(i,j)); + } + } + + // Testing getSubMapper and getLinearMapper + int i0 = internal::random(0,szm-2); + int j0 = internal::random(0,szn-2); + for(int i = i0; i < szm; i++) + { + for(int j = j0; j < szn; j++) + { + const BlasDataMapper& bdmSM = bdm.getSubMapper(i0,j0); + const internal::BlasLinearMapper& bdmLM = bdm.getLinearMapper(i0,j0); + + Scalar v = bdmSM(i - i0, j - j0); + Scalar vd = d[GET(i,j)]; + VERIFY_IS_EQUAL(vd, v); + VERIFY_IS_EQUAL(vd, bdmLM(GET(i-i0, j-j0))); + } + } + + // Testing loadPacket + for(int i = 0; i < szm - minSize; i++) + { + for(int j = 0; j < szn - minSize; j++) + { + Packet pktBDM = bdm.template loadPacket(i,j); + Packet pktD = internal::ploadu(d + GET(i,j)); + + compare(pktBDM, pktD); + } + } + + // Testing gatherPacket + Scalar *buff = new Scalar[packetSize]; + for(int i = 0; i < szm - minSize; i++) + { + for(int j = 0; j < szn - minSize; j++) + { + Packet p = bdm.template gatherPacket(i,j); + internal::pstoreu(buff, p); + + for(int k = 0; k < packetSize; k++) + { + VERIFY_IS_EQUAL(d[SCATTER(i,j,k)], buff[k]); + } + + } + } + delete[] buff; + + // Testing scatterPacket + for(int i = 0; i < szm - minSize; i++) + { + for(int j = 0; j < szn - minSize; j++) + { + Packet p = internal::pset1(static_cast(1)); + bdm.template scatterPacket(i,j,p); + for(int k = 0; k < packetSize; k++) + { + VERIFY_IS_EQUAL(d[SCATTER(i,j,k)], static_cast(1)); + } + } + } + + //Testing storePacketBlock + internal::PacketBlock block; + + PacketBlockSet pbs; + pbs.setPacketBlock(block, static_cast(2)); + + for(int i = 0; i < szm - minSize; i++) + { + for(int j = 0; j < szn - minSize; j++) + { + bdm.template storePacketBlock(i, j, block); + + pbs.comparePacketBlock(d, i, j, stride, block); + } + } + + delete[] d; +} + +template +void run_test() +{ + run_bdmp_spec_1(); + run_bdmp_spec_1(); + run_bdmp_spec_1(); + run_bdmp_spec_1(); + run_bdmp_spec_1(); + run_bdmp_spec_1(); + run_bdmp_spec_1(); + run_bdmp_spec_1(); + run_bdmp_spec_1(); + run_bdmp_spec_1(); +} + +EIGEN_DECLARE_TEST(blasutil) +{ + for(int i = 0; i < g_repeat; i++) + { + CALL_SUBTEST_1(run_test()); + CALL_SUBTEST_2(run_test()); + CALL_SUBTEST_3(run_test()); + +// TODO: Replace this by a call to numext::int64_t as soon as we have a way to +// detect the typedef for int64_t on all platforms +#if EIGEN_HAS_CXX11 + CALL_SUBTEST_4(run_test()); +#else + CALL_SUBTEST_4(run_test()); +#endif + + CALL_SUBTEST_5(run_test()); + CALL_SUBTEST_6(run_test()); + CALL_SUBTEST_7(run_test >()); + CALL_SUBTEST_8(run_test >()); + } +} diff --git a/include/eigen/test/block.cpp b/include/eigen/test/block.cpp new file mode 100644 index 0000000000000000000000000000000000000000..667a3be3914308978bcb94fa49971e65fbbd326e --- /dev/null +++ b/include/eigen/test/block.cpp @@ -0,0 +1,317 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2006-2010 Benoit Jacob +// +// 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/. + +#define EIGEN_NO_STATIC_ASSERT // otherwise we fail at compile time on unused paths +#include "main.h" + +template +typename Eigen::internal::enable_if::IsComplex,typename MatrixType::Scalar>::type +block_real_only(const MatrixType &m1, Index r1, Index r2, Index c1, Index c2, const Scalar& s1) { + // check cwise-Functions: + VERIFY_IS_APPROX(m1.row(r1).cwiseMax(s1), m1.cwiseMax(s1).row(r1)); + VERIFY_IS_APPROX(m1.col(c1).cwiseMin(s1), m1.cwiseMin(s1).col(c1)); + + VERIFY_IS_APPROX(m1.block(r1,c1,r2-r1+1,c2-c1+1).cwiseMin(s1), m1.cwiseMin(s1).block(r1,c1,r2-r1+1,c2-c1+1)); + VERIFY_IS_APPROX(m1.block(r1,c1,r2-r1+1,c2-c1+1).cwiseMax(s1), m1.cwiseMax(s1).block(r1,c1,r2-r1+1,c2-c1+1)); + + return Scalar(0); +} + +template +typename Eigen::internal::enable_if::IsComplex,typename MatrixType::Scalar>::type +block_real_only(const MatrixType &, Index, Index, Index, Index, const Scalar&) { + return Scalar(0); +} + +// Check at compile-time that T1==T2, and at runtime-time that a==b +template +typename internal::enable_if::value,bool>::type +is_same_block(const T1& a, const T2& b) +{ + return a.isApprox(b); +} + +template void block(const MatrixType& m) +{ + typedef typename MatrixType::Scalar Scalar; + typedef typename MatrixType::RealScalar RealScalar; + typedef Matrix VectorType; + typedef Matrix RowVectorType; + typedef Matrix DynamicMatrixType; + typedef Matrix DynamicVectorType; + + Index rows = m.rows(); + Index cols = m.cols(); + + MatrixType m1 = MatrixType::Random(rows, cols), + m1_copy = m1, + m2 = MatrixType::Random(rows, cols), + m3(rows, cols), + ones = MatrixType::Ones(rows, cols); + VectorType v1 = VectorType::Random(rows); + + Scalar s1 = internal::random(); + + Index r1 = internal::random(0,rows-1); + Index r2 = internal::random(r1,rows-1); + Index c1 = internal::random(0,cols-1); + Index c2 = internal::random(c1,cols-1); + + block_real_only(m1, r1, r2, c1, c1, s1); + + //check row() and col() + VERIFY_IS_EQUAL(m1.col(c1).transpose(), m1.transpose().row(c1)); + //check operator(), both constant and non-constant, on row() and col() + m1 = m1_copy; + m1.row(r1) += s1 * m1_copy.row(r2); + VERIFY_IS_APPROX(m1.row(r1), m1_copy.row(r1) + s1 * m1_copy.row(r2)); + // check nested block xpr on lhs + m1.row(r1).row(0) += s1 * m1_copy.row(r2); + VERIFY_IS_APPROX(m1.row(r1), m1_copy.row(r1) + Scalar(2) * s1 * m1_copy.row(r2)); + m1 = m1_copy; + m1.col(c1) += s1 * m1_copy.col(c2); + VERIFY_IS_APPROX(m1.col(c1), m1_copy.col(c1) + s1 * m1_copy.col(c2)); + m1.col(c1).col(0) += s1 * m1_copy.col(c2); + VERIFY_IS_APPROX(m1.col(c1), m1_copy.col(c1) + Scalar(2) * s1 * m1_copy.col(c2)); + + + //check block() + Matrix b1(1,1); b1(0,0) = m1(r1,c1); + + RowVectorType br1(m1.block(r1,0,1,cols)); + VectorType bc1(m1.block(0,c1,rows,1)); + VERIFY_IS_EQUAL(b1, m1.block(r1,c1,1,1)); + VERIFY_IS_EQUAL(m1.row(r1), br1); + VERIFY_IS_EQUAL(m1.col(c1), bc1); + //check operator(), both constant and non-constant, on block() + m1.block(r1,c1,r2-r1+1,c2-c1+1) = s1 * m2.block(0, 0, r2-r1+1,c2-c1+1); + m1.block(r1,c1,r2-r1+1,c2-c1+1)(r2-r1,c2-c1) = m2.block(0, 0, r2-r1+1,c2-c1+1)(0,0); + + const Index BlockRows = 2; + const Index BlockCols = 5; + + if (rows>=5 && cols>=8) + { + // test fixed block() as lvalue + m1.template block(1,1) *= s1; + // test operator() on fixed block() both as constant and non-constant + m1.template block(1,1)(0, 3) = m1.template block<2,5>(1,1)(1,2); + // check that fixed block() and block() agree + Matrix b = m1.template block(3,3); + VERIFY_IS_EQUAL(b, m1.block(3,3,BlockRows,BlockCols)); + + // same tests with mixed fixed/dynamic size + m1.template block(1,1,BlockRows,BlockCols) *= s1; + m1.template block(1,1,BlockRows,BlockCols)(0,3) = m1.template block<2,5>(1,1)(1,2); + Matrix b2 = m1.template block(3,3,2,5); + VERIFY_IS_EQUAL(b2, m1.block(3,3,BlockRows,BlockCols)); + + VERIFY(is_same_block(m1.block(3,3,BlockRows,BlockCols), m1.block(3,3,fix(BlockRows),fix(BlockCols)))); + VERIFY(is_same_block(m1.template block(1,1,BlockRows,BlockCols), m1.block(1,1,fix,BlockCols))); + VERIFY(is_same_block(m1.template block(1,1,BlockRows,BlockCols), m1.block(1,1,fix(),fix))); + VERIFY(is_same_block(m1.template block(1,1,BlockRows,BlockCols), m1.block(1,1,fix,fix(BlockCols)))); + } + + if (rows>2) + { + // test sub vectors + VERIFY_IS_EQUAL(v1.template head<2>(), v1.block(0,0,2,1)); + VERIFY_IS_EQUAL(v1.template head<2>(), v1.head(2)); + VERIFY_IS_EQUAL(v1.template head<2>(), v1.segment(0,2)); + VERIFY_IS_EQUAL(v1.template head<2>(), v1.template segment<2>(0)); + Index i = rows-2; + VERIFY_IS_EQUAL(v1.template tail<2>(), v1.block(i,0,2,1)); + VERIFY_IS_EQUAL(v1.template tail<2>(), v1.tail(2)); + VERIFY_IS_EQUAL(v1.template tail<2>(), v1.segment(i,2)); + VERIFY_IS_EQUAL(v1.template tail<2>(), v1.template segment<2>(i)); + i = internal::random(0,rows-2); + VERIFY_IS_EQUAL(v1.segment(i,2), v1.template segment<2>(i)); + } + + // stress some basic stuffs with block matrices + VERIFY(numext::real(ones.col(c1).sum()) == RealScalar(rows)); + VERIFY(numext::real(ones.row(r1).sum()) == RealScalar(cols)); + + VERIFY(numext::real(ones.col(c1).dot(ones.col(c2))) == RealScalar(rows)); + VERIFY(numext::real(ones.row(r1).dot(ones.row(r2))) == RealScalar(cols)); + + // check that linear acccessors works on blocks + m1 = m1_copy; + if (c1 > 0 && r1 > 0) { + if ((MatrixType::Flags & RowMajorBit) == 0) + VERIFY_IS_EQUAL(m1.leftCols(c1).coeff(r1 + c1 * rows), m1(r1, c1)); + else + VERIFY_IS_EQUAL(m1.topRows(r1).coeff(c1 + r1 * cols), m1(r1, c1)); + } + + // now test some block-inside-of-block. + + // expressions with direct access + VERIFY_IS_EQUAL( (m1.block(r1,c1,rows-r1,cols-c1).block(r2-r1,c2-c1,rows-r2,cols-c2)) , (m1.block(r2,c2,rows-r2,cols-c2)) ); + VERIFY_IS_EQUAL( (m1.block(r1,c1,r2-r1+1,c2-c1+1).row(0)) , (m1.row(r1).segment(c1,c2-c1+1)) ); + VERIFY_IS_EQUAL( (m1.block(r1,c1,r2-r1+1,c2-c1+1).col(0)) , (m1.col(c1).segment(r1,r2-r1+1)) ); + VERIFY_IS_EQUAL( (m1.block(r1,c1,r2-r1+1,c2-c1+1).transpose().col(0)) , (m1.row(r1).segment(c1,c2-c1+1)).transpose() ); + VERIFY_IS_EQUAL( (m1.transpose().block(c1,r1,c2-c1+1,r2-r1+1).col(0)) , (m1.row(r1).segment(c1,c2-c1+1)).transpose() ); + + // expressions without direct access + VERIFY_IS_APPROX( ((m1+m2).block(r1,c1,rows-r1,cols-c1).block(r2-r1,c2-c1,rows-r2,cols-c2)) , ((m1+m2).block(r2,c2,rows-r2,cols-c2)) ); + VERIFY_IS_APPROX( ((m1+m2).block(r1,c1,r2-r1+1,c2-c1+1).row(0)) , ((m1+m2).row(r1).segment(c1,c2-c1+1)) ); + VERIFY_IS_APPROX( ((m1+m2).block(r1,c1,r2-r1+1,c2-c1+1).row(0)) , ((m1+m2).eval().row(r1).segment(c1,c2-c1+1)) ); + VERIFY_IS_APPROX( ((m1+m2).block(r1,c1,r2-r1+1,c2-c1+1).col(0)) , ((m1+m2).col(c1).segment(r1,r2-r1+1)) ); + VERIFY_IS_APPROX( ((m1+m2).block(r1,c1,r2-r1+1,c2-c1+1).transpose().col(0)) , ((m1+m2).row(r1).segment(c1,c2-c1+1)).transpose() ); + VERIFY_IS_APPROX( ((m1+m2).transpose().block(c1,r1,c2-c1+1,r2-r1+1).col(0)) , ((m1+m2).row(r1).segment(c1,c2-c1+1)).transpose() ); + VERIFY_IS_APPROX( ((m1+m2).template block(r1,c1,r2-r1+1,1)) , ((m1+m2).eval().col(c1).eval().segment(r1,r2-r1+1)) ); + VERIFY_IS_APPROX( ((m1+m2).template block<1,Dynamic>(r1,c1,1,c2-c1+1)) , ((m1+m2).eval().row(r1).eval().segment(c1,c2-c1+1)) ); + VERIFY_IS_APPROX( ((m1+m2).transpose().template block<1,Dynamic>(c1,r1,1,r2-r1+1)) , ((m1+m2).eval().col(c1).eval().segment(r1,r2-r1+1)).transpose() ); + VERIFY_IS_APPROX( (m1+m2).row(r1).eval(), (m1+m2).eval().row(r1) ); + VERIFY_IS_APPROX( (m1+m2).adjoint().col(r1).eval(), (m1+m2).adjoint().eval().col(r1) ); + VERIFY_IS_APPROX( (m1+m2).adjoint().row(c1).eval(), (m1+m2).adjoint().eval().row(c1) ); + VERIFY_IS_APPROX( (m1*1).row(r1).segment(c1,c2-c1+1).eval(), m1.row(r1).eval().segment(c1,c2-c1+1).eval() ); + VERIFY_IS_APPROX( m1.col(c1).reverse().segment(r1,r2-r1+1).eval(),m1.col(c1).reverse().eval().segment(r1,r2-r1+1).eval() ); + + VERIFY_IS_APPROX( (m1*1).topRows(r1), m1.topRows(r1) ); + VERIFY_IS_APPROX( (m1*1).leftCols(c1), m1.leftCols(c1) ); + VERIFY_IS_APPROX( (m1*1).transpose().topRows(c1), m1.transpose().topRows(c1) ); + VERIFY_IS_APPROX( (m1*1).transpose().leftCols(r1), m1.transpose().leftCols(r1) ); + VERIFY_IS_APPROX( (m1*1).transpose().middleRows(c1,c2-c1+1), m1.transpose().middleRows(c1,c2-c1+1) ); + VERIFY_IS_APPROX( (m1*1).transpose().middleCols(r1,r2-r1+1), m1.transpose().middleCols(r1,r2-r1+1) ); + + // evaluation into plain matrices from expressions with direct access (stress MapBase) + DynamicMatrixType dm; + DynamicVectorType dv; + dm.setZero(); + dm = m1.block(r1,c1,rows-r1,cols-c1).block(r2-r1,c2-c1,rows-r2,cols-c2); + VERIFY_IS_EQUAL(dm, (m1.block(r2,c2,rows-r2,cols-c2))); + dm.setZero(); + dv.setZero(); + dm = m1.block(r1,c1,r2-r1+1,c2-c1+1).row(0).transpose(); + dv = m1.row(r1).segment(c1,c2-c1+1); + VERIFY_IS_EQUAL(dv, dm); + dm.setZero(); + dv.setZero(); + dm = m1.col(c1).segment(r1,r2-r1+1); + dv = m1.block(r1,c1,r2-r1+1,c2-c1+1).col(0); + VERIFY_IS_EQUAL(dv, dm); + dm.setZero(); + dv.setZero(); + dm = m1.block(r1,c1,r2-r1+1,c2-c1+1).transpose().col(0); + dv = m1.row(r1).segment(c1,c2-c1+1); + VERIFY_IS_EQUAL(dv, dm); + dm.setZero(); + dv.setZero(); + dm = m1.row(r1).segment(c1,c2-c1+1).transpose(); + dv = m1.transpose().block(c1,r1,c2-c1+1,r2-r1+1).col(0); + VERIFY_IS_EQUAL(dv, dm); + + VERIFY_IS_EQUAL( (m1.template block(1,0,0,1)), m1.block(1,0,0,1)); + VERIFY_IS_EQUAL( (m1.template block<1,Dynamic>(0,1,1,0)), m1.block(0,1,1,0)); + VERIFY_IS_EQUAL( ((m1*1).template block(1,0,0,1)), m1.block(1,0,0,1)); + VERIFY_IS_EQUAL( ((m1*1).template block<1,Dynamic>(0,1,1,0)), m1.block(0,1,1,0)); + + if (rows>=2 && cols>=2) + { + VERIFY_RAISES_ASSERT( m1 += m1.col(0) ); + VERIFY_RAISES_ASSERT( m1 -= m1.col(0) ); + VERIFY_RAISES_ASSERT( m1.array() *= m1.col(0).array() ); + VERIFY_RAISES_ASSERT( m1.array() /= m1.col(0).array() ); + } + + VERIFY_IS_EQUAL( m1.template subVector(r1), m1.row(r1) ); + VERIFY_IS_APPROX( (m1+m1).template subVector(r1), (m1+m1).row(r1) ); + VERIFY_IS_EQUAL( m1.template subVector(c1), m1.col(c1) ); + VERIFY_IS_APPROX( (m1+m1).template subVector(c1), (m1+m1).col(c1) ); + VERIFY_IS_EQUAL( m1.template subVectors(), m1.rows() ); + VERIFY_IS_EQUAL( m1.template subVectors(), m1.cols() ); + + if (rows>=2 || cols>=2) { + VERIFY_IS_EQUAL( int(m1.middleCols(0,0).IsRowMajor), int(m1.IsRowMajor) ); + VERIFY_IS_EQUAL( m1.middleCols(0,0).outerSize(), m1.IsRowMajor ? rows : 0); + VERIFY_IS_EQUAL( m1.middleCols(0,0).innerSize(), m1.IsRowMajor ? 0 : rows); + + VERIFY_IS_EQUAL( int(m1.middleRows(0,0).IsRowMajor), int(m1.IsRowMajor) ); + VERIFY_IS_EQUAL( m1.middleRows(0,0).outerSize(), m1.IsRowMajor ? 0 : cols); + VERIFY_IS_EQUAL( m1.middleRows(0,0).innerSize(), m1.IsRowMajor ? cols : 0); + } +} + + +template +void compare_using_data_and_stride(const MatrixType& m) +{ + Index rows = m.rows(); + Index cols = m.cols(); + Index size = m.size(); + Index innerStride = m.innerStride(); + Index outerStride = m.outerStride(); + Index rowStride = m.rowStride(); + Index colStride = m.colStride(); + const typename MatrixType::Scalar* data = m.data(); + + for(int j=0;j +void data_and_stride(const MatrixType& m) +{ + Index rows = m.rows(); + Index cols = m.cols(); + + Index r1 = internal::random(0,rows-1); + Index r2 = internal::random(r1,rows-1); + Index c1 = internal::random(0,cols-1); + Index c2 = internal::random(c1,cols-1); + + MatrixType m1 = MatrixType::Random(rows, cols); + compare_using_data_and_stride(m1.block(r1, c1, r2-r1+1, c2-c1+1)); + compare_using_data_and_stride(m1.transpose().block(c1, r1, c2-c1+1, r2-r1+1)); + compare_using_data_and_stride(m1.row(r1)); + compare_using_data_and_stride(m1.col(c1)); + compare_using_data_and_stride(m1.row(r1).transpose()); + compare_using_data_and_stride(m1.col(c1).transpose()); +} + +EIGEN_DECLARE_TEST(block) +{ + for(int i = 0; i < g_repeat; i++) { + CALL_SUBTEST_1( block(Matrix()) ); + CALL_SUBTEST_1( block(Matrix(internal::random(2,50))) ); + CALL_SUBTEST_1( block(Matrix(internal::random(2,50))) ); + CALL_SUBTEST_2( block(Matrix4d()) ); + CALL_SUBTEST_3( block(MatrixXcf(internal::random(2,50), internal::random(2,50))) ); + CALL_SUBTEST_4( block(MatrixXi(internal::random(2,50), internal::random(2,50))) ); + CALL_SUBTEST_5( block(MatrixXcd(internal::random(2,50), internal::random(2,50))) ); + CALL_SUBTEST_6( block(MatrixXf(internal::random(2,50), internal::random(2,50))) ); + CALL_SUBTEST_7( block(Matrix(internal::random(2,50), internal::random(2,50))) ); + + CALL_SUBTEST_8( block(Matrix(3, 4)) ); + +#ifndef EIGEN_DEFAULT_TO_ROW_MAJOR + CALL_SUBTEST_6( data_and_stride(MatrixXf(internal::random(5,50), internal::random(5,50))) ); + CALL_SUBTEST_7( data_and_stride(Matrix(internal::random(5,50), internal::random(5,50))) ); +#endif + } +} diff --git a/include/eigen/test/bug1213.cpp b/include/eigen/test/bug1213.cpp new file mode 100644 index 0000000000000000000000000000000000000000..581760c1a67e2f88eae29de5b18fd10f8ac23cab --- /dev/null +++ b/include/eigen/test/bug1213.cpp @@ -0,0 +1,13 @@ + +// This anonymous enum is essential to trigger the linking issue +enum { + Foo +}; + +#include "bug1213.h" + +bool bug1213_1(const Eigen::Vector3f& x) +{ + return bug1213_2(x); +} + diff --git a/include/eigen/test/bug1213.h b/include/eigen/test/bug1213.h new file mode 100644 index 0000000000000000000000000000000000000000..040e5a470d3a3e005d24ec52089a1e4aa89bc1b3 --- /dev/null +++ b/include/eigen/test/bug1213.h @@ -0,0 +1,8 @@ + +#include + +template +bool bug1213_2(const Eigen::Matrix& x); + +bool bug1213_1(const Eigen::Vector3f& x); + diff --git a/include/eigen/test/bug1213_main.cpp b/include/eigen/test/bug1213_main.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4802c00032f18f39e866cc59711b61036012bcdd --- /dev/null +++ b/include/eigen/test/bug1213_main.cpp @@ -0,0 +1,18 @@ + +// This is a regression unit regarding a weird linking issue with gcc. + +#include "bug1213.h" + +int main() +{ + return 0; +} + + +template +bool bug1213_2(const Eigen::Matrix& ) +{ + return true; +} + +template bool bug1213_2(const Eigen::Vector3f&); diff --git a/include/eigen/test/cholmod_support.cpp b/include/eigen/test/cholmod_support.cpp new file mode 100644 index 0000000000000000000000000000000000000000..89b9cf41e0fed1f45268056058b2dbd0a5ab3ef1 --- /dev/null +++ b/include/eigen/test/cholmod_support.cpp @@ -0,0 +1,69 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2011 Gael Guennebaud +// +// 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/. + +#define EIGEN_NO_DEBUG_SMALL_PRODUCT_BLOCKS +#include "sparse_solver.h" + +#include + +template void test_cholmod_ST() +{ + CholmodDecomposition g_chol_colmajor_lower; g_chol_colmajor_lower.setMode(CholmodSupernodalLLt); + CholmodDecomposition g_chol_colmajor_upper; g_chol_colmajor_upper.setMode(CholmodSupernodalLLt); + CholmodDecomposition g_llt_colmajor_lower; g_llt_colmajor_lower.setMode(CholmodSimplicialLLt); + CholmodDecomposition g_llt_colmajor_upper; g_llt_colmajor_upper.setMode(CholmodSimplicialLLt); + CholmodDecomposition g_ldlt_colmajor_lower; g_ldlt_colmajor_lower.setMode(CholmodLDLt); + CholmodDecomposition g_ldlt_colmajor_upper; g_ldlt_colmajor_upper.setMode(CholmodLDLt); + + CholmodSupernodalLLT chol_colmajor_lower; + CholmodSupernodalLLT chol_colmajor_upper; + CholmodSimplicialLLT llt_colmajor_lower; + CholmodSimplicialLLT llt_colmajor_upper; + CholmodSimplicialLDLT ldlt_colmajor_lower; + CholmodSimplicialLDLT ldlt_colmajor_upper; + + check_sparse_spd_solving(g_chol_colmajor_lower); + check_sparse_spd_solving(g_chol_colmajor_upper); + check_sparse_spd_solving(g_llt_colmajor_lower); + check_sparse_spd_solving(g_llt_colmajor_upper); + check_sparse_spd_solving(g_ldlt_colmajor_lower); + check_sparse_spd_solving(g_ldlt_colmajor_upper); + + check_sparse_spd_solving(chol_colmajor_lower); + check_sparse_spd_solving(chol_colmajor_upper); + check_sparse_spd_solving(llt_colmajor_lower); + check_sparse_spd_solving(llt_colmajor_upper); + check_sparse_spd_solving(ldlt_colmajor_lower); + check_sparse_spd_solving(ldlt_colmajor_upper); + + check_sparse_spd_determinant(chol_colmajor_lower); + check_sparse_spd_determinant(chol_colmajor_upper); + check_sparse_spd_determinant(llt_colmajor_lower); + check_sparse_spd_determinant(llt_colmajor_upper); + check_sparse_spd_determinant(ldlt_colmajor_lower); + check_sparse_spd_determinant(ldlt_colmajor_upper); +} + +template void test_cholmod_T() +{ + test_cholmod_ST >(); +} + +EIGEN_DECLARE_TEST(cholmod_support) +{ + CALL_SUBTEST_11( (test_cholmod_T()) ); + CALL_SUBTEST_12( (test_cholmod_T()) ); + CALL_SUBTEST_13( (test_cholmod_T()) ); + CALL_SUBTEST_14( (test_cholmod_T()) ); + CALL_SUBTEST_21( (test_cholmod_T, ColMajor, int >()) ); + CALL_SUBTEST_22( (test_cholmod_T, ColMajor, long>()) ); + // TODO complex row-major matrices do not work at the moment: + // CALL_SUBTEST_23( (test_cholmod_T, RowMajor, int >()) ); + // CALL_SUBTEST_24( (test_cholmod_T, RowMajor, long>()) ); +} diff --git a/include/eigen/test/conjugate_gradient.cpp b/include/eigen/test/conjugate_gradient.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b076a126b7cd8352eeb3199d8bb07640dc82a3f6 --- /dev/null +++ b/include/eigen/test/conjugate_gradient.cpp @@ -0,0 +1,34 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2011 Gael Guennebaud +// +// 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/. + +#include "sparse_solver.h" +#include + +template void test_conjugate_gradient_T() +{ + typedef SparseMatrix SparseMatrixType; + ConjugateGradient cg_colmajor_lower_diag; + ConjugateGradient cg_colmajor_upper_diag; + ConjugateGradient cg_colmajor_loup_diag; + ConjugateGradient cg_colmajor_lower_I; + ConjugateGradient cg_colmajor_upper_I; + + CALL_SUBTEST( check_sparse_spd_solving(cg_colmajor_lower_diag) ); + CALL_SUBTEST( check_sparse_spd_solving(cg_colmajor_upper_diag) ); + CALL_SUBTEST( check_sparse_spd_solving(cg_colmajor_loup_diag) ); + CALL_SUBTEST( check_sparse_spd_solving(cg_colmajor_lower_I) ); + CALL_SUBTEST( check_sparse_spd_solving(cg_colmajor_upper_I) ); +} + +EIGEN_DECLARE_TEST(conjugate_gradient) +{ + CALL_SUBTEST_1(( test_conjugate_gradient_T() )); + CALL_SUBTEST_2(( test_conjugate_gradient_T, int>() )); + CALL_SUBTEST_3(( test_conjugate_gradient_T() )); +} diff --git a/include/eigen/test/conservative_resize.cpp b/include/eigen/test/conservative_resize.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d48eb126fdb1fca779981e258f0c82430c1a01d1 --- /dev/null +++ b/include/eigen/test/conservative_resize.cpp @@ -0,0 +1,167 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2009 Hauke Heibel +// +// 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/. + +#include "main.h" + +#include +#include "AnnoyingScalar.h" + +using namespace Eigen; + +template +void run_matrix_tests() +{ + typedef Matrix MatrixType; + + MatrixType m, n; + + // boundary cases ... + m = n = MatrixType::Random(50,50); + m.conservativeResize(1,50); + VERIFY_IS_APPROX(m, n.block(0,0,1,50)); + + m = n = MatrixType::Random(50,50); + m.conservativeResize(50,1); + VERIFY_IS_APPROX(m, n.block(0,0,50,1)); + + m = n = MatrixType::Random(50,50); + m.conservativeResize(50,50); + VERIFY_IS_APPROX(m, n.block(0,0,50,50)); + + // random shrinking ... + for (int i=0; i<25; ++i) + { + const Index rows = internal::random(1,50); + const Index cols = internal::random(1,50); + m = n = MatrixType::Random(50,50); + m.conservativeResize(rows,cols); + VERIFY_IS_APPROX(m, n.block(0,0,rows,cols)); + } + + // random growing with zeroing ... + for (int i=0; i<25; ++i) + { + const Index rows = internal::random(50,75); + const Index cols = internal::random(50,75); + m = n = MatrixType::Random(50,50); + m.conservativeResizeLike(MatrixType::Zero(rows,cols)); + VERIFY_IS_APPROX(m.block(0,0,n.rows(),n.cols()), n); + VERIFY( rows<=50 || m.block(50,0,rows-50,cols).sum() == Scalar(0) ); + VERIFY( cols<=50 || m.block(0,50,rows,cols-50).sum() == Scalar(0) ); + } +} + +template +void run_vector_tests() +{ + typedef Matrix VectorType; + + VectorType m, n; + + // boundary cases ... + m = n = VectorType::Random(50); + m.conservativeResize(1); + VERIFY_IS_APPROX(m, n.segment(0,1)); + + m = n = VectorType::Random(50); + m.conservativeResize(50); + VERIFY_IS_APPROX(m, n.segment(0,50)); + + m = n = VectorType::Random(50); + m.conservativeResize(m.rows(),1); + VERIFY_IS_APPROX(m, n.segment(0,1)); + + m = n = VectorType::Random(50); + m.conservativeResize(m.rows(),50); + VERIFY_IS_APPROX(m, n.segment(0,50)); + + // random shrinking ... + for (int i=0; i<50; ++i) + { + const int size = internal::random(1,50); + m = n = VectorType::Random(50); + m.conservativeResize(size); + VERIFY_IS_APPROX(m, n.segment(0,size)); + + m = n = VectorType::Random(50); + m.conservativeResize(m.rows(), size); + VERIFY_IS_APPROX(m, n.segment(0,size)); + } + + // random growing with zeroing ... + for (int i=0; i<50; ++i) + { + const int size = internal::random(50,100); + m = n = VectorType::Random(50); + m.conservativeResizeLike(VectorType::Zero(size)); + VERIFY_IS_APPROX(m.segment(0,50), n); + VERIFY( size<=50 || m.segment(50,size-50).sum() == Scalar(0) ); + + m = n = VectorType::Random(50); + m.conservativeResizeLike(Matrix::Zero(1,size)); + VERIFY_IS_APPROX(m.segment(0,50), n); + VERIFY( size<=50 || m.segment(50,size-50).sum() == Scalar(0) ); + } +} + +// Basic memory leak check with a non-copyable scalar type +template void noncopyable() +{ + typedef Eigen::Matrix VectorType; + typedef Eigen::Matrix MatrixType; + + { +#ifndef EIGEN_TEST_ANNOYING_SCALAR_DONT_THROW + AnnoyingScalar::dont_throw = true; +#endif + int n = 50; + VectorType v0(n), v1(n); + MatrixType m0(n,n), m1(n,n), m2(n,n); + v0.setOnes(); v1.setOnes(); + m0.setOnes(); m1.setOnes(); m2.setOnes(); + VERIFY(m0==m1); + m0.conservativeResize(2*n,2*n); + VERIFY(m0.topLeftCorner(n,n) == m1); + + VERIFY(v0.head(n) == v1); + v0.conservativeResize(2*n); + VERIFY(v0.head(n) == v1); + } + VERIFY(AnnoyingScalar::instances==0 && "global memory leak detected in noncopyable"); +} + +EIGEN_DECLARE_TEST(conservative_resize) +{ + for(int i=0; i())); + CALL_SUBTEST_1((run_matrix_tests())); + CALL_SUBTEST_2((run_matrix_tests())); + CALL_SUBTEST_2((run_matrix_tests())); + CALL_SUBTEST_3((run_matrix_tests())); + CALL_SUBTEST_3((run_matrix_tests())); + CALL_SUBTEST_4((run_matrix_tests, Eigen::RowMajor>())); + CALL_SUBTEST_4((run_matrix_tests, Eigen::ColMajor>())); + CALL_SUBTEST_5((run_matrix_tests, Eigen::RowMajor>())); + CALL_SUBTEST_5((run_matrix_tests, Eigen::ColMajor>())); + CALL_SUBTEST_1((run_matrix_tests())); + + CALL_SUBTEST_1((run_vector_tests())); + CALL_SUBTEST_2((run_vector_tests())); + CALL_SUBTEST_3((run_vector_tests())); + CALL_SUBTEST_4((run_vector_tests >())); + CALL_SUBTEST_5((run_vector_tests >())); + +#ifndef EIGEN_TEST_ANNOYING_SCALAR_DONT_THROW + AnnoyingScalar::dont_throw = true; +#endif + CALL_SUBTEST_6(( run_vector_tests() )); + CALL_SUBTEST_6(( noncopyable<0>() )); + } +} diff --git a/include/eigen/test/constructor.cpp b/include/eigen/test/constructor.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ffd5e802abfb04a7fb28a8316ab065a9fa6ee9b5 --- /dev/null +++ b/include/eigen/test/constructor.cpp @@ -0,0 +1,98 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2017 Gael Guennebaud +// +// 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/. + + +#define TEST_ENABLE_TEMPORARY_TRACKING + +#include "main.h" + +template struct Wrapper +{ + MatrixType m_mat; + inline Wrapper(const MatrixType &x) : m_mat(x) {} + inline operator const MatrixType& () const { return m_mat; } + inline operator MatrixType& () { return m_mat; } +}; + +enum my_sizes { M = 12, N = 7}; + +template void ctor_init1(const MatrixType& m) +{ + // Check logic in PlainObjectBase::_init1 + Index rows = m.rows(); + Index cols = m.cols(); + + MatrixType m0 = MatrixType::Random(rows,cols); + + VERIFY_EVALUATION_COUNT( MatrixType m1(m0), 1); + VERIFY_EVALUATION_COUNT( MatrixType m2(m0+m0), 1); + VERIFY_EVALUATION_COUNT( MatrixType m2(m0.block(0,0,rows,cols)) , 1); + + Wrapper wrapper(m0); + VERIFY_EVALUATION_COUNT( MatrixType m3(wrapper) , 1); +} + + +EIGEN_DECLARE_TEST(constructor) +{ + for(int i = 0; i < g_repeat; i++) { + CALL_SUBTEST_1( ctor_init1(Matrix()) ); + CALL_SUBTEST_1( ctor_init1(Matrix4d()) ); + CALL_SUBTEST_1( ctor_init1(MatrixXcf(internal::random(1,EIGEN_TEST_MAX_SIZE), internal::random(1,EIGEN_TEST_MAX_SIZE))) ); + CALL_SUBTEST_1( ctor_init1(MatrixXi(internal::random(1,EIGEN_TEST_MAX_SIZE), internal::random(1,EIGEN_TEST_MAX_SIZE))) ); + } + { + Matrix a(123); + VERIFY_IS_EQUAL(a[0], 123); + } + { + Matrix a(123.0); + VERIFY_IS_EQUAL(a[0], 123); + } + { + Matrix a(123); + VERIFY_IS_EQUAL(a[0], 123.f); + } + { + Array a(123); + VERIFY_IS_EQUAL(a[0], 123); + } + { + Array a(123.0); + VERIFY_IS_EQUAL(a[0], 123); + } + { + Array a(123); + VERIFY_IS_EQUAL(a[0], 123.f); + } + { + Array a(123); + VERIFY_IS_EQUAL(a(4), 123); + } + { + Array a(123.0); + VERIFY_IS_EQUAL(a(4), 123); + } + { + Array a(123); + VERIFY_IS_EQUAL(a(4), 123.f); + } + { + MatrixXi m1(M,N); + VERIFY_IS_EQUAL(m1.rows(),M); + VERIFY_IS_EQUAL(m1.cols(),N); + ArrayXXi a1(M,N); + VERIFY_IS_EQUAL(a1.rows(),M); + VERIFY_IS_EQUAL(a1.cols(),N); + VectorXi v1(M); + VERIFY_IS_EQUAL(v1.size(),M); + ArrayXi a2(M); + VERIFY_IS_EQUAL(a2.size(),M); + } +} diff --git a/include/eigen/test/corners.cpp b/include/eigen/test/corners.cpp new file mode 100644 index 0000000000000000000000000000000000000000..73342a8ddb692d0ce0a60ffa1d1f547881896761 --- /dev/null +++ b/include/eigen/test/corners.cpp @@ -0,0 +1,117 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2006-2010 Benoit Jacob +// +// 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/. + +#include "main.h" + +#define COMPARE_CORNER(A,B) \ + VERIFY_IS_EQUAL(matrix.A, matrix.B); \ + VERIFY_IS_EQUAL(const_matrix.A, const_matrix.B); + +template void corners(const MatrixType& m) +{ + Index rows = m.rows(); + Index cols = m.cols(); + + Index r = internal::random(1,rows); + Index c = internal::random(1,cols); + + MatrixType matrix = MatrixType::Random(rows,cols); + const MatrixType const_matrix = MatrixType::Random(rows,cols); + + COMPARE_CORNER(topLeftCorner(r,c), block(0,0,r,c)); + COMPARE_CORNER(topRightCorner(r,c), block(0,cols-c,r,c)); + COMPARE_CORNER(bottomLeftCorner(r,c), block(rows-r,0,r,c)); + COMPARE_CORNER(bottomRightCorner(r,c), block(rows-r,cols-c,r,c)); + + Index sr = internal::random(1,rows) - 1; + Index nr = internal::random(1,rows-sr); + Index sc = internal::random(1,cols) - 1; + Index nc = internal::random(1,cols-sc); + + COMPARE_CORNER(topRows(r), block(0,0,r,cols)); + COMPARE_CORNER(middleRows(sr,nr), block(sr,0,nr,cols)); + COMPARE_CORNER(bottomRows(r), block(rows-r,0,r,cols)); + COMPARE_CORNER(leftCols(c), block(0,0,rows,c)); + COMPARE_CORNER(middleCols(sc,nc), block(0,sc,rows,nc)); + COMPARE_CORNER(rightCols(c), block(0,cols-c,rows,c)); +} + +template void corners_fixedsize() +{ + MatrixType matrix = MatrixType::Random(); + const MatrixType const_matrix = MatrixType::Random(); + + enum { + rows = MatrixType::RowsAtCompileTime, + cols = MatrixType::ColsAtCompileTime, + r = CRows, + c = CCols, + sr = SRows, + sc = SCols + }; + + VERIFY_IS_EQUAL((matrix.template topLeftCorner()), (matrix.template block(0,0))); + VERIFY_IS_EQUAL((matrix.template topRightCorner()), (matrix.template block(0,cols-c))); + VERIFY_IS_EQUAL((matrix.template bottomLeftCorner()), (matrix.template block(rows-r,0))); + VERIFY_IS_EQUAL((matrix.template bottomRightCorner()), (matrix.template block(rows-r,cols-c))); + + VERIFY_IS_EQUAL((matrix.template topLeftCorner()), (matrix.template topLeftCorner(r,c))); + VERIFY_IS_EQUAL((matrix.template topRightCorner()), (matrix.template topRightCorner(r,c))); + VERIFY_IS_EQUAL((matrix.template bottomLeftCorner()), (matrix.template bottomLeftCorner(r,c))); + VERIFY_IS_EQUAL((matrix.template bottomRightCorner()), (matrix.template bottomRightCorner(r,c))); + + VERIFY_IS_EQUAL((matrix.template topLeftCorner()), (matrix.template topLeftCorner(r,c))); + VERIFY_IS_EQUAL((matrix.template topRightCorner()), (matrix.template topRightCorner(r,c))); + VERIFY_IS_EQUAL((matrix.template bottomLeftCorner()), (matrix.template bottomLeftCorner(r,c))); + VERIFY_IS_EQUAL((matrix.template bottomRightCorner()), (matrix.template bottomRightCorner(r,c))); + + VERIFY_IS_EQUAL((matrix.template topRows()), (matrix.template block(0,0))); + VERIFY_IS_EQUAL((matrix.template middleRows(sr)), (matrix.template block(sr,0))); + VERIFY_IS_EQUAL((matrix.template bottomRows()), (matrix.template block(rows-r,0))); + VERIFY_IS_EQUAL((matrix.template leftCols()), (matrix.template block(0,0))); + VERIFY_IS_EQUAL((matrix.template middleCols(sc)), (matrix.template block(0,sc))); + VERIFY_IS_EQUAL((matrix.template rightCols()), (matrix.template block(0,cols-c))); + + VERIFY_IS_EQUAL((const_matrix.template topLeftCorner()), (const_matrix.template block(0,0))); + VERIFY_IS_EQUAL((const_matrix.template topRightCorner()), (const_matrix.template block(0,cols-c))); + VERIFY_IS_EQUAL((const_matrix.template bottomLeftCorner()), (const_matrix.template block(rows-r,0))); + VERIFY_IS_EQUAL((const_matrix.template bottomRightCorner()), (const_matrix.template block(rows-r,cols-c))); + + VERIFY_IS_EQUAL((const_matrix.template topLeftCorner()), (const_matrix.template topLeftCorner(r,c))); + VERIFY_IS_EQUAL((const_matrix.template topRightCorner()), (const_matrix.template topRightCorner(r,c))); + VERIFY_IS_EQUAL((const_matrix.template bottomLeftCorner()), (const_matrix.template bottomLeftCorner(r,c))); + VERIFY_IS_EQUAL((const_matrix.template bottomRightCorner()), (const_matrix.template bottomRightCorner(r,c))); + + VERIFY_IS_EQUAL((const_matrix.template topLeftCorner()), (const_matrix.template topLeftCorner(r,c))); + VERIFY_IS_EQUAL((const_matrix.template topRightCorner()), (const_matrix.template topRightCorner(r,c))); + VERIFY_IS_EQUAL((const_matrix.template bottomLeftCorner()), (const_matrix.template bottomLeftCorner(r,c))); + VERIFY_IS_EQUAL((const_matrix.template bottomRightCorner()), (const_matrix.template bottomRightCorner(r,c))); + + VERIFY_IS_EQUAL((const_matrix.template topRows()), (const_matrix.template block(0,0))); + VERIFY_IS_EQUAL((const_matrix.template middleRows(sr)), (const_matrix.template block(sr,0))); + VERIFY_IS_EQUAL((const_matrix.template bottomRows()), (const_matrix.template block(rows-r,0))); + VERIFY_IS_EQUAL((const_matrix.template leftCols()), (const_matrix.template block(0,0))); + VERIFY_IS_EQUAL((const_matrix.template middleCols(sc)), (const_matrix.template block(0,sc))); + VERIFY_IS_EQUAL((const_matrix.template rightCols()), (const_matrix.template block(0,cols-c))); +} + +EIGEN_DECLARE_TEST(corners) +{ + for(int i = 0; i < g_repeat; i++) { + CALL_SUBTEST_1( corners(Matrix()) ); + CALL_SUBTEST_2( corners(Matrix4d()) ); + CALL_SUBTEST_3( corners(Matrix()) ); + CALL_SUBTEST_4( corners(MatrixXcf(5, 7)) ); + CALL_SUBTEST_5( corners(MatrixXf(21, 20)) ); + + CALL_SUBTEST_1(( corners_fixedsize, 1, 1, 0, 0>() )); + CALL_SUBTEST_2(( corners_fixedsize() )); + CALL_SUBTEST_3(( corners_fixedsize,4,7,5,2>() )); + } +} diff --git a/include/eigen/test/ctorleak.cpp b/include/eigen/test/ctorleak.cpp new file mode 100644 index 0000000000000000000000000000000000000000..73904176bf0d9f1b37e0324eb6ba611cfb68b851 --- /dev/null +++ b/include/eigen/test/ctorleak.cpp @@ -0,0 +1,81 @@ +#include "main.h" + +#include // std::exception + +struct Foo +{ + static Index object_count; + static Index object_limit; + int dummy; + + Foo() : dummy(0) + { +#ifdef EIGEN_EXCEPTIONS + // TODO: Is this the correct way to handle this? + if (Foo::object_count > Foo::object_limit) { std::cout << "\nThrow!\n"; throw Foo::Fail(); } +#endif + std::cout << '+'; + ++Foo::object_count; + } + + ~Foo() + { + std::cout << '-'; + --Foo::object_count; + } + + class Fail : public std::exception {}; +}; + +Index Foo::object_count = 0; +Index Foo::object_limit = 0; + +#undef EIGEN_TEST_MAX_SIZE +#define EIGEN_TEST_MAX_SIZE 3 + +EIGEN_DECLARE_TEST(ctorleak) +{ + typedef Matrix MatrixX; + typedef Matrix VectorX; + + Foo::object_count = 0; + for(int i = 0; i < g_repeat; i++) { + Index rows = internal::random(2,EIGEN_TEST_MAX_SIZE), cols = internal::random(2,EIGEN_TEST_MAX_SIZE); + Foo::object_limit = rows*cols; + { + MatrixX r(rows, cols); + Foo::object_limit = r.size()+internal::random(0, rows*cols - 2); + std::cout << "object_limit =" << Foo::object_limit << std::endl; +#ifdef EIGEN_EXCEPTIONS + try + { +#endif + if(internal::random()) { + std::cout << "\nMatrixX m(" << rows << ", " << cols << ");\n"; + MatrixX m(rows, cols); + } + else { + std::cout << "\nMatrixX m(r);\n"; + MatrixX m(r); + } +#ifdef EIGEN_EXCEPTIONS + VERIFY(false); // not reached if exceptions are enabled + } + catch (const Foo::Fail&) { /* ignore */ } +#endif + } + VERIFY_IS_EQUAL(Index(0), Foo::object_count); + + { + Foo::object_limit = (rows+1)*(cols+1); + MatrixX A(rows, cols); + VERIFY_IS_EQUAL(Foo::object_count, rows*cols); + VectorX v=A.row(0); + VERIFY_IS_EQUAL(Foo::object_count, (rows+1)*cols); + v = A.col(0); + VERIFY_IS_EQUAL(Foo::object_count, rows*(cols+1)); + } + VERIFY_IS_EQUAL(Index(0), Foo::object_count); + } + std::cout << "\n"; +} diff --git a/include/eigen/test/dense_storage.cpp b/include/eigen/test/dense_storage.cpp new file mode 100644 index 0000000000000000000000000000000000000000..45c2bd728a993ee4747901536aea2876cbf18126 --- /dev/null +++ b/include/eigen/test/dense_storage.cpp @@ -0,0 +1,190 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2013 Hauke Heibel +// +// 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/. + +#include "main.h" +#include "AnnoyingScalar.h" +#include "SafeScalar.h" + +#include + +#if EIGEN_HAS_TYPE_TRAITS && EIGEN_HAS_CXX11 +using DenseStorageD3x3 = Eigen::DenseStorage; +static_assert(std::is_trivially_move_constructible::value, "DenseStorage not trivially_move_constructible"); +static_assert(std::is_trivially_move_assignable::value, "DenseStorage not trivially_move_assignable"); +#if !defined(EIGEN_DENSE_STORAGE_CTOR_PLUGIN) +static_assert(std::is_trivially_copy_constructible::value, "DenseStorage not trivially_copy_constructible"); +static_assert(std::is_trivially_copy_assignable::value, "DenseStorage not trivially_copy_assignable"); +static_assert(std::is_trivially_copyable::value, "DenseStorage not trivially_copyable"); +#endif +#endif + +template +void dense_storage_copy(int rows, int cols) +{ + typedef DenseStorage DenseStorageType; + + const int size = rows*cols; + DenseStorageType reference(size, rows, cols); + T* raw_reference = reference.data(); + for (int i=0; i(i); + + DenseStorageType copied_reference(reference); + const T* raw_copied_reference = copied_reference.data(); + for (int i=0; i +void dense_storage_assignment(int rows, int cols) +{ + typedef DenseStorage DenseStorageType; + + const int size = rows*cols; + DenseStorageType reference(size, rows, cols); + T* raw_reference = reference.data(); + for (int i=0; i(i); + + DenseStorageType copied_reference; + copied_reference = reference; + const T* raw_copied_reference = copied_reference.data(); + for (int i=0; i +void dense_storage_swap(int rows0, int cols0, int rows1, int cols1) +{ + typedef DenseStorage DenseStorageType; + + const int size0 = rows0*cols0; + DenseStorageType a(size0, rows0, cols0); + for (int i=0; i(i); + } + + const int size1 = rows1*cols1; + DenseStorageType b(size1, rows1, cols1); + for (int i=0; i(-i); + } + + a.swap(b); + + for (int i=0; i(i)); + } + + for (int i=0; i(-i)); + } +} + +template +void dense_storage_alignment() +{ + #if EIGEN_HAS_ALIGNAS + + struct alignas(Alignment) Empty1 {}; + VERIFY_IS_EQUAL(std::alignment_of::value, Alignment); + + struct EIGEN_ALIGN_TO_BOUNDARY(Alignment) Empty2 {}; + VERIFY_IS_EQUAL(std::alignment_of::value, Alignment); + + struct Nested1 { EIGEN_ALIGN_TO_BOUNDARY(Alignment) T data[Size]; }; + VERIFY_IS_EQUAL(std::alignment_of::value, Alignment); + + VERIFY_IS_EQUAL( (std::alignment_of >::value), Alignment); + + const std::size_t default_alignment = internal::compute_default_alignment::value; + + VERIFY_IS_EQUAL( (std::alignment_of >::value), default_alignment); + VERIFY_IS_EQUAL( (std::alignment_of >::value), default_alignment); + struct Nested2 { Matrix mat; }; + VERIFY_IS_EQUAL(std::alignment_of::value, default_alignment); + + #endif +} + +template +void dense_storage_tests() { + // Dynamic Storage. + dense_storage_copy(4, 3); + dense_storage_copy(4, 3); + dense_storage_copy(4, 3); + // Fixed Storage. + dense_storage_copy(4, 3); + dense_storage_copy(4, 3); + dense_storage_copy(4, 3); + dense_storage_copy(4, 3); + // Fixed Storage with Uninitialized Elements. + dense_storage_copy(4, 3); + dense_storage_copy(4, 3); + dense_storage_copy(4, 3); + + // Dynamic Storage. + dense_storage_assignment(4, 3); + dense_storage_assignment(4, 3); + dense_storage_assignment(4, 3); + // Fixed Storage. + dense_storage_assignment(4, 3); + dense_storage_assignment(4, 3); + dense_storage_assignment(4, 3); + dense_storage_assignment(4, 3); + // Fixed Storage with Uninitialized Elements. + dense_storage_assignment(4, 3); + dense_storage_assignment(4, 3); + dense_storage_assignment(4, 3); + + // Dynamic Storage. + dense_storage_swap(4, 3, 4, 3); + dense_storage_swap(4, 3, 2, 1); + dense_storage_swap(2, 1, 4, 3); + dense_storage_swap(4, 3, 4, 3); + dense_storage_swap(4, 3, 2, 3); + dense_storage_swap(2, 3, 4, 3); + dense_storage_swap(4, 3, 4, 3); + dense_storage_swap(4, 3, 4, 1); + dense_storage_swap(4, 1, 4, 3); + // Fixed Storage. + dense_storage_swap(4, 3, 4, 3); + dense_storage_swap(4, 3, 4, 3); + dense_storage_swap(4, 3, 2, 1); + dense_storage_swap(2, 1, 4, 3); + dense_storage_swap(4, 3, 4, 3); + dense_storage_swap(4, 3, 4, 1); + dense_storage_swap(4, 1, 4, 3); + dense_storage_swap(4, 3, 4, 3); + dense_storage_swap(4, 3, 2, 3); + dense_storage_swap(2, 3, 4, 3); + // Fixed Storage with Uninitialized Elements. + dense_storage_swap(4, 3, 4, 3); + dense_storage_swap(4, 3, 2, 1); + dense_storage_swap(2, 1, 4, 3); + dense_storage_swap(4, 3, 4, 3); + dense_storage_swap(4, 3, 4, 1); + dense_storage_swap(4, 1, 4, 3); + dense_storage_swap(4, 3, 4, 3); + dense_storage_swap(4, 3, 2, 3); + dense_storage_swap(2, 3, 4, 3); + + dense_storage_alignment(); + dense_storage_alignment(); + dense_storage_alignment(); + dense_storage_alignment(); +} + +EIGEN_DECLARE_TEST(dense_storage) +{ + dense_storage_tests(); + dense_storage_tests(); + dense_storage_tests >(); + dense_storage_tests(); +} diff --git a/include/eigen/test/determinant.cpp b/include/eigen/test/determinant.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7dd33c37389aa6b6ccdb8768a26696d3159e67b9 --- /dev/null +++ b/include/eigen/test/determinant.cpp @@ -0,0 +1,66 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2008 Benoit Jacob +// Copyright (C) 2008 Gael Guennebaud +// +// 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/. + +#include "main.h" +#include + +template void determinant(const MatrixType& m) +{ + /* this test covers the following files: + Determinant.h + */ + Index size = m.rows(); + + MatrixType m1(size, size), m2(size, size); + m1.setRandom(); + m2.setRandom(); + typedef typename MatrixType::Scalar Scalar; + Scalar x = internal::random(); + 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(0, size-1); + Index j; + do { + j = internal::random(0, size-1); + } while(j==i); + m2 = m1; + m2.row(i).swap(m2.row(j)); + VERIFY_IS_APPROX(m2.determinant(), -m1.determinant()); + m2 = m1; + m2.col(i).swap(m2.col(j)); + VERIFY_IS_APPROX(m2.determinant(), -m1.determinant()); + 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); + 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)); +} + +EIGEN_DECLARE_TEST(determinant) +{ + for(int i = 0; i < g_repeat; i++) { + int s = 0; + CALL_SUBTEST_1( determinant(Matrix()) ); + CALL_SUBTEST_2( determinant(Matrix()) ); + CALL_SUBTEST_3( determinant(Matrix()) ); + CALL_SUBTEST_4( determinant(Matrix()) ); + CALL_SUBTEST_5( determinant(Matrix, 10, 10>()) ); + s = internal::random(1,EIGEN_TEST_MAX_SIZE/4); + CALL_SUBTEST_6( determinant(MatrixXd(s, s)) ); + TEST_SET_BUT_UNUSED_VARIABLE(s) + } +} diff --git a/include/eigen/test/dontalign.cpp b/include/eigen/test/dontalign.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2e4102b86f63ad8c0e96b2ab1c039e4c08b4fe23 --- /dev/null +++ b/include/eigen/test/dontalign.cpp @@ -0,0 +1,62 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2011 Benoit Jacob +// +// 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/. + +#if defined EIGEN_TEST_PART_1 || defined EIGEN_TEST_PART_2 || defined EIGEN_TEST_PART_3 || defined EIGEN_TEST_PART_4 +#define EIGEN_DONT_ALIGN +#elif defined EIGEN_TEST_PART_5 || defined EIGEN_TEST_PART_6 || defined EIGEN_TEST_PART_7 || defined EIGEN_TEST_PART_8 +#define EIGEN_DONT_ALIGN_STATICALLY +#endif + +#include "main.h" +#include + +template +void dontalign(const MatrixType& m) +{ + typedef typename MatrixType::Scalar Scalar; + typedef Matrix VectorType; + typedef Matrix SquareMatrixType; + + Index rows = m.rows(); + Index cols = m.cols(); + + MatrixType a = MatrixType::Random(rows,cols); + SquareMatrixType square = SquareMatrixType::Random(rows,rows); + VectorType v = VectorType::Random(rows); + + VERIFY_IS_APPROX(v, square * square.colPivHouseholderQr().solve(v)); + square = square.inverse().eval(); + a = square * a; + square = square*square; + v = square * v; + v = a.adjoint() * v; + VERIFY(square.determinant() != Scalar(0)); + + // bug 219: MapAligned() was giving an assert with EIGEN_DONT_ALIGN, because Map Flags were miscomputed + Scalar* array = internal::aligned_new(rows); + v = VectorType::MapAligned(array, rows); + internal::aligned_delete(array, rows); +} + +EIGEN_DECLARE_TEST(dontalign) +{ +#if defined EIGEN_TEST_PART_1 || defined EIGEN_TEST_PART_5 + dontalign(Matrix3d()); + dontalign(Matrix4f()); +#elif defined EIGEN_TEST_PART_2 || defined EIGEN_TEST_PART_6 + dontalign(Matrix3cd()); + dontalign(Matrix4cf()); +#elif defined EIGEN_TEST_PART_3 || defined EIGEN_TEST_PART_7 + dontalign(Matrix()); + dontalign(Matrix, 32, 32>()); +#elif defined EIGEN_TEST_PART_4 || defined EIGEN_TEST_PART_8 + dontalign(MatrixXd(32, 32)); + dontalign(MatrixXcf(32, 32)); +#endif +} diff --git a/include/eigen/test/dynalloc.cpp b/include/eigen/test/dynalloc.cpp new file mode 100644 index 0000000000000000000000000000000000000000..23c90a7b5e901a2916b2ff7a418bcf51dad98a36 --- /dev/null +++ b/include/eigen/test/dynalloc.cpp @@ -0,0 +1,177 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2008 Gael Guennebaud +// +// 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/. + +#include "main.h" + +#if EIGEN_MAX_ALIGN_BYTES>0 +#define ALIGNMENT EIGEN_MAX_ALIGN_BYTES +#else +#define ALIGNMENT 1 +#endif + +typedef Matrix Vector16f; +typedef Matrix Vector8f; + +void check_handmade_aligned_malloc() +{ + for(int i = 1; i < 1000; i++) + { + char *p = (char*)internal::handmade_aligned_malloc(i); + VERIFY(internal::UIntPtr(p)%ALIGNMENT==0); + // if the buffer is wrongly allocated this will give a bad write --> check with valgrind + for(int j = 0; j < i; j++) p[j]=0; + internal::handmade_aligned_free(p); + } +} + +void check_aligned_malloc() +{ + for(int i = ALIGNMENT; i < 1000; i++) + { + char *p = (char*)internal::aligned_malloc(i); + VERIFY(internal::UIntPtr(p)%ALIGNMENT==0); + // if the buffer is wrongly allocated this will give a bad write --> check with valgrind + for(int j = 0; j < i; j++) p[j]=0; + internal::aligned_free(p); + } +} + +void check_aligned_new() +{ + for(int i = ALIGNMENT; i < 1000; i++) + { + float *p = internal::aligned_new(i); + VERIFY(internal::UIntPtr(p)%ALIGNMENT==0); + // if the buffer is wrongly allocated this will give a bad write --> check with valgrind + for(int j = 0; j < i; j++) p[j]=0; + internal::aligned_delete(p,i); + } +} + +void check_aligned_stack_alloc() +{ + for(int i = ALIGNMENT; i < 400; i++) + { + ei_declare_aligned_stack_constructed_variable(float,p,i,0); + VERIFY(internal::UIntPtr(p)%ALIGNMENT==0); + // if the buffer is wrongly allocated this will give a bad write --> check with valgrind + for(int j = 0; j < i; j++) p[j]=0; + } +} + + +// test compilation with both a struct and a class... +struct MyStruct +{ + EIGEN_MAKE_ALIGNED_OPERATOR_NEW + char dummychar; + Vector16f avec; +}; + +class MyClassA +{ + public: + EIGEN_MAKE_ALIGNED_OPERATOR_NEW + char dummychar; + Vector16f avec; +}; + +template void check_dynaligned() +{ + // TODO have to be updated once we support multiple alignment values + if(T::SizeAtCompileTime % ALIGNMENT == 0) + { + T* obj = new T; + VERIFY(T::NeedsToAlign==1); + VERIFY(internal::UIntPtr(obj)%ALIGNMENT==0); + delete obj; + } +} + +template void check_custom_new_delete() +{ + { + T* t = new T; + delete t; + } + + { + std::size_t N = internal::random(1,10); + T* t = new T[N]; + delete[] t; + } + +#if EIGEN_MAX_ALIGN_BYTES>0 && (!EIGEN_HAS_CXX17_OVERALIGN) + { + T* t = static_cast((T::operator new)(sizeof(T))); + (T::operator delete)(t, sizeof(T)); + } + + { + T* t = static_cast((T::operator new)(sizeof(T))); + (T::operator delete)(t); + } +#endif +} + +EIGEN_DECLARE_TEST(dynalloc) +{ + // low level dynamic memory allocation + CALL_SUBTEST(check_handmade_aligned_malloc()); + CALL_SUBTEST(check_aligned_malloc()); + CALL_SUBTEST(check_aligned_new()); + CALL_SUBTEST(check_aligned_stack_alloc()); + + for (int i=0; i() ); + CALL_SUBTEST( check_custom_new_delete() ); + CALL_SUBTEST( check_custom_new_delete() ); + CALL_SUBTEST( check_custom_new_delete() ); + } + + // check static allocation, who knows ? + #if EIGEN_MAX_STATIC_ALIGN_BYTES + for (int i=0; i() ); + CALL_SUBTEST(check_dynaligned() ); + CALL_SUBTEST(check_dynaligned() ); + CALL_SUBTEST(check_dynaligned() ); + CALL_SUBTEST(check_dynaligned() ); + CALL_SUBTEST(check_dynaligned() ); + CALL_SUBTEST(check_dynaligned() ); + } + + { + MyStruct foo0; VERIFY(internal::UIntPtr(foo0.avec.data())%ALIGNMENT==0); + MyClassA fooA; VERIFY(internal::UIntPtr(fooA.avec.data())%ALIGNMENT==0); + } + + // dynamic allocation, single object + for (int i=0; iavec.data())%ALIGNMENT==0); + MyClassA *fooA = new MyClassA(); VERIFY(internal::UIntPtr(fooA->avec.data())%ALIGNMENT==0); + delete foo0; + delete fooA; + } + + // dynamic allocation, array + const int N = 10; + for (int i=0; iavec.data())%ALIGNMENT==0); + MyClassA *fooA = new MyClassA[N]; VERIFY(internal::UIntPtr(fooA->avec.data())%ALIGNMENT==0); + delete[] foo0; + delete[] fooA; + } + #endif + +} diff --git a/include/eigen/test/eigensolver_complex.cpp b/include/eigen/test/eigensolver_complex.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c5373f420e482f390f5efdfea516462840cffee9 --- /dev/null +++ b/include/eigen/test/eigensolver_complex.cpp @@ -0,0 +1,176 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2008-2009 Gael Guennebaud +// Copyright (C) 2010 Jitse Niesen +// +// 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/. + +#include "main.h" +#include +#include +#include + +template bool find_pivot(typename MatrixType::Scalar tol, MatrixType &diffs, Index col=0) +{ + bool match = diffs.diagonal().sum() <= tol; + if(match || col==diffs.cols()) + { + return match; + } + else + { + Index n = diffs.cols(); + std::vector > transpositions; + for(Index i=col; i tol) + break; + + best_index += col; + + diffs.row(col).swap(diffs.row(best_index)); + if(find_pivot(tol,diffs,col+1)) return true; + diffs.row(col).swap(diffs.row(best_index)); + + // move current pivot to the end + diffs.row(n-(i-col)-1).swap(diffs.row(best_index)); + transpositions.push_back(std::pair(n-(i-col)-1,best_index)); + } + // restore + for(Index k=transpositions.size()-1; k>=0; --k) + diffs.row(transpositions[k].first).swap(diffs.row(transpositions[k].second)); + } + return false; +} + +/* Check that two column vectors are approximately equal up to permutations. + * Initially, this method checked that the k-th power sums are equal for all k = 1, ..., vec1.rows(), + * however this strategy is numerically inacurate because of numerical cancellation issues. + */ +template +void verify_is_approx_upto_permutation(const VectorType& vec1, const VectorType& vec2) +{ + typedef typename VectorType::Scalar Scalar; + typedef typename NumTraits::Real RealScalar; + + VERIFY(vec1.cols() == 1); + VERIFY(vec2.cols() == 1); + VERIFY(vec1.rows() == vec2.rows()); + + Index n = vec1.rows(); + RealScalar tol = test_precision()*test_precision()*numext::maxi(vec1.squaredNorm(),vec2.squaredNorm()); + Matrix diffs = (vec1.rowwise().replicate(n) - vec2.rowwise().replicate(n).transpose()).cwiseAbs2(); + + VERIFY( find_pivot(tol, diffs) ); +} + + +template void eigensolver(const MatrixType& m) +{ + /* this test covers the following files: + ComplexEigenSolver.h, and indirectly ComplexSchur.h + */ + Index rows = m.rows(); + Index cols = m.cols(); + + typedef typename MatrixType::Scalar Scalar; + typedef typename NumTraits::Real RealScalar; + + MatrixType a = MatrixType::Random(rows,cols); + MatrixType symmA = a.adjoint() * a; + + ComplexEigenSolver ei0(symmA); + VERIFY_IS_EQUAL(ei0.info(), Success); + VERIFY_IS_APPROX(symmA * ei0.eigenvectors(), ei0.eigenvectors() * ei0.eigenvalues().asDiagonal()); + + ComplexEigenSolver ei1(a); + VERIFY_IS_EQUAL(ei1.info(), Success); + VERIFY_IS_APPROX(a * ei1.eigenvectors(), ei1.eigenvectors() * ei1.eigenvalues().asDiagonal()); + // Note: If MatrixType is real then a.eigenvalues() uses EigenSolver and thus + // another algorithm so results may differ slightly + verify_is_approx_upto_permutation(a.eigenvalues(), ei1.eigenvalues()); + + ComplexEigenSolver ei2; + ei2.setMaxIterations(ComplexSchur::m_maxIterationsPerRow * rows).compute(a); + VERIFY_IS_EQUAL(ei2.info(), Success); + VERIFY_IS_EQUAL(ei2.eigenvectors(), ei1.eigenvectors()); + VERIFY_IS_EQUAL(ei2.eigenvalues(), ei1.eigenvalues()); + if (rows > 2) { + ei2.setMaxIterations(1).compute(a); + VERIFY_IS_EQUAL(ei2.info(), NoConvergence); + VERIFY_IS_EQUAL(ei2.getMaxIterations(), 1); + } + + ComplexEigenSolver eiNoEivecs(a, false); + VERIFY_IS_EQUAL(eiNoEivecs.info(), Success); + VERIFY_IS_APPROX(ei1.eigenvalues(), eiNoEivecs.eigenvalues()); + + // Regression test for issue #66 + MatrixType z = MatrixType::Zero(rows,cols); + ComplexEigenSolver eiz(z); + VERIFY((eiz.eigenvalues().cwiseEqual(0)).all()); + + MatrixType id = MatrixType::Identity(rows, cols); + VERIFY_IS_APPROX(id.operatorNorm(), RealScalar(1)); + + if (rows > 1 && rows < 20) + { + // Test matrix with NaN + a(0,0) = std::numeric_limits::quiet_NaN(); + ComplexEigenSolver eiNaN(a); + VERIFY_IS_EQUAL(eiNaN.info(), NoConvergence); + } + + // regression test for bug 1098 + { + ComplexEigenSolver eig(a.adjoint() * a); + eig.compute(a.adjoint() * a); + } + + // regression test for bug 478 + { + a.setZero(); + ComplexEigenSolver ei3(a); + VERIFY_IS_EQUAL(ei3.info(), Success); + VERIFY_IS_MUCH_SMALLER_THAN(ei3.eigenvalues().norm(),RealScalar(1)); + VERIFY((ei3.eigenvectors().transpose()*ei3.eigenvectors().transpose()).eval().isIdentity()); + } +} + +template void eigensolver_verify_assert(const MatrixType& m) +{ + ComplexEigenSolver eig; + VERIFY_RAISES_ASSERT(eig.eigenvectors()); + VERIFY_RAISES_ASSERT(eig.eigenvalues()); + + MatrixType a = MatrixType::Random(m.rows(),m.cols()); + eig.compute(a, false); + VERIFY_RAISES_ASSERT(eig.eigenvectors()); +} + +EIGEN_DECLARE_TEST(eigensolver_complex) +{ + int s = 0; + for(int i = 0; i < g_repeat; i++) { + CALL_SUBTEST_1( eigensolver(Matrix4cf()) ); + s = internal::random(1,EIGEN_TEST_MAX_SIZE/4); + CALL_SUBTEST_2( eigensolver(MatrixXcd(s,s)) ); + CALL_SUBTEST_3( eigensolver(Matrix, 1, 1>()) ); + CALL_SUBTEST_4( eigensolver(Matrix3f()) ); + TEST_SET_BUT_UNUSED_VARIABLE(s) + } + CALL_SUBTEST_1( eigensolver_verify_assert(Matrix4cf()) ); + s = internal::random(1,EIGEN_TEST_MAX_SIZE/4); + CALL_SUBTEST_2( eigensolver_verify_assert(MatrixXcd(s,s)) ); + CALL_SUBTEST_3( eigensolver_verify_assert(Matrix, 1, 1>()) ); + CALL_SUBTEST_4( eigensolver_verify_assert(Matrix3f()) ); + + // Test problem size constructors + CALL_SUBTEST_5(ComplexEigenSolver tmp(s)); + + TEST_SET_BUT_UNUSED_VARIABLE(s) +} diff --git a/include/eigen/test/eigensolver_generic.cpp b/include/eigen/test/eigensolver_generic.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7adb986658675525847cf40eb9b74cbb18d52f08 --- /dev/null +++ b/include/eigen/test/eigensolver_generic.cpp @@ -0,0 +1,247 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2008 Gael Guennebaud +// Copyright (C) 2010,2012 Jitse Niesen +// +// 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/. + +#include "main.h" +#include +#include + +template +void check_eigensolver_for_given_mat(const EigType &eig, const MatType& a) +{ + typedef typename NumTraits::Real RealScalar; + typedef Matrix RealVectorType; + typedef typename std::complex Complex; + Index n = a.rows(); + VERIFY_IS_EQUAL(eig.info(), Success); + VERIFY_IS_APPROX(a * eig.pseudoEigenvectors(), eig.pseudoEigenvectors() * eig.pseudoEigenvalueMatrix()); + VERIFY_IS_APPROX(a.template cast() * eig.eigenvectors(), + eig.eigenvectors() * eig.eigenvalues().asDiagonal()); + VERIFY_IS_APPROX(eig.eigenvectors().colwise().norm(), RealVectorType::Ones(n).transpose()); + VERIFY_IS_APPROX(a.eigenvalues(), eig.eigenvalues()); +} + +template void eigensolver(const MatrixType& m) +{ + /* this test covers the following files: + EigenSolver.h + */ + Index rows = m.rows(); + Index cols = m.cols(); + + typedef typename MatrixType::Scalar Scalar; + typedef typename NumTraits::Real RealScalar; + typedef typename std::complex Complex; + + MatrixType a = MatrixType::Random(rows,cols); + MatrixType a1 = MatrixType::Random(rows,cols); + MatrixType symmA = a.adjoint() * a + a1.adjoint() * a1; + + EigenSolver ei0(symmA); + VERIFY_IS_EQUAL(ei0.info(), Success); + VERIFY_IS_APPROX(symmA * ei0.pseudoEigenvectors(), ei0.pseudoEigenvectors() * ei0.pseudoEigenvalueMatrix()); + VERIFY_IS_APPROX((symmA.template cast()) * (ei0.pseudoEigenvectors().template cast()), + (ei0.pseudoEigenvectors().template cast()) * (ei0.eigenvalues().asDiagonal())); + + EigenSolver ei1(a); + CALL_SUBTEST( check_eigensolver_for_given_mat(ei1,a) ); + + EigenSolver ei2; + ei2.setMaxIterations(RealSchur::m_maxIterationsPerRow * rows).compute(a); + VERIFY_IS_EQUAL(ei2.info(), Success); + VERIFY_IS_EQUAL(ei2.eigenvectors(), ei1.eigenvectors()); + VERIFY_IS_EQUAL(ei2.eigenvalues(), ei1.eigenvalues()); + if (rows > 2) { + ei2.setMaxIterations(1).compute(a); + VERIFY_IS_EQUAL(ei2.info(), NoConvergence); + VERIFY_IS_EQUAL(ei2.getMaxIterations(), 1); + } + + EigenSolver eiNoEivecs(a, false); + VERIFY_IS_EQUAL(eiNoEivecs.info(), Success); + VERIFY_IS_APPROX(ei1.eigenvalues(), eiNoEivecs.eigenvalues()); + VERIFY_IS_APPROX(ei1.pseudoEigenvalueMatrix(), eiNoEivecs.pseudoEigenvalueMatrix()); + + MatrixType id = MatrixType::Identity(rows, cols); + VERIFY_IS_APPROX(id.operatorNorm(), RealScalar(1)); + + if (rows > 2 && rows < 20) + { + // Test matrix with NaN + a(0,0) = std::numeric_limits::quiet_NaN(); + EigenSolver eiNaN(a); + VERIFY_IS_NOT_EQUAL(eiNaN.info(), Success); + } + + // regression test for bug 1098 + { + EigenSolver eig(a.adjoint() * a); + eig.compute(a.adjoint() * a); + } + + // regression test for bug 478 + { + a.setZero(); + EigenSolver ei3(a); + VERIFY_IS_EQUAL(ei3.info(), Success); + VERIFY_IS_MUCH_SMALLER_THAN(ei3.eigenvalues().norm(),RealScalar(1)); + VERIFY((ei3.eigenvectors().transpose()*ei3.eigenvectors().transpose()).eval().isIdentity()); + } +} + +template void eigensolver_verify_assert(const MatrixType& m) +{ + EigenSolver eig; + VERIFY_RAISES_ASSERT(eig.eigenvectors()); + VERIFY_RAISES_ASSERT(eig.pseudoEigenvectors()); + VERIFY_RAISES_ASSERT(eig.pseudoEigenvalueMatrix()); + VERIFY_RAISES_ASSERT(eig.eigenvalues()); + + MatrixType a = MatrixType::Random(m.rows(),m.cols()); + eig.compute(a, false); + VERIFY_RAISES_ASSERT(eig.eigenvectors()); + VERIFY_RAISES_ASSERT(eig.pseudoEigenvectors()); +} + + +template +Matrix +make_companion(const CoeffType& coeffs) +{ + Index n = coeffs.size()-1; + Matrix res(n,n); + res.setZero(); + res.row(0) = -coeffs.tail(n) / coeffs(0); + res.diagonal(-1).setOnes(); + return res; +} + +template +void eigensolver_generic_extra() +{ + { + // regression test for bug 793 + MatrixXd a(3,3); + a << 0, 0, 1, + 1, 1, 1, + 1, 1e+200, 1; + Eigen::EigenSolver eig(a); + double scale = 1e-200; // scale to avoid overflow during the comparisons + VERIFY_IS_APPROX(a * eig.pseudoEigenvectors()*scale, eig.pseudoEigenvectors() * eig.pseudoEigenvalueMatrix()*scale); + VERIFY_IS_APPROX(a * eig.eigenvectors()*scale, eig.eigenvectors() * eig.eigenvalues().asDiagonal()*scale); + } + { + // check a case where all eigenvalues are null. + MatrixXd a(2,2); + a << 1, 1, + -1, -1; + Eigen::EigenSolver eig(a); + VERIFY_IS_APPROX(eig.pseudoEigenvectors().squaredNorm(), 2.); + VERIFY_IS_APPROX((a * eig.pseudoEigenvectors()).norm()+1., 1.); + VERIFY_IS_APPROX((eig.pseudoEigenvectors() * eig.pseudoEigenvalueMatrix()).norm()+1., 1.); + VERIFY_IS_APPROX((a * eig.eigenvectors()).norm()+1., 1.); + VERIFY_IS_APPROX((eig.eigenvectors() * eig.eigenvalues().asDiagonal()).norm()+1., 1.); + } + + // regression test for bug 933 + { + { + VectorXd coeffs(5); coeffs << 1, -3, -175, -225, 2250; + MatrixXd C = make_companion(coeffs); + EigenSolver eig(C); + CALL_SUBTEST( check_eigensolver_for_given_mat(eig,C) ); + } + { + // this test is tricky because it requires high accuracy in smallest eigenvalues + VectorXd coeffs(5); coeffs << 6.154671e-15, -1.003870e-10, -9.819570e-01, 3.995715e+03, 2.211511e+08; + MatrixXd C = make_companion(coeffs); + EigenSolver eig(C); + CALL_SUBTEST( check_eigensolver_for_given_mat(eig,C) ); + Index n = C.rows(); + for(Index i=0;i Complex; + MatrixXcd ac = C.cast(); + ac.diagonal().array() -= eig.eigenvalues()(i); + VectorXd sv = ac.jacobiSvd().singularValues(); + // comparing to sv(0) is not enough here to catch the "bug", + // the hard-coded 1.0 is important! + VERIFY_IS_MUCH_SMALLER_THAN(sv(n-1), 1.0); + } + } + } + // regression test for bug 1557 + { + // this test is interesting because it contains zeros on the diagonal. + MatrixXd A_bug1557(3,3); + A_bug1557 << 0, 0, 0, 1, 0, 0.5887907064808635127, 0, 1, 0; + EigenSolver eig(A_bug1557); + CALL_SUBTEST( check_eigensolver_for_given_mat(eig,A_bug1557) ); + } + + // regression test for bug 1174 + { + Index n = 12; + MatrixXf A_bug1174(n,n); + A_bug1174 << 262144, 0, 0, 262144, 786432, 0, 0, 0, 0, 0, 0, 786432, + 262144, 0, 0, 262144, 786432, 0, 0, 0, 0, 0, 0, 786432, + 262144, 0, 0, 262144, 786432, 0, 0, 0, 0, 0, 0, 786432, + 262144, 0, 0, 262144, 786432, 0, 0, 0, 0, 0, 0, 786432, + 0, 262144, 262144, 0, 0, 262144, 262144, 262144, 262144, 262144, 262144, 0, + 0, 262144, 262144, 0, 0, 262144, 262144, 262144, 262144, 262144, 262144, 0, + 0, 262144, 262144, 0, 0, 262144, 262144, 262144, 262144, 262144, 262144, 0, + 0, 262144, 262144, 0, 0, 262144, 262144, 262144, 262144, 262144, 262144, 0, + 0, 262144, 262144, 0, 0, 262144, 262144, 262144, 262144, 262144, 262144, 0, + 0, 262144, 262144, 0, 0, 262144, 262144, 262144, 262144, 262144, 262144, 0, + 0, 262144, 262144, 0, 0, 262144, 262144, 262144, 262144, 262144, 262144, 0, + 0, 262144, 262144, 0, 0, 262144, 262144, 262144, 262144, 262144, 262144, 0; + EigenSolver eig(A_bug1174); + CALL_SUBTEST( check_eigensolver_for_given_mat(eig,A_bug1174) ); + } +} + +EIGEN_DECLARE_TEST(eigensolver_generic) +{ + int s = 0; + for(int i = 0; i < g_repeat; i++) { + CALL_SUBTEST_1( eigensolver(Matrix4f()) ); + s = internal::random(1,EIGEN_TEST_MAX_SIZE/4); + CALL_SUBTEST_2( eigensolver(MatrixXd(s,s)) ); + TEST_SET_BUT_UNUSED_VARIABLE(s) + + // some trivial but implementation-wise tricky cases + CALL_SUBTEST_2( eigensolver(MatrixXd(1,1)) ); + CALL_SUBTEST_2( eigensolver(MatrixXd(2,2)) ); + CALL_SUBTEST_3( eigensolver(Matrix()) ); + CALL_SUBTEST_4( eigensolver(Matrix2d()) ); + } + + CALL_SUBTEST_1( eigensolver_verify_assert(Matrix4f()) ); + s = internal::random(1,EIGEN_TEST_MAX_SIZE/4); + CALL_SUBTEST_2( eigensolver_verify_assert(MatrixXd(s,s)) ); + CALL_SUBTEST_3( eigensolver_verify_assert(Matrix()) ); + CALL_SUBTEST_4( eigensolver_verify_assert(Matrix2d()) ); + + // Test problem size constructors + CALL_SUBTEST_5(EigenSolver tmp(s)); + + // regression test for bug 410 + CALL_SUBTEST_2( + { + MatrixXd A(1,1); + A(0,0) = std::sqrt(-1.); // is Not-a-Number + Eigen::EigenSolver solver(A); + VERIFY_IS_EQUAL(solver.info(), NumericalIssue); + } + ); + + CALL_SUBTEST_2( eigensolver_generic_extra<0>() ); + + TEST_SET_BUT_UNUSED_VARIABLE(s) +} diff --git a/include/eigen/test/evaluator_common.h b/include/eigen/test/evaluator_common.h new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/include/eigen/test/evaluators.cpp b/include/eigen/test/evaluators.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2810cd265187c27c669ee055f9a04528571a3664 --- /dev/null +++ b/include/eigen/test/evaluators.cpp @@ -0,0 +1,525 @@ + +#include "main.h" + +namespace Eigen { + + template + const Product + prod(const Lhs& lhs, const Rhs& rhs) + { + return Product(lhs,rhs); + } + + template + const Product + lazyprod(const Lhs& lhs, const Rhs& rhs) + { + return Product(lhs,rhs); + } + + template + EIGEN_STRONG_INLINE + DstXprType& copy_using_evaluator(const EigenBase &dst, const SrcXprType &src) + { + call_assignment(dst.const_cast_derived(), src.derived(), internal::assign_op()); + return dst.const_cast_derived(); + } + + template class StorageBase, typename SrcXprType> + EIGEN_STRONG_INLINE + const DstXprType& copy_using_evaluator(const NoAlias& dst, const SrcXprType &src) + { + call_assignment(dst, src.derived(), internal::assign_op()); + return dst.expression(); + } + + template + EIGEN_STRONG_INLINE + DstXprType& copy_using_evaluator(const PlainObjectBase &dst, const SrcXprType &src) + { + #ifdef EIGEN_NO_AUTOMATIC_RESIZING + eigen_assert((dst.size()==0 || (IsVectorAtCompileTime ? (dst.size() == src.size()) + : (dst.rows() == src.rows() && dst.cols() == src.cols()))) + && "Size mismatch. Automatic resizing is disabled because EIGEN_NO_AUTOMATIC_RESIZING is defined"); + #else + dst.const_cast_derived().resizeLike(src.derived()); + #endif + + call_assignment(dst.const_cast_derived(), src.derived(), internal::assign_op()); + return dst.const_cast_derived(); + } + + template + void add_assign_using_evaluator(const DstXprType& dst, const SrcXprType& src) + { + typedef typename DstXprType::Scalar Scalar; + call_assignment(const_cast(dst), src.derived(), internal::add_assign_op()); + } + + template + void subtract_assign_using_evaluator(const DstXprType& dst, const SrcXprType& src) + { + typedef typename DstXprType::Scalar Scalar; + call_assignment(const_cast(dst), src.derived(), internal::sub_assign_op()); + } + + template + void multiply_assign_using_evaluator(const DstXprType& dst, const SrcXprType& src) + { + typedef typename DstXprType::Scalar Scalar; + call_assignment(dst.const_cast_derived(), src.derived(), internal::mul_assign_op()); + } + + template + void divide_assign_using_evaluator(const DstXprType& dst, const SrcXprType& src) + { + typedef typename DstXprType::Scalar Scalar; + call_assignment(dst.const_cast_derived(), src.derived(), internal::div_assign_op()); + } + + template + void swap_using_evaluator(const DstXprType& dst, const SrcXprType& src) + { + typedef typename DstXprType::Scalar Scalar; + call_assignment(dst.const_cast_derived(), src.const_cast_derived(), internal::swap_assign_op()); + } + + namespace internal { + template class StorageBase, typename Src, typename Func> + EIGEN_DEVICE_FUNC void call_assignment(const NoAlias& dst, const Src& src, const Func& func) + { + call_assignment_no_alias(dst.expression(), src, func); + } + + template class StorageBase, typename Src, typename Func> + EIGEN_DEVICE_FUNC void call_restricted_packet_assignment(const NoAlias& dst, const Src& src, const Func& func) + { + call_restricted_packet_assignment_no_alias(dst.expression(), src, func); + } + } + +} + +template long get_cost(const XprType& ) { return Eigen::internal::evaluator::CoeffReadCost; } + +using namespace std; + +#define VERIFY_IS_APPROX_EVALUATOR(DEST,EXPR) VERIFY_IS_APPROX(copy_using_evaluator(DEST,(EXPR)), (EXPR).eval()); +#define VERIFY_IS_APPROX_EVALUATOR2(DEST,EXPR,REF) VERIFY_IS_APPROX(copy_using_evaluator(DEST,(EXPR)), (REF).eval()); + +EIGEN_DECLARE_TEST(evaluators) +{ + // Testing Matrix evaluator and Transpose + Vector2d v = Vector2d::Random(); + const Vector2d v_const(v); + Vector2d v2; + RowVector2d w; + + VERIFY_IS_APPROX_EVALUATOR(v2, v); + VERIFY_IS_APPROX_EVALUATOR(v2, v_const); + + // Testing Transpose + VERIFY_IS_APPROX_EVALUATOR(w, v.transpose()); // Transpose as rvalue + VERIFY_IS_APPROX_EVALUATOR(w, v_const.transpose()); + + copy_using_evaluator(w.transpose(), v); // Transpose as lvalue + VERIFY_IS_APPROX(w,v.transpose().eval()); + + copy_using_evaluator(w.transpose(), v_const); + VERIFY_IS_APPROX(w,v_const.transpose().eval()); + + // Testing Array evaluator + { + ArrayXXf a(2,3); + ArrayXXf b(3,2); + a << 1,2,3, 4,5,6; + const ArrayXXf a_const(a); + + VERIFY_IS_APPROX_EVALUATOR(b, a.transpose()); + + VERIFY_IS_APPROX_EVALUATOR(b, a_const.transpose()); + + // Testing CwiseNullaryOp evaluator + copy_using_evaluator(w, RowVector2d::Random()); + VERIFY((w.array() >= -1).all() && (w.array() <= 1).all()); // not easy to test ... + + VERIFY_IS_APPROX_EVALUATOR(w, RowVector2d::Zero()); + + VERIFY_IS_APPROX_EVALUATOR(w, RowVector2d::Constant(3)); + + // mix CwiseNullaryOp and transpose + VERIFY_IS_APPROX_EVALUATOR(w, Vector2d::Zero().transpose()); + } + + { + // test product expressions + int s = internal::random(1,100); + MatrixXf a(s,s), b(s,s), c(s,s), d(s,s); + a.setRandom(); + b.setRandom(); + c.setRandom(); + d.setRandom(); + VERIFY_IS_APPROX_EVALUATOR(d, (a + b)); + VERIFY_IS_APPROX_EVALUATOR(d, (a + b).transpose()); + VERIFY_IS_APPROX_EVALUATOR2(d, prod(a,b), a*b); + VERIFY_IS_APPROX_EVALUATOR2(d.noalias(), prod(a,b), a*b); + VERIFY_IS_APPROX_EVALUATOR2(d, prod(a,b) + c, a*b + c); + VERIFY_IS_APPROX_EVALUATOR2(d, s * prod(a,b), s * a*b); + VERIFY_IS_APPROX_EVALUATOR2(d, prod(a,b).transpose(), (a*b).transpose()); + VERIFY_IS_APPROX_EVALUATOR2(d, prod(a,b) + prod(b,c), a*b + b*c); + + // check that prod works even with aliasing present + c = a*a; + copy_using_evaluator(a, prod(a,a)); + VERIFY_IS_APPROX(a,c); + + // check compound assignment of products + d = c; + add_assign_using_evaluator(c.noalias(), prod(a,b)); + d.noalias() += a*b; + VERIFY_IS_APPROX(c, d); + + d = c; + subtract_assign_using_evaluator(c.noalias(), prod(a,b)); + d.noalias() -= a*b; + VERIFY_IS_APPROX(c, d); + } + + { + // test product with all possible sizes + int s = internal::random(1,100); + Matrix m11, res11; m11.setRandom(1,1); + Matrix m14, res14; m14.setRandom(1,4); + Matrix m1X, res1X; m1X.setRandom(1,s); + Matrix m41, res41; m41.setRandom(4,1); + Matrix m44, res44; m44.setRandom(4,4); + Matrix m4X, res4X; m4X.setRandom(4,s); + Matrix mX1, resX1; mX1.setRandom(s,1); + Matrix mX4, resX4; mX4.setRandom(s,4); + Matrix mXX, resXX; mXX.setRandom(s,s); + + VERIFY_IS_APPROX_EVALUATOR2(res11, prod(m11,m11), m11*m11); + VERIFY_IS_APPROX_EVALUATOR2(res11, prod(m14,m41), m14*m41); + VERIFY_IS_APPROX_EVALUATOR2(res11, prod(m1X,mX1), m1X*mX1); + VERIFY_IS_APPROX_EVALUATOR2(res14, prod(m11,m14), m11*m14); + VERIFY_IS_APPROX_EVALUATOR2(res14, prod(m14,m44), m14*m44); + VERIFY_IS_APPROX_EVALUATOR2(res14, prod(m1X,mX4), m1X*mX4); + VERIFY_IS_APPROX_EVALUATOR2(res1X, prod(m11,m1X), m11*m1X); + VERIFY_IS_APPROX_EVALUATOR2(res1X, prod(m14,m4X), m14*m4X); + VERIFY_IS_APPROX_EVALUATOR2(res1X, prod(m1X,mXX), m1X*mXX); + VERIFY_IS_APPROX_EVALUATOR2(res41, prod(m41,m11), m41*m11); + VERIFY_IS_APPROX_EVALUATOR2(res41, prod(m44,m41), m44*m41); + VERIFY_IS_APPROX_EVALUATOR2(res41, prod(m4X,mX1), m4X*mX1); + VERIFY_IS_APPROX_EVALUATOR2(res44, prod(m41,m14), m41*m14); + VERIFY_IS_APPROX_EVALUATOR2(res44, prod(m44,m44), m44*m44); + VERIFY_IS_APPROX_EVALUATOR2(res44, prod(m4X,mX4), m4X*mX4); + VERIFY_IS_APPROX_EVALUATOR2(res4X, prod(m41,m1X), m41*m1X); + VERIFY_IS_APPROX_EVALUATOR2(res4X, prod(m44,m4X), m44*m4X); + VERIFY_IS_APPROX_EVALUATOR2(res4X, prod(m4X,mXX), m4X*mXX); + VERIFY_IS_APPROX_EVALUATOR2(resX1, prod(mX1,m11), mX1*m11); + VERIFY_IS_APPROX_EVALUATOR2(resX1, prod(mX4,m41), mX4*m41); + VERIFY_IS_APPROX_EVALUATOR2(resX1, prod(mXX,mX1), mXX*mX1); + VERIFY_IS_APPROX_EVALUATOR2(resX4, prod(mX1,m14), mX1*m14); + VERIFY_IS_APPROX_EVALUATOR2(resX4, prod(mX4,m44), mX4*m44); + VERIFY_IS_APPROX_EVALUATOR2(resX4, prod(mXX,mX4), mXX*mX4); + VERIFY_IS_APPROX_EVALUATOR2(resXX, prod(mX1,m1X), mX1*m1X); + VERIFY_IS_APPROX_EVALUATOR2(resXX, prod(mX4,m4X), mX4*m4X); + VERIFY_IS_APPROX_EVALUATOR2(resXX, prod(mXX,mXX), mXX*mXX); + } + + { + ArrayXXf a(2,3); + ArrayXXf b(3,2); + a << 1,2,3, 4,5,6; + const ArrayXXf a_const(a); + + // this does not work because Random is eval-before-nested: + // copy_using_evaluator(w, Vector2d::Random().transpose()); + + // test CwiseUnaryOp + VERIFY_IS_APPROX_EVALUATOR(v2, 3 * v); + VERIFY_IS_APPROX_EVALUATOR(w, (3 * v).transpose()); + VERIFY_IS_APPROX_EVALUATOR(b, (a + 3).transpose()); + VERIFY_IS_APPROX_EVALUATOR(b, (2 * a_const + 3).transpose()); + + // test CwiseBinaryOp + VERIFY_IS_APPROX_EVALUATOR(v2, v + Vector2d::Ones()); + VERIFY_IS_APPROX_EVALUATOR(w, (v + Vector2d::Ones()).transpose().cwiseProduct(RowVector2d::Constant(3))); + + // dynamic matrices and arrays + MatrixXd mat1(6,6), mat2(6,6); + VERIFY_IS_APPROX_EVALUATOR(mat1, MatrixXd::Identity(6,6)); + VERIFY_IS_APPROX_EVALUATOR(mat2, mat1); + copy_using_evaluator(mat2.transpose(), mat1); + VERIFY_IS_APPROX(mat2.transpose(), mat1); + + ArrayXXd arr1(6,6), arr2(6,6); + VERIFY_IS_APPROX_EVALUATOR(arr1, ArrayXXd::Constant(6,6, 3.0)); + VERIFY_IS_APPROX_EVALUATOR(arr2, arr1); + + // test automatic resizing + mat2.resize(3,3); + VERIFY_IS_APPROX_EVALUATOR(mat2, mat1); + arr2.resize(9,9); + VERIFY_IS_APPROX_EVALUATOR(arr2, arr1); + + // test direct traversal + Matrix3f m3; + Array33f a3; + VERIFY_IS_APPROX_EVALUATOR(m3, Matrix3f::Identity()); // matrix, nullary + // TODO: find a way to test direct traversal with array + VERIFY_IS_APPROX_EVALUATOR(m3.transpose(), Matrix3f::Identity().transpose()); // transpose + VERIFY_IS_APPROX_EVALUATOR(m3, 2 * Matrix3f::Identity()); // unary + VERIFY_IS_APPROX_EVALUATOR(m3, Matrix3f::Identity() + Matrix3f::Zero()); // binary + VERIFY_IS_APPROX_EVALUATOR(m3.block(0,0,2,2), Matrix3f::Identity().block(1,1,2,2)); // block + + // test linear traversal + VERIFY_IS_APPROX_EVALUATOR(m3, Matrix3f::Zero()); // matrix, nullary + VERIFY_IS_APPROX_EVALUATOR(a3, Array33f::Zero()); // array + VERIFY_IS_APPROX_EVALUATOR(m3.transpose(), Matrix3f::Zero().transpose()); // transpose + VERIFY_IS_APPROX_EVALUATOR(m3, 2 * Matrix3f::Zero()); // unary + VERIFY_IS_APPROX_EVALUATOR(m3, Matrix3f::Zero() + m3); // binary + + // test inner vectorization + Matrix4f m4, m4src = Matrix4f::Random(); + Array44f a4, a4src = Matrix4f::Random(); + VERIFY_IS_APPROX_EVALUATOR(m4, m4src); // matrix + VERIFY_IS_APPROX_EVALUATOR(a4, a4src); // array + VERIFY_IS_APPROX_EVALUATOR(m4.transpose(), m4src.transpose()); // transpose + // TODO: find out why Matrix4f::Zero() does not allow inner vectorization + VERIFY_IS_APPROX_EVALUATOR(m4, 2 * m4src); // unary + VERIFY_IS_APPROX_EVALUATOR(m4, m4src + m4src); // binary + + // test linear vectorization + MatrixXf mX(6,6), mXsrc = MatrixXf::Random(6,6); + ArrayXXf aX(6,6), aXsrc = ArrayXXf::Random(6,6); + VERIFY_IS_APPROX_EVALUATOR(mX, mXsrc); // matrix + VERIFY_IS_APPROX_EVALUATOR(aX, aXsrc); // array + VERIFY_IS_APPROX_EVALUATOR(mX.transpose(), mXsrc.transpose()); // transpose + VERIFY_IS_APPROX_EVALUATOR(mX, MatrixXf::Zero(6,6)); // nullary + VERIFY_IS_APPROX_EVALUATOR(mX, 2 * mXsrc); // unary + VERIFY_IS_APPROX_EVALUATOR(mX, mXsrc + mXsrc); // binary + + // test blocks and slice vectorization + VERIFY_IS_APPROX_EVALUATOR(m4, (mXsrc.block<4,4>(1,0))); + VERIFY_IS_APPROX_EVALUATOR(aX, ArrayXXf::Constant(10, 10, 3.0).block(2, 3, 6, 6)); + + Matrix4f m4ref = m4; + copy_using_evaluator(m4.block(1, 1, 2, 3), m3.bottomRows(2)); + m4ref.block(1, 1, 2, 3) = m3.bottomRows(2); + VERIFY_IS_APPROX(m4, m4ref); + + mX.setIdentity(20,20); + MatrixXf mXref = MatrixXf::Identity(20,20); + mXsrc = MatrixXf::Random(9,12); + copy_using_evaluator(mX.block(4, 4, 9, 12), mXsrc); + mXref.block(4, 4, 9, 12) = mXsrc; + VERIFY_IS_APPROX(mX, mXref); + + // test Map + const float raw[3] = {1,2,3}; + float buffer[3] = {0,0,0}; + Vector3f v3; + Array3f a3f; + VERIFY_IS_APPROX_EVALUATOR(v3, Map(raw)); + VERIFY_IS_APPROX_EVALUATOR(a3f, Map(raw)); + Vector3f::Map(buffer) = 2*v3; + VERIFY(buffer[0] == 2); + VERIFY(buffer[1] == 4); + VERIFY(buffer[2] == 6); + + // test CwiseUnaryView + mat1.setRandom(); + mat2.setIdentity(); + MatrixXcd matXcd(6,6), matXcd_ref(6,6); + copy_using_evaluator(matXcd.real(), mat1); + copy_using_evaluator(matXcd.imag(), mat2); + matXcd_ref.real() = mat1; + matXcd_ref.imag() = mat2; + VERIFY_IS_APPROX(matXcd, matXcd_ref); + + // test Select + VERIFY_IS_APPROX_EVALUATOR(aX, (aXsrc > 0).select(aXsrc, -aXsrc)); + + // test Replicate + mXsrc = MatrixXf::Random(6, 6); + VectorXf vX = VectorXf::Random(6); + mX.resize(6, 6); + VERIFY_IS_APPROX_EVALUATOR(mX, mXsrc.colwise() + vX); + matXcd.resize(12, 12); + VERIFY_IS_APPROX_EVALUATOR(matXcd, matXcd_ref.replicate(2,2)); + VERIFY_IS_APPROX_EVALUATOR(matXcd, (matXcd_ref.replicate<2,2>())); + + // test partial reductions + VectorXd vec1(6); + VERIFY_IS_APPROX_EVALUATOR(vec1, mat1.rowwise().sum()); + VERIFY_IS_APPROX_EVALUATOR(vec1, mat1.colwise().sum().transpose()); + + // test MatrixWrapper and ArrayWrapper + mat1.setRandom(6,6); + arr1.setRandom(6,6); + VERIFY_IS_APPROX_EVALUATOR(mat2, arr1.matrix()); + VERIFY_IS_APPROX_EVALUATOR(arr2, mat1.array()); + VERIFY_IS_APPROX_EVALUATOR(mat2, (arr1 + 2).matrix()); + VERIFY_IS_APPROX_EVALUATOR(arr2, mat1.array() + 2); + mat2.array() = arr1 * arr1; + VERIFY_IS_APPROX(mat2, (arr1 * arr1).matrix()); + arr2.matrix() = MatrixXd::Identity(6,6); + VERIFY_IS_APPROX(arr2, MatrixXd::Identity(6,6).array()); + + // test Reverse + VERIFY_IS_APPROX_EVALUATOR(arr2, arr1.reverse()); + VERIFY_IS_APPROX_EVALUATOR(arr2, arr1.colwise().reverse()); + VERIFY_IS_APPROX_EVALUATOR(arr2, arr1.rowwise().reverse()); + arr2.reverse() = arr1; + VERIFY_IS_APPROX(arr2, arr1.reverse()); + mat2.array() = mat1.array().reverse(); + VERIFY_IS_APPROX(mat2.array(), mat1.array().reverse()); + + // test Diagonal + VERIFY_IS_APPROX_EVALUATOR(vec1, mat1.diagonal()); + vec1.resize(5); + VERIFY_IS_APPROX_EVALUATOR(vec1, mat1.diagonal(1)); + VERIFY_IS_APPROX_EVALUATOR(vec1, mat1.diagonal<-1>()); + vec1.setRandom(); + + mat2 = mat1; + copy_using_evaluator(mat1.diagonal(1), vec1); + mat2.diagonal(1) = vec1; + VERIFY_IS_APPROX(mat1, mat2); + + copy_using_evaluator(mat1.diagonal<-1>(), mat1.diagonal(1)); + mat2.diagonal<-1>() = mat2.diagonal(1); + VERIFY_IS_APPROX(mat1, mat2); + } + + { + // test swapping + MatrixXd mat1, mat2, mat1ref, mat2ref; + mat1ref = mat1 = MatrixXd::Random(6, 6); + mat2ref = mat2 = 2 * mat1 + MatrixXd::Identity(6, 6); + swap_using_evaluator(mat1, mat2); + mat1ref.swap(mat2ref); + VERIFY_IS_APPROX(mat1, mat1ref); + VERIFY_IS_APPROX(mat2, mat2ref); + + swap_using_evaluator(mat1.block(0, 0, 3, 3), mat2.block(3, 3, 3, 3)); + mat1ref.block(0, 0, 3, 3).swap(mat2ref.block(3, 3, 3, 3)); + VERIFY_IS_APPROX(mat1, mat1ref); + VERIFY_IS_APPROX(mat2, mat2ref); + + swap_using_evaluator(mat1.row(2), mat2.col(3).transpose()); + mat1.row(2).swap(mat2.col(3).transpose()); + VERIFY_IS_APPROX(mat1, mat1ref); + VERIFY_IS_APPROX(mat2, mat2ref); + } + + { + // test compound assignment + const Matrix4d mat_const = Matrix4d::Random(); + Matrix4d mat, mat_ref; + mat = mat_ref = Matrix4d::Identity(); + add_assign_using_evaluator(mat, mat_const); + mat_ref += mat_const; + VERIFY_IS_APPROX(mat, mat_ref); + + subtract_assign_using_evaluator(mat.row(1), 2*mat.row(2)); + mat_ref.row(1) -= 2*mat_ref.row(2); + VERIFY_IS_APPROX(mat, mat_ref); + + const ArrayXXf arr_const = ArrayXXf::Random(5,3); + ArrayXXf arr, arr_ref; + arr = arr_ref = ArrayXXf::Constant(5, 3, 0.5); + multiply_assign_using_evaluator(arr, arr_const); + arr_ref *= arr_const; + VERIFY_IS_APPROX(arr, arr_ref); + + divide_assign_using_evaluator(arr.row(1), arr.row(2) + 1); + arr_ref.row(1) /= (arr_ref.row(2) + 1); + VERIFY_IS_APPROX(arr, arr_ref); + } + + { + // test triangular shapes + MatrixXd A = MatrixXd::Random(6,6), B(6,6), C(6,6), D(6,6); + A.setRandom();B.setRandom(); + VERIFY_IS_APPROX_EVALUATOR2(B, A.triangularView(), MatrixXd(A.triangularView())); + + A.setRandom();B.setRandom(); + VERIFY_IS_APPROX_EVALUATOR2(B, A.triangularView(), MatrixXd(A.triangularView())); + + A.setRandom();B.setRandom(); + VERIFY_IS_APPROX_EVALUATOR2(B, A.triangularView(), MatrixXd(A.triangularView())); + + A.setRandom();B.setRandom(); + C = B; C.triangularView() = A; + copy_using_evaluator(B.triangularView(), A); + VERIFY(B.isApprox(C) && "copy_using_evaluator(B.triangularView(), A)"); + + A.setRandom();B.setRandom(); + C = B; C.triangularView() = A.triangularView(); + copy_using_evaluator(B.triangularView(), A.triangularView()); + VERIFY(B.isApprox(C) && "copy_using_evaluator(B.triangularView(), A.triangularView())"); + + + A.setRandom();B.setRandom(); + C = B; C.triangularView() = A.triangularView().transpose(); + copy_using_evaluator(B.triangularView(), A.triangularView().transpose()); + VERIFY(B.isApprox(C) && "copy_using_evaluator(B.triangularView(), A.triangularView().transpose())"); + + + A.setRandom();B.setRandom(); C = B; D = A; + C.triangularView().swap(D.triangularView()); + swap_using_evaluator(B.triangularView(), A.triangularView()); + VERIFY(B.isApprox(C) && "swap_using_evaluator(B.triangularView(), A.triangularView())"); + + + VERIFY_IS_APPROX_EVALUATOR2(B, prod(A.triangularView(),A), MatrixXd(A.triangularView()*A)); + + VERIFY_IS_APPROX_EVALUATOR2(B, prod(A.selfadjointView(),A), MatrixXd(A.selfadjointView()*A)); + } + + { + // test diagonal shapes + VectorXd d = VectorXd::Random(6); + MatrixXd A = MatrixXd::Random(6,6), B(6,6); + A.setRandom();B.setRandom(); + + VERIFY_IS_APPROX_EVALUATOR2(B, lazyprod(d.asDiagonal(),A), MatrixXd(d.asDiagonal()*A)); + VERIFY_IS_APPROX_EVALUATOR2(B, lazyprod(A,d.asDiagonal()), MatrixXd(A*d.asDiagonal())); + } + + { + // test CoeffReadCost + Matrix4d a, b; + VERIFY_IS_EQUAL( get_cost(a), 1 ); + VERIFY_IS_EQUAL( get_cost(a+b), 3); + VERIFY_IS_EQUAL( get_cost(2*a+b), 4); + VERIFY_IS_EQUAL( get_cost(a*b), 1); + VERIFY_IS_EQUAL( get_cost(a.lazyProduct(b)), 15); + VERIFY_IS_EQUAL( get_cost(a*(a*b)), 1); + VERIFY_IS_EQUAL( get_cost(a.lazyProduct(a*b)), 15); + VERIFY_IS_EQUAL( get_cost(a*(a+b)), 1); + VERIFY_IS_EQUAL( get_cost(a.lazyProduct(a+b)), 15); + } + + // regression test for PR 544 and bug 1622 (introduced in #71609c4) + { + // test restricted_packet_assignment with an unaligned destination + const size_t M = 2; + const size_t K = 2; + const size_t N = 5; + float *destMem = new float[(M*N) + 1]; + float *dest = (internal::UIntPtr(destMem)%EIGEN_MAX_ALIGN_BYTES) == 0 ? destMem+1 : destMem; + + const Matrix a = Matrix::Random(M, K); + const Matrix b = Matrix::Random(K, N); + + Map > z(dest, M, N);; + Product, Matrix, LazyProduct> tmp(a,b); + internal::call_restricted_packet_assignment(z.noalias(), tmp.derived(), internal::assign_op()); + + VERIFY_IS_APPROX(z, a*b); + delete[] destMem; + } +} diff --git a/include/eigen/test/exceptions.cpp b/include/eigen/test/exceptions.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3d93060aba2c31e028624b087cede4ffa6054c24 --- /dev/null +++ b/include/eigen/test/exceptions.cpp @@ -0,0 +1,49 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2011 Gael Guennebaud +// +// 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/. + + +// Various sanity tests with exceptions and non trivially copyable scalar type. +// - no memory leak when a custom scalar type trow an exceptions +// - todo: complete the list of tests! + +#define EIGEN_STACK_ALLOCATION_LIMIT 100000000 + +#include "main.h" +#include "AnnoyingScalar.h" + +#define CHECK_MEMLEAK(OP) { \ + AnnoyingScalar::countdown = 100; \ + int before = AnnoyingScalar::instances; \ + bool exception_thrown = false; \ + try { OP; } \ + catch (my_exception) { \ + exception_thrown = true; \ + VERIFY(AnnoyingScalar::instances==before && "memory leak detected in " && EIGEN_MAKESTRING(OP)); \ + } \ + VERIFY( (AnnoyingScalar::dont_throw) || (exception_thrown && " no exception thrown in " && EIGEN_MAKESTRING(OP)) ); \ + } + +EIGEN_DECLARE_TEST(exceptions) +{ + typedef Eigen::Matrix VectorType; + typedef Eigen::Matrix MatrixType; + + { + AnnoyingScalar::dont_throw = false; + int n = 50; + VectorType v0(n), v1(n); + MatrixType m0(n,n), m1(n,n), m2(n,n); + v0.setOnes(); v1.setOnes(); + m0.setOnes(); m1.setOnes(); m2.setOnes(); + CHECK_MEMLEAK(v0 = m0 * m1 * v1); + CHECK_MEMLEAK(m2 = m0 * m1 * m2); + CHECK_MEMLEAK((v0+v1).dot(v0+v1)); + } + VERIFY(AnnoyingScalar::instances==0 && "global memory leak detected in " && EIGEN_MAKESTRING(OP)); +} diff --git a/include/eigen/test/fastmath.cpp b/include/eigen/test/fastmath.cpp new file mode 100644 index 0000000000000000000000000000000000000000..00a1a59b8b51b72b88611585706da5b1cb6b1221 --- /dev/null +++ b/include/eigen/test/fastmath.cpp @@ -0,0 +1,99 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2015 Gael Guennebaud +// +// 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/. + +#include "main.h" + +void check(bool b, bool ref) +{ + std::cout << b; + if(b==ref) + std::cout << " OK "; + else + std::cout << " BAD "; +} + +#if EIGEN_COMP_MSVC && EIGEN_COMP_MSVC < 1800 +namespace std { + template bool (isfinite)(T x) { return _finite(x); } + template bool (isnan)(T x) { return _isnan(x); } + template bool (isinf)(T x) { return _fpclass(x)==_FPCLASS_NINF || _fpclass(x)==_FPCLASS_PINF; } +} +#endif + +template +void check_inf_nan(bool dryrun) { + Matrix m(10); + m.setRandom(); + m(3) = std::numeric_limits::quiet_NaN(); + + if(dryrun) + { + std::cout << "std::isfinite(" << m(3) << ") = "; check((std::isfinite)(m(3)),false); std::cout << " ; numext::isfinite = "; check((numext::isfinite)(m(3)), false); std::cout << "\n"; + std::cout << "std::isinf(" << m(3) << ") = "; check((std::isinf)(m(3)),false); std::cout << " ; numext::isinf = "; check((numext::isinf)(m(3)), false); std::cout << "\n"; + std::cout << "std::isnan(" << m(3) << ") = "; check((std::isnan)(m(3)),true); std::cout << " ; numext::isnan = "; check((numext::isnan)(m(3)), true); std::cout << "\n"; + std::cout << "allFinite: "; check(m.allFinite(), 0); std::cout << "\n"; + std::cout << "hasNaN: "; check(m.hasNaN(), 1); std::cout << "\n"; + std::cout << "\n"; + } + else + { + if( (std::isfinite)(m(3))) g_test_level=1; VERIFY( !(numext::isfinite)(m(3)) ); g_test_level=0; + if( (std::isinf) (m(3))) g_test_level=1; VERIFY( !(numext::isinf)(m(3)) ); g_test_level=0; + if(!(std::isnan) (m(3))) g_test_level=1; VERIFY( (numext::isnan)(m(3)) ); g_test_level=0; + if( (std::isfinite)(m(3))) g_test_level=1; VERIFY( !m.allFinite() ); g_test_level=0; + if(!(std::isnan) (m(3))) g_test_level=1; VERIFY( m.hasNaN() ); g_test_level=0; + } + T hidden_zero = (std::numeric_limits::min)()*(std::numeric_limits::min)(); + m(4) /= hidden_zero; + if(dryrun) + { + std::cout << "std::isfinite(" << m(4) << ") = "; check((std::isfinite)(m(4)),false); std::cout << " ; numext::isfinite = "; check((numext::isfinite)(m(4)), false); std::cout << "\n"; + std::cout << "std::isinf(" << m(4) << ") = "; check((std::isinf)(m(4)),true); std::cout << " ; numext::isinf = "; check((numext::isinf)(m(4)), true); std::cout << "\n"; + std::cout << "std::isnan(" << m(4) << ") = "; check((std::isnan)(m(4)),false); std::cout << " ; numext::isnan = "; check((numext::isnan)(m(4)), false); std::cout << "\n"; + std::cout << "allFinite: "; check(m.allFinite(), 0); std::cout << "\n"; + std::cout << "hasNaN: "; check(m.hasNaN(), 1); std::cout << "\n"; + std::cout << "\n"; + } + else + { + if( (std::isfinite)(m(3))) g_test_level=1; VERIFY( !(numext::isfinite)(m(4)) ); g_test_level=0; + if(!(std::isinf) (m(3))) g_test_level=1; VERIFY( (numext::isinf)(m(4)) ); g_test_level=0; + if( (std::isnan) (m(3))) g_test_level=1; VERIFY( !(numext::isnan)(m(4)) ); g_test_level=0; + if( (std::isfinite)(m(3))) g_test_level=1; VERIFY( !m.allFinite() ); g_test_level=0; + if(!(std::isnan) (m(3))) g_test_level=1; VERIFY( m.hasNaN() ); g_test_level=0; + } + m(3) = 0; + if(dryrun) + { + std::cout << "std::isfinite(" << m(3) << ") = "; check((std::isfinite)(m(3)),true); std::cout << " ; numext::isfinite = "; check((numext::isfinite)(m(3)), true); std::cout << "\n"; + std::cout << "std::isinf(" << m(3) << ") = "; check((std::isinf)(m(3)),false); std::cout << " ; numext::isinf = "; check((numext::isinf)(m(3)), false); std::cout << "\n"; + std::cout << "std::isnan(" << m(3) << ") = "; check((std::isnan)(m(3)),false); std::cout << " ; numext::isnan = "; check((numext::isnan)(m(3)), false); std::cout << "\n"; + std::cout << "allFinite: "; check(m.allFinite(), 0); std::cout << "\n"; + std::cout << "hasNaN: "; check(m.hasNaN(), 0); std::cout << "\n"; + std::cout << "\n\n"; + } + else + { + if(!(std::isfinite)(m(3))) g_test_level=1; VERIFY( (numext::isfinite)(m(3)) ); g_test_level=0; + if( (std::isinf) (m(3))) g_test_level=1; VERIFY( !(numext::isinf)(m(3)) ); g_test_level=0; + if( (std::isnan) (m(3))) g_test_level=1; VERIFY( !(numext::isnan)(m(3)) ); g_test_level=0; + if( (std::isfinite)(m(3))) g_test_level=1; VERIFY( !m.allFinite() ); g_test_level=0; + if( (std::isnan) (m(3))) g_test_level=1; VERIFY( !m.hasNaN() ); g_test_level=0; + } +} + +EIGEN_DECLARE_TEST(fastmath) { + std::cout << "*** float *** \n\n"; check_inf_nan(true); + std::cout << "*** double ***\n\n"; check_inf_nan(true); + std::cout << "*** long double *** \n\n"; check_inf_nan(true); + + check_inf_nan(false); + check_inf_nan(false); + check_inf_nan(false); +} diff --git a/include/eigen/test/first_aligned.cpp b/include/eigen/test/first_aligned.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ed9945077b97129414b63e27eef65d403f23310a --- /dev/null +++ b/include/eigen/test/first_aligned.cpp @@ -0,0 +1,51 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2009 Benoit Jacob +// +// 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/. + +#include "main.h" + +template +void test_first_aligned_helper(Scalar *array, int size) +{ + const int packet_size = sizeof(Scalar) * internal::packet_traits::size; + VERIFY(((size_t(array) + sizeof(Scalar) * internal::first_default_aligned(array, size)) % packet_size) == 0); +} + +template +void test_none_aligned_helper(Scalar *array, int size) +{ + EIGEN_UNUSED_VARIABLE(array); + EIGEN_UNUSED_VARIABLE(size); + VERIFY(internal::packet_traits::size == 1 || internal::first_default_aligned(array, size) == size); +} + +struct some_non_vectorizable_type { float x; }; + +EIGEN_DECLARE_TEST(first_aligned) +{ + EIGEN_ALIGN16 float array_float[100]; + test_first_aligned_helper(array_float, 50); + test_first_aligned_helper(array_float+1, 50); + test_first_aligned_helper(array_float+2, 50); + test_first_aligned_helper(array_float+3, 50); + test_first_aligned_helper(array_float+4, 50); + test_first_aligned_helper(array_float+5, 50); + + EIGEN_ALIGN16 double array_double[100]; + test_first_aligned_helper(array_double, 50); + test_first_aligned_helper(array_double+1, 50); + test_first_aligned_helper(array_double+2, 50); + + double *array_double_plus_4_bytes = (double*)(internal::UIntPtr(array_double)+4); + test_none_aligned_helper(array_double_plus_4_bytes, 50); + test_none_aligned_helper(array_double_plus_4_bytes+1, 50); + + some_non_vectorizable_type array_nonvec[100]; + test_first_aligned_helper(array_nonvec, 100); + test_none_aligned_helper(array_nonvec, 100); +} diff --git a/include/eigen/test/geo_alignedbox.cpp b/include/eigen/test/geo_alignedbox.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7b1684f292cdefc934c015b52f4c6c71ed03f6e9 --- /dev/null +++ b/include/eigen/test/geo_alignedbox.cpp @@ -0,0 +1,531 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2008-2009 Gael Guennebaud +// +// 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/. + +#include "main.h" +#include + +using namespace std; + +// NOTE the following workaround was needed on some 32 bits builds to kill extra precision of x87 registers. +// It seems that it is not needed anymore, but let's keep it here, just in case... + +template EIGEN_DONT_INLINE +void kill_extra_precision(T& /* x */) { + // This one worked but triggered a warning: + /* eigen_assert((void*)(&x) != (void*)0); */ + // An alternative could be: + /* volatile T tmp = x; */ + /* x = tmp; */ +} + + +template void alignedbox(const BoxType& box) +{ + /* this test covers the following files: + AlignedBox.h + */ + typedef typename BoxType::Scalar Scalar; + typedef NumTraits ScalarTraits; + typedef typename ScalarTraits::Real RealScalar; + typedef Matrix VectorType; + + const Index dim = box.dim(); + + VectorType p0 = VectorType::Random(dim); + VectorType p1 = VectorType::Random(dim); + while( p1 == p0 ){ + p1 = VectorType::Random(dim); } + RealScalar s1 = internal::random(0,1); + + BoxType b0(dim); + BoxType b1(VectorType::Random(dim),VectorType::Random(dim)); + BoxType b2; + + kill_extra_precision(b1); + kill_extra_precision(p0); + kill_extra_precision(p1); + + b0.extend(p0); + b0.extend(p1); + VERIFY(b0.contains(p0*s1+(Scalar(1)-s1)*p1)); + VERIFY(b0.contains(b0.center())); + VERIFY_IS_APPROX(b0.center(),(p0+p1)/Scalar(2)); + + (b2 = b0).extend(b1); + VERIFY(b2.contains(b0)); + VERIFY(b2.contains(b1)); + VERIFY_IS_APPROX(b2.clamp(b0), b0); + + // intersection + BoxType box1(VectorType::Random(dim)); + box1.extend(VectorType::Random(dim)); + BoxType box2(VectorType::Random(dim)); + box2.extend(VectorType::Random(dim)); + + VERIFY(box1.intersects(box2) == !box1.intersection(box2).isEmpty()); + + // alignment -- make sure there is no memory alignment assertion + BoxType *bp0 = new BoxType(dim); + BoxType *bp1 = new BoxType(dim); + bp0->extend(*bp1); + delete bp0; + delete bp1; + + // sampling + for( int i=0; i<10; ++i ) + { + VectorType r = b0.sample(); + VERIFY(b0.contains(r)); + } + +} + +template void alignedboxTranslatable(const BoxType& box) +{ + typedef typename BoxType::Scalar Scalar; + typedef Matrix VectorType; + typedef Transform IsometryTransform; + typedef Transform AffineTransform; + + alignedbox(box); + + const VectorType Ones = VectorType::Ones(); + const VectorType UnitX = VectorType::UnitX(); + const Index dim = box.dim(); + + // box((-1, -1, -1), (1, 1, 1)) + BoxType a(-Ones, Ones); + + VERIFY_IS_APPROX(a.sizes(), Ones * Scalar(2)); + + BoxType b = a; + VectorType translate = Ones; + translate[0] = Scalar(2); + b.translate(translate); + // translate by (2, 1, 1) -> box((1, 0, 0), (3, 2, 2)) + + VERIFY_IS_APPROX(b.sizes(), Ones * Scalar(2)); + VERIFY_IS_APPROX((b.min)(), UnitX); + VERIFY_IS_APPROX((b.max)(), Ones * Scalar(2) + UnitX); + + // Test transform + + IsometryTransform tf = IsometryTransform::Identity(); + tf.translation() = -translate; + + BoxType c = b.transformed(tf); + // translate by (-2, -1, -1) -> box((-1, -1, -1), (1, 1, 1)) + VERIFY_IS_APPROX(c.sizes(), a.sizes()); + VERIFY_IS_APPROX((c.min)(), (a.min)()); + VERIFY_IS_APPROX((c.max)(), (a.max)()); + + c.transform(tf); + // translate by (-2, -1, -1) -> box((-3, -2, -2), (-1, 0, 0)) + VERIFY_IS_APPROX(c.sizes(), a.sizes()); + VERIFY_IS_APPROX((c.min)(), Ones * Scalar(-2) - UnitX); + VERIFY_IS_APPROX((c.max)(), -UnitX); + + // Scaling + + AffineTransform atf = AffineTransform::Identity(); + atf.scale(Scalar(3)); + c.transform(atf); + // scale by 3 -> box((-9, -6, -6), (-3, 0, 0)) + VERIFY_IS_APPROX(c.sizes(), Scalar(3) * a.sizes()); + VERIFY_IS_APPROX((c.min)(), Ones * Scalar(-6) - UnitX * Scalar(3)); + VERIFY_IS_APPROX((c.max)(), UnitX * Scalar(-3)); + + atf = AffineTransform::Identity(); + atf.scale(Scalar(-3)); + c.transform(atf); + // scale by -3 -> box((27, 18, 18), (9, 0, 0)) + VERIFY_IS_APPROX(c.sizes(), Scalar(9) * a.sizes()); + VERIFY_IS_APPROX((c.min)(), UnitX * Scalar(9)); + VERIFY_IS_APPROX((c.max)(), Ones * Scalar(18) + UnitX * Scalar(9)); + + // Check identity transform within numerical precision. + BoxType transformedC = c.transformed(IsometryTransform::Identity()); + VERIFY_IS_APPROX(transformedC, c); + + for (size_t i = 0; i < 10; ++i) + { + VectorType minCorner; + VectorType maxCorner; + for (Index d = 0; d < dim; ++d) + { + minCorner[d] = internal::random(-10,10); + maxCorner[d] = minCorner[d] + internal::random(0, 10); + } + + c = BoxType(minCorner, maxCorner); + + translate = VectorType::Random(); + c.translate(translate); + + VERIFY_IS_APPROX((c.min)(), minCorner + translate); + VERIFY_IS_APPROX((c.max)(), maxCorner + translate); + } +} + +template +Rotation rotate2D(Scalar angle) { + return Rotation2D(angle); +} + +template +Rotation rotate2DIntegral(typename NumTraits::NonInteger angle) { + typedef typename NumTraits::NonInteger NonInteger; + return Rotation2D(angle).toRotationMatrix(). + template cast(); +} + +template +Rotation rotate3DZAxis(Scalar angle) { + return AngleAxis(angle, Matrix(0, 0, 1)); +} + +template +Rotation rotate3DZAxisIntegral(typename NumTraits::NonInteger angle) { + typedef typename NumTraits::NonInteger NonInteger; + return AngleAxis(angle, Matrix(0, 0, 1)). + toRotationMatrix().template cast(); +} + +template +Rotation rotate4DZWAxis(Scalar angle) { + Rotation result = Matrix::Identity(); + result.block(0, 0, 3, 3) = rotate3DZAxis(angle).toRotationMatrix(); + return result; +} + +template +MatrixType randomRotationMatrix() +{ + // algorithm from + // https://www.isprs-ann-photogramm-remote-sens-spatial-inf-sci.net/III-7/103/2016/isprs-annals-III-7-103-2016.pdf + const MatrixType rand = MatrixType::Random(); + const MatrixType q = rand.householderQr().householderQ(); + const JacobiSVD svd = q.jacobiSvd(ComputeFullU | ComputeFullV); + const typename MatrixType::Scalar det = (svd.matrixU() * svd.matrixV().transpose()).determinant(); + MatrixType diag = rand.Identity(); + diag(MatrixType::RowsAtCompileTime - 1, MatrixType::ColsAtCompileTime - 1) = det; + const MatrixType rotation = svd.matrixU() * diag * svd.matrixV().transpose(); + return rotation; +} + +template +Matrix boxGetCorners(const Matrix& min_, const Matrix& max_) +{ + Matrix result; + for(Index i=0; i<(1< void alignedboxRotatable( + const BoxType& box, + Rotation (*rotate)(typename NumTraits::NonInteger /*_angle*/)) +{ + alignedboxTranslatable(box); + + typedef typename BoxType::Scalar Scalar; + typedef typename NumTraits::NonInteger NonInteger; + typedef Matrix VectorType; + typedef Transform IsometryTransform; + typedef Transform AffineTransform; + + const VectorType Zero = VectorType::Zero(); + const VectorType Ones = VectorType::Ones(); + const VectorType UnitX = VectorType::UnitX(); + const VectorType UnitY = VectorType::UnitY(); + // this is vector (0, 0, -1, -1, -1, ...), i.e. with zeros at first and second dimensions + const VectorType UnitZ = Ones - UnitX - UnitY; + + // in this kind of comments the 3D case values will be illustrated + // box((-1, -1, -1), (1, 1, 1)) + BoxType a(-Ones, Ones); + + // to allow templating this test for both 2D and 3D cases, we always set all + // but the first coordinate to the same value; so basically 3D case works as + // if you were looking at the scene from top + + VectorType minPoint = -2 * Ones; + minPoint[0] = -3; + VectorType maxPoint = Zero; + maxPoint[0] = -1; + BoxType c(minPoint, maxPoint); + // box((-3, -2, -2), (-1, 0, 0)) + + IsometryTransform tf2 = IsometryTransform::Identity(); + // for some weird reason the following statement has to be put separate from + // the following rotate call, otherwise precision problems arise... + Rotation rot = rotate(NonInteger(EIGEN_PI)); + tf2.rotate(rot); + + c.transform(tf2); + // rotate by 180 deg around origin -> box((1, 0, -2), (3, 2, 0)) + + VERIFY_IS_APPROX(c.sizes(), a.sizes()); + VERIFY_IS_APPROX((c.min)(), UnitX - UnitZ * Scalar(2)); + VERIFY_IS_APPROX((c.max)(), UnitX * Scalar(3) + UnitY * Scalar(2)); + + rot = rotate(NonInteger(EIGEN_PI / 2)); + tf2.setIdentity(); + tf2.rotate(rot); + + c.transform(tf2); + // rotate by 90 deg around origin -> box((-2, 1, -2), (0, 3, 0)) + + VERIFY_IS_APPROX(c.sizes(), a.sizes()); + VERIFY_IS_APPROX((c.min)(), Ones * Scalar(-2) + UnitY * Scalar(3)); + VERIFY_IS_APPROX((c.max)(), UnitY * Scalar(3)); + + // box((-1, -1, -1), (1, 1, 1)) + AffineTransform atf = AffineTransform::Identity(); + atf.linearExt()(0, 1) = Scalar(1); + c = BoxType(-Ones, Ones); + c.transform(atf); + // 45 deg shear in x direction -> box((-2, -1, -1), (2, 1, 1)) + + VERIFY_IS_APPROX(c.sizes(), Ones * Scalar(2) + UnitX * Scalar(2)); + VERIFY_IS_APPROX((c.min)(), -Ones - UnitX); + VERIFY_IS_APPROX((c.max)(), Ones + UnitX); +} + +template void alignedboxNonIntegralRotatable( + const BoxType& box, + Rotation (*rotate)(typename NumTraits::NonInteger /*_angle*/)) +{ + alignedboxRotatable(box, rotate); + + typedef typename BoxType::Scalar Scalar; + typedef typename NumTraits::NonInteger NonInteger; + enum { Dim = BoxType::AmbientDimAtCompileTime }; + typedef Matrix VectorType; + typedef Matrix CornersType; + typedef Transform IsometryTransform; + typedef Transform AffineTransform; + + const Index dim = box.dim(); + const VectorType Zero = VectorType::Zero(); + const VectorType Ones = VectorType::Ones(); + + VectorType minPoint = -2 * Ones; + minPoint[1] = 1; + VectorType maxPoint = Zero; + maxPoint[1] = 3; + BoxType c(minPoint, maxPoint); + // ((-2, 1, -2), (0, 3, 0)) + + VectorType cornerBL = (c.min)(); + VectorType cornerTR = (c.max)(); + VectorType cornerBR = (c.min)(); cornerBR[0] = cornerTR[0]; + VectorType cornerTL = (c.max)(); cornerTL[0] = cornerBL[0]; + + NonInteger angle = NonInteger(EIGEN_PI/3); + Rotation rot = rotate(angle); + IsometryTransform tf2; + tf2.setIdentity(); + tf2.rotate(rot); + + c.transform(tf2); + // rotate by 60 deg -> box((-3.59, -1.23, -2), (-0.86, 1.5, 0)) + + cornerBL = tf2 * cornerBL; + cornerBR = tf2 * cornerBR; + cornerTL = tf2 * cornerTL; + cornerTR = tf2 * cornerTR; + + VectorType minCorner = Ones * Scalar(-2); + VectorType maxCorner = Zero; + minCorner[0] = (min)((min)(cornerBL[0], cornerBR[0]), (min)(cornerTL[0], cornerTR[0])); + maxCorner[0] = (max)((max)(cornerBL[0], cornerBR[0]), (max)(cornerTL[0], cornerTR[0])); + minCorner[1] = (min)((min)(cornerBL[1], cornerBR[1]), (min)(cornerTL[1], cornerTR[1])); + maxCorner[1] = (max)((max)(cornerBL[1], cornerBR[1]), (max)(cornerTL[1], cornerTR[1])); + + for (Index d = 2; d < dim; ++d) + VERIFY_IS_APPROX(c.sizes()[d], Scalar(2)); + + VERIFY_IS_APPROX((c.min)(), minCorner); + VERIFY_IS_APPROX((c.max)(), maxCorner); + + VectorType minCornerValue = Ones * Scalar(-2); + VectorType maxCornerValue = Zero; + minCornerValue[0] = Scalar(Scalar(-sqrt(2*2 + 3*3)) * Scalar(cos(Scalar(atan(2.0/3.0)) - angle/2))); + minCornerValue[1] = Scalar(Scalar(-sqrt(1*1 + 2*2)) * Scalar(sin(Scalar(atan(2.0/1.0)) - angle/2))); + maxCornerValue[0] = Scalar(-sin(angle)); + maxCornerValue[1] = Scalar(3 * cos(angle)); + VERIFY_IS_APPROX((c.min)(), minCornerValue); + VERIFY_IS_APPROX((c.max)(), maxCornerValue); + + // randomized test - translate and rotate the box and compare to a box made of transformed vertices + for (size_t i = 0; i < 10; ++i) + { + for (Index d = 0; d < dim; ++d) + { + minCorner[d] = internal::random(-10,10); + maxCorner[d] = minCorner[d] + internal::random(0, 10); + } + + c = BoxType(minCorner, maxCorner); + + CornersType corners = boxGetCorners(minCorner, maxCorner); + + typename AffineTransform::LinearMatrixType rotation = + randomRotationMatrix(); + + tf2.setIdentity(); + tf2.rotate(rotation); + tf2.translate(VectorType::Random()); + + c.transform(tf2); + corners = tf2 * corners; + + minCorner = corners.rowwise().minCoeff(); + maxCorner = corners.rowwise().maxCoeff(); + + VERIFY_IS_APPROX((c.min)(), minCorner); + VERIFY_IS_APPROX((c.max)(), maxCorner); + } + + // randomized test - transform the box with a random affine matrix and compare to a box made of transformed vertices + for (size_t i = 0; i < 10; ++i) + { + for (Index d = 0; d < dim; ++d) + { + minCorner[d] = internal::random(-10,10); + maxCorner[d] = minCorner[d] + internal::random(0, 10); + } + + c = BoxType(minCorner, maxCorner); + + CornersType corners = boxGetCorners(minCorner, maxCorner); + + AffineTransform atf = AffineTransform::Identity(); + atf.linearExt() = AffineTransform::LinearPart::Random(); + atf.translate(VectorType::Random()); + + c.transform(atf); + corners = atf * corners; + + minCorner = corners.rowwise().minCoeff(); + maxCorner = corners.rowwise().maxCoeff(); + + VERIFY_IS_APPROX((c.min)(), minCorner); + VERIFY_IS_APPROX((c.max)(), maxCorner); + } +} + +template +void alignedboxCastTests(const BoxType& box) +{ + // casting + typedef typename BoxType::Scalar Scalar; + typedef Matrix VectorType; + + const Index dim = box.dim(); + + VectorType p0 = VectorType::Random(dim); + VectorType p1 = VectorType::Random(dim); + + BoxType b0(dim); + + b0.extend(p0); + b0.extend(p1); + + const int Dim = BoxType::AmbientDimAtCompileTime; + typedef typename GetDifferentType::type OtherScalar; + AlignedBox hp1f = b0.template cast(); + VERIFY_IS_APPROX(hp1f.template cast(),b0); + AlignedBox hp1d = b0.template cast(); + VERIFY_IS_APPROX(hp1d.template cast(),b0); +} + + +void specificTest1() +{ + Vector2f m; m << -1.0f, -2.0f; + Vector2f M; M << 1.0f, 5.0f; + + typedef AlignedBox2f BoxType; + BoxType box( m, M ); + + Vector2f sides = M-m; + VERIFY_IS_APPROX(sides, box.sizes() ); + VERIFY_IS_APPROX(sides[1], box.sizes()[1] ); + VERIFY_IS_APPROX(sides[1], box.sizes().maxCoeff() ); + VERIFY_IS_APPROX(sides[0], box.sizes().minCoeff() ); + + VERIFY_IS_APPROX( 14.0f, box.volume() ); + VERIFY_IS_APPROX( 53.0f, box.diagonal().squaredNorm() ); + VERIFY_IS_APPROX( std::sqrt( 53.0f ), box.diagonal().norm() ); + + VERIFY_IS_APPROX( m, box.corner( BoxType::BottomLeft ) ); + VERIFY_IS_APPROX( M, box.corner( BoxType::TopRight ) ); + Vector2f bottomRight; bottomRight << M[0], m[1]; + Vector2f topLeft; topLeft << m[0], M[1]; + VERIFY_IS_APPROX( bottomRight, box.corner( BoxType::BottomRight ) ); + VERIFY_IS_APPROX( topLeft, box.corner( BoxType::TopLeft ) ); +} + + +void specificTest2() +{ + Vector3i m; m << -1, -2, 0; + Vector3i M; M << 1, 5, 3; + + typedef AlignedBox3i BoxType; + BoxType box( m, M ); + + Vector3i sides = M-m; + VERIFY_IS_APPROX(sides, box.sizes() ); + VERIFY_IS_APPROX(sides[1], box.sizes()[1] ); + VERIFY_IS_APPROX(sides[1], box.sizes().maxCoeff() ); + VERIFY_IS_APPROX(sides[0], box.sizes().minCoeff() ); + + VERIFY_IS_APPROX( 42, box.volume() ); + VERIFY_IS_APPROX( 62, box.diagonal().squaredNorm() ); + + VERIFY_IS_APPROX( m, box.corner( BoxType::BottomLeftFloor ) ); + VERIFY_IS_APPROX( M, box.corner( BoxType::TopRightCeil ) ); + Vector3i bottomRightFloor; bottomRightFloor << M[0], m[1], m[2]; + Vector3i topLeftFloor; topLeftFloor << m[0], M[1], m[2]; + VERIFY_IS_APPROX( bottomRightFloor, box.corner( BoxType::BottomRightFloor ) ); + VERIFY_IS_APPROX( topLeftFloor, box.corner( BoxType::TopLeftFloor ) ); +} + + +EIGEN_DECLARE_TEST(geo_alignedbox) +{ + for(int i = 0; i < g_repeat; i++) + { + CALL_SUBTEST_1( (alignedboxNonIntegralRotatable(AlignedBox2f(), &rotate2D)) ); + CALL_SUBTEST_2( alignedboxCastTests(AlignedBox2f()) ); + + CALL_SUBTEST_3( (alignedboxNonIntegralRotatable(AlignedBox3f(), &rotate3DZAxis)) ); + CALL_SUBTEST_4( alignedboxCastTests(AlignedBox3f()) ); + + CALL_SUBTEST_5( (alignedboxNonIntegralRotatable(AlignedBox4d(), &rotate4DZWAxis)) ); + CALL_SUBTEST_6( alignedboxCastTests(AlignedBox4d()) ); + + CALL_SUBTEST_7( alignedboxTranslatable(AlignedBox1d()) ); + CALL_SUBTEST_8( alignedboxCastTests(AlignedBox1d()) ); + + CALL_SUBTEST_9( alignedboxTranslatable(AlignedBox1i()) ); + CALL_SUBTEST_10( (alignedboxRotatable(AlignedBox2i(), &rotate2DIntegral)) ); + CALL_SUBTEST_11( (alignedboxRotatable(AlignedBox3i(), &rotate3DZAxisIntegral)) ); + + CALL_SUBTEST_14( alignedbox(AlignedBox(4)) ); + } + CALL_SUBTEST_12( specificTest1() ); + CALL_SUBTEST_13( specificTest2() ); +} diff --git a/include/eigen/test/geo_eulerangles.cpp b/include/eigen/test/geo_eulerangles.cpp new file mode 100644 index 0000000000000000000000000000000000000000..693c627a9a451cdebf9c447d4729ed10ec64689a --- /dev/null +++ b/include/eigen/test/geo_eulerangles.cpp @@ -0,0 +1,112 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2008-2012 Gael Guennebaud +// +// 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/. + +#include "main.h" +#include +#include +#include + + +template +void verify_euler(const Matrix& ea, int i, int j, int k) +{ + typedef Matrix Matrix3; + typedef Matrix Vector3; + typedef AngleAxis AngleAxisx; + using std::abs; + Matrix3 m(AngleAxisx(ea[0], Vector3::Unit(i)) * AngleAxisx(ea[1], Vector3::Unit(j)) * AngleAxisx(ea[2], Vector3::Unit(k))); + Vector3 eabis = m.eulerAngles(i, j, k); + Matrix3 mbis(AngleAxisx(eabis[0], Vector3::Unit(i)) * AngleAxisx(eabis[1], Vector3::Unit(j)) * AngleAxisx(eabis[2], Vector3::Unit(k))); + VERIFY_IS_APPROX(m, mbis); + /* If I==K, and ea[1]==0, then there no unique solution. */ + /* The remark apply in the case where I!=K, and |ea[1]| is close to pi/2. */ + if( (i!=k || ea[1]!=0) && (i==k || !internal::isApprox(abs(ea[1]),Scalar(EIGEN_PI/2),test_precision())) ) + VERIFY((ea-eabis).norm() <= test_precision()); + + // approx_or_less_than does not work for 0 + VERIFY(0 < eabis[0] || test_isMuchSmallerThan(eabis[0], Scalar(1))); + VERIFY_IS_APPROX_OR_LESS_THAN(eabis[0], Scalar(EIGEN_PI)); + VERIFY_IS_APPROX_OR_LESS_THAN(-Scalar(EIGEN_PI), eabis[1]); + VERIFY_IS_APPROX_OR_LESS_THAN(eabis[1], Scalar(EIGEN_PI)); + VERIFY_IS_APPROX_OR_LESS_THAN(-Scalar(EIGEN_PI), eabis[2]); + VERIFY_IS_APPROX_OR_LESS_THAN(eabis[2], Scalar(EIGEN_PI)); +} + +template void check_all_var(const Matrix& ea) +{ + verify_euler(ea, 0,1,2); + verify_euler(ea, 0,1,0); + verify_euler(ea, 0,2,1); + verify_euler(ea, 0,2,0); + + verify_euler(ea, 1,2,0); + verify_euler(ea, 1,2,1); + verify_euler(ea, 1,0,2); + verify_euler(ea, 1,0,1); + + verify_euler(ea, 2,0,1); + verify_euler(ea, 2,0,2); + verify_euler(ea, 2,1,0); + verify_euler(ea, 2,1,2); +} + +template void eulerangles() +{ + typedef Matrix Matrix3; + typedef Matrix Vector3; + typedef Array Array3; + typedef Quaternion Quaternionx; + typedef AngleAxis AngleAxisx; + + Scalar a = internal::random(-Scalar(EIGEN_PI), Scalar(EIGEN_PI)); + Quaternionx q1; + q1 = AngleAxisx(a, Vector3::Random().normalized()); + Matrix3 m; + m = q1; + + Vector3 ea = m.eulerAngles(0,1,2); + check_all_var(ea); + ea = m.eulerAngles(0,1,0); + check_all_var(ea); + + // Check with purely random Quaternion: + q1.coeffs() = Quaternionx::Coefficients::Random().normalized(); + m = q1; + ea = m.eulerAngles(0,1,2); + check_all_var(ea); + ea = m.eulerAngles(0,1,0); + check_all_var(ea); + + // Check with random angles in range [0:pi]x[-pi:pi]x[-pi:pi]. + ea = (Array3::Random() + Array3(1,0,0))*Scalar(EIGEN_PI)*Array3(0.5,1,1); + check_all_var(ea); + + ea[2] = ea[0] = internal::random(0,Scalar(EIGEN_PI)); + check_all_var(ea); + + ea[0] = ea[1] = internal::random(0,Scalar(EIGEN_PI)); + check_all_var(ea); + + ea[1] = 0; + check_all_var(ea); + + ea.head(2).setZero(); + check_all_var(ea); + + ea.setZero(); + check_all_var(ea); +} + +EIGEN_DECLARE_TEST(geo_eulerangles) +{ + for(int i = 0; i < g_repeat; i++) { + CALL_SUBTEST_1( eulerangles() ); + CALL_SUBTEST_2( eulerangles() ); + } +} diff --git a/include/eigen/test/geo_homogeneous.cpp b/include/eigen/test/geo_homogeneous.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9aebe6226ff23907cb202c590cdc2b247ac09506 --- /dev/null +++ b/include/eigen/test/geo_homogeneous.cpp @@ -0,0 +1,125 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2009 Gael Guennebaud +// +// 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/. + +#include "main.h" +#include + +template void homogeneous(void) +{ + /* this test covers the following files: + Homogeneous.h + */ + + typedef Matrix MatrixType; + typedef Matrix VectorType; + + typedef Matrix HMatrixType; + typedef Matrix HVectorType; + + typedef Matrix T1MatrixType; + typedef Matrix T2MatrixType; + typedef Matrix T3MatrixType; + + VectorType v0 = VectorType::Random(), + ones = VectorType::Ones(); + + HVectorType hv0 = HVectorType::Random(); + + MatrixType m0 = MatrixType::Random(); + + HMatrixType hm0 = HMatrixType::Random(); + + hv0 << v0, 1; + VERIFY_IS_APPROX(v0.homogeneous(), hv0); + VERIFY_IS_APPROX(v0, hv0.hnormalized()); + + VERIFY_IS_APPROX(v0.homogeneous().sum(), hv0.sum()); + VERIFY_IS_APPROX(v0.homogeneous().minCoeff(), hv0.minCoeff()); + VERIFY_IS_APPROX(v0.homogeneous().maxCoeff(), hv0.maxCoeff()); + + hm0 << m0, ones.transpose(); + VERIFY_IS_APPROX(m0.colwise().homogeneous(), hm0); + VERIFY_IS_APPROX(m0, hm0.colwise().hnormalized()); + hm0.row(Size-1).setRandom(); + for(int j=0; j aff; + Transform caff; + Transform proj; + Matrix pts; + Matrix pts1, pts2; + + aff.affine().setRandom(); + proj = caff = aff; + pts.setRandom(Size,internal::random(1,20)); + + pts1 = pts.colwise().homogeneous(); + VERIFY_IS_APPROX(aff * pts.colwise().homogeneous(), (aff * pts1).colwise().hnormalized()); + VERIFY_IS_APPROX(caff * pts.colwise().homogeneous(), (caff * pts1).colwise().hnormalized()); + VERIFY_IS_APPROX(proj * pts.colwise().homogeneous(), (proj * pts1)); + + VERIFY_IS_APPROX((aff * pts1).colwise().hnormalized(), aff * pts); + VERIFY_IS_APPROX((caff * pts1).colwise().hnormalized(), caff * pts); + + pts2 = pts1; + pts2.row(Size).setRandom(); + VERIFY_IS_APPROX((aff * pts2).colwise().hnormalized(), aff * pts2.colwise().hnormalized()); + VERIFY_IS_APPROX((caff * pts2).colwise().hnormalized(), caff * pts2.colwise().hnormalized()); + VERIFY_IS_APPROX((proj * pts2).colwise().hnormalized(), (proj * pts2.colwise().hnormalized().colwise().homogeneous()).colwise().hnormalized()); + + // Test combination of homogeneous + + VERIFY_IS_APPROX( (t2 * v0.homogeneous()).hnormalized(), + (t2.template topLeftCorner() * v0 + t2.template topRightCorner()) + / ((t2.template bottomLeftCorner<1,Size>()*v0).value() + t2(Size,Size)) ); + + VERIFY_IS_APPROX( (t2 * pts.colwise().homogeneous()).colwise().hnormalized(), + (Matrix(t2 * pts1).colwise().hnormalized()) ); + + VERIFY_IS_APPROX( (t2 .lazyProduct( v0.homogeneous() )).hnormalized(), (t2 * v0.homogeneous()).hnormalized() ); + VERIFY_IS_APPROX( (t2 .lazyProduct ( pts.colwise().homogeneous() )).colwise().hnormalized(), (t2 * pts1).colwise().hnormalized() ); + + VERIFY_IS_APPROX( (v0.transpose().homogeneous() .lazyProduct( t2 )).hnormalized(), (v0.transpose().homogeneous()*t2).hnormalized() ); + VERIFY_IS_APPROX( (pts.transpose().rowwise().homogeneous() .lazyProduct( t2 )).rowwise().hnormalized(), (pts1.transpose()*t2).rowwise().hnormalized() ); + + VERIFY_IS_APPROX( (t2.template triangularView() * v0.homogeneous()).eval(), (t2.template triangularView()*hv0) ); +} + +EIGEN_DECLARE_TEST(geo_homogeneous) +{ + for(int i = 0; i < g_repeat; i++) { + CALL_SUBTEST_1(( homogeneous() )); + CALL_SUBTEST_2(( homogeneous() )); + CALL_SUBTEST_3(( homogeneous() )); + } +} diff --git a/include/eigen/test/geo_orthomethods.cpp b/include/eigen/test/geo_orthomethods.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5f7ddb91f730e02428867bd1a019377ac83ad19f --- /dev/null +++ b/include/eigen/test/geo_orthomethods.cpp @@ -0,0 +1,134 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2008-2009 Gael Guennebaud +// +// 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/. + +#include "main.h" +#include +#include +#include + +/* this test covers the following files: + Geometry/OrthoMethods.h +*/ + +template void orthomethods_3() +{ + typedef typename NumTraits::Real RealScalar; + typedef Matrix Matrix3; + typedef Matrix Vector3; + + typedef Matrix Vector4; + + Vector3 v0 = Vector3::Random(), + v1 = Vector3::Random(), + v2 = Vector3::Random(); + + // cross product + VERIFY_IS_MUCH_SMALLER_THAN(v1.cross(v2).dot(v1), Scalar(1)); + VERIFY_IS_MUCH_SMALLER_THAN(v1.dot(v1.cross(v2)), Scalar(1)); + VERIFY_IS_MUCH_SMALLER_THAN(v1.cross(v2).dot(v2), Scalar(1)); + VERIFY_IS_MUCH_SMALLER_THAN(v2.dot(v1.cross(v2)), Scalar(1)); + VERIFY_IS_MUCH_SMALLER_THAN(v1.cross(Vector3::Random()).dot(v1), Scalar(1)); + Matrix3 mat3; + mat3 << v0.normalized(), + (v0.cross(v1)).normalized(), + (v0.cross(v1).cross(v0)).normalized(); + VERIFY(mat3.isUnitary()); + + mat3.setRandom(); + VERIFY_IS_APPROX(v0.cross(mat3*v1), -(mat3*v1).cross(v0)); + VERIFY_IS_APPROX(v0.cross(mat3.lazyProduct(v1)), -(mat3.lazyProduct(v1)).cross(v0)); + + // colwise/rowwise cross product + mat3.setRandom(); + Vector3 vec3 = Vector3::Random(); + Matrix3 mcross; + int i = internal::random(0,2); + mcross = mat3.colwise().cross(vec3); + VERIFY_IS_APPROX(mcross.col(i), mat3.col(i).cross(vec3)); + + VERIFY_IS_MUCH_SMALLER_THAN((mat3.adjoint() * mat3.colwise().cross(vec3)).diagonal().cwiseAbs().sum(), Scalar(1)); + VERIFY_IS_MUCH_SMALLER_THAN((mat3.adjoint() * mat3.colwise().cross(Vector3::Random())).diagonal().cwiseAbs().sum(), Scalar(1)); + + VERIFY_IS_MUCH_SMALLER_THAN((vec3.adjoint() * mat3.colwise().cross(vec3)).cwiseAbs().sum(), Scalar(1)); + VERIFY_IS_MUCH_SMALLER_THAN((vec3.adjoint() * Matrix3::Random().colwise().cross(vec3)).cwiseAbs().sum(), Scalar(1)); + + mcross = mat3.rowwise().cross(vec3); + VERIFY_IS_APPROX(mcross.row(i), mat3.row(i).cross(vec3)); + + // cross3 + Vector4 v40 = Vector4::Random(), + v41 = Vector4::Random(), + v42 = Vector4::Random(); + v40.w() = v41.w() = v42.w() = 0; + v42.template head<3>() = v40.template head<3>().cross(v41.template head<3>()); + VERIFY_IS_APPROX(v40.cross3(v41), v42); + VERIFY_IS_MUCH_SMALLER_THAN(v40.cross3(Vector4::Random()).dot(v40), Scalar(1)); + + // check mixed product + typedef Matrix RealVector3; + RealVector3 rv1 = RealVector3::Random(); + v2 = rv1.template cast(); + VERIFY_IS_APPROX(v1.cross(v2), v1.cross(rv1)); + VERIFY_IS_APPROX(v2.cross(v1), rv1.cross(v1)); +} + +template void orthomethods(int size=Size) +{ + typedef typename NumTraits::Real RealScalar; + typedef Matrix VectorType; + typedef Matrix Matrix3N; + typedef Matrix MatrixN3; + typedef Matrix Vector3; + + VectorType v0 = VectorType::Random(size); + + // unitOrthogonal + VERIFY_IS_MUCH_SMALLER_THAN(v0.unitOrthogonal().dot(v0), Scalar(1)); + VERIFY_IS_APPROX(v0.unitOrthogonal().norm(), RealScalar(1)); + + if (size>=3) + { + v0.template head<2>().setZero(); + v0.tail(size-2).setRandom(); + + VERIFY_IS_MUCH_SMALLER_THAN(v0.unitOrthogonal().dot(v0), Scalar(1)); + VERIFY_IS_APPROX(v0.unitOrthogonal().norm(), RealScalar(1)); + } + + // colwise/rowwise cross product + Vector3 vec3 = Vector3::Random(); + int i = internal::random(0,size-1); + + Matrix3N mat3N(3,size), mcross3N(3,size); + mat3N.setRandom(); + mcross3N = mat3N.colwise().cross(vec3); + VERIFY_IS_APPROX(mcross3N.col(i), mat3N.col(i).cross(vec3)); + + MatrixN3 matN3(size,3), mcrossN3(size,3); + matN3.setRandom(); + mcrossN3 = matN3.rowwise().cross(vec3); + VERIFY_IS_APPROX(mcrossN3.row(i), matN3.row(i).cross(vec3)); +} + +EIGEN_DECLARE_TEST(geo_orthomethods) +{ + for(int i = 0; i < g_repeat; i++) { + CALL_SUBTEST_1( orthomethods_3() ); + CALL_SUBTEST_2( orthomethods_3() ); + CALL_SUBTEST_4( orthomethods_3 >() ); + CALL_SUBTEST_1( (orthomethods()) ); + CALL_SUBTEST_2( (orthomethods()) ); + CALL_SUBTEST_1( (orthomethods()) ); + CALL_SUBTEST_2( (orthomethods()) ); + CALL_SUBTEST_3( (orthomethods()) ); + CALL_SUBTEST_4( (orthomethods,8>()) ); + CALL_SUBTEST_5( (orthomethods(36)) ); + CALL_SUBTEST_6( (orthomethods(35)) ); + } +} diff --git a/include/eigen/test/geo_parametrizedline.cpp b/include/eigen/test/geo_parametrizedline.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e4b194abc407a7b45bbc437688462051b1132864 --- /dev/null +++ b/include/eigen/test/geo_parametrizedline.cpp @@ -0,0 +1,125 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2008 Gael Guennebaud +// Copyright (C) 2008 Benoit Jacob +// +// 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/. + +#include "main.h" +#include +#include +#include + +template void parametrizedline(const LineType& _line) +{ + /* this test covers the following files: + ParametrizedLine.h + */ + using std::abs; + const Index dim = _line.dim(); + typedef typename LineType::Scalar Scalar; + typedef typename NumTraits::Real RealScalar; + typedef Matrix VectorType; + typedef Hyperplane HyperplaneType; + typedef Matrix MatrixType; + + VectorType p0 = VectorType::Random(dim); + VectorType p1 = VectorType::Random(dim); + + VectorType d0 = VectorType::Random(dim).normalized(); + + LineType l0(p0, d0); + + Scalar s0 = internal::random(); + Scalar s1 = abs(internal::random()); + + VERIFY_IS_MUCH_SMALLER_THAN( l0.distance(p0), RealScalar(1) ); + VERIFY_IS_MUCH_SMALLER_THAN( l0.distance(p0+s0*d0), RealScalar(1) ); + VERIFY_IS_APPROX( (l0.projection(p1)-p1).norm(), l0.distance(p1) ); + VERIFY_IS_MUCH_SMALLER_THAN( l0.distance(l0.projection(p1)), RealScalar(1) ); + VERIFY_IS_APPROX( Scalar(l0.distance((p0+s0*d0) + d0.unitOrthogonal() * s1)), s1 ); + + // casting + const int Dim = LineType::AmbientDimAtCompileTime; + typedef typename GetDifferentType::type OtherScalar; + ParametrizedLine hp1f = l0.template cast(); + VERIFY_IS_APPROX(hp1f.template cast(),l0); + ParametrizedLine hp1d = l0.template cast(); + VERIFY_IS_APPROX(hp1d.template cast(),l0); + + // intersections + VectorType p2 = VectorType::Random(dim); + VectorType n2 = VectorType::Random(dim).normalized(); + HyperplaneType hp(p2,n2); + Scalar t = l0.intersectionParameter(hp); + VectorType pi = l0.pointAt(t); + VERIFY_IS_MUCH_SMALLER_THAN(hp.signedDistance(pi), RealScalar(1)); + VERIFY_IS_MUCH_SMALLER_THAN(l0.distance(pi), RealScalar(1)); + VERIFY_IS_APPROX(l0.intersectionPoint(hp), pi); + + // transform + if (!NumTraits::IsComplex) + { + MatrixType rot = MatrixType::Random(dim,dim).householderQr().householderQ(); + DiagonalMatrix scaling(VectorType::Random()); + Translation translation(VectorType::Random()); + + while(scaling.diagonal().cwiseAbs().minCoeff() void parametrizedline_alignment() +{ + typedef ParametrizedLine Line4a; + typedef ParametrizedLine Line4u; + + EIGEN_ALIGN_MAX Scalar array1[16]; + EIGEN_ALIGN_MAX Scalar array2[16]; + EIGEN_ALIGN_MAX Scalar array3[16+1]; + Scalar* array3u = array3+1; + + Line4a *p1 = ::new(reinterpret_cast(array1)) Line4a; + Line4u *p2 = ::new(reinterpret_cast(array2)) Line4u; + Line4u *p3 = ::new(reinterpret_cast(array3u)) Line4u; + + p1->origin().setRandom(); + p1->direction().setRandom(); + *p2 = *p1; + *p3 = *p1; + + VERIFY_IS_APPROX(p1->origin(), p2->origin()); + VERIFY_IS_APPROX(p1->origin(), p3->origin()); + VERIFY_IS_APPROX(p1->direction(), p2->direction()); + VERIFY_IS_APPROX(p1->direction(), p3->direction()); +} + +EIGEN_DECLARE_TEST(geo_parametrizedline) +{ + for(int i = 0; i < g_repeat; i++) { + CALL_SUBTEST_1( parametrizedline(ParametrizedLine()) ); + CALL_SUBTEST_2( parametrizedline(ParametrizedLine()) ); + CALL_SUBTEST_2( parametrizedline_alignment() ); + CALL_SUBTEST_3( parametrizedline(ParametrizedLine()) ); + CALL_SUBTEST_3( parametrizedline_alignment() ); + CALL_SUBTEST_4( parametrizedline(ParametrizedLine,5>()) ); + } +} diff --git a/include/eigen/test/geo_quaternion.cpp b/include/eigen/test/geo_quaternion.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c561fc89d0e8f314354468824cce8a3bfd8d3511 --- /dev/null +++ b/include/eigen/test/geo_quaternion.cpp @@ -0,0 +1,332 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2008-2009 Gael Guennebaud +// Copyright (C) 2009 Mathieu Gautier +// +// 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/. + +#include "main.h" +#include +#include +#include +#include "AnnoyingScalar.h" + +template T bounded_acos(T v) +{ + using std::acos; + using std::min; + using std::max; + return acos((max)(T(-1),(min)(v,T(1)))); +} + +template void check_slerp(const QuatType& q0, const QuatType& q1) +{ + using std::abs; + typedef typename QuatType::Scalar Scalar; + typedef AngleAxis AA; + + Scalar largeEps = test_precision(); + + Scalar theta_tot = AA(q1*q0.inverse()).angle(); + if(theta_tot>Scalar(EIGEN_PI)) + theta_tot = Scalar(2.)*Scalar(EIGEN_PI)-theta_tot; + for(Scalar t=0; t<=Scalar(1.001); t+=Scalar(0.1)) + { + QuatType q = q0.slerp(t,q1); + Scalar theta = AA(q*q0.inverse()).angle(); + VERIFY(abs(q.norm() - 1) < largeEps); + if(theta_tot==0) VERIFY(theta_tot==0); + else VERIFY(abs(theta - t * theta_tot) < largeEps); + } +} + +template void quaternion(void) +{ + /* this test covers the following files: + Quaternion.h + */ + using std::abs; + typedef Matrix Vector3; + typedef Matrix Matrix3; + typedef Quaternion Quaternionx; + typedef AngleAxis AngleAxisx; + + Scalar largeEps = test_precision(); + if (internal::is_same::value) + largeEps = Scalar(1e-3); + + Scalar eps = internal::random() * Scalar(1e-2); + + Vector3 v0 = Vector3::Random(), + v1 = Vector3::Random(), + v2 = Vector3::Random(), + v3 = Vector3::Random(); + + Scalar a = internal::random(-Scalar(EIGEN_PI), Scalar(EIGEN_PI)), + b = internal::random(-Scalar(EIGEN_PI), Scalar(EIGEN_PI)); + + // Quaternion: Identity(), setIdentity(); + Quaternionx q1, q2; + q2.setIdentity(); + VERIFY_IS_APPROX(Quaternionx(Quaternionx::Identity()).coeffs(), q2.coeffs()); + q1.coeffs().setRandom(); + VERIFY_IS_APPROX(q1.coeffs(), (q1*q2).coeffs()); + +#ifndef EIGEN_NO_IO + // Printing + std::ostringstream ss; + ss << q2; + VERIFY(ss.str() == "0i + 0j + 0k + 1"); +#endif + + // concatenation + q1 *= q2; + + q1 = AngleAxisx(a, v0.normalized()); + q2 = AngleAxisx(a, v1.normalized()); + + // angular distance + Scalar refangle = abs(AngleAxisx(q1.inverse()*q2).angle()); + if (refangle>Scalar(EIGEN_PI)) + refangle = Scalar(2)*Scalar(EIGEN_PI) - refangle; + + if((q1.coeffs()-q2.coeffs()).norm() > Scalar(10)*largeEps) + { + VERIFY_IS_MUCH_SMALLER_THAN(abs(q1.angularDistance(q2) - refangle), Scalar(1)); + } + + // rotation matrix conversion + VERIFY_IS_APPROX(q1 * v2, q1.toRotationMatrix() * v2); + VERIFY_IS_APPROX(q1 * q2 * v2, + q1.toRotationMatrix() * q2.toRotationMatrix() * v2); + + VERIFY( (q2*q1).isApprox(q1*q2, largeEps) + || !(q2 * q1 * v2).isApprox(q1.toRotationMatrix() * q2.toRotationMatrix() * v2)); + + q2 = q1.toRotationMatrix(); + VERIFY_IS_APPROX(q1*v1,q2*v1); + + Matrix3 rot1(q1); + VERIFY_IS_APPROX(q1*v1,rot1*v1); + Quaternionx q3(rot1.transpose()*rot1); + VERIFY_IS_APPROX(q3*v1,v1); + + + // angle-axis conversion + AngleAxisx aa = AngleAxisx(q1); + VERIFY_IS_APPROX(q1 * v1, Quaternionx(aa) * v1); + + // Do not execute the test if the rotation angle is almost zero, or + // the rotation axis and v1 are almost parallel. + if (abs(aa.angle()) > Scalar(5)*test_precision() + && (aa.axis() - v1.normalized()).norm() < Scalar(1.99) + && (aa.axis() + v1.normalized()).norm() < Scalar(1.99)) + { + VERIFY_IS_NOT_APPROX(q1 * v1, Quaternionx(AngleAxisx(aa.angle()*2,aa.axis())) * v1); + } + + // from two vector creation + VERIFY_IS_APPROX( v2.normalized(),(q2.setFromTwoVectors(v1, v2)*v1).normalized()); + VERIFY_IS_APPROX( v1.normalized(),(q2.setFromTwoVectors(v1, v1)*v1).normalized()); + VERIFY_IS_APPROX(-v1.normalized(),(q2.setFromTwoVectors(v1,-v1)*v1).normalized()); + if (internal::is_same::value) + { + v3 = (v1.array()+eps).matrix(); + VERIFY_IS_APPROX( v3.normalized(),(q2.setFromTwoVectors(v1, v3)*v1).normalized()); + VERIFY_IS_APPROX(-v3.normalized(),(q2.setFromTwoVectors(v1,-v3)*v1).normalized()); + } + + // from two vector creation static function + VERIFY_IS_APPROX( v2.normalized(),(Quaternionx::FromTwoVectors(v1, v2)*v1).normalized()); + VERIFY_IS_APPROX( v1.normalized(),(Quaternionx::FromTwoVectors(v1, v1)*v1).normalized()); + VERIFY_IS_APPROX(-v1.normalized(),(Quaternionx::FromTwoVectors(v1,-v1)*v1).normalized()); + if (internal::is_same::value) + { + v3 = (v1.array()+eps).matrix(); + VERIFY_IS_APPROX( v3.normalized(),(Quaternionx::FromTwoVectors(v1, v3)*v1).normalized()); + VERIFY_IS_APPROX(-v3.normalized(),(Quaternionx::FromTwoVectors(v1,-v3)*v1).normalized()); + } + + // inverse and conjugate + VERIFY_IS_APPROX(q1 * (q1.inverse() * v1), v1); + VERIFY_IS_APPROX(q1 * (q1.conjugate() * v1), v1); + + // test casting + Quaternion q1f = q1.template cast(); + VERIFY_IS_APPROX(q1f.template cast(),q1); + Quaternion q1d = q1.template cast(); + VERIFY_IS_APPROX(q1d.template cast(),q1); + + // test bug 369 - improper alignment. + Quaternionx *q = new Quaternionx; + delete q; + + q1 = Quaternionx::UnitRandom(); + q2 = Quaternionx::UnitRandom(); + check_slerp(q1,q2); + + q1 = AngleAxisx(b, v1.normalized()); + q2 = AngleAxisx(b+Scalar(EIGEN_PI), v1.normalized()); + check_slerp(q1,q2); + + q1 = AngleAxisx(b, v1.normalized()); + q2 = AngleAxisx(-b, -v1.normalized()); + check_slerp(q1,q2); + + q1 = Quaternionx::UnitRandom(); + q2.coeffs() = -q1.coeffs(); + check_slerp(q1,q2); +} + +template void mapQuaternion(void){ + typedef Map, Aligned> MQuaternionA; + typedef Map, Aligned> MCQuaternionA; + typedef Map > MQuaternionUA; + typedef Map > MCQuaternionUA; + typedef Quaternion Quaternionx; + typedef Matrix Vector3; + typedef AngleAxis AngleAxisx; + + Vector3 v0 = Vector3::Random(), + v1 = Vector3::Random(); + Scalar a = internal::random(-Scalar(EIGEN_PI), Scalar(EIGEN_PI)); + + EIGEN_ALIGN_MAX Scalar array1[4]; + EIGEN_ALIGN_MAX Scalar array2[4]; + EIGEN_ALIGN_MAX Scalar array3[4+1]; + Scalar* array3unaligned = array3+1; + + MQuaternionA mq1(array1); + MCQuaternionA mcq1(array1); + MQuaternionA mq2(array2); + MQuaternionUA mq3(array3unaligned); + MCQuaternionUA mcq3(array3unaligned); + +// std::cerr << array1 << " " << array2 << " " << array3 << "\n"; + mq1 = AngleAxisx(a, v0.normalized()); + mq2 = mq1; + mq3 = mq1; + + Quaternionx q1 = mq1; + Quaternionx q2 = mq2; + Quaternionx q3 = mq3; + Quaternionx q4 = MCQuaternionUA(array3unaligned); + + VERIFY_IS_APPROX(q1.coeffs(), q2.coeffs()); + VERIFY_IS_APPROX(q1.coeffs(), q3.coeffs()); + VERIFY_IS_APPROX(q4.coeffs(), q3.coeffs()); + + VERIFY_IS_APPROX(mq1 * (mq1.inverse() * v1), v1); + VERIFY_IS_APPROX(mq1 * (mq1.conjugate() * v1), v1); + + VERIFY_IS_APPROX(mcq1 * (mcq1.inverse() * v1), v1); + VERIFY_IS_APPROX(mcq1 * (mcq1.conjugate() * v1), v1); + + VERIFY_IS_APPROX(mq3 * (mq3.inverse() * v1), v1); + VERIFY_IS_APPROX(mq3 * (mq3.conjugate() * v1), v1); + + VERIFY_IS_APPROX(mcq3 * (mcq3.inverse() * v1), v1); + VERIFY_IS_APPROX(mcq3 * (mcq3.conjugate() * v1), v1); + + VERIFY_IS_APPROX(mq1*mq2, q1*q2); + VERIFY_IS_APPROX(mq3*mq2, q3*q2); + VERIFY_IS_APPROX(mcq1*mq2, q1*q2); + VERIFY_IS_APPROX(mcq3*mq2, q3*q2); + + // Bug 1461, compilation issue with Map::w(), and other reference/constness checks: + VERIFY_IS_APPROX(mcq3.coeffs().x() + mcq3.coeffs().y() + mcq3.coeffs().z() + mcq3.coeffs().w(), mcq3.coeffs().sum()); + VERIFY_IS_APPROX(mcq3.x() + mcq3.y() + mcq3.z() + mcq3.w(), mcq3.coeffs().sum()); + mq3.w() = 1; + const Quaternionx& cq3(q3); + VERIFY( &cq3.x() == &q3.x() ); + const MQuaternionUA& cmq3(mq3); + VERIFY( &cmq3.x() == &mq3.x() ); + // FIXME the following should be ok. The problem is that currently the LValueBit flag + // is used to determine whether we can return a coeff by reference or not, which is not enough for Map. + //const MCQuaternionUA& cmcq3(mcq3); + //VERIFY( &cmcq3.x() == &mcq3.x() ); + + // test cast + { + Quaternion q1f = mq1.template cast(); + VERIFY_IS_APPROX(q1f.template cast(),mq1); + Quaternion q1d = mq1.template cast(); + VERIFY_IS_APPROX(q1d.template cast(),mq1); + } +} + +template void quaternionAlignment(void){ + typedef Quaternion QuaternionA; + typedef Quaternion QuaternionUA; + + EIGEN_ALIGN_MAX Scalar array1[4]; + EIGEN_ALIGN_MAX Scalar array2[4]; + EIGEN_ALIGN_MAX Scalar array3[4+1]; + Scalar* arrayunaligned = array3+1; + + QuaternionA *q1 = ::new(reinterpret_cast(array1)) QuaternionA; + QuaternionUA *q2 = ::new(reinterpret_cast(array2)) QuaternionUA; + QuaternionUA *q3 = ::new(reinterpret_cast(arrayunaligned)) QuaternionUA; + + q1->coeffs().setRandom(); + *q2 = *q1; + *q3 = *q1; + + VERIFY_IS_APPROX(q1->coeffs(), q2->coeffs()); + VERIFY_IS_APPROX(q1->coeffs(), q3->coeffs()); +} + +template void check_const_correctness(const PlainObjectType&) +{ + // there's a lot that we can't test here while still having this test compile! + // the only possible approach would be to run a script trying to compile stuff and checking that it fails. + // CMake can help with that. + + // verify that map-to-const don't have LvalueBit + typedef typename internal::add_const::type ConstPlainObjectType; + VERIFY( !(internal::traits >::Flags & LvalueBit) ); + VERIFY( !(internal::traits >::Flags & LvalueBit) ); + VERIFY( !(Map::Flags & LvalueBit) ); + VERIFY( !(Map::Flags & LvalueBit) ); +} + +#if EIGEN_HAS_RVALUE_REFERENCES + +// Regression for bug 1573 +struct MovableClass { + // The following line is a workaround for gcc 4.7 and 4.8 (see bug 1573 comments). + static_assert(std::is_nothrow_move_constructible::value,""); + MovableClass() = default; + MovableClass(const MovableClass&) = default; + MovableClass(MovableClass&&) noexcept = default; + MovableClass& operator=(const MovableClass&) = default; + MovableClass& operator=(MovableClass&&) = default; + Quaternionf m_quat; +}; + +#endif + +EIGEN_DECLARE_TEST(geo_quaternion) +{ + for(int i = 0; i < g_repeat; i++) { + CALL_SUBTEST_1(( quaternion() )); + CALL_SUBTEST_1( check_const_correctness(Quaternionf()) ); + CALL_SUBTEST_1(( quaternion() )); + CALL_SUBTEST_1(( quaternionAlignment() )); + CALL_SUBTEST_1( mapQuaternion() ); + + CALL_SUBTEST_2(( quaternion() )); + CALL_SUBTEST_2( check_const_correctness(Quaterniond()) ); + CALL_SUBTEST_2(( quaternion() )); + CALL_SUBTEST_2(( quaternionAlignment() )); + CALL_SUBTEST_2( mapQuaternion() ); + +#ifndef EIGEN_TEST_ANNOYING_SCALAR_DONT_THROW + AnnoyingScalar::dont_throw = true; +#endif + CALL_SUBTEST_3(( quaternion() )); + } +} diff --git a/include/eigen/test/geo_transformations.cpp b/include/eigen/test/geo_transformations.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ed31c304a710036bc5b634c45c6d51f9d8581787 --- /dev/null +++ b/include/eigen/test/geo_transformations.cpp @@ -0,0 +1,737 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2008-2009 Gael Guennebaud +// +// 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/. + +#include "main.h" +#include +#include +#include + +template +Matrix angleToVec(T a) +{ + return Matrix(std::cos(a), std::sin(a)); +} + +// This permits to workaround a bug in clang/llvm code generation. +template +EIGEN_DONT_INLINE +void dont_over_optimize(T& x) { volatile typename T::Scalar tmp = x(0); x(0) = tmp; } + +template void non_projective_only() +{ + /* this test covers the following files: + Cross.h Quaternion.h, Transform.cpp + */ + typedef Matrix Vector3; + typedef Quaternion Quaternionx; + typedef AngleAxis AngleAxisx; + typedef Transform Transform3; + typedef DiagonalMatrix AlignedScaling3; + typedef Translation Translation3; + + Vector3 v0 = Vector3::Random(), + v1 = Vector3::Random(); + + Transform3 t0, t1, t2; + + Scalar a = internal::random(-Scalar(EIGEN_PI), Scalar(EIGEN_PI)); + + Quaternionx q1, q2; + + q1 = AngleAxisx(a, v0.normalized()); + + t0 = Transform3::Identity(); + VERIFY_IS_APPROX(t0.matrix(), Transform3::MatrixType::Identity()); + + t0.linear() = q1.toRotationMatrix(); + + v0 << 50, 2, 1; + t0.scale(v0); + + VERIFY_IS_APPROX( (t0 * Vector3(1,0,0)).template head<3>().norm(), v0.x()); + + t0.setIdentity(); + t1.setIdentity(); + v1 << 1, 2, 3; + t0.linear() = q1.toRotationMatrix(); + t0.pretranslate(v0); + t0.scale(v1); + t1.linear() = q1.conjugate().toRotationMatrix(); + t1.prescale(v1.cwiseInverse()); + t1.translate(-v0); + + VERIFY((t0 * t1).matrix().isIdentity(test_precision())); + + t1.fromPositionOrientationScale(v0, q1, v1); + VERIFY_IS_APPROX(t1.matrix(), t0.matrix()); + VERIFY_IS_APPROX(t1*v1, t0*v1); + + // translation * vector + t0.setIdentity(); + t0.translate(v0); + VERIFY_IS_APPROX((t0 * v1).template head<3>(), Translation3(v0) * v1); + + // AlignedScaling * vector + t0.setIdentity(); + t0.scale(v0); + VERIFY_IS_APPROX((t0 * v1).template head<3>(), AlignedScaling3(v0) * v1); +} + +template void transformations() +{ + /* this test covers the following files: + Cross.h Quaternion.h, Transform.cpp + */ + using std::cos; + using std::abs; + typedef Matrix Matrix3; + typedef Matrix Matrix4; + typedef Matrix Vector2; + typedef Matrix Vector3; + typedef Matrix Vector4; + typedef Quaternion Quaternionx; + typedef AngleAxis AngleAxisx; + typedef Transform Transform2; + typedef Transform Transform3; + typedef typename Transform3::MatrixType MatrixType; + typedef DiagonalMatrix AlignedScaling3; + typedef Translation Translation2; + typedef Translation Translation3; + + Vector3 v0 = Vector3::Random(), + v1 = Vector3::Random(); + Matrix3 matrot1, m; + + Scalar a = internal::random(-Scalar(EIGEN_PI), Scalar(EIGEN_PI)); + Scalar s0 = internal::random(), s1 = internal::random(); + + while(v0.norm() < test_precision()) v0 = Vector3::Random(); + while(v1.norm() < test_precision()) v1 = Vector3::Random(); + + VERIFY_IS_APPROX(v0, AngleAxisx(a, v0.normalized()) * v0); + VERIFY_IS_APPROX(-v0, AngleAxisx(Scalar(EIGEN_PI), v0.unitOrthogonal()) * v0); + if(abs(cos(a)) > test_precision()) + { + VERIFY_IS_APPROX(cos(a)*v0.squaredNorm(), v0.dot(AngleAxisx(a, v0.unitOrthogonal()) * v0)); + } + m = AngleAxisx(a, v0.normalized()).toRotationMatrix().adjoint(); + VERIFY_IS_APPROX(Matrix3::Identity(), m * AngleAxisx(a, v0.normalized())); + VERIFY_IS_APPROX(Matrix3::Identity(), AngleAxisx(a, v0.normalized()) * m); + + Quaternionx q1, q2; + q1 = AngleAxisx(a, v0.normalized()); + q2 = AngleAxisx(a, v1.normalized()); + + // rotation matrix conversion + matrot1 = AngleAxisx(Scalar(0.1), Vector3::UnitX()) + * AngleAxisx(Scalar(0.2), Vector3::UnitY()) + * AngleAxisx(Scalar(0.3), Vector3::UnitZ()); + VERIFY_IS_APPROX(matrot1 * v1, + AngleAxisx(Scalar(0.1), Vector3(1,0,0)).toRotationMatrix() + * (AngleAxisx(Scalar(0.2), Vector3(0,1,0)).toRotationMatrix() + * (AngleAxisx(Scalar(0.3), Vector3(0,0,1)).toRotationMatrix() * v1))); + + // angle-axis conversion + AngleAxisx aa = AngleAxisx(q1); + VERIFY_IS_APPROX(q1 * v1, Quaternionx(aa) * v1); + + // The following test is stable only if 2*angle != angle and v1 is not colinear with axis + if( (abs(aa.angle()) > test_precision()) && (abs(aa.axis().dot(v1.normalized()))<(Scalar(1)-Scalar(4)*test_precision())) ) + { + VERIFY( !(q1 * v1).isApprox(Quaternionx(AngleAxisx(aa.angle()*2,aa.axis())) * v1) ); + } + + aa.fromRotationMatrix(aa.toRotationMatrix()); + VERIFY_IS_APPROX(q1 * v1, Quaternionx(aa) * v1); + // The following test is stable only if 2*angle != angle and v1 is not colinear with axis + if( (abs(aa.angle()) > test_precision()) && (abs(aa.axis().dot(v1.normalized()))<(Scalar(1)-Scalar(4)*test_precision())) ) + { + VERIFY( !(q1 * v1).isApprox(Quaternionx(AngleAxisx(aa.angle()*2,aa.axis())) * v1) ); + } + + // AngleAxis + VERIFY_IS_APPROX(AngleAxisx(a,v1.normalized()).toRotationMatrix(), + Quaternionx(AngleAxisx(a,v1.normalized())).toRotationMatrix()); + + AngleAxisx aa1; + m = q1.toRotationMatrix(); + aa1 = m; + VERIFY_IS_APPROX(AngleAxisx(m).toRotationMatrix(), + Quaternionx(m).toRotationMatrix()); + + // Transform + // TODO complete the tests ! + a = 0; + while (abs(a)(-Scalar(0.4)*Scalar(EIGEN_PI), Scalar(0.4)*Scalar(EIGEN_PI)); + q1 = AngleAxisx(a, v0.normalized()); + Transform3 t0, t1, t2; + + // first test setIdentity() and Identity() + t0.setIdentity(); + VERIFY_IS_APPROX(t0.matrix(), Transform3::MatrixType::Identity()); + t0.matrix().setZero(); + t0 = Transform3::Identity(); + VERIFY_IS_APPROX(t0.matrix(), Transform3::MatrixType::Identity()); + + t0.setIdentity(); + t1.setIdentity(); + v1 << 1, 2, 3; + t0.linear() = q1.toRotationMatrix(); + t0.pretranslate(v0); + t0.scale(v1); + t1.linear() = q1.conjugate().toRotationMatrix(); + t1.prescale(v1.cwiseInverse()); + t1.translate(-v0); + + VERIFY((t0 * t1).matrix().isIdentity(test_precision())); + + t1.fromPositionOrientationScale(v0, q1, v1); + VERIFY_IS_APPROX(t1.matrix(), t0.matrix()); + + t0.setIdentity(); t0.scale(v0).rotate(q1.toRotationMatrix()); + t1.setIdentity(); t1.scale(v0).rotate(q1); + VERIFY_IS_APPROX(t0.matrix(), t1.matrix()); + + t0.setIdentity(); t0.scale(v0).rotate(AngleAxisx(q1)); + VERIFY_IS_APPROX(t0.matrix(), t1.matrix()); + + VERIFY_IS_APPROX(t0.scale(a).matrix(), t1.scale(Vector3::Constant(a)).matrix()); + VERIFY_IS_APPROX(t0.prescale(a).matrix(), t1.prescale(Vector3::Constant(a)).matrix()); + + // More transform constructors, operator=, operator*= + + Matrix3 mat3 = Matrix3::Random(); + Matrix4 mat4; + mat4 << mat3 , Vector3::Zero() , Vector4::Zero().transpose(); + Transform3 tmat3(mat3), tmat4(mat4); + if(Mode!=int(AffineCompact)) + tmat4.matrix()(3,3) = Scalar(1); + VERIFY_IS_APPROX(tmat3.matrix(), tmat4.matrix()); + + Scalar a3 = internal::random(-Scalar(EIGEN_PI), Scalar(EIGEN_PI)); + Vector3 v3 = Vector3::Random().normalized(); + AngleAxisx aa3(a3, v3); + Transform3 t3(aa3); + Transform3 t4; + t4 = aa3; + VERIFY_IS_APPROX(t3.matrix(), t4.matrix()); + t4.rotate(AngleAxisx(-a3,v3)); + VERIFY_IS_APPROX(t4.matrix(), MatrixType::Identity()); + t4 *= aa3; + VERIFY_IS_APPROX(t3.matrix(), t4.matrix()); + + do { + v3 = Vector3::Random(); + dont_over_optimize(v3); + } while (v3.cwiseAbs().minCoeff()::epsilon()); + Translation3 tv3(v3); + Transform3 t5(tv3); + t4 = tv3; + VERIFY_IS_APPROX(t5.matrix(), t4.matrix()); + t4.translate((-v3).eval()); + VERIFY_IS_APPROX(t4.matrix(), MatrixType::Identity()); + t4 *= tv3; + VERIFY_IS_APPROX(t5.matrix(), t4.matrix()); + + AlignedScaling3 sv3(v3); + Transform3 t6(sv3); + t4 = sv3; + VERIFY_IS_APPROX(t6.matrix(), t4.matrix()); + t4.scale(v3.cwiseInverse()); + VERIFY_IS_APPROX(t4.matrix(), MatrixType::Identity()); + t4 *= sv3; + VERIFY_IS_APPROX(t6.matrix(), t4.matrix()); + + // matrix * transform + VERIFY_IS_APPROX((t3.matrix()*t4).matrix(), (t3*t4).matrix()); + + // chained Transform product + VERIFY_IS_APPROX(((t3*t4)*t5).matrix(), (t3*(t4*t5)).matrix()); + + // check that Transform product doesn't have aliasing problems + t5 = t4; + t5 = t5*t5; + VERIFY_IS_APPROX(t5, t4*t4); + + // 2D transformation + Transform2 t20, t21; + Vector2 v20 = Vector2::Random(); + Vector2 v21 = Vector2::Random(); + for (int k=0; k<2; ++k) + if (abs(v21[k])(a).toRotationMatrix(); + VERIFY_IS_APPROX(t20.fromPositionOrientationScale(v20,a,v21).matrix(), + t21.pretranslate(v20).scale(v21).matrix()); + + t21.setIdentity(); + t21.linear() = Rotation2D(-a).toRotationMatrix(); + VERIFY( (t20.fromPositionOrientationScale(v20,a,v21) + * (t21.prescale(v21.cwiseInverse()).translate(-v20))).matrix().isIdentity(test_precision()) ); + + t20.setIdentity(); + t20.shear(Scalar(2), Scalar(3)); + Transform2 t23 = t20 * t21; + t21.preshear(Scalar(2), Scalar(3)); + VERIFY_IS_APPROX(t21, t23); + + // Transform - new API + // 3D + t0.setIdentity(); + t0.rotate(q1).scale(v0).translate(v0); + // mat * aligned scaling and mat * translation + t1 = (Matrix3(q1) * AlignedScaling3(v0)) * Translation3(v0); + VERIFY_IS_APPROX(t0.matrix(), t1.matrix()); + t1 = (Matrix3(q1) * Eigen::Scaling(v0)) * Translation3(v0); + VERIFY_IS_APPROX(t0.matrix(), t1.matrix()); + t1 = (q1 * Eigen::Scaling(v0)) * Translation3(v0); + VERIFY_IS_APPROX(t0.matrix(), t1.matrix()); + // mat * transformation and aligned scaling * translation + t1 = Matrix3(q1) * (AlignedScaling3(v0) * Translation3(v0)); + VERIFY_IS_APPROX(t0.matrix(), t1.matrix()); + + + t0.setIdentity(); + t0.scale(s0).translate(v0); + t1 = Eigen::Scaling(s0) * Translation3(v0); + VERIFY_IS_APPROX(t0.matrix(), t1.matrix()); + t0.prescale(s0); + t1 = Eigen::Scaling(s0) * t1; + VERIFY_IS_APPROX(t0.matrix(), t1.matrix()); + + t0 = t3; + t0.scale(s0); + t1 = t3 * Eigen::Scaling(s0,s0,s0); + VERIFY_IS_APPROX(t0.matrix(), t1.matrix()); + t0.prescale(s0); + t1 = Eigen::Scaling(s0,s0,s0) * t1; + VERIFY_IS_APPROX(t0.matrix(), t1.matrix()); + + t0 = t3; + t0.scale(s0); + t1 = t3 * Eigen::Scaling(s0); + VERIFY_IS_APPROX(t0.matrix(), t1.matrix()); + t0.prescale(s0); + t1 = Eigen::Scaling(s0) * t1; + VERIFY_IS_APPROX(t0.matrix(), t1.matrix()); + + t0.setIdentity(); + t0.prerotate(q1).prescale(v0).pretranslate(v0); + // translation * aligned scaling and transformation * mat + t1 = (Translation3(v0) * AlignedScaling3(v0)) * Transform3(q1); + VERIFY_IS_APPROX(t0.matrix(), t1.matrix()); + // scaling * mat and translation * mat + t1 = Translation3(v0) * (AlignedScaling3(v0) * Transform3(q1)); + VERIFY_IS_APPROX(t0.matrix(), t1.matrix()); + + t0.setIdentity(); + t0.scale(v0).translate(v0).rotate(q1); + // translation * mat and aligned scaling * transformation + t1 = AlignedScaling3(v0) * (Translation3(v0) * Transform3(q1)); + VERIFY_IS_APPROX(t0.matrix(), t1.matrix()); + // transformation * aligned scaling + t0.scale(v0); + t1 *= AlignedScaling3(v0); + VERIFY_IS_APPROX(t0.matrix(), t1.matrix()); + t1 = AlignedScaling3(v0) * (Translation3(v0) * Transform3(q1)); + t1 = t1 * v0.asDiagonal(); + VERIFY_IS_APPROX(t0.matrix(), t1.matrix()); + // transformation * translation + t0.translate(v0); + t1 = t1 * Translation3(v0); + VERIFY_IS_APPROX(t0.matrix(), t1.matrix()); + // translation * transformation + t0.pretranslate(v0); + t1 = Translation3(v0) * t1; + VERIFY_IS_APPROX(t0.matrix(), t1.matrix()); + + // transform * quaternion + t0.rotate(q1); + t1 = t1 * q1; + VERIFY_IS_APPROX(t0.matrix(), t1.matrix()); + + // translation * quaternion + t0.translate(v1).rotate(q1); + t1 = t1 * (Translation3(v1) * q1); + VERIFY_IS_APPROX(t0.matrix(), t1.matrix()); + + // aligned scaling * quaternion + t0.scale(v1).rotate(q1); + t1 = t1 * (AlignedScaling3(v1) * q1); + VERIFY_IS_APPROX(t0.matrix(), t1.matrix()); + + // quaternion * transform + t0.prerotate(q1); + t1 = q1 * t1; + VERIFY_IS_APPROX(t0.matrix(), t1.matrix()); + + // quaternion * translation + t0.rotate(q1).translate(v1); + t1 = t1 * (q1 * Translation3(v1)); + VERIFY_IS_APPROX(t0.matrix(), t1.matrix()); + + // quaternion * aligned scaling + t0.rotate(q1).scale(v1); + t1 = t1 * (q1 * AlignedScaling3(v1)); + VERIFY_IS_APPROX(t0.matrix(), t1.matrix()); + + // test transform inversion + t0.setIdentity(); + t0.translate(v0); + do { + t0.linear().setRandom(); + } while(t0.linear().jacobiSvd().singularValues()(2)()); + Matrix4 t044 = Matrix4::Zero(); + t044(3,3) = 1; + t044.block(0,0,t0.matrix().rows(),4) = t0.matrix(); + VERIFY_IS_APPROX(t0.inverse(Affine).matrix(), t044.inverse().block(0,0,t0.matrix().rows(),4)); + t0.setIdentity(); + t0.translate(v0).rotate(q1); + t044 = Matrix4::Zero(); + t044(3,3) = 1; + t044.block(0,0,t0.matrix().rows(),4) = t0.matrix(); + VERIFY_IS_APPROX(t0.inverse(Isometry).matrix(), t044.inverse().block(0,0,t0.matrix().rows(),4)); + + Matrix3 mat_rotation, mat_scaling; + t0.setIdentity(); + t0.translate(v0).rotate(q1).scale(v1); + t0.computeRotationScaling(&mat_rotation, &mat_scaling); + VERIFY_IS_APPROX(t0.linear(), mat_rotation * mat_scaling); + VERIFY_IS_APPROX(mat_rotation*mat_rotation.adjoint(), Matrix3::Identity()); + VERIFY_IS_APPROX(mat_rotation.determinant(), Scalar(1)); + t0.computeScalingRotation(&mat_scaling, &mat_rotation); + VERIFY_IS_APPROX(t0.linear(), mat_scaling * mat_rotation); + VERIFY_IS_APPROX(mat_rotation*mat_rotation.adjoint(), Matrix3::Identity()); + VERIFY_IS_APPROX(mat_rotation.determinant(), Scalar(1)); + + // test casting + Transform t1f = t1.template cast(); + VERIFY_IS_APPROX(t1f.template cast(),t1); + Transform t1d = t1.template cast(); + VERIFY_IS_APPROX(t1d.template cast(),t1); + + Translation3 tr1(v0); + Translation tr1f = tr1.template cast(); + VERIFY_IS_APPROX(tr1f.template cast(),tr1); + Translation tr1d = tr1.template cast(); + VERIFY_IS_APPROX(tr1d.template cast(),tr1); + + AngleAxis aa1f = aa1.template cast(); + VERIFY_IS_APPROX(aa1f.template cast(),aa1); + AngleAxis aa1d = aa1.template cast(); + VERIFY_IS_APPROX(aa1d.template cast(),aa1); + + Rotation2D r2d1(internal::random()); + Rotation2D r2d1f = r2d1.template cast(); + VERIFY_IS_APPROX(r2d1f.template cast(),r2d1); + Rotation2D r2d1d = r2d1.template cast(); + VERIFY_IS_APPROX(r2d1d.template cast(),r2d1); + + for(int k=0; k<100; ++k) + { + Scalar angle = internal::random(-100,100); + Rotation2D rot2(angle); + VERIFY( rot2.smallestPositiveAngle() >= 0 ); + VERIFY( rot2.smallestPositiveAngle() <= Scalar(2)*Scalar(EIGEN_PI) ); + VERIFY_IS_APPROX( angleToVec(rot2.smallestPositiveAngle()), angleToVec(rot2.angle()) ); + + VERIFY( rot2.smallestAngle() >= -Scalar(EIGEN_PI) ); + VERIFY( rot2.smallestAngle() <= Scalar(EIGEN_PI) ); + VERIFY_IS_APPROX( angleToVec(rot2.smallestAngle()), angleToVec(rot2.angle()) ); + + Matrix rot2_as_mat(rot2); + Rotation2D rot3(rot2_as_mat); + VERIFY_IS_APPROX( angleToVec(rot2.smallestAngle()), angleToVec(rot3.angle()) ); + } + + s0 = internal::random(-100,100); + s1 = internal::random(-100,100); + Rotation2D R0(s0), R1(s1); + + t20 = Translation2(v20) * (R0 * Eigen::Scaling(s0)); + t21 = Translation2(v20) * R0 * Eigen::Scaling(s0); + VERIFY_IS_APPROX(t20,t21); + + t20 = Translation2(v20) * (R0 * R0.inverse() * Eigen::Scaling(s0)); + t21 = Translation2(v20) * Eigen::Scaling(s0); + VERIFY_IS_APPROX(t20,t21); + + VERIFY_IS_APPROX(s0, (R0.slerp(0, R1)).angle()); + VERIFY_IS_APPROX( angleToVec(R1.smallestPositiveAngle()), angleToVec((R0.slerp(1, R1)).smallestPositiveAngle()) ); + VERIFY_IS_APPROX(R0.smallestPositiveAngle(), (R0.slerp(0.5, R0)).smallestPositiveAngle()); + + if(std::cos(s0)>0) + VERIFY_IS_MUCH_SMALLER_THAN((R0.slerp(0.5, R0.inverse())).smallestAngle(), Scalar(1)); + else + VERIFY_IS_APPROX(Scalar(EIGEN_PI), (R0.slerp(0.5, R0.inverse())).smallestPositiveAngle()); + + // Check path length + Scalar l = 0; + int path_steps = 100; + for(int k=0; k::epsilon()*Scalar(path_steps/2))); + + // check basic features + { + Rotation2D r1; // default ctor + r1 = Rotation2D(s0); // copy assignment + VERIFY_IS_APPROX(r1.angle(),s0); + Rotation2D r2(r1); // copy ctor + VERIFY_IS_APPROX(r2.angle(),s0); + } + + { + Transform3 t32(Matrix4::Random()), t33, t34; + t34 = t33 = t32; + t32.scale(v0); + t33*=AlignedScaling3(v0); + VERIFY_IS_APPROX(t32.matrix(), t33.matrix()); + t33 = t34 * AlignedScaling3(v0); + VERIFY_IS_APPROX(t32.matrix(), t33.matrix()); + } + +} + +template +void transform_associativity_left(const A1& a1, const A2& a2, const P& p, const Q& q, const V& v, const H& h) +{ + VERIFY_IS_APPROX( q*(a1*v), (q*a1)*v ); + VERIFY_IS_APPROX( q*(a2*v), (q*a2)*v ); + VERIFY_IS_APPROX( q*(p*h).hnormalized(), ((q*p)*h).hnormalized() ); +} + +template +void transform_associativity2(const A1& a1, const A2& a2, const P& p, const Q& q, const V& v, const H& h) +{ + VERIFY_IS_APPROX( a1*(q*v), (a1*q)*v ); + VERIFY_IS_APPROX( a2*(q*v), (a2*q)*v ); + VERIFY_IS_APPROX( p *(q*v).homogeneous(), (p *q)*v.homogeneous() ); + + transform_associativity_left(a1, a2,p, q, v, h); +} + +template +void transform_associativity(const RotationType& R) +{ + typedef Matrix VectorType; + typedef Matrix HVectorType; + typedef Matrix LinearType; + typedef Matrix MatrixType; + typedef Transform AffineCompactType; + typedef Transform AffineType; + typedef Transform ProjectiveType; + typedef DiagonalMatrix ScalingType; + typedef Translation TranslationType; + + AffineCompactType A1c; A1c.matrix().setRandom(); + AffineCompactType A2c; A2c.matrix().setRandom(); + AffineType A1(A1c); + AffineType A2(A2c); + ProjectiveType P1; P1.matrix().setRandom(); + VectorType v1 = VectorType::Random(); + VectorType v2 = VectorType::Random(); + HVectorType h1 = HVectorType::Random(); + Scalar s1 = internal::random(); + LinearType L = LinearType::Random(); + MatrixType M = MatrixType::Random(); + + CALL_SUBTEST( transform_associativity2(A1c, A1, P1, A2, v2, h1) ); + CALL_SUBTEST( transform_associativity2(A1c, A1, P1, A2c, v2, h1) ); + CALL_SUBTEST( transform_associativity2(A1c, A1, P1, v1.asDiagonal(), v2, h1) ); + CALL_SUBTEST( transform_associativity2(A1c, A1, P1, ScalingType(v1), v2, h1) ); + CALL_SUBTEST( transform_associativity2(A1c, A1, P1, Scaling(v1), v2, h1) ); + CALL_SUBTEST( transform_associativity2(A1c, A1, P1, Scaling(s1), v2, h1) ); + CALL_SUBTEST( transform_associativity2(A1c, A1, P1, TranslationType(v1), v2, h1) ); + CALL_SUBTEST( transform_associativity_left(A1c, A1, P1, L, v2, h1) ); + CALL_SUBTEST( transform_associativity2(A1c, A1, P1, R, v2, h1) ); + + VERIFY_IS_APPROX( A1*(M*h1), (A1*M)*h1 ); + VERIFY_IS_APPROX( A1c*(M*h1), (A1c*M)*h1 ); + VERIFY_IS_APPROX( P1*(M*h1), (P1*M)*h1 ); + + VERIFY_IS_APPROX( M*(A1*h1), (M*A1)*h1 ); + VERIFY_IS_APPROX( M*(A1c*h1), (M*A1c)*h1 ); + VERIFY_IS_APPROX( M*(P1*h1), ((M*P1)*h1) ); +} + +template void transform_alignment() +{ + typedef Transform Projective3a; + typedef Transform Projective3u; + + EIGEN_ALIGN_MAX Scalar array1[16]; + EIGEN_ALIGN_MAX Scalar array2[16]; + EIGEN_ALIGN_MAX Scalar array3[16+1]; + Scalar* array3u = array3+1; + + Projective3a *p1 = ::new(reinterpret_cast(array1)) Projective3a; + Projective3u *p2 = ::new(reinterpret_cast(array2)) Projective3u; + Projective3u *p3 = ::new(reinterpret_cast(array3u)) Projective3u; + + p1->matrix().setRandom(); + *p2 = *p1; + *p3 = *p1; + + VERIFY_IS_APPROX(p1->matrix(), p2->matrix()); + VERIFY_IS_APPROX(p1->matrix(), p3->matrix()); + + VERIFY_IS_APPROX( (*p1) * (*p1), (*p2)*(*p3)); +} + +template void transform_products() +{ + typedef Matrix Mat; + typedef Transform Proj; + typedef Transform Aff; + typedef Transform AffC; + + Proj p; p.matrix().setRandom(); + Aff a; a.linear().setRandom(); a.translation().setRandom(); + AffC ac = a; + + Mat p_m(p.matrix()), a_m(a.matrix()); + + VERIFY_IS_APPROX((p*p).matrix(), p_m*p_m); + VERIFY_IS_APPROX((a*a).matrix(), a_m*a_m); + VERIFY_IS_APPROX((p*a).matrix(), p_m*a_m); + VERIFY_IS_APPROX((a*p).matrix(), a_m*p_m); + VERIFY_IS_APPROX((ac*a).matrix(), a_m*a_m); + VERIFY_IS_APPROX((a*ac).matrix(), a_m*a_m); + VERIFY_IS_APPROX((p*ac).matrix(), p_m*a_m); + VERIFY_IS_APPROX((ac*p).matrix(), a_m*p_m); +} + +template void transformations_no_scale() +{ + /* this test covers the following files: + Cross.h Quaternion.h, Transform.h + */ + typedef Matrix Vector3; + typedef Matrix Vector4; + typedef Quaternion Quaternionx; + typedef AngleAxis AngleAxisx; + typedef Transform Transform3; + typedef Translation Translation3; + typedef Matrix Matrix4; + + Vector3 v0 = Vector3::Random(), + v1 = Vector3::Random(); + + Transform3 t0, t1, t2; + + Scalar a = internal::random(-Scalar(EIGEN_PI), Scalar(EIGEN_PI)); + + Quaternionx q1, q2; + + q1 = AngleAxisx(a, v0.normalized()); + + t0 = Transform3::Identity(); + VERIFY_IS_APPROX(t0.matrix(), Transform3::MatrixType::Identity()); + + t0.setIdentity(); + t1.setIdentity(); + v1 = Vector3::Ones(); + t0.linear() = q1.toRotationMatrix(); + t0.pretranslate(v0); + t1.linear() = q1.conjugate().toRotationMatrix(); + t1.translate(-v0); + + VERIFY((t0 * t1).matrix().isIdentity(test_precision())); + + t1.fromPositionOrientationScale(v0, q1, v1); + VERIFY_IS_APPROX(t1.matrix(), t0.matrix()); + VERIFY_IS_APPROX(t1*v1, t0*v1); + + // translation * vector + t0.setIdentity(); + t0.translate(v0); + VERIFY_IS_APPROX((t0 * v1).template head<3>(), Translation3(v0) * v1); + + // Conversion to matrix. + Transform3 t3; + t3.linear() = q1.toRotationMatrix(); + t3.translation() = v1; + Matrix4 m3 = t3.matrix(); + VERIFY((m3 * m3.inverse()).isIdentity(test_precision())); + // Verify implicit last row is initialized. + VERIFY_IS_APPROX(Vector4(m3.row(3)), Vector4(0.0, 0.0, 0.0, 1.0)); + + VERIFY_IS_APPROX(t3.rotation(), t3.linear()); + if(Mode==Isometry) + VERIFY(t3.rotation().data()==t3.linear().data()); +} + +template void transformations_computed_scaling_continuity() +{ + typedef Matrix Vector3; + typedef Transform Transform3; + typedef Matrix Matrix3; + + // Given: two transforms that differ by '2*eps'. + Scalar eps(1e-3); + Vector3 v0 = Vector3::Random().normalized(), + v1 = Vector3::Random().normalized(), + v3 = Vector3::Random().normalized(); + Transform3 t0, t1; + // The interesting case is when their determinants have different signs. + Matrix3 rank2 = 50 * v0 * v0.adjoint() + 20 * v1 * v1.adjoint(); + t0.linear() = rank2 + eps * v3 * v3.adjoint(); + t1.linear() = rank2 - eps * v3 * v3.adjoint(); + + // When: computing the rotation-scaling parts + Matrix3 r0, s0, r1, s1; + t0.computeRotationScaling(&r0, &s0); + t1.computeRotationScaling(&r1, &s1); + + // Then: the scaling parts should differ by no more than '2*eps'. + const Scalar c(2.1); // 2 + room for rounding errors + VERIFY((s0 - s1).norm() < c * eps); +} + +EIGEN_DECLARE_TEST(geo_transformations) +{ + for(int i = 0; i < g_repeat; i++) { + CALL_SUBTEST_1(( transformations() )); + CALL_SUBTEST_1(( non_projective_only() )); + CALL_SUBTEST_1(( transformations_computed_scaling_continuity() )); + + CALL_SUBTEST_2(( transformations() )); + CALL_SUBTEST_2(( non_projective_only() )); + CALL_SUBTEST_2(( transform_alignment() )); + + CALL_SUBTEST_3(( transformations() )); + CALL_SUBTEST_3(( transformations() )); + CALL_SUBTEST_3(( transform_alignment() )); + + CALL_SUBTEST_4(( transformations() )); + CALL_SUBTEST_4(( non_projective_only() )); + + CALL_SUBTEST_5(( transformations() )); + CALL_SUBTEST_5(( non_projective_only() )); + + CALL_SUBTEST_6(( transformations() )); + CALL_SUBTEST_6(( transformations() )); + + + CALL_SUBTEST_7(( transform_products() )); + CALL_SUBTEST_7(( transform_products() )); + + CALL_SUBTEST_8(( transform_associativity(Rotation2D(internal::random()*double(EIGEN_PI))) )); + CALL_SUBTEST_8(( transform_associativity(Quaterniond::UnitRandom()) )); + + CALL_SUBTEST_9(( transformations_no_scale() )); + CALL_SUBTEST_9(( transformations_no_scale() )); + } +} diff --git a/include/eigen/test/half_float.cpp b/include/eigen/test/half_float.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ffb3215b9d85fcd574122654a907ddfd2d08d923 --- /dev/null +++ b/include/eigen/test/half_float.cpp @@ -0,0 +1,352 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// 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/. + +#include + +#include "main.h" + +#include + +#define VERIFY_HALF_BITS_EQUAL(h, bits) \ + VERIFY_IS_EQUAL((numext::bit_cast(h)), (static_cast(bits))) + +// Make sure it's possible to forward declare Eigen::half +namespace Eigen { +struct half; +} + +using Eigen::half; + +void test_conversion() +{ + using Eigen::half_impl::__half_raw; + + // Round-trip bit-cast with uint16. + VERIFY_IS_EQUAL( + numext::bit_cast(numext::bit_cast(half(1.0f))), + half(1.0f)); + VERIFY_IS_EQUAL( + numext::bit_cast(numext::bit_cast(half(0.5f))), + half(0.5f)); + VERIFY_IS_EQUAL( + numext::bit_cast(numext::bit_cast(half(-0.33333f))), + half(-0.33333f)); + VERIFY_IS_EQUAL( + numext::bit_cast(numext::bit_cast(half(0.0f))), + half(0.0f)); + + // Conversion from float. + VERIFY_HALF_BITS_EQUAL(half(1.0f), 0x3c00); + VERIFY_HALF_BITS_EQUAL(half(0.5f), 0x3800); + VERIFY_HALF_BITS_EQUAL(half(0.33333f), 0x3555); + VERIFY_HALF_BITS_EQUAL(half(0.0f), 0x0000); + VERIFY_HALF_BITS_EQUAL(half(-0.0f), 0x8000); + VERIFY_HALF_BITS_EQUAL(half(65504.0f), 0x7bff); + VERIFY_HALF_BITS_EQUAL(half(65536.0f), 0x7c00); // Becomes infinity. + + // Denormals. + VERIFY_HALF_BITS_EQUAL(half(-5.96046e-08f), 0x8001); + VERIFY_HALF_BITS_EQUAL(half(5.96046e-08f), 0x0001); + VERIFY_HALF_BITS_EQUAL(half(1.19209e-07f), 0x0002); + + // Verify round-to-nearest-even behavior. + float val1 = float(half(__half_raw(0x3c00))); + float val2 = float(half(__half_raw(0x3c01))); + float val3 = float(half(__half_raw(0x3c02))); + VERIFY_HALF_BITS_EQUAL(half(0.5f * (val1 + val2)), 0x3c00); + VERIFY_HALF_BITS_EQUAL(half(0.5f * (val2 + val3)), 0x3c02); + + // Conversion from int. + VERIFY_HALF_BITS_EQUAL(half(-1), 0xbc00); + VERIFY_HALF_BITS_EQUAL(half(0), 0x0000); + VERIFY_HALF_BITS_EQUAL(half(1), 0x3c00); + VERIFY_HALF_BITS_EQUAL(half(2), 0x4000); + VERIFY_HALF_BITS_EQUAL(half(3), 0x4200); + + // Conversion from bool. + VERIFY_HALF_BITS_EQUAL(half(false), 0x0000); + VERIFY_HALF_BITS_EQUAL(half(true), 0x3c00); + + // Conversion to float. + VERIFY_IS_EQUAL(float(half(__half_raw(0x0000))), 0.0f); + VERIFY_IS_EQUAL(float(half(__half_raw(0x3c00))), 1.0f); + + // Denormals. + VERIFY_IS_APPROX(float(half(__half_raw(0x8001))), -5.96046e-08f); + VERIFY_IS_APPROX(float(half(__half_raw(0x0001))), 5.96046e-08f); + VERIFY_IS_APPROX(float(half(__half_raw(0x0002))), 1.19209e-07f); + + // NaNs and infinities. + VERIFY(!(numext::isinf)(float(half(65504.0f)))); // Largest finite number. + VERIFY(!(numext::isnan)(float(half(0.0f)))); + VERIFY((numext::isinf)(float(half(__half_raw(0xfc00))))); + VERIFY((numext::isnan)(float(half(__half_raw(0xfc01))))); + VERIFY((numext::isinf)(float(half(__half_raw(0x7c00))))); + VERIFY((numext::isnan)(float(half(__half_raw(0x7c01))))); + +#if !EIGEN_COMP_MSVC + // Visual Studio errors out on divisions by 0 + VERIFY((numext::isnan)(float(half(0.0 / 0.0)))); + VERIFY((numext::isinf)(float(half(1.0 / 0.0)))); + VERIFY((numext::isinf)(float(half(-1.0 / 0.0)))); +#endif + + // Exactly same checks as above, just directly on the half representation. + VERIFY(!(numext::isinf)(half(__half_raw(0x7bff)))); + VERIFY(!(numext::isnan)(half(__half_raw(0x0000)))); + VERIFY((numext::isinf)(half(__half_raw(0xfc00)))); + VERIFY((numext::isnan)(half(__half_raw(0xfc01)))); + VERIFY((numext::isinf)(half(__half_raw(0x7c00)))); + VERIFY((numext::isnan)(half(__half_raw(0x7c01)))); + +#if !EIGEN_COMP_MSVC + // Visual Studio errors out on divisions by 0 + VERIFY((numext::isnan)(half(0.0 / 0.0))); + VERIFY((numext::isinf)(half(1.0 / 0.0))); + VERIFY((numext::isinf)(half(-1.0 / 0.0))); +#endif + + // Conversion to bool + VERIFY(!static_cast(half(0.0))); + VERIFY(!static_cast(half(-0.0))); + VERIFY(static_cast(half(__half_raw(0x7bff)))); + VERIFY(static_cast(half(-0.33333))); + VERIFY(static_cast(half(1.0))); + VERIFY(static_cast(half(-1.0))); + VERIFY(static_cast(half(-5.96046e-08f))); +} + +void test_numtraits() +{ + std::cout << "epsilon = " << NumTraits::epsilon() << " (0x" << std::hex << numext::bit_cast(NumTraits::epsilon()) << ")" << std::endl; + std::cout << "highest = " << NumTraits::highest() << " (0x" << std::hex << numext::bit_cast(NumTraits::highest()) << ")" << std::endl; + std::cout << "lowest = " << NumTraits::lowest() << " (0x" << std::hex << numext::bit_cast(NumTraits::lowest()) << ")" << std::endl; + std::cout << "min = " << (std::numeric_limits::min)() << " (0x" << std::hex << numext::bit_cast(half((std::numeric_limits::min)())) << ")" << std::endl; + std::cout << "denorm min = " << (std::numeric_limits::denorm_min)() << " (0x" << std::hex << numext::bit_cast(half((std::numeric_limits::denorm_min)())) << ")" << std::endl; + std::cout << "infinity = " << NumTraits::infinity() << " (0x" << std::hex << numext::bit_cast(NumTraits::infinity()) << ")" << std::endl; + std::cout << "quiet nan = " << NumTraits::quiet_NaN() << " (0x" << std::hex << numext::bit_cast(NumTraits::quiet_NaN()) << ")" << std::endl; + std::cout << "signaling nan = " << std::numeric_limits::signaling_NaN() << " (0x" << std::hex << numext::bit_cast(std::numeric_limits::signaling_NaN()) << ")" << std::endl; + + VERIFY(NumTraits::IsSigned); + + VERIFY_IS_EQUAL( + numext::bit_cast(std::numeric_limits::infinity()), + numext::bit_cast(half(std::numeric_limits::infinity())) ); + // There is no guarantee that casting a 32-bit NaN to 16-bit has a precise + // bit pattern. We test that it is in fact a NaN, then test the signaling + // bit (msb of significand is 1 for quiet, 0 for signaling). + const numext::uint16_t HALF_QUIET_BIT = 0x0200; + VERIFY( + (numext::isnan)(std::numeric_limits::quiet_NaN()) + && (numext::isnan)(half(std::numeric_limits::quiet_NaN())) + && ((numext::bit_cast(std::numeric_limits::quiet_NaN()) & HALF_QUIET_BIT) > 0) + && ((numext::bit_cast(half(std::numeric_limits::quiet_NaN())) & HALF_QUIET_BIT) > 0) ); + // After a cast to half, a signaling NaN may become non-signaling + // (e.g. in the case of casting float to native __fp16). Thus, we check that + // both are NaN, and that only the `numeric_limits` version is signaling. + VERIFY( + (numext::isnan)(std::numeric_limits::signaling_NaN()) + && (numext::isnan)(half(std::numeric_limits::signaling_NaN())) + && ((numext::bit_cast(std::numeric_limits::signaling_NaN()) & HALF_QUIET_BIT) == 0) ); + + VERIFY( (std::numeric_limits::min)() > half(0.f) ); + VERIFY( (std::numeric_limits::denorm_min)() > half(0.f) ); + VERIFY( (std::numeric_limits::min)()/half(2) > half(0.f) ); + VERIFY_IS_EQUAL( (std::numeric_limits::denorm_min)()/half(2), half(0.f) ); +} + +void test_arithmetic() +{ + VERIFY_IS_EQUAL(float(half(2) + half(2)), 4); + VERIFY_IS_EQUAL(float(half(2) + half(-2)), 0); + VERIFY_IS_APPROX(float(half(0.33333f) + half(0.66667f)), 1.0f); + VERIFY_IS_EQUAL(float(half(2.0f) * half(-5.5f)), -11.0f); + VERIFY_IS_APPROX(float(half(1.0f) / half(3.0f)), 0.33333f); + VERIFY_IS_EQUAL(float(-half(4096.0f)), -4096.0f); + VERIFY_IS_EQUAL(float(-half(-4096.0f)), 4096.0f); + + half x(3); + half y = ++x; + VERIFY_IS_EQUAL(x, half(4)); + VERIFY_IS_EQUAL(y, half(4)); + y = --x; + VERIFY_IS_EQUAL(x, half(3)); + VERIFY_IS_EQUAL(y, half(3)); + y = x++; + VERIFY_IS_EQUAL(x, half(4)); + VERIFY_IS_EQUAL(y, half(3)); + y = x--; + VERIFY_IS_EQUAL(x, half(3)); + VERIFY_IS_EQUAL(y, half(4)); +} + +void test_comparison() +{ + VERIFY(half(1.0f) > half(0.5f)); + VERIFY(half(0.5f) < half(1.0f)); + VERIFY(!(half(1.0f) < half(0.5f))); + VERIFY(!(half(0.5f) > half(1.0f))); + + VERIFY(!(half(4.0f) > half(4.0f))); + VERIFY(!(half(4.0f) < half(4.0f))); + + VERIFY(!(half(0.0f) < half(-0.0f))); + VERIFY(!(half(-0.0f) < half(0.0f))); + VERIFY(!(half(0.0f) > half(-0.0f))); + VERIFY(!(half(-0.0f) > half(0.0f))); + + VERIFY(half(0.2f) > half(-1.0f)); + VERIFY(half(-1.0f) < half(0.2f)); + VERIFY(half(-16.0f) < half(-15.0f)); + + VERIFY(half(1.0f) == half(1.0f)); + VERIFY(half(1.0f) != half(2.0f)); + + // Comparisons with NaNs and infinities. +#if !EIGEN_COMP_MSVC + // Visual Studio errors out on divisions by 0 + VERIFY(!(half(0.0 / 0.0) == half(0.0 / 0.0))); + VERIFY(half(0.0 / 0.0) != half(0.0 / 0.0)); + + VERIFY(!(half(1.0) == half(0.0 / 0.0))); + VERIFY(!(half(1.0) < half(0.0 / 0.0))); + VERIFY(!(half(1.0) > half(0.0 / 0.0))); + VERIFY(half(1.0) != half(0.0 / 0.0)); + + VERIFY(half(1.0) < half(1.0 / 0.0)); + VERIFY(half(1.0) > half(-1.0 / 0.0)); +#endif +} + +void test_basic_functions() +{ + const float PI = static_cast(EIGEN_PI); + + VERIFY_IS_EQUAL(float(numext::abs(half(3.5f))), 3.5f); + VERIFY_IS_EQUAL(float(abs(half(3.5f))), 3.5f); + VERIFY_IS_EQUAL(float(numext::abs(half(-3.5f))), 3.5f); + VERIFY_IS_EQUAL(float(abs(half(-3.5f))), 3.5f); + + VERIFY_IS_EQUAL(float(numext::floor(half(3.5f))), 3.0f); + VERIFY_IS_EQUAL(float(floor(half(3.5f))), 3.0f); + VERIFY_IS_EQUAL(float(numext::floor(half(-3.5f))), -4.0f); + VERIFY_IS_EQUAL(float(floor(half(-3.5f))), -4.0f); + + VERIFY_IS_EQUAL(float(numext::ceil(half(3.5f))), 4.0f); + VERIFY_IS_EQUAL(float(ceil(half(3.5f))), 4.0f); + VERIFY_IS_EQUAL(float(numext::ceil(half(-3.5f))), -3.0f); + VERIFY_IS_EQUAL(float(ceil(half(-3.5f))), -3.0f); + + VERIFY_IS_APPROX(float(numext::sqrt(half(0.0f))), 0.0f); + VERIFY_IS_APPROX(float(sqrt(half(0.0f))), 0.0f); + VERIFY_IS_APPROX(float(numext::sqrt(half(4.0f))), 2.0f); + VERIFY_IS_APPROX(float(sqrt(half(4.0f))), 2.0f); + + VERIFY_IS_APPROX(float(numext::pow(half(0.0f), half(1.0f))), 0.0f); + VERIFY_IS_APPROX(float(pow(half(0.0f), half(1.0f))), 0.0f); + VERIFY_IS_APPROX(float(numext::pow(half(2.0f), half(2.0f))), 4.0f); + VERIFY_IS_APPROX(float(pow(half(2.0f), half(2.0f))), 4.0f); + + VERIFY_IS_EQUAL(float(numext::exp(half(0.0f))), 1.0f); + VERIFY_IS_EQUAL(float(exp(half(0.0f))), 1.0f); + VERIFY_IS_APPROX(float(numext::exp(half(PI))), 20.f + PI); + VERIFY_IS_APPROX(float(exp(half(PI))), 20.f + PI); + + VERIFY_IS_EQUAL(float(numext::expm1(half(0.0f))), 0.0f); + VERIFY_IS_EQUAL(float(expm1(half(0.0f))), 0.0f); + VERIFY_IS_APPROX(float(numext::expm1(half(2.0f))), 6.3890561f); + VERIFY_IS_APPROX(float(expm1(half(2.0f))), 6.3890561f); + + VERIFY_IS_EQUAL(float(numext::log(half(1.0f))), 0.0f); + VERIFY_IS_EQUAL(float(log(half(1.0f))), 0.0f); + VERIFY_IS_APPROX(float(numext::log(half(10.0f))), 2.30273f); + VERIFY_IS_APPROX(float(log(half(10.0f))), 2.30273f); + + VERIFY_IS_EQUAL(float(numext::log1p(half(0.0f))), 0.0f); + VERIFY_IS_EQUAL(float(log1p(half(0.0f))), 0.0f); + VERIFY_IS_APPROX(float(numext::log1p(half(10.0f))), 2.3978953f); + VERIFY_IS_APPROX(float(log1p(half(10.0f))), 2.3978953f); + + VERIFY_IS_APPROX(numext::fmod(half(5.3f), half(2.0f)), half(1.3f)); + VERIFY_IS_APPROX(fmod(half(5.3f), half(2.0f)), half(1.3f)); + VERIFY_IS_APPROX(numext::fmod(half(-18.5f), half(-4.2f)), half(-1.7f)); + VERIFY_IS_APPROX(fmod(half(-18.5f), half(-4.2f)), half(-1.7f)); +} + +void test_trigonometric_functions() +{ + const float PI = static_cast(EIGEN_PI); + VERIFY_IS_APPROX(numext::cos(half(0.0f)), half(cosf(0.0f))); + VERIFY_IS_APPROX(cos(half(0.0f)), half(cosf(0.0f))); + VERIFY_IS_APPROX(numext::cos(half(PI)), half(cosf(PI))); + // VERIFY_IS_APPROX(numext::cos(half(PI/2)), half(cosf(PI/2))); + // VERIFY_IS_APPROX(numext::cos(half(3*PI/2)), half(cosf(3*PI/2))); + VERIFY_IS_APPROX(numext::cos(half(3.5f)), half(cosf(3.5f))); + + VERIFY_IS_APPROX(numext::sin(half(0.0f)), half(sinf(0.0f))); + VERIFY_IS_APPROX(sin(half(0.0f)), half(sinf(0.0f))); + // VERIFY_IS_APPROX(numext::sin(half(PI)), half(sinf(PI))); + VERIFY_IS_APPROX(numext::sin(half(PI/2)), half(sinf(PI/2))); + VERIFY_IS_APPROX(numext::sin(half(3*PI/2)), half(sinf(3*PI/2))); + VERIFY_IS_APPROX(numext::sin(half(3.5f)), half(sinf(3.5f))); + + VERIFY_IS_APPROX(numext::tan(half(0.0f)), half(tanf(0.0f))); + VERIFY_IS_APPROX(tan(half(0.0f)), half(tanf(0.0f))); + // VERIFY_IS_APPROX(numext::tan(half(PI)), half(tanf(PI))); + // VERIFY_IS_APPROX(numext::tan(half(PI/2)), half(tanf(PI/2))); + //VERIFY_IS_APPROX(numext::tan(half(3*PI/2)), half(tanf(3*PI/2))); + VERIFY_IS_APPROX(numext::tan(half(3.5f)), half(tanf(3.5f))); +} + +void test_array() +{ + typedef Array ArrayXh; + Index size = internal::random(1,10); + Index i = internal::random(0,size-1); + ArrayXh a1 = ArrayXh::Random(size), a2 = ArrayXh::Random(size); + VERIFY_IS_APPROX( a1+a1, half(2)*a1 ); + VERIFY( (a1.abs() >= half(0)).all() ); + VERIFY_IS_APPROX( (a1*a1).sqrt(), a1.abs() ); + + VERIFY( ((a1.min)(a2) <= (a1.max)(a2)).all() ); + a1(i) = half(-10.); + VERIFY_IS_EQUAL( a1.minCoeff(), half(-10.) ); + a1(i) = half(10.); + VERIFY_IS_EQUAL( a1.maxCoeff(), half(10.) ); + + std::stringstream ss; + ss << a1; +} + +void test_product() +{ + typedef Matrix MatrixXh; + Index rows = internal::random(1,EIGEN_TEST_MAX_SIZE); + Index cols = internal::random(1,EIGEN_TEST_MAX_SIZE); + Index depth = internal::random(1,EIGEN_TEST_MAX_SIZE); + MatrixXh Ah = MatrixXh::Random(rows,depth); + MatrixXh Bh = MatrixXh::Random(depth,cols); + MatrixXh Ch = MatrixXh::Random(rows,cols); + MatrixXf Af = Ah.cast(); + MatrixXf Bf = Bh.cast(); + MatrixXf Cf = Ch.cast(); + VERIFY_IS_APPROX(Ch.noalias()+=Ah*Bh, (Cf.noalias()+=Af*Bf).cast()); +} + +EIGEN_DECLARE_TEST(half_float) +{ + CALL_SUBTEST(test_numtraits()); + for(int i = 0; i < g_repeat; i++) { + CALL_SUBTEST(test_conversion()); + CALL_SUBTEST(test_arithmetic()); + CALL_SUBTEST(test_comparison()); + CALL_SUBTEST(test_basic_functions()); + CALL_SUBTEST(test_trigonometric_functions()); + CALL_SUBTEST(test_array()); + CALL_SUBTEST(test_product()); + } +} diff --git a/include/eigen/test/householder.cpp b/include/eigen/test/householder.cpp new file mode 100644 index 0000000000000000000000000000000000000000..cad8138a2aa11701d2b14a5ccf3d864539c6eb37 --- /dev/null +++ b/include/eigen/test/householder.cpp @@ -0,0 +1,148 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2009-2010 Benoit Jacob +// +// 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/. + +#include "main.h" +#include + +template void householder(const MatrixType& m) +{ + static bool even = true; + even = !even; + /* this test covers the following files: + Householder.h + */ + Index rows = m.rows(); + Index cols = m.cols(); + + typedef typename MatrixType::Scalar Scalar; + typedef typename NumTraits::Real RealScalar; + typedef Matrix VectorType; + typedef Matrix::ret, 1> EssentialVectorType; + typedef Matrix SquareMatrixType; + typedef Matrix HBlockMatrixType; + typedef Matrix HCoeffsVectorType; + + typedef Matrix TMatrixType; + + Matrix _tmp((std::max)(rows,cols)); + Scalar* tmp = &_tmp.coeffRef(0,0); + + Scalar beta; + RealScalar alpha; + EssentialVectorType essential; + + VectorType v1 = VectorType::Random(rows), v2; + v2 = v1; + v1.makeHouseholder(essential, beta, alpha); + v1.applyHouseholderOnTheLeft(essential,beta,tmp); + VERIFY_IS_APPROX(v1.norm(), v2.norm()); + if(rows>=2) VERIFY_IS_MUCH_SMALLER_THAN(v1.tail(rows-1).norm(), v1.norm()); + v1 = VectorType::Random(rows); + v2 = v1; + v1.applyHouseholderOnTheLeft(essential,beta,tmp); + VERIFY_IS_APPROX(v1.norm(), v2.norm()); + + // reconstruct householder matrix: + SquareMatrixType id, H1, H2; + id.setIdentity(rows, rows); + H1 = H2 = id; + VectorType vv(rows); + vv << Scalar(1), essential; + H1.applyHouseholderOnTheLeft(essential, beta, tmp); + H2.applyHouseholderOnTheRight(essential, beta, tmp); + VERIFY_IS_APPROX(H1, H2); + VERIFY_IS_APPROX(H1, id - beta * vv*vv.adjoint()); + + MatrixType m1(rows, cols), + m2(rows, cols); + + v1 = VectorType::Random(rows); + if(even) v1.tail(rows-1).setZero(); + m1.colwise() = v1; + m2 = m1; + m1.col(0).makeHouseholder(essential, beta, alpha); + m1.applyHouseholderOnTheLeft(essential,beta,tmp); + VERIFY_IS_APPROX(m1.norm(), m2.norm()); + if(rows>=2) VERIFY_IS_MUCH_SMALLER_THAN(m1.block(1,0,rows-1,cols).norm(), m1.norm()); + VERIFY_IS_MUCH_SMALLER_THAN(numext::imag(m1(0,0)), numext::real(m1(0,0))); + VERIFY_IS_APPROX(numext::real(m1(0,0)), alpha); + + v1 = VectorType::Random(rows); + if(even) v1.tail(rows-1).setZero(); + SquareMatrixType m3(rows,rows), m4(rows,rows); + m3.rowwise() = v1.transpose(); + m4 = m3; + m3.row(0).makeHouseholder(essential, beta, alpha); + m3.applyHouseholderOnTheRight(essential.conjugate(),beta,tmp); + VERIFY_IS_APPROX(m3.norm(), m4.norm()); + if(rows>=2) VERIFY_IS_MUCH_SMALLER_THAN(m3.block(0,1,rows,rows-1).norm(), m3.norm()); + VERIFY_IS_MUCH_SMALLER_THAN(numext::imag(m3(0,0)), numext::real(m3(0,0))); + VERIFY_IS_APPROX(numext::real(m3(0,0)), alpha); + + // test householder sequence on the left with a shift + + Index shift = internal::random(0, std::max(rows-2,0)); + Index brows = rows - shift; + m1.setRandom(rows, cols); + HBlockMatrixType hbm = m1.block(shift,0,brows,cols); + HouseholderQR qr(hbm); + m2 = m1; + m2.block(shift,0,brows,cols) = qr.matrixQR(); + HCoeffsVectorType hc = qr.hCoeffs().conjugate(); + HouseholderSequence hseq(m2, hc); + hseq.setLength(hc.size()).setShift(shift); + VERIFY(hseq.length() == hc.size()); + VERIFY(hseq.shift() == shift); + + MatrixType m5 = m2; + m5.block(shift,0,brows,cols).template triangularView().setZero(); + VERIFY_IS_APPROX(hseq * m5, m1); // test applying hseq directly + m3 = hseq; + VERIFY_IS_APPROX(m3 * m5, m1); // test evaluating hseq to a dense matrix, then applying + + SquareMatrixType hseq_mat = hseq; + SquareMatrixType hseq_mat_conj = hseq.conjugate(); + SquareMatrixType hseq_mat_adj = hseq.adjoint(); + SquareMatrixType hseq_mat_trans = hseq.transpose(); + SquareMatrixType m6 = SquareMatrixType::Random(rows, rows); + VERIFY_IS_APPROX(hseq_mat.adjoint(), hseq_mat_adj); + VERIFY_IS_APPROX(hseq_mat.conjugate(), hseq_mat_conj); + VERIFY_IS_APPROX(hseq_mat.transpose(), hseq_mat_trans); + VERIFY_IS_APPROX(hseq * m6, hseq_mat * m6); + VERIFY_IS_APPROX(hseq.adjoint() * m6, hseq_mat_adj * m6); + VERIFY_IS_APPROX(hseq.conjugate() * m6, hseq_mat_conj * m6); + VERIFY_IS_APPROX(hseq.transpose() * m6, hseq_mat_trans * m6); + VERIFY_IS_APPROX(m6 * hseq, m6 * hseq_mat); + VERIFY_IS_APPROX(m6 * hseq.adjoint(), m6 * hseq_mat_adj); + VERIFY_IS_APPROX(m6 * hseq.conjugate(), m6 * hseq_mat_conj); + VERIFY_IS_APPROX(m6 * hseq.transpose(), m6 * hseq_mat_trans); + + // test householder sequence on the right with a shift + + TMatrixType tm2 = m2.transpose(); + HouseholderSequence rhseq(tm2, hc); + rhseq.setLength(hc.size()).setShift(shift); + VERIFY_IS_APPROX(rhseq * m5, m1); // test applying rhseq directly + m3 = rhseq; + VERIFY_IS_APPROX(m3 * m5, m1); // test evaluating rhseq to a dense matrix, then applying +} + +EIGEN_DECLARE_TEST(householder) +{ + for(int i = 0; i < g_repeat; i++) { + CALL_SUBTEST_1( householder(Matrix()) ); + CALL_SUBTEST_2( householder(Matrix()) ); + CALL_SUBTEST_3( householder(Matrix()) ); + CALL_SUBTEST_4( householder(Matrix()) ); + CALL_SUBTEST_5( householder(MatrixXd(internal::random(1,EIGEN_TEST_MAX_SIZE),internal::random(1,EIGEN_TEST_MAX_SIZE))) ); + CALL_SUBTEST_6( householder(MatrixXcf(internal::random(1,EIGEN_TEST_MAX_SIZE),internal::random(1,EIGEN_TEST_MAX_SIZE))) ); + CALL_SUBTEST_7( householder(MatrixXf(internal::random(1,EIGEN_TEST_MAX_SIZE),internal::random(1,EIGEN_TEST_MAX_SIZE))) ); + CALL_SUBTEST_8( householder(Matrix()) ); + } +} diff --git a/include/eigen/test/incomplete_cholesky.cpp b/include/eigen/test/incomplete_cholesky.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ecc17f5c3582cbf3d39089ac0496dfec197b737b --- /dev/null +++ b/include/eigen/test/incomplete_cholesky.cpp @@ -0,0 +1,69 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2015-2016 Gael Guennebaud +// +// 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/. +// #define EIGEN_DONT_VECTORIZE +// #define EIGEN_MAX_ALIGN_BYTES 0 +#include "sparse_solver.h" +#include +#include + +template void test_incomplete_cholesky_T() +{ + typedef SparseMatrix SparseMatrixType; + ConjugateGradient > > cg_illt_lower_amd; + ConjugateGradient > > cg_illt_lower_nat; + ConjugateGradient > > cg_illt_upper_amd; + ConjugateGradient > > cg_illt_upper_nat; + ConjugateGradient > > cg_illt_uplo_amd; + + + CALL_SUBTEST( check_sparse_spd_solving(cg_illt_lower_amd) ); + CALL_SUBTEST( check_sparse_spd_solving(cg_illt_lower_nat) ); + CALL_SUBTEST( check_sparse_spd_solving(cg_illt_upper_amd) ); + CALL_SUBTEST( check_sparse_spd_solving(cg_illt_upper_nat) ); + CALL_SUBTEST( check_sparse_spd_solving(cg_illt_uplo_amd) ); +} + +template +void bug1150() +{ + // regression for bug 1150 + for(int N = 1; N<20; ++N) + { + Eigen::MatrixXd b( N, N ); + b.setOnes(); + + Eigen::SparseMatrix m( N, N ); + m.reserve(Eigen::VectorXi::Constant(N,4)); + for( int i = 0; i < N; ++i ) + { + m.insert( i, i ) = 1; + m.coeffRef( i, i / 2 ) = 2; + m.coeffRef( i, i / 3 ) = 2; + m.coeffRef( i, i / 4 ) = 2; + } + + Eigen::SparseMatrix A; + A = m * m.transpose(); + + Eigen::ConjugateGradient, + Eigen::Lower | Eigen::Upper, + Eigen::IncompleteCholesky > solver( A ); + VERIFY(solver.preconditioner().info() == Eigen::Success); + VERIFY(solver.info() == Eigen::Success); + } +} + +EIGEN_DECLARE_TEST(incomplete_cholesky) +{ + CALL_SUBTEST_1(( test_incomplete_cholesky_T() )); + CALL_SUBTEST_2(( test_incomplete_cholesky_T, int>() )); + CALL_SUBTEST_3(( test_incomplete_cholesky_T() )); + + CALL_SUBTEST_1(( bug1150<0>() )); +} diff --git a/include/eigen/test/indexed_view.cpp b/include/eigen/test/indexed_view.cpp new file mode 100644 index 0000000000000000000000000000000000000000..72c54af6845ec34de338a34222738b50dab7838b --- /dev/null +++ b/include/eigen/test/indexed_view.cpp @@ -0,0 +1,473 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2017 Gael Guennebaud +// +// 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/. + +#ifdef EIGEN_TEST_PART_2 +// Make sure we also check c++11 max implementation +#define EIGEN_MAX_CPP_VER 11 +#endif + +#ifdef EIGEN_TEST_PART_3 +// Make sure we also check c++98 max implementation +#define EIGEN_MAX_CPP_VER 03 + +// We need to disable this warning when compiling with c++11 while limiting Eigen to c++98 +// Ideally we would rather configure the compiler to build in c++98 mode but this needs +// to be done at the CMakeLists.txt level. +#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)) + #pragma GCC diagnostic ignored "-Wdeprecated" +#endif + +#if defined(__GNUC__) && (__GNUC__ >=9) + #pragma GCC diagnostic ignored "-Wdeprecated-copy" +#endif +#if defined(__clang__) && (__clang_major__ >= 10) + #pragma clang diagnostic ignored "-Wdeprecated-copy" +#endif + +#endif + +#include +#include +#include "main.h" + +#if EIGEN_HAS_CXX11 +#include +#endif + +typedef std::pair IndexPair; + +int encode(Index i, Index j) { + return int(i*100 + j); +} + +IndexPair decode(Index ij) { + return IndexPair(ij / 100, ij % 100); +} + +template +bool match(const T& xpr, std::string ref, std::string str_xpr = "") { + EIGEN_UNUSED_VARIABLE(str_xpr); + std::stringstream str; + str << xpr; + if(!(str.str() == ref)) + std::cout << str_xpr << "\n" << xpr << "\n\n"; + return str.str() == ref; +} + +#define MATCH(X,R) match(X, R, #X) + +template +typename internal::enable_if::value,bool>::type +is_same_eq(const T1& a, const T2& b) +{ + return (a == b).all(); +} + +template +bool is_same_seq(const T1& a, const T2& b) +{ + bool ok = a.first()==b.first() && a.size() == b.size() && Index(a.incrObject())==Index(b.incrObject());; + if(!ok) + { + std::cerr << "seqN(" << a.first() << ", " << a.size() << ", " << Index(a.incrObject()) << ") != "; + std::cerr << "seqN(" << b.first() << ", " << b.size() << ", " << Index(b.incrObject()) << ")\n"; + } + return ok; +} + +template +typename internal::enable_if::value,bool>::type +is_same_seq_type(const T1& a, const T2& b) +{ + return is_same_seq(a,b); +} + + + +#define VERIFY_EQ_INT(A,B) VERIFY_IS_APPROX(int(A),int(B)) + +// C++03 does not allow local or unnamed enums as index +enum DummyEnum { XX=0, YY=1 }; + +void check_indexed_view() +{ + Index n = 10; + + ArrayXd a = ArrayXd::LinSpaced(n,0,n-1); + Array b = a.transpose(); + + #if EIGEN_COMP_CXXVER>=14 + ArrayXXi A = ArrayXXi::NullaryExpr(n,n, std::ref(encode)); + #else + ArrayXXi A = ArrayXXi::NullaryExpr(n,n, std::ptr_fun(&encode)); + #endif + + for(Index i=0; i vali(4); Map(&vali[0],4) = eii; + std::vector veci(4); Map(veci.data(),4) = eii; + + VERIFY( MATCH( A(3, seq(9,3,-1)), + "309 308 307 306 305 304 303") + ); + + VERIFY( MATCH( A(seqN(2,5), seq(9,3,-1)), + "209 208 207 206 205 204 203\n" + "309 308 307 306 305 304 303\n" + "409 408 407 406 405 404 403\n" + "509 508 507 506 505 504 503\n" + "609 608 607 606 605 604 603") + ); + + VERIFY( MATCH( A(seqN(2,5), 5), + "205\n" + "305\n" + "405\n" + "505\n" + "605") + ); + + VERIFY( MATCH( A(seqN(last,5,-1), seq(2,last)), + "902 903 904 905 906 907 908 909\n" + "802 803 804 805 806 807 808 809\n" + "702 703 704 705 706 707 708 709\n" + "602 603 604 605 606 607 608 609\n" + "502 503 504 505 506 507 508 509") + ); + + VERIFY( MATCH( A(eii, veci), + "303 301 306 305\n" + "103 101 106 105\n" + "603 601 606 605\n" + "503 501 506 505") + ); + + VERIFY( MATCH( A(eii, all), + "300 301 302 303 304 305 306 307 308 309\n" + "100 101 102 103 104 105 106 107 108 109\n" + "600 601 602 603 604 605 606 607 608 609\n" + "500 501 502 503 504 505 506 507 508 509") + ); + + // take row number 3, and repeat it 5 times + VERIFY( MATCH( A(seqN(3,5,0), all), + "300 301 302 303 304 305 306 307 308 309\n" + "300 301 302 303 304 305 306 307 308 309\n" + "300 301 302 303 304 305 306 307 308 309\n" + "300 301 302 303 304 305 306 307 308 309\n" + "300 301 302 303 304 305 306 307 308 309") + ); + + VERIFY( MATCH( a(seqN(3,3),0), "3\n4\n5" ) ); + VERIFY( MATCH( a(seq(3,5)), "3\n4\n5" ) ); + VERIFY( MATCH( a(seqN(3,3,1)), "3\n4\n5" ) ); + VERIFY( MATCH( a(seqN(5,3,-1)), "5\n4\n3" ) ); + + VERIFY( MATCH( b(0,seqN(3,3)), "3 4 5" ) ); + VERIFY( MATCH( b(seq(3,5)), "3 4 5" ) ); + VERIFY( MATCH( b(seqN(3,3,1)), "3 4 5" ) ); + VERIFY( MATCH( b(seqN(5,3,-1)), "5 4 3" ) ); + + VERIFY( MATCH( b(all), "0 1 2 3 4 5 6 7 8 9" ) ); + VERIFY( MATCH( b(eii), "3 1 6 5" ) ); + + Array44i B; + B.setRandom(); + VERIFY( (A(seqN(2,5), 5)).ColsAtCompileTime == 1); + VERIFY( (A(seqN(2,5), 5)).RowsAtCompileTime == Dynamic); + VERIFY_EQ_INT( (A(seqN(2,5), 5)).InnerStrideAtCompileTime , A.InnerStrideAtCompileTime); + VERIFY_EQ_INT( (A(seqN(2,5), 5)).OuterStrideAtCompileTime , A.col(5).OuterStrideAtCompileTime); + + VERIFY_EQ_INT( (A(5,seqN(2,5))).InnerStrideAtCompileTime , A.row(5).InnerStrideAtCompileTime); + VERIFY_EQ_INT( (A(5,seqN(2,5))).OuterStrideAtCompileTime , A.row(5).OuterStrideAtCompileTime); + VERIFY_EQ_INT( (B(1,seqN(1,2))).InnerStrideAtCompileTime , B.row(1).InnerStrideAtCompileTime); + VERIFY_EQ_INT( (B(1,seqN(1,2))).OuterStrideAtCompileTime , B.row(1).OuterStrideAtCompileTime); + + VERIFY_EQ_INT( (A(seqN(2,5), seq(1,3))).InnerStrideAtCompileTime , A.InnerStrideAtCompileTime); + VERIFY_EQ_INT( (A(seqN(2,5), seq(1,3))).OuterStrideAtCompileTime , A.OuterStrideAtCompileTime); + VERIFY_EQ_INT( (B(seqN(1,2), seq(1,3))).InnerStrideAtCompileTime , B.InnerStrideAtCompileTime); + VERIFY_EQ_INT( (B(seqN(1,2), seq(1,3))).OuterStrideAtCompileTime , B.OuterStrideAtCompileTime); + VERIFY_EQ_INT( (A(seqN(2,5,2), seq(1,3,2))).InnerStrideAtCompileTime , Dynamic); + VERIFY_EQ_INT( (A(seqN(2,5,2), seq(1,3,2))).OuterStrideAtCompileTime , Dynamic); + VERIFY_EQ_INT( (A(seqN(2,5,fix<2>), seq(1,3,fix<3>))).InnerStrideAtCompileTime , 2); + VERIFY_EQ_INT( (A(seqN(2,5,fix<2>), seq(1,3,fix<3>))).OuterStrideAtCompileTime , Dynamic); + VERIFY_EQ_INT( (B(seqN(1,2,fix<2>), seq(1,3,fix<3>))).InnerStrideAtCompileTime , 2); + VERIFY_EQ_INT( (B(seqN(1,2,fix<2>), seq(1,3,fix<3>))).OuterStrideAtCompileTime , 3*4); + + VERIFY_EQ_INT( (A(seqN(2,fix<5>), seqN(1,fix<3>))).RowsAtCompileTime, 5); + VERIFY_EQ_INT( (A(seqN(2,fix<5>), seqN(1,fix<3>))).ColsAtCompileTime, 3); + VERIFY_EQ_INT( (A(seqN(2,fix<5>(5)), seqN(1,fix<3>(3)))).RowsAtCompileTime, 5); + VERIFY_EQ_INT( (A(seqN(2,fix<5>(5)), seqN(1,fix<3>(3)))).ColsAtCompileTime, 3); + VERIFY_EQ_INT( (A(seqN(2,fix(5)), seqN(1,fix(3)))).RowsAtCompileTime, Dynamic); + VERIFY_EQ_INT( (A(seqN(2,fix(5)), seqN(1,fix(3)))).ColsAtCompileTime, Dynamic); + VERIFY_EQ_INT( (A(seqN(2,fix(5)), seqN(1,fix(3)))).rows(), 5); + VERIFY_EQ_INT( (A(seqN(2,fix(5)), seqN(1,fix(3)))).cols(), 3); + + VERIFY( is_same_seq_type( seqN(2,5,fix<-1>), seqN(2,5,fix<-1>(-1)) ) ); + VERIFY( is_same_seq_type( seqN(2,5), seqN(2,5,fix<1>(1)) ) ); + VERIFY( is_same_seq_type( seqN(2,5,3), seqN(2,5,fix(3)) ) ); + VERIFY( is_same_seq_type( seq(2,7,fix<3>), seqN(2,2,fix<3>) ) ); + VERIFY( is_same_seq_type( seqN(2,fix(5),3), seqN(2,5,fix(3)) ) ); + VERIFY( is_same_seq_type( seqN(2,fix<5>(5),fix<-2>), seqN(2,fix<5>,fix<-2>()) ) ); + + VERIFY( is_same_seq_type( seq(2,fix<5>), seqN(2,4) ) ); +#if EIGEN_HAS_CXX11 + VERIFY( is_same_seq_type( seq(fix<2>,fix<5>), seqN(fix<2>,fix<4>) ) ); + VERIFY( is_same_seq( seqN(2,std::integral_constant(),std::integral_constant()), seqN(2,fix<5>,fix<-2>()) ) ); + VERIFY( is_same_seq( seq(std::integral_constant(),std::integral_constant(),std::integral_constant()), + seq(fix<1>,fix<5>,fix<2>()) ) ); + VERIFY( is_same_seq_type( seqN(2,std::integral_constant(),std::integral_constant()), seqN(2,fix<5>,fix<-2>()) ) ); + VERIFY( is_same_seq_type( seq(std::integral_constant(),std::integral_constant(),std::integral_constant()), + seq(fix<1>,fix<5>,fix<2>()) ) ); + + VERIFY( is_same_seq_type( seqN(2,std::integral_constant()), seqN(2,fix<5>) ) ); + VERIFY( is_same_seq_type( seq(std::integral_constant(),std::integral_constant()), seq(fix<1>,fix<5>) ) ); +#else + // sorry, no compile-time size recovery in c++98/03 + VERIFY( is_same_seq( seq(fix<2>,fix<5>), seqN(fix<2>,fix<4>) ) ); +#endif + + VERIFY( (A(seqN(2,fix<5>), 5)).RowsAtCompileTime == 5); + VERIFY( (A(4, all)).ColsAtCompileTime == Dynamic); + VERIFY( (A(4, all)).RowsAtCompileTime == 1); + VERIFY( (B(1, all)).ColsAtCompileTime == 4); + VERIFY( (B(1, all)).RowsAtCompileTime == 1); + VERIFY( (B(all,1)).ColsAtCompileTime == 1); + VERIFY( (B(all,1)).RowsAtCompileTime == 4); + + VERIFY(int( (A(all, eii)).ColsAtCompileTime) == int(eii.SizeAtCompileTime)); + VERIFY_EQ_INT( (A(eii, eii)).Flags&DirectAccessBit, (unsigned int)(0)); + VERIFY_EQ_INT( (A(eii, eii)).InnerStrideAtCompileTime, 0); + VERIFY_EQ_INT( (A(eii, eii)).OuterStrideAtCompileTime, 0); + + VERIFY_IS_APPROX( A(seq(n-1,2,-2), seqN(n-1-6,3,-1)), A(seq(last,2,fix<-2>), seqN(last-6,3,fix<-1>)) ); + + VERIFY_IS_APPROX( A(seq(n-1,2,-2), seqN(n-1-6,4)), A(seq(last,2,-2), seqN(last-6,4)) ); + VERIFY_IS_APPROX( A(seq(n-1-6,n-1-2), seqN(n-1-6,4)), A(seq(last-6,last-2), seqN(6+last-6-6,4)) ); + VERIFY_IS_APPROX( A(seq((n-1)/2,(n)/2+3), seqN(2,4)), A(seq(last/2,(last+1)/2+3), seqN(last+2-last,4)) ); + VERIFY_IS_APPROX( A(seq(n-2,2,-2), seqN(n-8,4)), A(seq(lastp1-2,2,-2), seqN(lastp1-8,4)) ); + + // Check all combinations of seq: + VERIFY_IS_APPROX( A(seq(1,n-1-2,2), seq(1,n-1-2,2)), A(seq(1,last-2,2), seq(1,last-2,fix<2>)) ); + VERIFY_IS_APPROX( A(seq(n-1-5,n-1-2,2), seq(n-1-5,n-1-2,2)), A(seq(last-5,last-2,2), seq(last-5,last-2,fix<2>)) ); + VERIFY_IS_APPROX( A(seq(n-1-5,7,2), seq(n-1-5,7,2)), A(seq(last-5,7,2), seq(last-5,7,fix<2>)) ); + VERIFY_IS_APPROX( A(seq(1,n-1-2), seq(n-1-5,7)), A(seq(1,last-2), seq(last-5,7)) ); + VERIFY_IS_APPROX( A(seq(n-1-5,n-1-2), seq(n-1-5,n-1-2)), A(seq(last-5,last-2), seq(last-5,last-2)) ); + + VERIFY_IS_APPROX( A.col(A.cols()-1), A(all,last) ); + VERIFY_IS_APPROX( A(A.rows()-2, A.cols()/2), A(last-1, lastp1/2) ); + VERIFY_IS_APPROX( a(a.size()-2), a(last-1) ); + VERIFY_IS_APPROX( a(a.size()/2), a((last+1)/2) ); + + // Check fall-back to Block + { + VERIFY( is_same_eq(A.col(0), A(all,0)) ); + VERIFY( is_same_eq(A.row(0), A(0,all)) ); + VERIFY( is_same_eq(A.block(0,0,2,2), A(seqN(0,2),seq(0,1))) ); + VERIFY( is_same_eq(A.middleRows(2,4), A(seqN(2,4),all)) ); + VERIFY( is_same_eq(A.middleCols(2,4), A(all,seqN(2,4))) ); + + VERIFY( is_same_eq(A.col(A.cols()-1), A(all,last)) ); + + const ArrayXXi& cA(A); + VERIFY( is_same_eq(cA.col(0), cA(all,0)) ); + VERIFY( is_same_eq(cA.row(0), cA(0,all)) ); + VERIFY( is_same_eq(cA.block(0,0,2,2), cA(seqN(0,2),seq(0,1))) ); + VERIFY( is_same_eq(cA.middleRows(2,4), cA(seqN(2,4),all)) ); + VERIFY( is_same_eq(cA.middleCols(2,4), cA(all,seqN(2,4))) ); + + VERIFY( is_same_eq(a.head(4), a(seq(0,3))) ); + VERIFY( is_same_eq(a.tail(4), a(seqN(last-3,4))) ); + VERIFY( is_same_eq(a.tail(4), a(seq(lastp1-4,last))) ); + VERIFY( is_same_eq(a.segment<4>(3), a(seqN(3,fix<4>))) ); + } + + ArrayXXi A1=A, A2 = ArrayXXi::Random(4,4); + ArrayXi range25(4); range25 << 3,2,4,5; + A1(seqN(3,4),seq(2,5)) = A2; + VERIFY_IS_APPROX( A1.block(3,2,4,4), A2 ); + A1 = A; + A2.setOnes(); + A1(seq(6,3,-1),range25) = A2; + VERIFY_IS_APPROX( A1.block(3,2,4,4), A2 ); + + // check reverse + { + VERIFY( is_same_seq_type( seq(3,7).reverse(), seqN(7,5,fix<-1>) ) ); + VERIFY( is_same_seq_type( seq(7,3,fix<-2>).reverse(), seqN(3,3,fix<2>) ) ); + VERIFY_IS_APPROX( a(seqN(2,last/2).reverse()), a(seqN(2+(last/2-1)*1,last/2,fix<-1>)) ); + VERIFY_IS_APPROX( a(seqN(last/2,fix<4>).reverse()),a(seqN(last/2,fix<4>)).reverse() ); + VERIFY_IS_APPROX( A(seq(last-5,last-1,2).reverse(), seqN(last-3,3,fix<-2>).reverse()), + A(seq(last-5,last-1,2), seqN(last-3,3,fix<-2>)).reverse() ); + } + +#if EIGEN_HAS_CXX11 + // check lastN + VERIFY_IS_APPROX( a(lastN(3)), a.tail(3) ); + VERIFY( MATCH( a(lastN(3)), "7\n8\n9" ) ); + VERIFY_IS_APPROX( a(lastN(fix<3>())), a.tail<3>() ); + VERIFY( MATCH( a(lastN(3,2)), "5\n7\n9" ) ); + VERIFY( MATCH( a(lastN(3,fix<2>())), "5\n7\n9" ) ); + VERIFY( a(lastN(fix<3>())).SizeAtCompileTime == 3 ); + + VERIFY( (A(all, std::array{{1,3,2,4}})).ColsAtCompileTime == 4); + + VERIFY_IS_APPROX( (A(std::array{{1,3,5}}, std::array{{9,6,3,0}})), A(seqN(1,3,2), seqN(9,4,-3)) ); + +#if EIGEN_HAS_STATIC_ARRAY_TEMPLATE + VERIFY_IS_APPROX( A({3, 1, 6, 5}, all), A(std::array{{3, 1, 6, 5}}, all) ); + VERIFY_IS_APPROX( A(all,{3, 1, 6, 5}), A(all,std::array{{3, 1, 6, 5}}) ); + VERIFY_IS_APPROX( A({1,3,5},{3, 1, 6, 5}), A(std::array{{1,3,5}},std::array{{3, 1, 6, 5}}) ); + + VERIFY_IS_EQUAL( A({1,3,5},{3, 1, 6, 5}).RowsAtCompileTime, 3 ); + VERIFY_IS_EQUAL( A({1,3,5},{3, 1, 6, 5}).ColsAtCompileTime, 4 ); + + VERIFY_IS_APPROX( a({3, 1, 6, 5}), a(std::array{{3, 1, 6, 5}}) ); + VERIFY_IS_EQUAL( a({1,3,5}).SizeAtCompileTime, 3 ); + + VERIFY_IS_APPROX( b({3, 1, 6, 5}), b(std::array{{3, 1, 6, 5}}) ); + VERIFY_IS_EQUAL( b({1,3,5}).SizeAtCompileTime, 3 ); +#endif + +#endif + + // check mat(i,j) with weird types for i and j + { + VERIFY_IS_APPROX( A(B.RowsAtCompileTime-1, 1), A(3,1) ); + VERIFY_IS_APPROX( A(B.RowsAtCompileTime, 1), A(4,1) ); + VERIFY_IS_APPROX( A(B.RowsAtCompileTime-1, B.ColsAtCompileTime-1), A(3,3) ); + VERIFY_IS_APPROX( A(B.RowsAtCompileTime, B.ColsAtCompileTime), A(4,4) ); + const Index I_ = 3, J_ = 4; + VERIFY_IS_APPROX( A(I_,J_), A(3,4) ); + } + + // check extended block API + { + VERIFY( is_same_eq( A.block<3,4>(1,1), A.block(1,1,fix<3>,fix<4>)) ); + VERIFY( is_same_eq( A.block<3,4>(1,1,3,4), A.block(1,1,fix<3>(),fix<4>(4))) ); + VERIFY( is_same_eq( A.block<3,Dynamic>(1,1,3,4), A.block(1,1,fix<3>,4)) ); + VERIFY( is_same_eq( A.block(1,1,3,4), A.block(1,1,fix(3),fix<4>)) ); + VERIFY( is_same_eq( A.block(1,1,3,4), A.block(1,1,fix(3),fix(4))) ); + + VERIFY( is_same_eq( A.topLeftCorner<3,4>(), A.topLeftCorner(fix<3>,fix<4>)) ); + VERIFY( is_same_eq( A.bottomLeftCorner<3,4>(), A.bottomLeftCorner(fix<3>,fix<4>)) ); + VERIFY( is_same_eq( A.bottomRightCorner<3,4>(), A.bottomRightCorner(fix<3>,fix<4>)) ); + VERIFY( is_same_eq( A.topRightCorner<3,4>(), A.topRightCorner(fix<3>,fix<4>)) ); + + VERIFY( is_same_eq( A.leftCols<3>(), A.leftCols(fix<3>)) ); + VERIFY( is_same_eq( A.rightCols<3>(), A.rightCols(fix<3>)) ); + VERIFY( is_same_eq( A.middleCols<3>(1), A.middleCols(1,fix<3>)) ); + + VERIFY( is_same_eq( A.topRows<3>(), A.topRows(fix<3>)) ); + VERIFY( is_same_eq( A.bottomRows<3>(), A.bottomRows(fix<3>)) ); + VERIFY( is_same_eq( A.middleRows<3>(1), A.middleRows(1,fix<3>)) ); + + VERIFY( is_same_eq( a.segment<3>(1), a.segment(1,fix<3>)) ); + VERIFY( is_same_eq( a.head<3>(), a.head(fix<3>)) ); + VERIFY( is_same_eq( a.tail<3>(), a.tail(fix<3>)) ); + + const ArrayXXi& cA(A); + VERIFY( is_same_eq( cA.block(1,1,3,4), cA.block(1,1,fix(3),fix<4>)) ); + + VERIFY( is_same_eq( cA.topLeftCorner<3,4>(), cA.topLeftCorner(fix<3>,fix<4>)) ); + VERIFY( is_same_eq( cA.bottomLeftCorner<3,4>(), cA.bottomLeftCorner(fix<3>,fix<4>)) ); + VERIFY( is_same_eq( cA.bottomRightCorner<3,4>(), cA.bottomRightCorner(fix<3>,fix<4>)) ); + VERIFY( is_same_eq( cA.topRightCorner<3,4>(), cA.topRightCorner(fix<3>,fix<4>)) ); + + VERIFY( is_same_eq( cA.leftCols<3>(), cA.leftCols(fix<3>)) ); + VERIFY( is_same_eq( cA.rightCols<3>(), cA.rightCols(fix<3>)) ); + VERIFY( is_same_eq( cA.middleCols<3>(1), cA.middleCols(1,fix<3>)) ); + + VERIFY( is_same_eq( cA.topRows<3>(), cA.topRows(fix<3>)) ); + VERIFY( is_same_eq( cA.bottomRows<3>(), cA.bottomRows(fix<3>)) ); + VERIFY( is_same_eq( cA.middleRows<3>(1), cA.middleRows(1,fix<3>)) ); + } + + // Check compilation of enums as index type: + a(XX) = 1; + A(XX,YY) = 1; + // Anonymous enums only work with C++11 +#if EIGEN_HAS_CXX11 + enum { X=0, Y=1 }; + a(X) = 1; + A(X,Y) = 1; + A(XX,Y) = 1; + A(X,YY) = 1; +#endif + + // Check compilation of varying integer types as index types: + Index i = n/2; + short i_short(i); + std::size_t i_sizet(i); + VERIFY_IS_EQUAL( a(i), a.coeff(i_short) ); + VERIFY_IS_EQUAL( a(i), a.coeff(i_sizet) ); + + VERIFY_IS_EQUAL( A(i,i), A.coeff(i_short, i_short) ); + VERIFY_IS_EQUAL( A(i,i), A.coeff(i_short, i) ); + VERIFY_IS_EQUAL( A(i,i), A.coeff(i, i_short) ); + VERIFY_IS_EQUAL( A(i,i), A.coeff(i, i_sizet) ); + VERIFY_IS_EQUAL( A(i,i), A.coeff(i_sizet, i) ); + VERIFY_IS_EQUAL( A(i,i), A.coeff(i_sizet, i_short) ); + VERIFY_IS_EQUAL( A(i,i), A.coeff(5, i_sizet) ); + + // Regression test for Max{Rows,Cols}AtCompileTime + { + Matrix3i A3 = Matrix3i::Random(); + ArrayXi ind(5); ind << 1,1,1,1,1; + VERIFY_IS_EQUAL( A3(ind,ind).eval(), MatrixXi::Constant(5,5,A3(1,1)) ); + } + + // Regression for bug 1736 + { + VERIFY_IS_APPROX(A(all, eii).col(0).eval(), A.col(eii(0))); + A(all, eii).col(0) = A.col(eii(0)); + } + + // bug 1815: IndexedView should allow linear access + { + VERIFY( MATCH( b(eii)(0), "3" ) ); + VERIFY( MATCH( a(eii)(0), "3" ) ); + VERIFY( MATCH( A(1,eii)(0), "103")); + VERIFY( MATCH( A(eii,1)(0), "301")); + VERIFY( MATCH( A(1,all)(1), "101")); + VERIFY( MATCH( A(all,1)(1), "101")); + } + +#if EIGEN_HAS_CXX11 + //Bug IndexView with a single static row should be RowMajor: + { + // A(1, seq(0,2,1)).cwiseAbs().colwise().replicate(2).eval(); + STATIC_CHECK(( (internal::evaluator::Flags & RowMajorBit) == RowMajorBit )); + } +#endif + +} + +EIGEN_DECLARE_TEST(indexed_view) +{ +// for(int i = 0; i < g_repeat; i++) { + CALL_SUBTEST_1( check_indexed_view() ); + CALL_SUBTEST_2( check_indexed_view() ); + CALL_SUBTEST_3( check_indexed_view() ); +// } + + // static checks of some internals: + STATIC_CHECK(( internal::is_valid_index_type::value )); + STATIC_CHECK(( internal::is_valid_index_type::value )); + STATIC_CHECK(( internal::is_valid_index_type::value )); + STATIC_CHECK(( internal::is_valid_index_type::value )); + STATIC_CHECK(( internal::is_valid_index_type::value )); + STATIC_CHECK(( !internal::valid_indexed_view_overload::value )); + STATIC_CHECK(( !internal::valid_indexed_view_overload::value )); + STATIC_CHECK(( !internal::valid_indexed_view_overload::value )); + STATIC_CHECK(( !internal::valid_indexed_view_overload::value )); +} diff --git a/include/eigen/test/initializer_list_construction.cpp b/include/eigen/test/initializer_list_construction.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7a9c49e8d476e60cf1103f930319298bf7f81304 --- /dev/null +++ b/include/eigen/test/initializer_list_construction.cpp @@ -0,0 +1,385 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2019 David Tellenbach +// +// 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/. + +#define EIGEN_NO_STATIC_ASSERT + +#include "main.h" + +template::IsInteger> +struct TestMethodDispatching { + static void run() {} +}; + +template +struct TestMethodDispatching { + static void run() + { + { + Matrix m {3, 4}; + Array a {3, 4}; + VERIFY(m.rows() == 3); + VERIFY(m.cols() == 4); + VERIFY(a.rows() == 3); + VERIFY(a.cols() == 4); + } + { + Matrix m {3, 4}; + Array a {3, 4}; + VERIFY(m(0) == 3); + VERIFY(m(1) == 4); + VERIFY(a(0) == 3); + VERIFY(a(1) == 4); + } + { + Matrix m {3, 4}; + Array a {3, 4}; + VERIFY(m(0) == 3); + VERIFY(m(1) == 4); + VERIFY(a(0) == 3); + VERIFY(a(1) == 4); + } + } +}; + +template void fixedsizeVariadicVectorConstruction2() +{ + { + Vec4 ref = Vec4::Random(); + Vec4 v{ ref[0], ref[1], ref[2], ref[3] }; + VERIFY_IS_APPROX(v, ref); + VERIFY_IS_APPROX(v, (Vec4( ref[0], ref[1], ref[2], ref[3] ))); + VERIFY_IS_APPROX(v, (Vec4({ref[0], ref[1], ref[2], ref[3]}))); + + Vec4 v2 = { ref[0], ref[1], ref[2], ref[3] }; + VERIFY_IS_APPROX(v2, ref); + } + { + Vec5 ref = Vec5::Random(); + Vec5 v{ ref[0], ref[1], ref[2], ref[3], ref[4] }; + VERIFY_IS_APPROX(v, ref); + VERIFY_IS_APPROX(v, (Vec5( ref[0], ref[1], ref[2], ref[3], ref[4] ))); + VERIFY_IS_APPROX(v, (Vec5({ref[0], ref[1], ref[2], ref[3], ref[4]}))); + + Vec5 v2 = { ref[0], ref[1], ref[2], ref[3], ref[4] }; + VERIFY_IS_APPROX(v2, ref); + } +} + +#define CHECK_MIXSCALAR_V5_APPROX(V, A0, A1, A2, A3, A4) { \ + VERIFY_IS_APPROX(V[0], Scalar(A0) ); \ + VERIFY_IS_APPROX(V[1], Scalar(A1) ); \ + VERIFY_IS_APPROX(V[2], Scalar(A2) ); \ + VERIFY_IS_APPROX(V[3], Scalar(A3) ); \ + VERIFY_IS_APPROX(V[4], Scalar(A4) ); \ +} + +#define CHECK_MIXSCALAR_V5(VEC5, A0, A1, A2, A3, A4) { \ + typedef VEC5::Scalar Scalar; \ + VEC5 v = { A0 , A1 , A2 , A3 , A4 }; \ + CHECK_MIXSCALAR_V5_APPROX(v, A0 , A1 , A2 , A3 , A4); \ +} + +template void fixedsizeVariadicVectorConstruction3() +{ + typedef Matrix Vec5; + typedef Array Arr5; + CHECK_MIXSCALAR_V5(Vec5, 1, 2., -3, 4.121, 5.53252); + CHECK_MIXSCALAR_V5(Arr5, 1, 2., 3.12f, 4.121, 5.53252); +} + +template void fixedsizeVariadicVectorConstruction() +{ + CALL_SUBTEST(( fixedsizeVariadicVectorConstruction2, Matrix >() )); + CALL_SUBTEST(( fixedsizeVariadicVectorConstruction2, Matrix >() )); + CALL_SUBTEST(( fixedsizeVariadicVectorConstruction2, Array >() )); + CALL_SUBTEST(( fixedsizeVariadicVectorConstruction2, Array >() )); +} + + +template void initializerListVectorConstruction() +{ + Scalar raw[4]; + for(int k = 0; k < 4; ++k) { + raw[k] = internal::random(); + } + { + Matrix m { {raw[0]}, {raw[1]},{raw[2]},{raw[3]} }; + Array a { {raw[0]}, {raw[1]}, {raw[2]}, {raw[3]} }; + for(int k = 0; k < 4; ++k) { + VERIFY(m(k) == raw[k]); + } + for(int k = 0; k < 4; ++k) { + VERIFY(a(k) == raw[k]); + } + VERIFY_IS_EQUAL(m, (Matrix({ {raw[0]}, {raw[1]}, {raw[2]}, {raw[3]} }))); + VERIFY((a == (Array({ {raw[0]}, {raw[1]}, {raw[2]}, {raw[3]} }))).all()); + } + { + Matrix m { {raw[0], raw[1], raw[2], raw[3]} }; + Array a { {raw[0], raw[1], raw[2], raw[3]} }; + for(int k = 0; k < 4; ++k) { + VERIFY(m(k) == raw[k]); + } + for(int k = 0; k < 4; ++k) { + VERIFY(a(k) == raw[k]); + } + VERIFY_IS_EQUAL(m, (Matrix({{raw[0],raw[1],raw[2],raw[3]}}))); + VERIFY((a == (Array({{raw[0],raw[1],raw[2],raw[3]}}))).all()); + } + { + Matrix m { {raw[0]}, {raw[1]}, {raw[2]}, {raw[3]} }; + Array a { {raw[0]}, {raw[1]}, {raw[2]}, {raw[3]} }; + for(int k=0; k < 4; ++k) { + VERIFY(m(k) == raw[k]); + } + for(int k=0; k < 4; ++k) { + VERIFY(a(k) == raw[k]); + } + VERIFY_IS_EQUAL(m, (Matrix({ {raw[0]}, {raw[1]}, {raw[2]}, {raw[3]} }))); + VERIFY((a == (Array({ {raw[0]}, {raw[1]}, {raw[2]}, {raw[3]} }))).all()); + } + { + Matrix m {{raw[0],raw[1],raw[2],raw[3]}}; + Array a {{raw[0],raw[1],raw[2],raw[3]}}; + for(int k=0; k < 4; ++k) { + VERIFY(m(k) == raw[k]); + } + for(int k=0; k < 4; ++k) { + VERIFY(a(k) == raw[k]); + } + VERIFY_IS_EQUAL(m, (Matrix({{raw[0],raw[1],raw[2],raw[3]}}))); + VERIFY((a == (Array({{raw[0],raw[1],raw[2],raw[3]}}))).all()); + } +} + +template void initializerListMatrixConstruction() +{ + const Index RowsAtCompileTime = 5; + const Index ColsAtCompileTime = 4; + const Index SizeAtCompileTime = RowsAtCompileTime * ColsAtCompileTime; + + Scalar raw[SizeAtCompileTime]; + for (int i = 0; i < SizeAtCompileTime; ++i) { + raw[i] = internal::random(); + } + { + Matrix m {}; + VERIFY(m.cols() == 0); + VERIFY(m.rows() == 0); + VERIFY_IS_EQUAL(m, (Matrix())); + } + { + Matrix m { + {raw[0], raw[1], raw[2], raw[3]}, + {raw[4], raw[5], raw[6], raw[7]}, + {raw[8], raw[9], raw[10], raw[11]}, + {raw[12], raw[13], raw[14], raw[15]}, + {raw[16], raw[17], raw[18], raw[19]} + }; + + Matrix m2; + m2 << raw[0], raw[1], raw[2], raw[3], + raw[4], raw[5], raw[6], raw[7], + raw[8], raw[9], raw[10], raw[11], + raw[12], raw[13], raw[14], raw[15], + raw[16], raw[17], raw[18], raw[19]; + + int k = 0; + for(int i = 0; i < RowsAtCompileTime; ++i) { + for (int j = 0; j < ColsAtCompileTime; ++j) { + VERIFY(m(i, j) == raw[k]); + ++k; + } + } + VERIFY_IS_EQUAL(m, m2); + } + { + Matrix m{ + {raw[0], raw[1], raw[2], raw[3]}, + {raw[4], raw[5], raw[6], raw[7]}, + {raw[8], raw[9], raw[10], raw[11]}, + {raw[12], raw[13], raw[14], raw[15]}, + {raw[16], raw[17], raw[18], raw[19]} + }; + + VERIFY(m.cols() == 4); + VERIFY(m.rows() == 5); + int k = 0; + for(int i = 0; i < RowsAtCompileTime; ++i) { + for (int j = 0; j < ColsAtCompileTime; ++j) { + VERIFY(m(i, j) == raw[k]); + ++k; + } + } + + Matrix m2(RowsAtCompileTime, ColsAtCompileTime); + k = 0; + for(int i = 0; i < RowsAtCompileTime; ++i) { + for (int j = 0; j < ColsAtCompileTime; ++j) { + m2(i, j) = raw[k]; + ++k; + } + } + VERIFY_IS_EQUAL(m, m2); + } +} + +template void initializerListArrayConstruction() +{ + const Index RowsAtCompileTime = 5; + const Index ColsAtCompileTime = 4; + const Index SizeAtCompileTime = RowsAtCompileTime * ColsAtCompileTime; + + Scalar raw[SizeAtCompileTime]; + for (int i = 0; i < SizeAtCompileTime; ++i) { + raw[i] = internal::random(); + } + { + Array a {}; + VERIFY(a.cols() == 0); + VERIFY(a.rows() == 0); + } + { + Array m { + {raw[0], raw[1], raw[2], raw[3]}, + {raw[4], raw[5], raw[6], raw[7]}, + {raw[8], raw[9], raw[10], raw[11]}, + {raw[12], raw[13], raw[14], raw[15]}, + {raw[16], raw[17], raw[18], raw[19]} + }; + + Array m2; + m2 << raw[0], raw[1], raw[2], raw[3], + raw[4], raw[5], raw[6], raw[7], + raw[8], raw[9], raw[10], raw[11], + raw[12], raw[13], raw[14], raw[15], + raw[16], raw[17], raw[18], raw[19]; + + int k = 0; + for(int i = 0; i < RowsAtCompileTime; ++i) { + for (int j = 0; j < ColsAtCompileTime; ++j) { + VERIFY(m(i, j) == raw[k]); + ++k; + } + } + VERIFY_IS_APPROX(m, m2); + } + { + Array m { + {raw[0], raw[1], raw[2], raw[3]}, + {raw[4], raw[5], raw[6], raw[7]}, + {raw[8], raw[9], raw[10], raw[11]}, + {raw[12], raw[13], raw[14], raw[15]}, + {raw[16], raw[17], raw[18], raw[19]} + }; + + VERIFY(m.cols() == 4); + VERIFY(m.rows() == 5); + int k = 0; + for(int i = 0; i < RowsAtCompileTime; ++i) { + for (int j = 0; j < ColsAtCompileTime; ++j) { + VERIFY(m(i, j) == raw[k]); + ++k; + } + } + + Array m2(RowsAtCompileTime, ColsAtCompileTime); + k = 0; + for(int i = 0; i < RowsAtCompileTime; ++i) { + for (int j = 0; j < ColsAtCompileTime; ++j) { + m2(i, j) = raw[k]; + ++k; + } + } + VERIFY_IS_APPROX(m, m2); + } +} + +template void dynamicVectorConstruction() +{ + const Index size = 4; + Scalar raw[size]; + for (int i = 0; i < size; ++i) { + raw[i] = internal::random(); + } + + typedef Matrix VectorX; + + { + VectorX v {{raw[0], raw[1], raw[2], raw[3]}}; + for (int i = 0; i < size; ++i) { + VERIFY(v(i) == raw[i]); + } + VERIFY(v.rows() == size); + VERIFY(v.cols() == 1); + VERIFY_IS_EQUAL(v, (VectorX {{raw[0], raw[1], raw[2], raw[3]}})); + } + + { + VERIFY_RAISES_ASSERT((VectorX {raw[0], raw[1], raw[2], raw[3]})); + } + { + VERIFY_RAISES_ASSERT((VectorX { + {raw[0], raw[1], raw[2], raw[3]}, + {raw[0], raw[1], raw[2], raw[3]}, + })); + } +} + +EIGEN_DECLARE_TEST(initializer_list_construction) +{ + CALL_SUBTEST_1(initializerListVectorConstruction()); + CALL_SUBTEST_1(initializerListVectorConstruction()); + CALL_SUBTEST_1(initializerListVectorConstruction()); + CALL_SUBTEST_1(initializerListVectorConstruction()); + CALL_SUBTEST_1(initializerListVectorConstruction()); + CALL_SUBTEST_1(initializerListVectorConstruction()); + CALL_SUBTEST_1(initializerListVectorConstruction>()); + CALL_SUBTEST_1(initializerListVectorConstruction>()); + + CALL_SUBTEST_2(initializerListMatrixConstruction()); + CALL_SUBTEST_2(initializerListMatrixConstruction()); + CALL_SUBTEST_2(initializerListMatrixConstruction()); + CALL_SUBTEST_2(initializerListMatrixConstruction()); + CALL_SUBTEST_2(initializerListMatrixConstruction()); + CALL_SUBTEST_2(initializerListMatrixConstruction()); + CALL_SUBTEST_2(initializerListMatrixConstruction>()); + CALL_SUBTEST_2(initializerListMatrixConstruction>()); + + CALL_SUBTEST_3(initializerListArrayConstruction()); + CALL_SUBTEST_3(initializerListArrayConstruction()); + CALL_SUBTEST_3(initializerListArrayConstruction()); + CALL_SUBTEST_3(initializerListArrayConstruction()); + CALL_SUBTEST_3(initializerListArrayConstruction()); + CALL_SUBTEST_3(initializerListArrayConstruction()); + CALL_SUBTEST_3(initializerListArrayConstruction>()); + CALL_SUBTEST_3(initializerListArrayConstruction>()); + + CALL_SUBTEST_4(fixedsizeVariadicVectorConstruction()); + CALL_SUBTEST_4(fixedsizeVariadicVectorConstruction()); + CALL_SUBTEST_4(fixedsizeVariadicVectorConstruction()); + CALL_SUBTEST_4(fixedsizeVariadicVectorConstruction()); + CALL_SUBTEST_4(fixedsizeVariadicVectorConstruction()); + CALL_SUBTEST_4(fixedsizeVariadicVectorConstruction()); + CALL_SUBTEST_4(fixedsizeVariadicVectorConstruction>()); + CALL_SUBTEST_4(fixedsizeVariadicVectorConstruction>()); + CALL_SUBTEST_4(fixedsizeVariadicVectorConstruction3<0>()); + + CALL_SUBTEST_5(TestMethodDispatching::run()); + CALL_SUBTEST_5(TestMethodDispatching::run()); + + CALL_SUBTEST_6(dynamicVectorConstruction()); + CALL_SUBTEST_6(dynamicVectorConstruction()); + CALL_SUBTEST_6(dynamicVectorConstruction()); + CALL_SUBTEST_6(dynamicVectorConstruction()); + CALL_SUBTEST_6(dynamicVectorConstruction()); + CALL_SUBTEST_6(dynamicVectorConstruction()); + CALL_SUBTEST_6(dynamicVectorConstruction>()); + CALL_SUBTEST_6(dynamicVectorConstruction>()); +} diff --git a/include/eigen/test/inplace_decomposition.cpp b/include/eigen/test/inplace_decomposition.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e3aa9957d0338463b1b8c5a602965d362aabf1c1 --- /dev/null +++ b/include/eigen/test/inplace_decomposition.cpp @@ -0,0 +1,110 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2016 Gael Guennebaud +// +// 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/. + +#include "main.h" +#include +#include +#include + +// This file test inplace decomposition through Ref<>, as supported by Cholesky, LU, and QR decompositions. + +template void inplace(bool square = false, bool SPD = false) +{ + typedef typename MatrixType::Scalar Scalar; + typedef Matrix RhsType; + typedef Matrix ResType; + + Index rows = MatrixType::RowsAtCompileTime==Dynamic ? internal::random(2,EIGEN_TEST_MAX_SIZE/2) : Index(MatrixType::RowsAtCompileTime); + Index cols = MatrixType::ColsAtCompileTime==Dynamic ? (square?rows:internal::random(2,rows)) : Index(MatrixType::ColsAtCompileTime); + + MatrixType A = MatrixType::Random(rows,cols); + RhsType b = RhsType::Random(rows); + ResType x(cols); + + if(SPD) + { + assert(square); + A.topRows(cols) = A.topRows(cols).adjoint() * A.topRows(cols); + A.diagonal().array() += 1e-3; + } + + MatrixType A0 = A; + MatrixType A1 = A; + + DecType dec(A); + + // Check that the content of A has been modified + VERIFY_IS_NOT_APPROX( A, A0 ); + + // Check that the decomposition is correct: + if(rows==cols) + { + VERIFY_IS_APPROX( A0 * (x = dec.solve(b)), b ); + } + else + { + VERIFY_IS_APPROX( A0.transpose() * A0 * (x = dec.solve(b)), A0.transpose() * b ); + } + + // Check that modifying A breaks the current dec: + A.setRandom(); + if(rows==cols) + { + VERIFY_IS_NOT_APPROX( A0 * (x = dec.solve(b)), b ); + } + else + { + VERIFY_IS_NOT_APPROX( A0.transpose() * A0 * (x = dec.solve(b)), A0.transpose() * b ); + } + + // Check that calling compute(A1) does not modify A1: + A = A0; + dec.compute(A1); + VERIFY_IS_EQUAL(A0,A1); + VERIFY_IS_NOT_APPROX( A, A0 ); + if(rows==cols) + { + VERIFY_IS_APPROX( A0 * (x = dec.solve(b)), b ); + } + else + { + VERIFY_IS_APPROX( A0.transpose() * A0 * (x = dec.solve(b)), A0.transpose() * b ); + } +} + + +EIGEN_DECLARE_TEST(inplace_decomposition) +{ + EIGEN_UNUSED typedef Matrix Matrix43d; + for(int i = 0; i < g_repeat; i++) { + CALL_SUBTEST_1(( inplace >, MatrixXd>(true,true) )); + CALL_SUBTEST_1(( inplace >, Matrix4d>(true,true) )); + + CALL_SUBTEST_2(( inplace >, MatrixXd>(true,true) )); + CALL_SUBTEST_2(( inplace >, Matrix4d>(true,true) )); + + CALL_SUBTEST_3(( inplace >, MatrixXd>(true,false) )); + CALL_SUBTEST_3(( inplace >, Matrix4d>(true,false) )); + + CALL_SUBTEST_4(( inplace >, MatrixXd>(true,false) )); + CALL_SUBTEST_4(( inplace >, Matrix4d>(true,false) )); + + CALL_SUBTEST_5(( inplace >, MatrixXd>(false,false) )); + CALL_SUBTEST_5(( inplace >, Matrix43d>(false,false) )); + + CALL_SUBTEST_6(( inplace >, MatrixXd>(false,false) )); + CALL_SUBTEST_6(( inplace >, Matrix43d>(false,false) )); + + CALL_SUBTEST_7(( inplace >, MatrixXd>(false,false) )); + CALL_SUBTEST_7(( inplace >, Matrix43d>(false,false) )); + + CALL_SUBTEST_8(( inplace >, MatrixXd>(false,false) )); + CALL_SUBTEST_8(( inplace >, Matrix43d>(false,false) )); + } +} diff --git a/include/eigen/test/integer_types.cpp b/include/eigen/test/integer_types.cpp new file mode 100644 index 0000000000000000000000000000000000000000..31f4100c5ad05bf213c1844eb263e45dcc7e633a --- /dev/null +++ b/include/eigen/test/integer_types.cpp @@ -0,0 +1,173 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2010 Benoit Jacob +// +// 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/. + +#define EIGEN_NO_STATIC_ASSERT + +#include "main.h" + +#undef VERIFY_IS_APPROX +#define VERIFY_IS_APPROX(a, b) VERIFY((a)==(b)); +#undef VERIFY_IS_NOT_APPROX +#define VERIFY_IS_NOT_APPROX(a, b) VERIFY((a)!=(b)); + +template void signed_integer_type_tests(const MatrixType& m) +{ + typedef typename MatrixType::Scalar Scalar; + + enum { is_signed = (Scalar(-1) > Scalar(0)) ? 0 : 1 }; + VERIFY(is_signed == 1); + + Index rows = m.rows(); + Index cols = m.cols(); + + MatrixType m1(rows, cols), + m2 = MatrixType::Random(rows, cols), + mzero = MatrixType::Zero(rows, cols); + + do { + m1 = MatrixType::Random(rows, cols); + } while(m1 == mzero || m1 == m2); + + // check linear structure + + Scalar s1; + do { + s1 = internal::random(); + } while(s1 == 0); + + VERIFY_IS_EQUAL(-(-m1), m1); + VERIFY_IS_EQUAL(-m2+m1+m2, m1); + VERIFY_IS_EQUAL((-m1+m2)*s1, -s1*m1+s1*m2); +} + +template void integer_type_tests(const MatrixType& m) +{ + typedef typename MatrixType::Scalar Scalar; + + VERIFY(NumTraits::IsInteger); + enum { is_signed = (Scalar(-1) > Scalar(0)) ? 0 : 1 }; + VERIFY(int(NumTraits::IsSigned) == is_signed); + + typedef Matrix VectorType; + + Index rows = m.rows(); + Index cols = m.cols(); + + // this test relies a lot on Random.h, and there's not much more that we can do + // to test it, hence I consider that we will have tested Random.h + MatrixType m1(rows, cols), + m2 = MatrixType::Random(rows, cols), + m3(rows, cols), + mzero = MatrixType::Zero(rows, cols); + + typedef Matrix SquareMatrixType; + SquareMatrixType identity = SquareMatrixType::Identity(rows, rows), + square = SquareMatrixType::Random(rows, rows); + VectorType v1(rows), + v2 = VectorType::Random(rows), + vzero = VectorType::Zero(rows); + + do { + m1 = MatrixType::Random(rows, cols); + } while(m1 == mzero || m1 == m2); + + do { + v1 = VectorType::Random(rows); + } while(v1 == vzero || v1 == v2); + + VERIFY_IS_APPROX( v1, v1); + VERIFY_IS_NOT_APPROX( v1, 2*v1); + VERIFY_IS_APPROX( vzero, v1-v1); + VERIFY_IS_APPROX( m1, m1); + VERIFY_IS_NOT_APPROX( m1, 2*m1); + VERIFY_IS_APPROX( mzero, m1-m1); + + VERIFY_IS_APPROX(m3 = m1,m1); + MatrixType m4; + VERIFY_IS_APPROX(m4 = m1,m1); + + m3.real() = m1.real(); + VERIFY_IS_APPROX(static_cast(m3).real(), static_cast(m1).real()); + VERIFY_IS_APPROX(static_cast(m3).real(), m1.real()); + + // check == / != operators + VERIFY(m1==m1); + VERIFY(m1!=m2); + VERIFY(!(m1==m2)); + VERIFY(!(m1!=m1)); + m1 = m2; + VERIFY(m1==m2); + VERIFY(!(m1!=m2)); + + // check linear structure + + Scalar s1; + do { + s1 = internal::random(); + } while(s1 == 0); + + VERIFY_IS_EQUAL(m1+m1, 2*m1); + VERIFY_IS_EQUAL(m1+m2-m1, m2); + VERIFY_IS_EQUAL(m1*s1, s1*m1); + VERIFY_IS_EQUAL((m1+m2)*s1, s1*m1+s1*m2); + m3 = m2; m3 += m1; + VERIFY_IS_EQUAL(m3, m1+m2); + m3 = m2; m3 -= m1; + VERIFY_IS_EQUAL(m3, m2-m1); + m3 = m2; m3 *= s1; + VERIFY_IS_EQUAL(m3, s1*m2); + + // check matrix product. + + VERIFY_IS_APPROX(identity * m1, m1); + VERIFY_IS_APPROX(square * (m1 + m2), square * m1 + square * m2); + VERIFY_IS_APPROX((m1 + m2).transpose() * square, m1.transpose() * square + m2.transpose() * square); + VERIFY_IS_APPROX((m1 * m2.transpose()) * m1, m1 * (m2.transpose() * m1)); +} + +template +void integer_types_extra() +{ + VERIFY_IS_EQUAL(int(internal::scalar_div_cost::value), 8); + VERIFY_IS_EQUAL(int(internal::scalar_div_cost::value), 8); + if(sizeof(long)>sizeof(int)) { + VERIFY(int(internal::scalar_div_cost::value) > int(internal::scalar_div_cost::value)); + VERIFY(int(internal::scalar_div_cost::value) > int(internal::scalar_div_cost::value)); + } +} + +EIGEN_DECLARE_TEST(integer_types) +{ + for(int i = 0; i < g_repeat; i++) { + CALL_SUBTEST_1( integer_type_tests(Matrix()) ); + CALL_SUBTEST_1( integer_type_tests(Matrix()) ); + + CALL_SUBTEST_2( integer_type_tests(Matrix()) ); + CALL_SUBTEST_2( signed_integer_type_tests(Matrix()) ); + + CALL_SUBTEST_3( integer_type_tests(Matrix(2, 10)) ); + CALL_SUBTEST_3( signed_integer_type_tests(Matrix(2, 10)) ); + + CALL_SUBTEST_4( integer_type_tests(Matrix()) ); + CALL_SUBTEST_4( integer_type_tests(Matrix(20, 20)) ); + + CALL_SUBTEST_5( integer_type_tests(Matrix(7, 4)) ); + CALL_SUBTEST_5( signed_integer_type_tests(Matrix(7, 4)) ); + + CALL_SUBTEST_6( integer_type_tests(Matrix()) ); + +#if EIGEN_HAS_CXX11 + CALL_SUBTEST_7( integer_type_tests(Matrix()) ); + CALL_SUBTEST_7( signed_integer_type_tests(Matrix()) ); + + CALL_SUBTEST_8( integer_type_tests(Matrix(1, 5)) ); +#endif + } + CALL_SUBTEST_9( integer_types_extra<0>() ); +} diff --git a/include/eigen/test/io.cpp b/include/eigen/test/io.cpp new file mode 100644 index 0000000000000000000000000000000000000000..aa14e76e9b984d922e09fb743d78648e92de6bdb --- /dev/null +++ b/include/eigen/test/io.cpp @@ -0,0 +1,71 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2019 Joel Holdsworth +// +// 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/. + +#include + +#include "main.h" + +template +struct check_ostream_impl +{ + static void run() + { + const Array array(123); + std::ostringstream ss; + ss << array; + VERIFY(ss.str() == "123"); + + check_ostream_impl< std::complex >::run(); + }; +}; + +template<> +struct check_ostream_impl +{ + static void run() + { + const Array array(1, 0); + std::ostringstream ss; + ss << array; + VERIFY(ss.str() == "1 0"); + }; +}; + +template +struct check_ostream_impl< std::complex > +{ + static void run() + { + const Array,1,1> array(std::complex(12, 34)); + std::ostringstream ss; + ss << array; + VERIFY(ss.str() == "(12,34)"); + }; +}; + +template +static void check_ostream() +{ + check_ostream_impl::run(); +} + +EIGEN_DECLARE_TEST(rand) +{ + CALL_SUBTEST(check_ostream()); + CALL_SUBTEST(check_ostream()); + CALL_SUBTEST(check_ostream()); + CALL_SUBTEST(check_ostream()); + CALL_SUBTEST(check_ostream()); + CALL_SUBTEST(check_ostream()); + CALL_SUBTEST(check_ostream()); + CALL_SUBTEST(check_ostream()); + CALL_SUBTEST(check_ostream()); + CALL_SUBTEST(check_ostream()); + CALL_SUBTEST(check_ostream()); +} diff --git a/include/eigen/test/is_same_dense.cpp b/include/eigen/test/is_same_dense.cpp new file mode 100644 index 0000000000000000000000000000000000000000..23dd806ebd9941b6c5477cbed2eb37749e4d7156 --- /dev/null +++ b/include/eigen/test/is_same_dense.cpp @@ -0,0 +1,41 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2015 Gael Guennebaud +// +// 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/. + +#include "main.h" + +using internal::is_same_dense; + +EIGEN_DECLARE_TEST(is_same_dense) +{ + typedef Matrix ColMatrixXd; + typedef Matrix,Dynamic,Dynamic,ColMajor> ColMatrixXcd; + ColMatrixXd m1(10,10); + ColMatrixXcd m2(10,10); + Ref ref_m1(m1); + Ref > ref_m2_real(m2.real()); + Ref const_ref_m1(m1); + + VERIFY(is_same_dense(m1,m1)); + VERIFY(is_same_dense(m1,ref_m1)); + VERIFY(is_same_dense(const_ref_m1,m1)); + VERIFY(is_same_dense(const_ref_m1,ref_m1)); + + VERIFY(is_same_dense(m1.block(0,0,m1.rows(),m1.cols()),m1)); + VERIFY(!is_same_dense(m1.row(0),m1.col(0))); + + Ref const_ref_m1_row(m1.row(1)); + VERIFY(!is_same_dense(m1.row(1),const_ref_m1_row)); + + Ref const_ref_m1_col(m1.col(1)); + VERIFY(is_same_dense(m1.col(1),const_ref_m1_col)); + + + VERIFY(!is_same_dense(m1, ref_m2_real)); + VERIFY(!is_same_dense(m2, ref_m2_real)); +} diff --git a/include/eigen/test/jacobi.cpp b/include/eigen/test/jacobi.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5604797f526089176bb061f86ab1503b162985c8 --- /dev/null +++ b/include/eigen/test/jacobi.cpp @@ -0,0 +1,80 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2008 Gael Guennebaud +// Copyright (C) 2009 Benoit Jacob +// +// 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/. + +#include "main.h" +#include + +template +void jacobi(const MatrixType& m = MatrixType()) +{ + Index rows = m.rows(); + Index cols = m.cols(); + + enum { + RowsAtCompileTime = MatrixType::RowsAtCompileTime, + ColsAtCompileTime = MatrixType::ColsAtCompileTime + }; + + typedef Matrix JacobiVector; + + const MatrixType a(MatrixType::Random(rows, cols)); + + JacobiVector v = JacobiVector::Random().normalized(); + JacobiScalar c = v.x(), s = v.y(); + JacobiRotation rot(c, s); + + { + Index p = internal::random(0, rows-1); + Index q; + do { + q = internal::random(0, rows-1); + } while (q == p); + + MatrixType b = a; + b.applyOnTheLeft(p, q, rot); + VERIFY_IS_APPROX(b.row(p), c * a.row(p) + numext::conj(s) * a.row(q)); + VERIFY_IS_APPROX(b.row(q), -s * a.row(p) + numext::conj(c) * a.row(q)); + } + + { + Index p = internal::random(0, cols-1); + Index q; + do { + q = internal::random(0, cols-1); + } while (q == p); + + MatrixType b = a; + b.applyOnTheRight(p, q, rot); + VERIFY_IS_APPROX(b.col(p), c * a.col(p) - s * a.col(q)); + VERIFY_IS_APPROX(b.col(q), numext::conj(s) * a.col(p) + numext::conj(c) * a.col(q)); + } +} + +EIGEN_DECLARE_TEST(jacobi) +{ + for(int i = 0; i < g_repeat; i++) { + CALL_SUBTEST_1(( jacobi() )); + CALL_SUBTEST_2(( jacobi() )); + CALL_SUBTEST_3(( jacobi() )); + CALL_SUBTEST_3(( jacobi >() )); + + int r = internal::random(2, internal::random(1,EIGEN_TEST_MAX_SIZE)/2), + c = internal::random(2, internal::random(1,EIGEN_TEST_MAX_SIZE)/2); + CALL_SUBTEST_4(( jacobi(MatrixXf(r,c)) )); + CALL_SUBTEST_5(( jacobi(MatrixXcd(r,c)) )); + CALL_SUBTEST_5(( jacobi >(MatrixXcd(r,c)) )); + // complex is really important to test as it is the only way to cover conjugation issues in certain unaligned paths + CALL_SUBTEST_6(( jacobi(MatrixXcf(r,c)) )); + CALL_SUBTEST_6(( jacobi >(MatrixXcf(r,c)) )); + + TEST_SET_BUT_UNUSED_VARIABLE(r); + TEST_SET_BUT_UNUSED_VARIABLE(c); + } +} diff --git a/include/eigen/test/lscg.cpp b/include/eigen/test/lscg.cpp new file mode 100644 index 0000000000000000000000000000000000000000..feb2347a8fc7c20400bbbc9c170cf54690279788 --- /dev/null +++ b/include/eigen/test/lscg.cpp @@ -0,0 +1,37 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2011 Gael Guennebaud +// +// 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/. + +#include "sparse_solver.h" +#include + +template void test_lscg_T() +{ + LeastSquaresConjugateGradient > lscg_colmajor_diag; + LeastSquaresConjugateGradient, IdentityPreconditioner> lscg_colmajor_I; + LeastSquaresConjugateGradient > lscg_rowmajor_diag; + LeastSquaresConjugateGradient, IdentityPreconditioner> lscg_rowmajor_I; + + CALL_SUBTEST( check_sparse_square_solving(lscg_colmajor_diag) ); + CALL_SUBTEST( check_sparse_square_solving(lscg_colmajor_I) ); + + CALL_SUBTEST( check_sparse_leastsquare_solving(lscg_colmajor_diag) ); + CALL_SUBTEST( check_sparse_leastsquare_solving(lscg_colmajor_I) ); + + CALL_SUBTEST( check_sparse_square_solving(lscg_rowmajor_diag) ); + CALL_SUBTEST( check_sparse_square_solving(lscg_rowmajor_I) ); + + CALL_SUBTEST( check_sparse_leastsquare_solving(lscg_rowmajor_diag) ); + CALL_SUBTEST( check_sparse_leastsquare_solving(lscg_rowmajor_I) ); +} + +EIGEN_DECLARE_TEST(lscg) +{ + CALL_SUBTEST_1(test_lscg_T()); + CALL_SUBTEST_2(test_lscg_T >()); +} diff --git a/include/eigen/test/main.h b/include/eigen/test/main.h new file mode 100644 index 0000000000000000000000000000000000000000..19bbf1b8191d7b0e07c23ffe506e8ef6c351f6ee --- /dev/null +++ b/include/eigen/test/main.h @@ -0,0 +1,884 @@ + +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2006-2008 Benoit Jacob +// Copyright (C) 2008 Gael Guennebaud +// +// 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/. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// The following includes of STL headers have to be done _before_ the +// definition of macros min() and max(). The reason is that many STL +// implementations will not work properly as the min and max symbols collide +// with the STL functions std:min() and std::max(). The STL headers may check +// for the macro definition of min/max and issue a warning or undefine the +// macros. +// +// Still, Windows defines min() and max() in windef.h as part of the regular +// Windows system interfaces and many other Windows APIs depend on these +// macros being available. To prevent the macro expansion of min/max and to +// make Eigen compatible with the Windows environment all function calls of +// std::min() and std::max() have to be written with parenthesis around the +// function name. +// +// All STL headers used by Eigen should be included here. Because main.h is +// included before any Eigen header and because the STL headers are guarded +// against multiple inclusions, no STL header will see our own min/max macro +// definitions. +#include +#include +// Disable ICC's std::complex operator specializations so we can use our own. +#define _OVERRIDE_COMPLEX_SPECIALIZATION_ 1 +#include +#include +#include +#include +#include +#if __cplusplus >= 201103L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201103L) +#include +#include +#ifdef EIGEN_USE_THREADS +#include +#endif +#endif + +// Same for cuda_fp16.h +#if defined(__CUDACC__) && !defined(EIGEN_NO_CUDA) + // Means the compiler is either nvcc or clang with CUDA enabled + #define EIGEN_CUDACC __CUDACC__ +#endif +#if defined(EIGEN_CUDACC) +#include + #define EIGEN_CUDA_SDK_VER (CUDA_VERSION * 10) +#else + #define EIGEN_CUDA_SDK_VER 0 +#endif +#if EIGEN_CUDA_SDK_VER >= 70500 +#include +#endif + +// To test that all calls from Eigen code to std::min() and std::max() are +// protected by parenthesis against macro expansion, the min()/max() macros +// are defined here and any not-parenthesized min/max call will cause a +// compiler error. +#if !defined(__HIPCC__) && !defined(EIGEN_USE_SYCL) + // + // HIP header files include the following files + // + // + // + // which seem to contain not-parenthesized calls to "max"/"min", triggering the following check and causing the compile to fail + // + // Including those header files before the following macro definition for "min" / "max", only partially resolves the issue + // This is because other HIP header files also define "isnan" / "isinf" / "isfinite" functions, which are needed in other + // headers. + // + // So instead choosing to simply disable this check for HIP + // + #define min(A,B) please_protect_your_min_with_parentheses + #define max(A,B) please_protect_your_max_with_parentheses + #define isnan(X) please_protect_your_isnan_with_parentheses + #define isinf(X) please_protect_your_isinf_with_parentheses + #define isfinite(X) please_protect_your_isfinite_with_parentheses +#endif + + +// test possible conflicts +struct real {}; +struct imag {}; + +#ifdef M_PI +#undef M_PI +#endif +#define M_PI please_use_EIGEN_PI_instead_of_M_PI + +#define FORBIDDEN_IDENTIFIER (this_identifier_is_forbidden_to_avoid_clashes) this_identifier_is_forbidden_to_avoid_clashes +// B0 is defined in POSIX header termios.h +#define B0 FORBIDDEN_IDENTIFIER +// `I` may be defined by complex.h: +#define I FORBIDDEN_IDENTIFIER + +// _res is defined by resolv.h +#define _res FORBIDDEN_IDENTIFIER + +// Unit tests calling Eigen's blas library must preserve the default blocking size +// to avoid troubles. +#ifndef EIGEN_NO_DEBUG_SMALL_PRODUCT_BLOCKS +#define EIGEN_DEBUG_SMALL_PRODUCT_BLOCKS +#endif + +// shuts down ICC's remark #593: variable "XXX" was set but never used +#define TEST_SET_BUT_UNUSED_VARIABLE(X) EIGEN_UNUSED_VARIABLE(X) + +#ifdef TEST_ENABLE_TEMPORARY_TRACKING + +static long int nb_temporaries; +static long int nb_temporaries_on_assert = -1; + +inline void on_temporary_creation(long int size) { + // here's a great place to set a breakpoint when debugging failures in this test! + if(size!=0) nb_temporaries++; + if(nb_temporaries_on_assert>0) assert(nb_temporaries if NDEBUG is not defined. +#ifndef DEBUG +#define DEBUG +#endif + +// bounds integer values for AltiVec +#if defined(__ALTIVEC__) || defined(__VSX__) +#define EIGEN_MAKING_DOCS +#endif + +#define DEFAULT_REPEAT 10 + +namespace Eigen +{ + static std::vector g_test_stack; + // level == 0 <=> abort if test fail + // level >= 1 <=> warning message to std::cerr if test fail + static int g_test_level = 0; + static int g_repeat = 1; + static unsigned int g_seed = 0; + static bool g_has_set_repeat = false, g_has_set_seed = false; + + class EigenTest + { + public: + EigenTest() : m_func(0) {} + EigenTest(const char* a_name, void (*func)(void)) + : m_name(a_name), m_func(func) + { + get_registered_tests().push_back(this); + } + const std::string& name() const { return m_name; } + void operator()() const { m_func(); } + + static const std::vector& all() { return get_registered_tests(); } + protected: + static std::vector& get_registered_tests() + { + static std::vector* ms_registered_tests = new std::vector(); + return *ms_registered_tests; + } + std::string m_name; + void (*m_func)(void); + }; + + // Declare and register a test, e.g.: + // EIGEN_DECLARE_TEST(mytest) { ... } + // will create a function: + // void test_mytest() { ... } + // that will be automatically called. + #define EIGEN_DECLARE_TEST(X) \ + void EIGEN_CAT(test_,X) (); \ + static EigenTest EIGEN_CAT(test_handler_,X) (EIGEN_MAKESTRING(X), & EIGEN_CAT(test_,X)); \ + void EIGEN_CAT(test_,X) () +} + +#define TRACK std::cerr << __FILE__ << " " << __LINE__ << std::endl +// #define TRACK while() + +#define EIGEN_DEFAULT_IO_FORMAT IOFormat(4, 0, " ", "\n", "", "", "", "") + +#if (defined(_CPPUNWIND) || defined(__EXCEPTIONS)) && !defined(__CUDA_ARCH__) && !defined(__HIP_DEVICE_COMPILE__) && !defined(__SYCL_DEVICE_ONLY__) + #define EIGEN_EXCEPTIONS +#endif + +#ifndef EIGEN_NO_ASSERTION_CHECKING + + namespace Eigen + { + static const bool should_raise_an_assert = false; + + // Used to avoid to raise two exceptions at a time in which + // case the exception is not properly caught. + // This may happen when a second exceptions is triggered in a destructor. + static bool no_more_assert = false; + static bool report_on_cerr_on_assert_failure = true; + + struct eigen_assert_exception + { + eigen_assert_exception(void) {} + ~eigen_assert_exception() { Eigen::no_more_assert = false; } + }; + + struct eigen_static_assert_exception + { + eigen_static_assert_exception(void) {} + ~eigen_static_assert_exception() { Eigen::no_more_assert = false; } + }; + } + // If EIGEN_DEBUG_ASSERTS is defined and if no assertion is triggered while + // one should have been, then the list of executed assertions is printed out. + // + // EIGEN_DEBUG_ASSERTS is not enabled by default as it + // significantly increases the compilation time + // and might even introduce side effects that would hide + // some memory errors. + #ifdef EIGEN_DEBUG_ASSERTS + + namespace Eigen + { + namespace internal + { + static bool push_assert = false; + } + static std::vector eigen_assert_list; + } + #define eigen_assert(a) \ + if( (!(a)) && (!no_more_assert) ) \ + { \ + if(report_on_cerr_on_assert_failure) \ + std::cerr << #a << " " __FILE__ << "(" << __LINE__ << ")\n"; \ + Eigen::no_more_assert = true; \ + EIGEN_THROW_X(Eigen::eigen_assert_exception()); \ + } \ + else if (Eigen::internal::push_assert) \ + { \ + eigen_assert_list.push_back(std::string(EIGEN_MAKESTRING(__FILE__) " (" EIGEN_MAKESTRING(__LINE__) ") : " #a) ); \ + } + + #ifdef EIGEN_EXCEPTIONS + #define VERIFY_RAISES_ASSERT(a) \ + { \ + Eigen::no_more_assert = false; \ + Eigen::eigen_assert_list.clear(); \ + Eigen::internal::push_assert = true; \ + Eigen::report_on_cerr_on_assert_failure = false; \ + try { \ + a; \ + std::cerr << "One of the following asserts should have been triggered:\n"; \ + for (uint ai=0 ; ai // required for createRandomPIMatrixOfRank + +inline void verify_impl(bool condition, const char *testname, const char *file, int line, const char *condition_as_string) +{ + if (!condition) + { + if(Eigen::g_test_level>0) + std::cerr << "WARNING: "; + std::cerr << "Test " << testname << " failed in " << file << " (" << line << ")" + << std::endl << " " << condition_as_string << std::endl; + std::cerr << "Stack:\n"; + const int test_stack_size = static_cast(Eigen::g_test_stack.size()); + for(int i=test_stack_size-1; i>=0; --i) + std::cerr << " - " << Eigen::g_test_stack[i] << "\n"; + std::cerr << "\n"; + if(Eigen::g_test_level==0) + abort(); + } +} + +#define VERIFY(a) ::verify_impl(a, g_test_stack.back().c_str(), __FILE__, __LINE__, EIGEN_MAKESTRING(a)) + +#define VERIFY_GE(a, b) ::verify_impl(a >= b, g_test_stack.back().c_str(), __FILE__, __LINE__, EIGEN_MAKESTRING(a >= b)) +#define VERIFY_LE(a, b) ::verify_impl(a <= b, g_test_stack.back().c_str(), __FILE__, __LINE__, EIGEN_MAKESTRING(a <= b)) + + +#define VERIFY_IS_EQUAL(a, b) VERIFY(test_is_equal(a, b, true)) +#define VERIFY_IS_NOT_EQUAL(a, b) VERIFY(test_is_equal(a, b, false)) +#define VERIFY_IS_APPROX(a, b) VERIFY(verifyIsApprox(a, b)) +#define VERIFY_IS_NOT_APPROX(a, b) VERIFY(!test_isApprox(a, b)) +#define VERIFY_IS_MUCH_SMALLER_THAN(a, b) VERIFY(test_isMuchSmallerThan(a, b)) +#define VERIFY_IS_NOT_MUCH_SMALLER_THAN(a, b) VERIFY(!test_isMuchSmallerThan(a, b)) +#define VERIFY_IS_APPROX_OR_LESS_THAN(a, b) VERIFY(test_isApproxOrLessThan(a, b)) +#define VERIFY_IS_NOT_APPROX_OR_LESS_THAN(a, b) VERIFY(!test_isApproxOrLessThan(a, b)) +#define VERIFY_IS_CWISE_EQUAL(a, b) VERIFY(verifyIsCwiseApprox(a, b, true)) +#define VERIFY_IS_CWISE_APPROX(a, b) VERIFY(verifyIsCwiseApprox(a, b, false)) + +#define VERIFY_IS_UNITARY(a) VERIFY(test_isUnitary(a)) + +#define STATIC_CHECK(COND) EIGEN_STATIC_ASSERT( (COND) , EIGEN_INTERNAL_ERROR_PLEASE_FILE_A_BUG_REPORT ) + +#define CALL_SUBTEST(FUNC) do { \ + g_test_stack.push_back(EIGEN_MAKESTRING(FUNC)); \ + FUNC; \ + g_test_stack.pop_back(); \ + } while (0) + + +namespace Eigen { + +template +typename internal::enable_if::value,bool>::type +is_same_type(const T1&, const T2&) +{ + return true; +} + +template inline typename NumTraits::Real test_precision() { return NumTraits::dummy_precision(); } +template<> inline float test_precision() { return 1e-3f; } +template<> inline double test_precision() { return 1e-6; } +template<> inline long double test_precision() { return 1e-6l; } +template<> inline float test_precision >() { return test_precision(); } +template<> inline double test_precision >() { return test_precision(); } +template<> inline long double test_precision >() { return test_precision(); } + +#define EIGEN_TEST_SCALAR_TEST_OVERLOAD(TYPE) \ + inline bool test_isApprox(TYPE a, TYPE b) \ + { return numext::equal_strict(a, b) || \ + ((numext::isnan)(a) && (numext::isnan)(b)) || \ + (internal::isApprox(a, b, test_precision())); } \ + inline bool test_isCwiseApprox(TYPE a, TYPE b, bool exact) \ + { return numext::equal_strict(a, b) || \ + ((numext::isnan)(a) && (numext::isnan)(b)) || \ + (!exact && internal::isApprox(a, b, test_precision())); } \ + inline bool test_isMuchSmallerThan(TYPE a, TYPE b) \ + { return internal::isMuchSmallerThan(a, b, test_precision()); } \ + inline bool test_isApproxOrLessThan(TYPE a, TYPE b) \ + { return internal::isApproxOrLessThan(a, b, test_precision()); } + +EIGEN_TEST_SCALAR_TEST_OVERLOAD(short) +EIGEN_TEST_SCALAR_TEST_OVERLOAD(unsigned short) +EIGEN_TEST_SCALAR_TEST_OVERLOAD(int) +EIGEN_TEST_SCALAR_TEST_OVERLOAD(unsigned int) +EIGEN_TEST_SCALAR_TEST_OVERLOAD(long) +EIGEN_TEST_SCALAR_TEST_OVERLOAD(unsigned long) +#if EIGEN_HAS_CXX11 +EIGEN_TEST_SCALAR_TEST_OVERLOAD(long long) +EIGEN_TEST_SCALAR_TEST_OVERLOAD(unsigned long long) +#endif +EIGEN_TEST_SCALAR_TEST_OVERLOAD(float) +EIGEN_TEST_SCALAR_TEST_OVERLOAD(double) +EIGEN_TEST_SCALAR_TEST_OVERLOAD(half) +EIGEN_TEST_SCALAR_TEST_OVERLOAD(bfloat16) + +#undef EIGEN_TEST_SCALAR_TEST_OVERLOAD + +#ifndef EIGEN_TEST_NO_COMPLEX +inline bool test_isApprox(const std::complex& a, const std::complex& b) +{ return internal::isApprox(a, b, test_precision >()); } +inline bool test_isMuchSmallerThan(const std::complex& a, const std::complex& b) +{ return internal::isMuchSmallerThan(a, b, test_precision >()); } + +inline bool test_isApprox(const std::complex& a, const std::complex& b) +{ return internal::isApprox(a, b, test_precision >()); } +inline bool test_isMuchSmallerThan(const std::complex& a, const std::complex& b) +{ return internal::isMuchSmallerThan(a, b, test_precision >()); } + +#ifndef EIGEN_TEST_NO_LONGDOUBLE +inline bool test_isApprox(const std::complex& a, const std::complex& b) +{ return internal::isApprox(a, b, test_precision >()); } +inline bool test_isMuchSmallerThan(const std::complex& a, const std::complex& b) +{ return internal::isMuchSmallerThan(a, b, test_precision >()); } +#endif +#endif + +#ifndef EIGEN_TEST_NO_LONGDOUBLE +inline bool test_isApprox(const long double& a, const long double& b) +{ + bool ret = internal::isApprox(a, b, test_precision()); + if (!ret) std::cerr + << std::endl << " actual = " << a + << std::endl << " expected = " << b << std::endl << std::endl; + return ret; +} + +inline bool test_isMuchSmallerThan(const long double& a, const long double& b) +{ return internal::isMuchSmallerThan(a, b, test_precision()); } +inline bool test_isApproxOrLessThan(const long double& a, const long double& b) +{ return internal::isApproxOrLessThan(a, b, test_precision()); } +#endif // EIGEN_TEST_NO_LONGDOUBLE + +// test_relative_error returns the relative difference between a and b as a real scalar as used in isApprox. +template +typename NumTraits::NonInteger test_relative_error(const EigenBase &a, const EigenBase &b) +{ + using std::sqrt; + typedef typename NumTraits::NonInteger RealScalar; + typename internal::nested_eval::type ea(a.derived()); + typename internal::nested_eval::type eb(b.derived()); + return sqrt(RealScalar((ea-eb).cwiseAbs2().sum()) / RealScalar((std::min)(eb.cwiseAbs2().sum(),ea.cwiseAbs2().sum()))); +} + +template +typename T1::RealScalar test_relative_error(const T1 &a, const T2 &b, const typename T1::Coefficients* = 0) +{ + return test_relative_error(a.coeffs(), b.coeffs()); +} + +template +typename T1::Scalar test_relative_error(const T1 &a, const T2 &b, const typename T1::MatrixType* = 0) +{ + return test_relative_error(a.matrix(), b.matrix()); +} + +template +S test_relative_error(const Translation &a, const Translation &b) +{ + return test_relative_error(a.vector(), b.vector()); +} + +template +S test_relative_error(const ParametrizedLine &a, const ParametrizedLine &b) +{ + return (std::max)(test_relative_error(a.origin(), b.origin()), test_relative_error(a.origin(), b.origin())); +} + +template +S test_relative_error(const AlignedBox &a, const AlignedBox &b) +{ + return (std::max)(test_relative_error((a.min)(), (b.min)()), test_relative_error((a.max)(), (b.max)())); +} + +template class SparseMatrixBase; +template +typename T1::RealScalar test_relative_error(const MatrixBase &a, const SparseMatrixBase &b) +{ + return test_relative_error(a,b.toDense()); +} + +template class SparseMatrixBase; +template +typename T1::RealScalar test_relative_error(const SparseMatrixBase &a, const MatrixBase &b) +{ + return test_relative_error(a.toDense(),b); +} + +template class SparseMatrixBase; +template +typename T1::RealScalar test_relative_error(const SparseMatrixBase &a, const SparseMatrixBase &b) +{ + return test_relative_error(a.toDense(),b.toDense()); +} + +template +typename NumTraits::Real>::NonInteger test_relative_error(const T1 &a, const T2 &b, typename internal::enable_if::Real>::value, T1>::type* = 0) +{ + typedef typename NumTraits::Real>::NonInteger RealScalar; + return numext::sqrt(RealScalar(numext::abs2(a-b))/(numext::mini)(RealScalar(numext::abs2(a)),RealScalar(numext::abs2(b)))); +} + +template +T test_relative_error(const Rotation2D &a, const Rotation2D &b) +{ + return test_relative_error(a.angle(), b.angle()); +} + +template +T test_relative_error(const AngleAxis &a, const AngleAxis &b) +{ + return (std::max)(test_relative_error(a.angle(), b.angle()), test_relative_error(a.axis(), b.axis())); +} + +template +inline bool test_isApprox(const Type1& a, const Type2& b, typename Type1::Scalar* = 0) // Enabled for Eigen's type only +{ + return a.isApprox(b, test_precision()); +} + +// get_test_precision is a small wrapper to test_precision allowing to return the scalar precision for either scalars or expressions +template +typename NumTraits::Real get_test_precision(const T&, const typename T::Scalar* = 0) +{ + return test_precision::Real>(); +} + +template +typename NumTraits::Real get_test_precision(const T&,typename internal::enable_if::Real>::value, T>::type* = 0) +{ + return test_precision::Real>(); +} + +// verifyIsApprox is a wrapper to test_isApprox that outputs the relative difference magnitude if the test fails. +template +inline bool verifyIsApprox(const Type1& a, const Type2& b) +{ + bool ret = test_isApprox(a,b); + if(!ret) + { + std::cerr << "Difference too large wrt tolerance " << get_test_precision(a) << ", relative error is: " << test_relative_error(a,b) << std::endl; + } + return ret; +} + +// verifyIsCwiseApprox is a wrapper to test_isCwiseApprox that outputs the relative difference magnitude if the test fails. +template +inline bool verifyIsCwiseApprox(const Type1& a, const Type2& b, bool exact) +{ + bool ret = test_isCwiseApprox(a,b,exact); + if(!ret) { + if (exact) { + std::cerr << "Values are not an exact match"; + } else { + std::cerr << "Difference too large wrt tolerance " << get_test_precision(a); + } + std::cerr << ", relative error is: " << test_relative_error(a,b) << std::endl; + } + return ret; +} + +// The idea behind this function is to compare the two scalars a and b where +// the scalar ref is a hint about the expected order of magnitude of a and b. +// WARNING: the scalar a and b must be positive +// Therefore, if for some reason a and b are very small compared to ref, +// we won't issue a false negative. +// This test could be: abs(a-b) <= eps * ref +// However, it seems that simply comparing a+ref and b+ref is more sensitive to true error. +template +inline bool test_isApproxWithRef(const Scalar& a, const Scalar& b, const ScalarRef& ref) +{ + return test_isApprox(a+ref, b+ref); +} + +template +inline bool test_isMuchSmallerThan(const MatrixBase& m1, + const MatrixBase& m2) +{ + return m1.isMuchSmallerThan(m2, test_precision::Scalar>()); +} + +template +inline bool test_isMuchSmallerThan(const MatrixBase& m, + const typename NumTraits::Scalar>::Real& s) +{ + return m.isMuchSmallerThan(s, test_precision::Scalar>()); +} + +template +inline bool test_isUnitary(const MatrixBase& m) +{ + return m.isUnitary(test_precision::Scalar>()); +} + +// Forward declaration to avoid ICC warning +template +bool test_is_equal(const T& actual, const U& expected, bool expect_equal=true); + +template +bool test_is_equal(const T& actual, const U& expected, bool expect_equal) +{ + if ((actual==expected) == expect_equal) + return true; + // false: + std::cerr + << "\n actual = " << actual + << "\n expected " << (expect_equal ? "= " : "!=") << expected << "\n\n"; + return false; +} + +/** Creates a random Partial Isometry matrix of given rank. + * + * A partial isometry is a matrix all of whose singular values are either 0 or 1. + * This is very useful to test rank-revealing algorithms. + */ +// Forward declaration to avoid ICC warning +template +void createRandomPIMatrixOfRank(Index desired_rank, Index rows, Index cols, MatrixType& m); +template +void createRandomPIMatrixOfRank(Index desired_rank, Index rows, Index cols, MatrixType& m) +{ + typedef typename internal::traits::Scalar Scalar; + enum { Rows = MatrixType::RowsAtCompileTime, Cols = MatrixType::ColsAtCompileTime }; + + typedef Matrix VectorType; + typedef Matrix MatrixAType; + typedef Matrix MatrixBType; + + if(desired_rank == 0) + { + m.setZero(rows,cols); + return; + } + + if(desired_rank == 1) + { + // here we normalize the vectors to get a partial isometry + m = VectorType::Random(rows).normalized() * VectorType::Random(cols).normalized().transpose(); + return; + } + + MatrixAType a = MatrixAType::Random(rows,rows); + MatrixType d = MatrixType::Identity(rows,cols); + MatrixBType b = MatrixBType::Random(cols,cols); + + // set the diagonal such that only desired_rank non-zero entries reamain + const Index diag_size = (std::min)(d.rows(),d.cols()); + if(diag_size != desired_rank) + d.diagonal().segment(desired_rank, diag_size-desired_rank) = VectorType::Zero(diag_size-desired_rank); + + HouseholderQR qra(a); + HouseholderQR qrb(b); + m = qra.householderQ() * d * qrb.householderQ(); +} + +// Forward declaration to avoid ICC warning +template +void randomPermutationVector(PermutationVectorType& v, Index size); +template +void randomPermutationVector(PermutationVectorType& v, Index size) +{ + typedef typename PermutationVectorType::Scalar Scalar; + v.resize(size); + for(Index i = 0; i < size; ++i) v(i) = Scalar(i); + if(size == 1) return; + for(Index n = 0; n < 3 * size; ++n) + { + Index i = internal::random(0, size-1); + Index j; + do j = internal::random(0, size-1); while(j==i); + std::swap(v(i), v(j)); + } +} + +template bool isNotNaN(const T& x) +{ + return x==x; +} + +template bool isPlusInf(const T& x) +{ + return x > NumTraits::highest(); +} + +template bool isMinusInf(const T& x) +{ + return x < NumTraits::lowest(); +} + +} // end namespace Eigen + +template struct GetDifferentType; + +template<> struct GetDifferentType { typedef double type; }; +template<> struct GetDifferentType { typedef float type; }; +template struct GetDifferentType > +{ typedef std::complex::type> type; }; + +// Forward declaration to avoid ICC warning +template std::string type_name(); +template std::string type_name() { return "other"; } +template<> std::string type_name() { return "float"; } +template<> std::string type_name() { return "double"; } +template<> std::string type_name() { return "long double"; } +template<> std::string type_name() { return "int"; } +template<> std::string type_name >() { return "complex"; } +template<> std::string type_name >() { return "complex"; } +template<> std::string type_name >() { return "complex"; } +template<> std::string type_name >() { return "complex"; } + +using namespace Eigen; + +inline void set_repeat_from_string(const char *str) +{ + errno = 0; + g_repeat = int(strtoul(str, 0, 10)); + if(errno || g_repeat <= 0) + { + std::cout << "Invalid repeat value " << str << std::endl; + exit(EXIT_FAILURE); + } + g_has_set_repeat = true; +} + +inline void set_seed_from_string(const char *str) +{ + errno = 0; + g_seed = int(strtoul(str, 0, 10)); + if(errno || g_seed == 0) + { + std::cout << "Invalid seed value " << str << std::endl; + exit(EXIT_FAILURE); + } + g_has_set_seed = true; +} + +int main(int argc, char *argv[]) +{ + g_has_set_repeat = false; + g_has_set_seed = false; + bool need_help = false; + + for(int i = 1; i < argc; i++) + { + if(argv[i][0] == 'r') + { + if(g_has_set_repeat) + { + std::cout << "Argument " << argv[i] << " conflicting with a former argument" << std::endl; + return 1; + } + set_repeat_from_string(argv[i]+1); + } + else if(argv[i][0] == 's') + { + if(g_has_set_seed) + { + std::cout << "Argument " << argv[i] << " conflicting with a former argument" << std::endl; + return 1; + } + set_seed_from_string(argv[i]+1); + } + else + { + need_help = true; + } + } + + if(need_help) + { + std::cout << "This test application takes the following optional arguments:" << std::endl; + std::cout << " rN Repeat each test N times (default: " << DEFAULT_REPEAT << ")" << std::endl; + std::cout << " sN Use N as seed for random numbers (default: based on current time)" << std::endl; + std::cout << std::endl; + std::cout << "If defined, the environment variables EIGEN_REPEAT and EIGEN_SEED" << std::endl; + std::cout << "will be used as default values for these parameters." << std::endl; + return 1; + } + + char *env_EIGEN_REPEAT = getenv("EIGEN_REPEAT"); + if(!g_has_set_repeat && env_EIGEN_REPEAT) + set_repeat_from_string(env_EIGEN_REPEAT); + char *env_EIGEN_SEED = getenv("EIGEN_SEED"); + if(!g_has_set_seed && env_EIGEN_SEED) + set_seed_from_string(env_EIGEN_SEED); + + if(!g_has_set_seed) g_seed = (unsigned int) time(NULL); + if(!g_has_set_repeat) g_repeat = DEFAULT_REPEAT; + + std::cout << "Initializing random number generator with seed " << g_seed << std::endl; + std::stringstream ss; + ss << "Seed: " << g_seed; + g_test_stack.push_back(ss.str()); + srand(g_seed); + std::cout << "Repeating each test " << g_repeat << " times" << std::endl; + + VERIFY(EigenTest::all().size()>0); + + for(std::size_t i=0; i this warning is raised even for legal usage as: g_test_stack.push_back("foo"); where g_test_stack is a std::vector + // remark #1418: external function definition with no prior declaration + // -> this warning is raised for all our test functions. Declaring them static would fix the issue. + // warning #279: controlling expression is constant + // remark #1572: floating-point equality and inequality comparisons are unreliable + #pragma warning disable 279 383 1418 1572 +#endif + +#ifdef _MSC_VER + // 4503 - decorated name length exceeded, name was truncated + #pragma warning( disable : 4503) +#endif diff --git a/include/eigen/test/meta.cpp b/include/eigen/test/meta.cpp new file mode 100644 index 0000000000000000000000000000000000000000..03025eec92e3de322669651adf69f6742a5875f3 --- /dev/null +++ b/include/eigen/test/meta.cpp @@ -0,0 +1,138 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2008 Gael Guennebaud +// +// 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/. + +#include "main.h" + +template +bool check_is_convertible(const From&, const To&) +{ + return internal::is_convertible::value; +} + +struct FooReturnType { + typedef int ReturnType; +}; + +struct MyInterface { + virtual void func() = 0; + virtual ~MyInterface() {} +}; +struct MyImpl : public MyInterface { + void func() {} +}; + +EIGEN_DECLARE_TEST(meta) +{ + VERIFY((internal::conditional<(3<4),internal::true_type, internal::false_type>::type::value)); + VERIFY(( internal::is_same::value)); + VERIFY((!internal::is_same::value)); + VERIFY((!internal::is_same::value)); + VERIFY((!internal::is_same::value)); + + VERIFY(( internal::is_same::type >::value)); + VERIFY(( internal::is_same::type >::value)); + VERIFY(( internal::is_same::type >::value)); + VERIFY(( internal::is_same::type >::value)); + VERIFY(( internal::is_same::type >::value)); + VERIFY(( internal::is_same::type >::value)); + VERIFY(( internal::is_same::type >::value)); + + // test add_const + VERIFY(( internal::is_same< internal::add_const::type, const float >::value)); + VERIFY(( internal::is_same< internal::add_const::type, float* const>::value)); + VERIFY(( internal::is_same< internal::add_const::type, float const* const>::value)); + VERIFY(( internal::is_same< internal::add_const::type, float& >::value)); + + // test remove_const + VERIFY(( internal::is_same< internal::remove_const::type, float const* >::value)); + VERIFY(( internal::is_same< internal::remove_const::type, float const* >::value)); + VERIFY(( internal::is_same< internal::remove_const::type, float* >::value)); + + // test add_const_on_value_type + VERIFY(( internal::is_same< internal::add_const_on_value_type::type, float const& >::value)); + VERIFY(( internal::is_same< internal::add_const_on_value_type::type, float const* >::value)); + + VERIFY(( internal::is_same< internal::add_const_on_value_type::type, const float >::value)); + VERIFY(( internal::is_same< internal::add_const_on_value_type::type, const float >::value)); + + VERIFY(( internal::is_same< internal::add_const_on_value_type::type, const float* const>::value)); + VERIFY(( internal::is_same< internal::add_const_on_value_type::type, const float* const>::value)); + + VERIFY(( internal::is_same::type >::value)); + VERIFY(( internal::is_same::type >::value)); + VERIFY(( internal::is_same::type >::value)); + VERIFY(( internal::is_same::type >::value)); + VERIFY(( internal::is_same::type >::value)); + + + // is_convertible + STATIC_CHECK(( internal::is_convertible::value )); + STATIC_CHECK(( internal::is_convertible::value )); + STATIC_CHECK(( internal::is_convertible::value )); + STATIC_CHECK(( internal::is_convertible::value )); + STATIC_CHECK(( internal::is_convertible::value )); + STATIC_CHECK(( internal::is_convertible >::value )); + STATIC_CHECK((!internal::is_convertible,double>::value )); + STATIC_CHECK(( internal::is_convertible::value )); + STATIC_CHECK(( internal::is_convertible::value )); + STATIC_CHECK(( internal::is_convertible::value )); + STATIC_CHECK(( internal::is_convertible::value )); + STATIC_CHECK(( internal::is_convertible::value )); + STATIC_CHECK(( internal::is_convertible::value )); + STATIC_CHECK((!internal::is_convertible::value )); + STATIC_CHECK((!internal::is_convertible::value )); + STATIC_CHECK(!( internal::is_convertible::value )); + + STATIC_CHECK(!( internal::is_convertible::value )); + STATIC_CHECK(( internal::is_convertible::value )); + + //STATIC_CHECK((!internal::is_convertible::value )); //does not even compile because the conversion is prevented by a static assertion + STATIC_CHECK((!internal::is_convertible::value )); + STATIC_CHECK((!internal::is_convertible::value )); + { + float f = 0.0f; + MatrixXf A, B; + VectorXf a, b; + VERIFY(( check_is_convertible(a.dot(b), f) )); + VERIFY(( check_is_convertible(a.transpose()*b, f) )); + VERIFY((!check_is_convertible(A*B, f) )); + VERIFY(( check_is_convertible(A*B, A) )); + } + + { + int i = 0; + VERIFY(( check_is_convertible(fix<3>(), i) )); + VERIFY((!check_is_convertible(i, fix()) )); + } + + + VERIFY(( internal::has_ReturnType::value )); + VERIFY(( internal::has_ReturnType >::value )); + VERIFY(( !internal::has_ReturnType::value )); + VERIFY(( !internal::has_ReturnType::value )); + + VERIFY(internal::meta_sqrt<1>::ret == 1); + #define VERIFY_META_SQRT(X) VERIFY(internal::meta_sqrt::ret == int(std::sqrt(double(X)))) + VERIFY_META_SQRT(2); + VERIFY_META_SQRT(3); + VERIFY_META_SQRT(4); + VERIFY_META_SQRT(5); + VERIFY_META_SQRT(6); + VERIFY_META_SQRT(8); + VERIFY_META_SQRT(9); + VERIFY_META_SQRT(15); + VERIFY_META_SQRT(16); + VERIFY_META_SQRT(17); + VERIFY_META_SQRT(255); + VERIFY_META_SQRT(256); + VERIFY_META_SQRT(257); + VERIFY_META_SQRT(1023); + VERIFY_META_SQRT(1024); + VERIFY_META_SQRT(1025); +} diff --git a/include/eigen/test/metis_support.cpp b/include/eigen/test/metis_support.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b490dacde9839aaf51d67ceaa6e846d745db52db --- /dev/null +++ b/include/eigen/test/metis_support.cpp @@ -0,0 +1,25 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2012 Désiré Nuentsa-Wakam +// +// 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/. + +#include "sparse_solver.h" +#include +#include +#include + +template void test_metis_T() +{ + SparseLU, MetisOrdering > sparselu_metis; + + check_sparse_square_solving(sparselu_metis); +} + +EIGEN_DECLARE_TEST(metis_support) +{ + CALL_SUBTEST_1(test_metis_T()); +} diff --git a/include/eigen/test/miscmatrices.cpp b/include/eigen/test/miscmatrices.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e71712f33290ae1c716d198e53b922530f3fcf10 --- /dev/null +++ b/include/eigen/test/miscmatrices.cpp @@ -0,0 +1,46 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2006-2008 Benoit Jacob +// +// 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/. + +#include "main.h" + +template void miscMatrices(const MatrixType& m) +{ + /* this test covers the following files: + DiagonalMatrix.h Ones.h + */ + typedef typename MatrixType::Scalar Scalar; + typedef Matrix VectorType; + Index rows = m.rows(); + Index cols = m.cols(); + + Index r = internal::random(0, rows-1), r2 = internal::random(0, rows-1), c = internal::random(0, cols-1); + VERIFY_IS_APPROX(MatrixType::Ones(rows,cols)(r,c), static_cast(1)); + MatrixType m1 = MatrixType::Ones(rows,cols); + VERIFY_IS_APPROX(m1(r,c), static_cast(1)); + VectorType v1 = VectorType::Random(rows); + v1[0]; + Matrix + square(v1.asDiagonal()); + if(r==r2) VERIFY_IS_APPROX(square(r,r2), v1[r]); + else VERIFY_IS_MUCH_SMALLER_THAN(square(r,r2), static_cast(1)); + square = MatrixType::Zero(rows, rows); + square.diagonal() = VectorType::Ones(rows); + VERIFY_IS_APPROX(square, MatrixType::Identity(rows, rows)); +} + +EIGEN_DECLARE_TEST(miscmatrices) +{ + for(int i = 0; i < g_repeat; i++) { + CALL_SUBTEST_1( miscMatrices(Matrix()) ); + CALL_SUBTEST_2( miscMatrices(Matrix4d()) ); + CALL_SUBTEST_3( miscMatrices(MatrixXcf(3, 3)) ); + CALL_SUBTEST_4( miscMatrices(MatrixXi(8, 12)) ); + CALL_SUBTEST_5( miscMatrices(MatrixXcd(20, 20)) ); + } +} diff --git a/include/eigen/test/mixingtypes.cpp b/include/eigen/test/mixingtypes.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2af7b888747598d546615e2d92de8ff3a8deb937 --- /dev/null +++ b/include/eigen/test/mixingtypes.cpp @@ -0,0 +1,330 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2008-2015 Gael Guennebaud +// Copyright (C) 2008 Benoit Jacob +// +// 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/. + +#if defined(EIGEN_TEST_PART_7) + +#ifndef EIGEN_NO_STATIC_ASSERT +#define EIGEN_NO_STATIC_ASSERT // turn static asserts into runtime asserts in order to check them +#endif + +// ignore double-promotion diagnostic for clang and gcc, if we check for static assertion anyway: +// TODO do the same for MSVC? +#if defined(__clang__) +# if (__clang_major__ * 100 + __clang_minor__) >= 308 +# pragma clang diagnostic ignored "-Wdouble-promotion" +# endif +#elif defined(__GNUC__) + // TODO is there a minimal GCC version for this? At least g++-4.7 seems to be fine with this. +# pragma GCC diagnostic ignored "-Wdouble-promotion" +#endif + +#endif + + + +#if defined(EIGEN_TEST_PART_1) || defined(EIGEN_TEST_PART_2) || defined(EIGEN_TEST_PART_3) + +#ifndef EIGEN_DONT_VECTORIZE +#define EIGEN_DONT_VECTORIZE +#endif + +#endif + +static bool g_called; +#define EIGEN_SCALAR_BINARY_OP_PLUGIN { g_called |= (!internal::is_same::value); } + +#include "main.h" + +using namespace std; + +#define VERIFY_MIX_SCALAR(XPR,REF) \ + g_called = false; \ + VERIFY_IS_APPROX(XPR,REF); \ + VERIFY( g_called && #XPR" not properly optimized"); + +template +void raise_assertion(Index size = SizeAtCompileType) +{ + // VERIFY_RAISES_ASSERT(mf+md); // does not even compile + Matrix vf; vf.setRandom(size); + Matrix vd; vd.setRandom(size); + VERIFY_RAISES_ASSERT(vf=vd); + VERIFY_RAISES_ASSERT(vf+=vd); + VERIFY_RAISES_ASSERT(vf-=vd); + VERIFY_RAISES_ASSERT(vd=vf); + VERIFY_RAISES_ASSERT(vd+=vf); + VERIFY_RAISES_ASSERT(vd-=vf); + + // vd.asDiagonal() * mf; // does not even compile + // vcd.asDiagonal() * mf; // does not even compile + +#if 0 // we get other compilation errors here than just static asserts + VERIFY_RAISES_ASSERT(vd.dot(vf)); +#endif +} + + +template void mixingtypes(int size = SizeAtCompileType) +{ + typedef std::complex CF; + typedef std::complex CD; + typedef Matrix Mat_f; + typedef Matrix Mat_d; + typedef Matrix, SizeAtCompileType, SizeAtCompileType> Mat_cf; + typedef Matrix, SizeAtCompileType, SizeAtCompileType> Mat_cd; + typedef Matrix Vec_f; + typedef Matrix Vec_d; + typedef Matrix, SizeAtCompileType, 1> Vec_cf; + typedef Matrix, SizeAtCompileType, 1> Vec_cd; + + Mat_f mf = Mat_f::Random(size,size); + Mat_d md = mf.template cast(); + //Mat_d rd = md; + Mat_cf mcf = Mat_cf::Random(size,size); + Mat_cd mcd = mcf.template cast >(); + Mat_cd rcd = mcd; + Vec_f vf = Vec_f::Random(size,1); + Vec_d vd = vf.template cast(); + Vec_cf vcf = Vec_cf::Random(size,1); + Vec_cd vcd = vcf.template cast >(); + float sf = internal::random(); + double sd = internal::random(); + complex scf = internal::random >(); + complex scd = internal::random >(); + + mf+mf; + + float epsf = std::sqrt(std::numeric_limits ::min EIGEN_EMPTY ()); + double epsd = std::sqrt(std::numeric_limits::min EIGEN_EMPTY ()); + + while(std::abs(sf )(); + while(std::abs(sd )(); + while(std::abs(scf)(); + while(std::abs(scd)(); + + // check scalar products + VERIFY_MIX_SCALAR(vcf * sf , vcf * complex(sf)); + VERIFY_MIX_SCALAR(sd * vcd , complex(sd) * vcd); + VERIFY_MIX_SCALAR(vf * scf , vf.template cast >() * scf); + VERIFY_MIX_SCALAR(scd * vd , scd * vd.template cast >()); + + VERIFY_MIX_SCALAR(vcf * 2 , vcf * complex(2)); + VERIFY_MIX_SCALAR(vcf * 2.1 , vcf * complex(2.1)); + VERIFY_MIX_SCALAR(2 * vcf, vcf * complex(2)); + VERIFY_MIX_SCALAR(2.1 * vcf , vcf * complex(2.1)); + + // check scalar quotients + VERIFY_MIX_SCALAR(vcf / sf , vcf / complex(sf)); + VERIFY_MIX_SCALAR(vf / scf , vf.template cast >() / scf); + VERIFY_MIX_SCALAR(vf.array() / scf, vf.template cast >().array() / scf); + VERIFY_MIX_SCALAR(scd / vd.array() , scd / vd.template cast >().array()); + + // check scalar increment + VERIFY_MIX_SCALAR(vcf.array() + sf , vcf.array() + complex(sf)); + VERIFY_MIX_SCALAR(sd + vcd.array(), complex(sd) + vcd.array()); + VERIFY_MIX_SCALAR(vf.array() + scf, vf.template cast >().array() + scf); + VERIFY_MIX_SCALAR(scd + vd.array() , scd + vd.template cast >().array()); + + // check scalar subtractions + VERIFY_MIX_SCALAR(vcf.array() - sf , vcf.array() - complex(sf)); + VERIFY_MIX_SCALAR(sd - vcd.array(), complex(sd) - vcd.array()); + VERIFY_MIX_SCALAR(vf.array() - scf, vf.template cast >().array() - scf); + VERIFY_MIX_SCALAR(scd - vd.array() , scd - vd.template cast >().array()); + + // check scalar powers + // NOTE: scalar exponents use a unary op. + VERIFY_IS_APPROX( pow(vcf.array(), sf), Eigen::pow(vcf.array(), complex(sf)) ); + VERIFY_IS_APPROX( vcf.array().pow(sf) , Eigen::pow(vcf.array(), complex(sf)) ); + VERIFY_MIX_SCALAR( pow(sd, vcd.array()), Eigen::pow(complex(sd), vcd.array()) ); + VERIFY_IS_APPROX( Eigen::pow(vf.array(), scf), Eigen::pow(vf.template cast >().array(), scf) ); + VERIFY_IS_APPROX( vf.array().pow(scf) , Eigen::pow(vf.template cast >().array(), scf) ); + VERIFY_MIX_SCALAR( Eigen::pow(scd, vd.array()), Eigen::pow(scd, vd.template cast >().array()) ); + + // check dot product + vf.dot(vf); + VERIFY_IS_APPROX(vcf.dot(vf), vcf.dot(vf.template cast >())); + + // check diagonal product + VERIFY_IS_APPROX(vf.asDiagonal() * mcf, vf.template cast >().asDiagonal() * mcf); + VERIFY_IS_APPROX(vcd.asDiagonal() * md, vcd.asDiagonal() * md.template cast >()); + VERIFY_IS_APPROX(mcf * vf.asDiagonal(), mcf * vf.template cast >().asDiagonal()); + VERIFY_IS_APPROX(md * vcd.asDiagonal(), md.template cast >() * vcd.asDiagonal()); + + // check inner product + VERIFY_IS_APPROX((vf.transpose() * vcf).value(), (vf.template cast >().transpose() * vcf).value()); + + // check outer product + VERIFY_IS_APPROX((vf * vcf.transpose()).eval(), (vf.template cast >() * vcf.transpose()).eval()); + + // coeff wise product + + VERIFY_IS_APPROX((vf * vcf.transpose()).eval(), (vf.template cast >() * vcf.transpose()).eval()); + + Mat_cd mcd2 = mcd; + VERIFY_IS_APPROX(mcd.array() *= md.array(), mcd2.array() *= md.array().template cast >()); + + // check matrix-matrix products + VERIFY_IS_APPROX(sd*md*mcd, (sd*md).template cast().eval()*mcd); + VERIFY_IS_APPROX(sd*mcd*md, sd*mcd*md.template cast()); + VERIFY_IS_APPROX(scd*md*mcd, scd*md.template cast().eval()*mcd); + VERIFY_IS_APPROX(scd*mcd*md, scd*mcd*md.template cast()); + + VERIFY_IS_APPROX(sf*mf*mcf, sf*mf.template cast()*mcf); + VERIFY_IS_APPROX(sf*mcf*mf, sf*mcf*mf.template cast()); + VERIFY_IS_APPROX(scf*mf*mcf, scf*mf.template cast()*mcf); + VERIFY_IS_APPROX(scf*mcf*mf, scf*mcf*mf.template cast()); + + VERIFY_IS_APPROX(sd*md.adjoint()*mcd, (sd*md).template cast().eval().adjoint()*mcd); + VERIFY_IS_APPROX(sd*mcd.adjoint()*md, sd*mcd.adjoint()*md.template cast()); + VERIFY_IS_APPROX(sd*md.adjoint()*mcd.adjoint(), (sd*md).template cast().eval().adjoint()*mcd.adjoint()); + VERIFY_IS_APPROX(sd*mcd.adjoint()*md.adjoint(), sd*mcd.adjoint()*md.template cast().adjoint()); + VERIFY_IS_APPROX(sd*md*mcd.adjoint(), (sd*md).template cast().eval()*mcd.adjoint()); + VERIFY_IS_APPROX(sd*mcd*md.adjoint(), sd*mcd*md.template cast().adjoint()); + + VERIFY_IS_APPROX(sf*mf.adjoint()*mcf, (sf*mf).template cast().eval().adjoint()*mcf); + VERIFY_IS_APPROX(sf*mcf.adjoint()*mf, sf*mcf.adjoint()*mf.template cast()); + VERIFY_IS_APPROX(sf*mf.adjoint()*mcf.adjoint(), (sf*mf).template cast().eval().adjoint()*mcf.adjoint()); + VERIFY_IS_APPROX(sf*mcf.adjoint()*mf.adjoint(), sf*mcf.adjoint()*mf.template cast().adjoint()); + VERIFY_IS_APPROX(sf*mf*mcf.adjoint(), (sf*mf).template cast().eval()*mcf.adjoint()); + VERIFY_IS_APPROX(sf*mcf*mf.adjoint(), sf*mcf*mf.template cast().adjoint()); + + VERIFY_IS_APPROX(sf*mf*vcf, (sf*mf).template cast().eval()*vcf); + VERIFY_IS_APPROX(scf*mf*vcf,(scf*mf.template cast()).eval()*vcf); + VERIFY_IS_APPROX(sf*mcf*vf, sf*mcf*vf.template cast()); + VERIFY_IS_APPROX(scf*mcf*vf,scf*mcf*vf.template cast()); + + VERIFY_IS_APPROX(sf*vcf.adjoint()*mf, sf*vcf.adjoint()*mf.template cast().eval()); + VERIFY_IS_APPROX(scf*vcf.adjoint()*mf, scf*vcf.adjoint()*mf.template cast().eval()); + VERIFY_IS_APPROX(sf*vf.adjoint()*mcf, sf*vf.adjoint().template cast().eval()*mcf); + VERIFY_IS_APPROX(scf*vf.adjoint()*mcf, scf*vf.adjoint().template cast().eval()*mcf); + + VERIFY_IS_APPROX(sd*md*vcd, (sd*md).template cast().eval()*vcd); + VERIFY_IS_APPROX(scd*md*vcd,(scd*md.template cast()).eval()*vcd); + VERIFY_IS_APPROX(sd*mcd*vd, sd*mcd*vd.template cast().eval()); + VERIFY_IS_APPROX(scd*mcd*vd,scd*mcd*vd.template cast().eval()); + + VERIFY_IS_APPROX(sd*vcd.adjoint()*md, sd*vcd.adjoint()*md.template cast().eval()); + VERIFY_IS_APPROX(scd*vcd.adjoint()*md, scd*vcd.adjoint()*md.template cast().eval()); + VERIFY_IS_APPROX(sd*vd.adjoint()*mcd, sd*vd.adjoint().template cast().eval()*mcd); + VERIFY_IS_APPROX(scd*vd.adjoint()*mcd, scd*vd.adjoint().template cast().eval()*mcd); + + VERIFY_IS_APPROX( sd*vcd.adjoint()*md.template triangularView(), sd*vcd.adjoint()*md.template cast().eval().template triangularView()); + VERIFY_IS_APPROX(scd*vcd.adjoint()*md.template triangularView(), scd*vcd.adjoint()*md.template cast().eval().template triangularView()); + VERIFY_IS_APPROX( sd*vcd.adjoint()*md.transpose().template triangularView(), sd*vcd.adjoint()*md.transpose().template cast().eval().template triangularView()); + VERIFY_IS_APPROX(scd*vcd.adjoint()*md.transpose().template triangularView(), scd*vcd.adjoint()*md.transpose().template cast().eval().template triangularView()); + VERIFY_IS_APPROX( sd*vd.adjoint()*mcd.template triangularView(), sd*vd.adjoint().template cast().eval()*mcd.template triangularView()); + VERIFY_IS_APPROX(scd*vd.adjoint()*mcd.template triangularView(), scd*vd.adjoint().template cast().eval()*mcd.template triangularView()); + VERIFY_IS_APPROX( sd*vd.adjoint()*mcd.transpose().template triangularView(), sd*vd.adjoint().template cast().eval()*mcd.transpose().template triangularView()); + VERIFY_IS_APPROX(scd*vd.adjoint()*mcd.transpose().template triangularView(), scd*vd.adjoint().template cast().eval()*mcd.transpose().template triangularView()); + + // Not supported yet: trmm +// VERIFY_IS_APPROX(sd*mcd*md.template triangularView(), sd*mcd*md.template cast().eval().template triangularView()); +// VERIFY_IS_APPROX(scd*mcd*md.template triangularView(), scd*mcd*md.template cast().eval().template triangularView()); +// VERIFY_IS_APPROX(sd*md*mcd.template triangularView(), sd*md.template cast().eval()*mcd.template triangularView()); +// VERIFY_IS_APPROX(scd*md*mcd.template triangularView(), scd*md.template cast().eval()*mcd.template triangularView()); + + // Not supported yet: symv +// VERIFY_IS_APPROX(sd*vcd.adjoint()*md.template selfadjointView(), sd*vcd.adjoint()*md.template cast().eval().template selfadjointView()); +// VERIFY_IS_APPROX(scd*vcd.adjoint()*md.template selfadjointView(), scd*vcd.adjoint()*md.template cast().eval().template selfadjointView()); +// VERIFY_IS_APPROX(sd*vd.adjoint()*mcd.template selfadjointView(), sd*vd.adjoint().template cast().eval()*mcd.template selfadjointView()); +// VERIFY_IS_APPROX(scd*vd.adjoint()*mcd.template selfadjointView(), scd*vd.adjoint().template cast().eval()*mcd.template selfadjointView()); + + // Not supported yet: symm +// VERIFY_IS_APPROX(sd*vcd.adjoint()*md.template selfadjointView(), sd*vcd.adjoint()*md.template cast().eval().template selfadjointView()); +// VERIFY_IS_APPROX(scd*vcd.adjoint()*md.template selfadjointView(), scd*vcd.adjoint()*md.template cast().eval().template selfadjointView()); +// VERIFY_IS_APPROX(sd*vd.adjoint()*mcd.template selfadjointView(), sd*vd.adjoint().template cast().eval()*mcd.template selfadjointView()); +// VERIFY_IS_APPROX(scd*vd.adjoint()*mcd.template selfadjointView(), scd*vd.adjoint().template cast().eval()*mcd.template selfadjointView()); + + rcd.setZero(); + VERIFY_IS_APPROX(Mat_cd(rcd.template triangularView() = sd * mcd * md), + Mat_cd((sd * mcd * md.template cast().eval()).template triangularView())); + VERIFY_IS_APPROX(Mat_cd(rcd.template triangularView() = sd * md * mcd), + Mat_cd((sd * md.template cast().eval() * mcd).template triangularView())); + VERIFY_IS_APPROX(Mat_cd(rcd.template triangularView() = scd * mcd * md), + Mat_cd((scd * mcd * md.template cast().eval()).template triangularView())); + VERIFY_IS_APPROX(Mat_cd(rcd.template triangularView() = scd * md * mcd), + Mat_cd((scd * md.template cast().eval() * mcd).template triangularView())); + + + VERIFY_IS_APPROX( md.array() * mcd.array(), md.template cast().eval().array() * mcd.array() ); + VERIFY_IS_APPROX( mcd.array() * md.array(), mcd.array() * md.template cast().eval().array() ); + + VERIFY_IS_APPROX( md.array() + mcd.array(), md.template cast().eval().array() + mcd.array() ); + VERIFY_IS_APPROX( mcd.array() + md.array(), mcd.array() + md.template cast().eval().array() ); + + VERIFY_IS_APPROX( md.array() - mcd.array(), md.template cast().eval().array() - mcd.array() ); + VERIFY_IS_APPROX( mcd.array() - md.array(), mcd.array() - md.template cast().eval().array() ); + + if(mcd.array().abs().minCoeff()>epsd) + { + VERIFY_IS_APPROX( md.array() / mcd.array(), md.template cast().eval().array() / mcd.array() ); + } + if(md.array().abs().minCoeff()>epsd) + { + VERIFY_IS_APPROX( mcd.array() / md.array(), mcd.array() / md.template cast().eval().array() ); + } + + if(md.array().abs().minCoeff()>epsd || mcd.array().abs().minCoeff()>epsd) + { + VERIFY_IS_APPROX( md.array().pow(mcd.array()), md.template cast().eval().array().pow(mcd.array()) ); + VERIFY_IS_APPROX( mcd.array().pow(md.array()), mcd.array().pow(md.template cast().eval().array()) ); + + VERIFY_IS_APPROX( pow(md.array(),mcd.array()), md.template cast().eval().array().pow(mcd.array()) ); + VERIFY_IS_APPROX( pow(mcd.array(),md.array()), mcd.array().pow(md.template cast().eval().array()) ); + } + + rcd = mcd; + VERIFY_IS_APPROX( rcd = md, md.template cast().eval() ); + rcd = mcd; + VERIFY_IS_APPROX( rcd += md, mcd + md.template cast().eval() ); + rcd = mcd; + VERIFY_IS_APPROX( rcd -= md, mcd - md.template cast().eval() ); + rcd = mcd; + VERIFY_IS_APPROX( rcd.array() *= md.array(), mcd.array() * md.template cast().eval().array() ); + rcd = mcd; + if(md.array().abs().minCoeff()>epsd) + { + VERIFY_IS_APPROX( rcd.array() /= md.array(), mcd.array() / md.template cast().eval().array() ); + } + + rcd = mcd; + VERIFY_IS_APPROX( rcd.noalias() += md + mcd*md, mcd + (md.template cast().eval()) + mcd*(md.template cast().eval())); + + VERIFY_IS_APPROX( rcd.noalias() = md*md, ((md*md).eval().template cast()) ); + rcd = mcd; + VERIFY_IS_APPROX( rcd.noalias() += md*md, mcd + ((md*md).eval().template cast()) ); + rcd = mcd; + VERIFY_IS_APPROX( rcd.noalias() -= md*md, mcd - ((md*md).eval().template cast()) ); + + VERIFY_IS_APPROX( rcd.noalias() = mcd + md*md, mcd + ((md*md).eval().template cast()) ); + rcd = mcd; + VERIFY_IS_APPROX( rcd.noalias() += mcd + md*md, mcd + mcd + ((md*md).eval().template cast()) ); + rcd = mcd; + VERIFY_IS_APPROX( rcd.noalias() -= mcd + md*md, - ((md*md).eval().template cast()) ); +} + +EIGEN_DECLARE_TEST(mixingtypes) +{ + g_called = false; // Silence -Wunneeded-internal-declaration. + for(int i = 0; i < g_repeat; i++) { + CALL_SUBTEST_1(mixingtypes<3>()); + CALL_SUBTEST_2(mixingtypes<4>()); + CALL_SUBTEST_3(mixingtypes(internal::random(1,EIGEN_TEST_MAX_SIZE))); + + CALL_SUBTEST_4(mixingtypes<3>()); + CALL_SUBTEST_5(mixingtypes<4>()); + CALL_SUBTEST_6(mixingtypes(internal::random(1,EIGEN_TEST_MAX_SIZE))); + CALL_SUBTEST_7(raise_assertion(internal::random(1,EIGEN_TEST_MAX_SIZE))); + } + CALL_SUBTEST_7(raise_assertion<0>()); + CALL_SUBTEST_7(raise_assertion<3>()); + CALL_SUBTEST_7(raise_assertion<4>()); + CALL_SUBTEST_7(raise_assertion(0)); +} diff --git a/include/eigen/test/mpl2only.cpp b/include/eigen/test/mpl2only.cpp new file mode 100644 index 0000000000000000000000000000000000000000..296350d082fdf7d3e989ae56afe0d01c54786a11 --- /dev/null +++ b/include/eigen/test/mpl2only.cpp @@ -0,0 +1,24 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2015 Gael Guennebaud +// +// 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/. + +#ifndef EIGEN_MPL2_ONLY +#define EIGEN_MPL2_ONLY +#endif +#include +#include +#include +#include +#include +#include +#include + +int main() +{ + return 0; +} diff --git a/include/eigen/test/nestbyvalue.cpp b/include/eigen/test/nestbyvalue.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3a86bea5057e7da82d7a9e79ed780b8ebbfd44a0 --- /dev/null +++ b/include/eigen/test/nestbyvalue.cpp @@ -0,0 +1,37 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2019 Gael Guennebaud +// +// 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/. + +#define TEST_ENABLE_TEMPORARY_TRACKING + +#include "main.h" + +typedef NestByValue CpyMatrixXd; +typedef CwiseBinaryOp,const CpyMatrixXd,const CpyMatrixXd> XprType; + +XprType get_xpr_with_temps(const MatrixXd& a) +{ + MatrixXd t1 = a.rowwise().reverse(); + MatrixXd t2 = a+a; + return t1.nestByValue() + t2.nestByValue(); +} + +EIGEN_DECLARE_TEST(nestbyvalue) +{ + for(int i = 0; i < g_repeat; i++) { + Index rows = internal::random(1,EIGEN_TEST_MAX_SIZE); + Index cols = internal::random(1,EIGEN_TEST_MAX_SIZE); + MatrixXd a = MatrixXd::Random(rows,cols); + nb_temporaries = 0; + XprType x = get_xpr_with_temps(a); + VERIFY_IS_EQUAL(nb_temporaries,6); + MatrixXd b = x; + VERIFY_IS_EQUAL(nb_temporaries,6+1); + VERIFY_IS_APPROX(b, a.rowwise().reverse().eval() + (a+a).eval()); + } +} diff --git a/include/eigen/test/packetmath.cpp b/include/eigen/test/packetmath.cpp new file mode 100644 index 0000000000000000000000000000000000000000..09dbccedb35a2fd7fdc89820e4a160329bb92f78 --- /dev/null +++ b/include/eigen/test/packetmath.cpp @@ -0,0 +1,1404 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2008-2009 Gael Guennebaud +// Copyright (C) 2006-2008 Benoit Jacob +// +// 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/. + +#include "packetmath_test_shared.h" +#include "random_without_cast_overflow.h" + +template +inline T REF_ADD(const T& a, const T& b) { + return a + b; +} +template +inline T REF_SUB(const T& a, const T& b) { + return a - b; +} +template +inline T REF_MUL(const T& a, const T& b) { + return a * b; +} +template +inline T REF_DIV(const T& a, const T& b) { + return a / b; +} +template +inline T REF_ABS_DIFF(const T& a, const T& b) { + return a > b ? a - b : b - a; +} + +// Specializations for bool. +template <> +inline bool REF_ADD(const bool& a, const bool& b) { + return a || b; +} +template <> +inline bool REF_SUB(const bool& a, const bool& b) { + return a ^ b; +} +template <> +inline bool REF_MUL(const bool& a, const bool& b) { + return a && b; +} + +template +inline T REF_FREXP(const T& x, T& exp) { + int iexp; + EIGEN_USING_STD(frexp) + const T out = static_cast(frexp(x, &iexp)); + exp = static_cast(iexp); + + // The exponent value is unspecified if the input is inf or NaN, but MSVC + // seems to set it to 1. We need to set it back to zero for consistency. + if (!(numext::isfinite)(x)) { + exp = T(0); + } + return out; +} + +template +inline T REF_LDEXP(const T& x, const T& exp) { + EIGEN_USING_STD(ldexp) + return static_cast(ldexp(x, static_cast(exp))); +} + +// Uses pcast to cast from one array to another. +template +struct pcast_array; + +template +struct pcast_array { + typedef typename internal::unpacket_traits::type SrcScalar; + typedef typename internal::unpacket_traits::type TgtScalar; + static void cast(const SrcScalar* src, size_t size, TgtScalar* dst) { + static const int SrcPacketSize = internal::unpacket_traits::size; + static const int TgtPacketSize = internal::unpacket_traits::size; + size_t i; + for (i = 0; i < size && i + SrcPacketSize <= size; i += TgtPacketSize) { + internal::pstoreu(dst + i, internal::pcast(internal::ploadu(src + i))); + } + // Leftovers that cannot be loaded into a packet. + for (; i < size; ++i) { + dst[i] = static_cast(src[i]); + } + } +}; + +template +struct pcast_array { + static void cast(const typename internal::unpacket_traits::type* src, size_t size, + typename internal::unpacket_traits::type* dst) { + static const int SrcPacketSize = internal::unpacket_traits::size; + static const int TgtPacketSize = internal::unpacket_traits::size; + for (size_t i = 0; i < size; i += TgtPacketSize) { + SrcPacket a = internal::ploadu(src + i); + SrcPacket b = internal::ploadu(src + i + SrcPacketSize); + internal::pstoreu(dst + i, internal::pcast(a, b)); + } + } +}; + +template +struct pcast_array { + static void cast(const typename internal::unpacket_traits::type* src, size_t size, + typename internal::unpacket_traits::type* dst) { + static const int SrcPacketSize = internal::unpacket_traits::size; + static const int TgtPacketSize = internal::unpacket_traits::size; + for (size_t i = 0; i < size; i += TgtPacketSize) { + SrcPacket a = internal::ploadu(src + i); + SrcPacket b = internal::ploadu(src + i + SrcPacketSize); + SrcPacket c = internal::ploadu(src + i + 2 * SrcPacketSize); + SrcPacket d = internal::ploadu(src + i + 3 * SrcPacketSize); + internal::pstoreu(dst + i, internal::pcast(a, b, c, d)); + } + } +}; + +template +struct pcast_array { + static void cast(const typename internal::unpacket_traits::type* src, size_t size, + typename internal::unpacket_traits::type* dst) { + static const int SrcPacketSize = internal::unpacket_traits::size; + static const int TgtPacketSize = internal::unpacket_traits::size; + for (size_t i = 0; i < size; i += TgtPacketSize) { + SrcPacket a = internal::ploadu(src + i); + SrcPacket b = internal::ploadu(src + i + SrcPacketSize); + SrcPacket c = internal::ploadu(src + i + 2 * SrcPacketSize); + SrcPacket d = internal::ploadu(src + i + 3 * SrcPacketSize); + SrcPacket e = internal::ploadu(src + i + 4 * SrcPacketSize); + SrcPacket f = internal::ploadu(src + i + 5 * SrcPacketSize); + SrcPacket g = internal::ploadu(src + i + 6 * SrcPacketSize); + SrcPacket h = internal::ploadu(src + i + 7 * SrcPacketSize); + internal::pstoreu(dst + i, internal::pcast(a, b, c, d, e, f, g, h)); + } + } +}; + +template +struct test_cast_helper; + +template +struct test_cast_helper { + static void run() {} +}; + +template +struct test_cast_helper { + static void run() { + typedef typename internal::unpacket_traits::type SrcScalar; + typedef typename internal::unpacket_traits::type TgtScalar; + static const int SrcPacketSize = internal::unpacket_traits::size; + static const int TgtPacketSize = internal::unpacket_traits::size; + static const int BlockSize = SrcPacketSize * SrcCoeffRatio; + eigen_assert(BlockSize == TgtPacketSize * TgtCoeffRatio && "Packet sizes and cast ratios are mismatched."); + + static const int DataSize = 10 * BlockSize; + EIGEN_ALIGN_MAX SrcScalar data1[DataSize]; + EIGEN_ALIGN_MAX TgtScalar data2[DataSize]; + EIGEN_ALIGN_MAX TgtScalar ref[DataSize]; + + // Construct a packet of scalars that will not overflow when casting + for (int i = 0; i < DataSize; ++i) { + data1[i] = internal::random_without_cast_overflow::value(); + } + + for (int i = 0; i < DataSize; ++i) { + ref[i] = static_cast(data1[i]); + } + + pcast_array::cast(data1, DataSize, data2); + + VERIFY(test::areApprox(ref, data2, DataSize) && "internal::pcast<>"); + } +}; + +template +struct test_cast { + static void run() { + typedef typename internal::unpacket_traits::type SrcScalar; + typedef typename internal::unpacket_traits::type TgtScalar; + typedef typename internal::type_casting_traits TypeCastingTraits; + static const int SrcCoeffRatio = TypeCastingTraits::SrcCoeffRatio; + static const int TgtCoeffRatio = TypeCastingTraits::TgtCoeffRatio; + static const int SrcPacketSize = internal::unpacket_traits::size; + static const int TgtPacketSize = internal::unpacket_traits::size; + static const bool HasCast = + internal::unpacket_traits::vectorizable && internal::unpacket_traits::vectorizable && + TypeCastingTraits::VectorizedCast && (SrcPacketSize * SrcCoeffRatio == TgtPacketSize * TgtCoeffRatio); + test_cast_helper::run(); + } +}; + +template ::type, + bool Vectorized = internal::packet_traits::Vectorizable, + bool HasHalf = !internal::is_same::half, TgtPacket>::value> +struct test_cast_runner; + +template +struct test_cast_runner { + static void run() { test_cast::run(); } +}; + +template +struct test_cast_runner { + static void run() { + test_cast::run(); + test_cast_runner::half>::run(); + } +}; + +template +struct test_cast_runner { + static void run() {} +}; + +template +struct packetmath_pcast_ops_runner { + static void run() { + test_cast_runner::run(); + test_cast_runner::run(); + test_cast_runner::run(); + test_cast_runner::run(); + test_cast_runner::run(); + test_cast_runner::run(); + test_cast_runner::run(); + test_cast_runner::run(); + test_cast_runner::run(); + test_cast_runner::run(); + test_cast_runner::run(); + test_cast_runner >::run(); + test_cast_runner >::run(); + test_cast_runner::run(); + test_cast_runner::run(); + } +}; + +// Only some types support cast from std::complex<>. +template +struct packetmath_pcast_ops_runner::IsComplex>::type> { + static void run() { + test_cast_runner >::run(); + test_cast_runner >::run(); + test_cast_runner::run(); + test_cast_runner::run(); + } +}; + +template +void packetmath_boolean_mask_ops() { + const int PacketSize = internal::unpacket_traits::size; + const int size = 2 * PacketSize; + EIGEN_ALIGN_MAX Scalar data1[size]; + EIGEN_ALIGN_MAX Scalar data2[size]; + EIGEN_ALIGN_MAX Scalar ref[size]; + + for (int i = 0; i < size; ++i) { + data1[i] = internal::random(); + } + CHECK_CWISE1(internal::ptrue, internal::ptrue); + CHECK_CWISE2_IF(true, internal::pandnot, internal::pandnot); + for (int i = 0; i < PacketSize; ++i) { + data1[i] = Scalar(i); + data1[i + PacketSize] = internal::random() ? data1[i] : Scalar(0); + } + + CHECK_CWISE2_IF(true, internal::pcmp_eq, internal::pcmp_eq); + + //Test (-0) == (0) for signed operations + for (int i = 0; i < PacketSize; ++i) { + data1[i] = Scalar(-0.0); + data1[i + PacketSize] = internal::random() ? data1[i] : Scalar(0); + } + CHECK_CWISE2_IF(true, internal::pcmp_eq, internal::pcmp_eq); + + //Test NaN + for (int i = 0; i < PacketSize; ++i) { + data1[i] = NumTraits::quiet_NaN(); + data1[i + PacketSize] = internal::random() ? data1[i] : Scalar(0); + } + CHECK_CWISE2_IF(true, internal::pcmp_eq, internal::pcmp_eq); +} + +template +void packetmath_boolean_mask_ops_real() { + const int PacketSize = internal::unpacket_traits::size; + const int size = 2 * PacketSize; + EIGEN_ALIGN_MAX Scalar data1[size]; + EIGEN_ALIGN_MAX Scalar data2[size]; + EIGEN_ALIGN_MAX Scalar ref[size]; + + for (int i = 0; i < PacketSize; ++i) { + data1[i] = internal::random(); + data1[i + PacketSize] = internal::random() ? data1[i] : Scalar(0); + } + + CHECK_CWISE2_IF(true, internal::pcmp_lt_or_nan, internal::pcmp_lt_or_nan); + + //Test (-0) <=/< (0) for signed operations + for (int i = 0; i < PacketSize; ++i) { + data1[i] = Scalar(-0.0); + data1[i + PacketSize] = internal::random() ? data1[i] : Scalar(0); + } + CHECK_CWISE2_IF(true, internal::pcmp_lt_or_nan, internal::pcmp_lt_or_nan); + + //Test NaN + for (int i = 0; i < PacketSize; ++i) { + data1[i] = NumTraits::quiet_NaN(); + data1[i + PacketSize] = internal::random() ? data1[i] : Scalar(0); + } + CHECK_CWISE2_IF(true, internal::pcmp_lt_or_nan, internal::pcmp_lt_or_nan); +} + +template +void packetmath_boolean_mask_ops_notcomplex() { + const int PacketSize = internal::unpacket_traits::size; + const int size = 2 * PacketSize; + EIGEN_ALIGN_MAX Scalar data1[size]; + EIGEN_ALIGN_MAX Scalar data2[size]; + EIGEN_ALIGN_MAX Scalar ref[size]; + + for (int i = 0; i < PacketSize; ++i) { + data1[i] = internal::random(); + data1[i + PacketSize] = internal::random() ? data1[i] : Scalar(0); + } + + CHECK_CWISE2_IF(true, internal::pcmp_le, internal::pcmp_le); + CHECK_CWISE2_IF(true, internal::pcmp_lt, internal::pcmp_lt); + + //Test (-0) <=/< (0) for signed operations + for (int i = 0; i < PacketSize; ++i) { + data1[i] = Scalar(-0.0); + data1[i + PacketSize] = internal::random() ? data1[i] : Scalar(0); + } + CHECK_CWISE2_IF(true, internal::pcmp_le, internal::pcmp_le); + CHECK_CWISE2_IF(true, internal::pcmp_lt, internal::pcmp_lt); + + //Test NaN + for (int i = 0; i < PacketSize; ++i) { + data1[i] = NumTraits::quiet_NaN(); + data1[i + PacketSize] = internal::random() ? data1[i] : Scalar(0); + } + CHECK_CWISE2_IF(true, internal::pcmp_le, internal::pcmp_le); + CHECK_CWISE2_IF(true, internal::pcmp_lt, internal::pcmp_lt); +} + +// Packet16b representing bool does not support ptrue, pandnot or pcmp_eq, since the scalar path +// (for some compilers) compute the bitwise and with 0x1 of the results to keep the value in [0,1]. +template<> +void packetmath_boolean_mask_ops::type>() {} +template<> +void packetmath_boolean_mask_ops_notcomplex::type>() {} + +template +void packetmath_minus_zero_add() { + const int PacketSize = internal::unpacket_traits::size; + const int size = 2 * PacketSize; + EIGEN_ALIGN_MAX Scalar data1[size] = {}; + EIGEN_ALIGN_MAX Scalar data2[size] = {}; + EIGEN_ALIGN_MAX Scalar ref[size] = {}; + + for (int i = 0; i < PacketSize; ++i) { + data1[i] = Scalar(-0.0); + data1[i + PacketSize] = Scalar(-0.0); + } + CHECK_CWISE2_IF(internal::packet_traits::HasAdd, REF_ADD, internal::padd); +} + +// Ensure optimization barrier compiles and doesn't modify contents. +// Only applies to raw types, so will not work for std::complex, Eigen::half +// or Eigen::bfloat16. For those you would need to refer to an underlying +// storage element. +template +struct eigen_optimization_barrier_test { + static void run() {} +}; + +template +struct eigen_optimization_barrier_test::IsComplex && + !internal::is_same::value && + !internal::is_same::value + >::type> { + static void run() { + typedef typename internal::unpacket_traits::type Scalar; + Scalar s = internal::random(); + Packet barrier = internal::pset1(s); + EIGEN_OPTIMIZATION_BARRIER(barrier); + eigen_assert(s == internal::pfirst(barrier) && "EIGEN_OPTIMIZATION_BARRIER"); + } +}; + +template +void packetmath() { + typedef internal::packet_traits PacketTraits; + const int PacketSize = internal::unpacket_traits::size; + typedef typename NumTraits::Real RealScalar; + + if (g_first_pass) + std::cerr << "=== Testing packet of type '" << typeid(Packet).name() << "' and scalar type '" + << typeid(Scalar).name() << "' and size '" << PacketSize << "' ===\n"; + + const int max_size = PacketSize > 4 ? PacketSize : 4; + const int size = PacketSize * max_size; + EIGEN_ALIGN_MAX Scalar data1[size]; + EIGEN_ALIGN_MAX Scalar data2[size]; + EIGEN_ALIGN_MAX Scalar data3[size]; + EIGEN_ALIGN_MAX Scalar ref[size]; + RealScalar refvalue = RealScalar(0); + + eigen_optimization_barrier_test::run(); + eigen_optimization_barrier_test::run(); + + for (int i = 0; i < size; ++i) { + data1[i] = internal::random() / RealScalar(PacketSize); + data2[i] = internal::random() / RealScalar(PacketSize); + refvalue = (std::max)(refvalue, numext::abs(data1[i])); + } + + internal::pstore(data2, internal::pload(data1)); + VERIFY(test::areApprox(data1, data2, PacketSize) && "aligned load/store"); + + for (int offset = 0; offset < PacketSize; ++offset) { + internal::pstore(data2, internal::ploadu(data1 + offset)); + VERIFY(test::areApprox(data1 + offset, data2, PacketSize) && "internal::ploadu"); + } + + for (int offset = 0; offset < PacketSize; ++offset) { + internal::pstoreu(data2 + offset, internal::pload(data1)); + VERIFY(test::areApprox(data1, data2 + offset, PacketSize) && "internal::pstoreu"); + } + + if (internal::unpacket_traits::masked_load_available) { + test::packet_helper::masked_load_available, Packet> h; + unsigned long long max_umask = (0x1ull << PacketSize); + + for (int offset = 0; offset < PacketSize; ++offset) { + for (unsigned long long umask = 0; umask < max_umask; ++umask) { + h.store(data2, h.load(data1 + offset, umask)); + for (int k = 0; k < PacketSize; ++k) data3[k] = ((umask & (0x1ull << k)) >> k) ? data1[k + offset] : Scalar(0); + VERIFY(test::areApprox(data3, data2, PacketSize) && "internal::ploadu masked"); + } + } + } + + if (internal::unpacket_traits::masked_store_available) { + test::packet_helper::masked_store_available, Packet> h; + unsigned long long max_umask = (0x1ull << PacketSize); + + for (int offset = 0; offset < PacketSize; ++offset) { + for (unsigned long long umask = 0; umask < max_umask; ++umask) { + internal::pstore(data2, internal::pset1(Scalar(0))); + h.store(data2, h.loadu(data1 + offset), umask); + for (int k = 0; k < PacketSize; ++k) data3[k] = ((umask & (0x1ull << k)) >> k) ? data1[k + offset] : Scalar(0); + VERIFY(test::areApprox(data3, data2, PacketSize) && "internal::pstoreu masked"); + } + } + } + + VERIFY((!PacketTraits::Vectorizable) || PacketTraits::HasAdd); + VERIFY((!PacketTraits::Vectorizable) || PacketTraits::HasSub); + VERIFY((!PacketTraits::Vectorizable) || PacketTraits::HasMul); + + CHECK_CWISE2_IF(PacketTraits::HasAdd, REF_ADD, internal::padd); + CHECK_CWISE2_IF(PacketTraits::HasSub, REF_SUB, internal::psub); + CHECK_CWISE2_IF(PacketTraits::HasMul, REF_MUL, internal::pmul); + CHECK_CWISE2_IF(PacketTraits::HasDiv, REF_DIV, internal::pdiv); + + if (PacketTraits::HasNegate) CHECK_CWISE1(internal::negate, internal::pnegate); + CHECK_CWISE1(numext::conj, internal::pconj); + + for (int offset = 0; offset < 3; ++offset) { + for (int i = 0; i < PacketSize; ++i) ref[i] = data1[offset]; + internal::pstore(data2, internal::pset1(data1[offset])); + VERIFY(test::areApprox(ref, data2, PacketSize) && "internal::pset1"); + } + + { + for (int i = 0; i < PacketSize * 4; ++i) ref[i] = data1[i / PacketSize]; + Packet A0, A1, A2, A3; + internal::pbroadcast4(data1, A0, A1, A2, A3); + internal::pstore(data2 + 0 * PacketSize, A0); + internal::pstore(data2 + 1 * PacketSize, A1); + internal::pstore(data2 + 2 * PacketSize, A2); + internal::pstore(data2 + 3 * PacketSize, A3); + VERIFY(test::areApprox(ref, data2, 4 * PacketSize) && "internal::pbroadcast4"); + } + + { + for (int i = 0; i < PacketSize * 2; ++i) ref[i] = data1[i / PacketSize]; + Packet A0, A1; + internal::pbroadcast2(data1, A0, A1); + internal::pstore(data2 + 0 * PacketSize, A0); + internal::pstore(data2 + 1 * PacketSize, A1); + VERIFY(test::areApprox(ref, data2, 2 * PacketSize) && "internal::pbroadcast2"); + } + + VERIFY(internal::isApprox(data1[0], internal::pfirst(internal::pload(data1))) && "internal::pfirst"); + + if (PacketSize > 1) { + // apply different offsets to check that ploaddup is robust to unaligned inputs + for (int offset = 0; offset < 4; ++offset) { + for (int i = 0; i < PacketSize / 2; ++i) ref[2 * i + 0] = ref[2 * i + 1] = data1[offset + i]; + internal::pstore(data2, internal::ploaddup(data1 + offset)); + VERIFY(test::areApprox(ref, data2, PacketSize) && "ploaddup"); + } + } + + if (PacketSize > 2) { + // apply different offsets to check that ploadquad is robust to unaligned inputs + for (int offset = 0; offset < 4; ++offset) { + for (int i = 0; i < PacketSize / 4; ++i) + ref[4 * i + 0] = ref[4 * i + 1] = ref[4 * i + 2] = ref[4 * i + 3] = data1[offset + i]; + internal::pstore(data2, internal::ploadquad(data1 + offset)); + VERIFY(test::areApprox(ref, data2, PacketSize) && "ploadquad"); + } + } + + ref[0] = Scalar(0); + for (int i = 0; i < PacketSize; ++i) ref[0] += data1[i]; + VERIFY(test::isApproxAbs(ref[0], internal::predux(internal::pload(data1)), refvalue) && "internal::predux"); + + if (!internal::is_same::half>::value) { + int HalfPacketSize = PacketSize > 4 ? PacketSize / 2 : PacketSize; + for (int i = 0; i < HalfPacketSize; ++i) ref[i] = Scalar(0); + for (int i = 0; i < PacketSize; ++i) ref[i % HalfPacketSize] += data1[i]; + internal::pstore(data2, internal::predux_half_dowto4(internal::pload(data1))); + VERIFY(test::areApprox(ref, data2, HalfPacketSize) && "internal::predux_half_dowto4"); + } + + ref[0] = Scalar(1); + for (int i = 0; i < PacketSize; ++i) ref[0] = REF_MUL(ref[0], data1[i]); + VERIFY(internal::isApprox(ref[0], internal::predux_mul(internal::pload(data1))) && "internal::predux_mul"); + + for (int i = 0; i < PacketSize; ++i) ref[i] = data1[PacketSize - i - 1]; + internal::pstore(data2, internal::preverse(internal::pload(data1))); + VERIFY(test::areApprox(ref, data2, PacketSize) && "internal::preverse"); + + internal::PacketBlock kernel; + for (int i = 0; i < PacketSize; ++i) { + kernel.packet[i] = internal::pload(data1 + i * PacketSize); + } + ptranspose(kernel); + for (int i = 0; i < PacketSize; ++i) { + internal::pstore(data2, kernel.packet[i]); + for (int j = 0; j < PacketSize; ++j) { + VERIFY(test::isApproxAbs(data2[j], data1[i + j * PacketSize], refvalue) && "ptranspose"); + } + } + + // GeneralBlockPanelKernel also checks PacketBlock; + if (PacketSize > 4 && PacketSize % 4 == 0) { + internal::PacketBlock kernel2; + for (int i = 0; i < 4; ++i) { + kernel2.packet[i] = internal::pload(data1 + i * PacketSize); + } + ptranspose(kernel2); + int data_counter = 0; + for (int i = 0; i < PacketSize; ++i) { + for (int j = 0; j < 4; ++j) { + data2[data_counter++] = data1[j*PacketSize + i]; + } + } + for (int i = 0; i < 4; ++i) { + internal::pstore(data3, kernel2.packet[i]); + for (int j = 0; j < PacketSize; ++j) { + VERIFY(test::isApproxAbs(data3[j], data2[i*PacketSize + j], refvalue) && "ptranspose"); + } + } + } + + if (PacketTraits::HasBlend) { + Packet thenPacket = internal::pload(data1); + Packet elsePacket = internal::pload(data2); + EIGEN_ALIGN_MAX internal::Selector selector; + for (int i = 0; i < PacketSize; ++i) { + selector.select[i] = i; + } + + Packet blend = internal::pblend(selector, thenPacket, elsePacket); + EIGEN_ALIGN_MAX Scalar result[size]; + internal::pstore(result, blend); + for (int i = 0; i < PacketSize; ++i) { + VERIFY(test::isApproxAbs(result[i], (selector.select[i] ? data1[i] : data2[i]), refvalue)); + } + } + + { + for (int i = 0; i < PacketSize; ++i) { + // "if" mask + unsigned char v = internal::random() ? 0xff : 0; + char* bytes = (char*)(data1 + i); + for (int k = 0; k < int(sizeof(Scalar)); ++k) { + bytes[k] = v; + } + // "then" packet + data1[i + PacketSize] = internal::random(); + // "else" packet + data1[i + 2 * PacketSize] = internal::random(); + } + CHECK_CWISE3_IF(true, internal::pselect, internal::pselect); + } + + for (int i = 0; i < size; ++i) { + data1[i] = internal::random(); + } + CHECK_CWISE1(internal::pzero, internal::pzero); + CHECK_CWISE2_IF(true, internal::por, internal::por); + CHECK_CWISE2_IF(true, internal::pxor, internal::pxor); + CHECK_CWISE2_IF(true, internal::pand, internal::pand); + + packetmath_boolean_mask_ops(); + packetmath_pcast_ops_runner::run(); + packetmath_minus_zero_add(); + + for (int i = 0; i < size; ++i) { + data1[i] = numext::abs(internal::random()); + } + CHECK_CWISE1_IF(PacketTraits::HasSqrt, numext::sqrt, internal::psqrt); + CHECK_CWISE1_IF(PacketTraits::HasRsqrt, numext::rsqrt, internal::prsqrt); +} + +// Notice that this definition works for complex types as well. +// c++11 has std::log2 for real, but not for complex types. +template +Scalar log2(Scalar x) { + return Scalar(EIGEN_LOG2E) * std::log(x); +} + +// Create a functor out of a function so it can be passed (with overloads) +// to another function as an input argument. +#define CREATE_FUNCTOR(Name, Func) \ +struct Name { \ + template \ + T operator()(const T& val) const { \ + return Func(val); \ + } \ + } + +CREATE_FUNCTOR(psqrt_functor, internal::psqrt); +CREATE_FUNCTOR(prsqrt_functor, internal::prsqrt); + +// TODO(rmlarsen): Run this test for more functions. +template +void packetmath_test_IEEE_corner_cases(const RefFunctorT& ref_fun, + const FunctorT& fun) { + const int PacketSize = internal::unpacket_traits::size; + const Scalar norm_min = (std::numeric_limits::min)(); + const Scalar norm_max = (std::numeric_limits::max)(); + + const int size = PacketSize * 2; + EIGEN_ALIGN_MAX Scalar data1[PacketSize * 2]; + EIGEN_ALIGN_MAX Scalar data2[PacketSize * 2]; + EIGEN_ALIGN_MAX Scalar ref[PacketSize * 2]; + for (int i = 0; i < size; ++i) { + data1[i] = data2[i] = ref[i] = Scalar(0); + } + + // Test for subnormals. + if (Cond && std::numeric_limits::has_denorm == std::denorm_present && !EIGEN_ARCH_ARM) { + + for (int scale = 1; scale < 5; ++scale) { + // When EIGEN_FAST_MATH is 1 we relax the conditions slightly, and allow the function + // to return the same value for subnormals as the reference would return for zero with + // the same sign as the input. +#if EIGEN_FAST_MATH + data1[0] = Scalar(scale) * std::numeric_limits::denorm_min(); + data1[1] = -data1[0]; + test::packet_helper h; + h.store(data2, fun(h.load(data1))); + for (int i=0; i < PacketSize; ++i) { + const Scalar ref_zero = ref_fun(data1[i] < 0 ? -Scalar(0) : Scalar(0)); + const Scalar ref_val = ref_fun(data1[i]); + VERIFY(((std::isnan)(data2[i]) && (std::isnan)(ref_val)) || data2[i] == ref_zero || + verifyIsApprox(data2[i], ref_val)); + } +#else + CHECK_CWISE1_IF(Cond, ref_fun, fun); +#endif + } + } + + // Test for smallest normalized floats. + data1[0] = norm_min; + data1[1] = -data1[0]; + CHECK_CWISE1_IF(Cond, ref_fun, fun); + + // Test for largest floats. + data1[0] = norm_max; + data1[1] = -data1[0]; + CHECK_CWISE1_IF(Cond, ref_fun, fun); + + // Test for zeros. + data1[0] = Scalar(0.0); + data1[1] = -data1[0]; + CHECK_CWISE1_IF(Cond, ref_fun, fun); + + // Test for infinities. + data1[0] = NumTraits::infinity(); + data1[1] = -data1[0]; + CHECK_CWISE1_IF(Cond, ref_fun, fun); + + // Test for quiet NaNs. + data1[0] = std::numeric_limits::quiet_NaN(); + data1[1] = -std::numeric_limits::quiet_NaN(); + CHECK_CWISE1_IF(Cond, ref_fun, fun); +} + +template +void packetmath_real() { + typedef internal::packet_traits PacketTraits; + const int PacketSize = internal::unpacket_traits::size; + + const int size = PacketSize * 4; + EIGEN_ALIGN_MAX Scalar data1[PacketSize * 4] = {}; + EIGEN_ALIGN_MAX Scalar data2[PacketSize * 4] = {}; + EIGEN_ALIGN_MAX Scalar ref[PacketSize * 4] = {}; + + // Negate with -0. + if (PacketTraits::HasNegate) { + test::packet_helper h; + data1[0] = Scalar(-0); + h.store(data2, internal::pnegate(h.load(data1))); + typedef typename internal::make_unsigned::type>::type Bits; + Bits bits = numext::bit_cast(data2[0]); + VERIFY_IS_EQUAL(bits, static_cast(Bits(1)<<(sizeof(Scalar)*CHAR_BIT - 1))); + } + + for (int i = 0; i < size; ++i) { + data1[i] = Scalar(internal::random(0, 1) * std::pow(10., internal::random(-6, 6))); + data2[i] = Scalar(internal::random(0, 1) * std::pow(10., internal::random(-6, 6))); + } + + if (internal::random(0, 1) < 0.1f) data1[internal::random(0, PacketSize)] = Scalar(0); + + CHECK_CWISE1_IF(PacketTraits::HasLog, std::log, internal::plog); + CHECK_CWISE1_IF(PacketTraits::HasLog, log2, internal::plog2); + CHECK_CWISE1_IF(PacketTraits::HasRsqrt, numext::rsqrt, internal::prsqrt); + + for (int i = 0; i < size; ++i) { + data1[i] = Scalar(internal::random(-1, 1) * std::pow(10., internal::random(-3, 3))); + data2[i] = Scalar(internal::random(-1, 1) * std::pow(10., internal::random(-3, 3))); + } + CHECK_CWISE1_IF(PacketTraits::HasSin, std::sin, internal::psin); + CHECK_CWISE1_IF(PacketTraits::HasCos, std::cos, internal::pcos); + CHECK_CWISE1_IF(PacketTraits::HasTan, std::tan, internal::ptan); + + CHECK_CWISE1_EXACT_IF(PacketTraits::HasRound, numext::round, internal::pround); + CHECK_CWISE1_EXACT_IF(PacketTraits::HasCeil, numext::ceil, internal::pceil); + CHECK_CWISE1_EXACT_IF(PacketTraits::HasFloor, numext::floor, internal::pfloor); + CHECK_CWISE1_EXACT_IF(PacketTraits::HasRint, numext::rint, internal::print); + + packetmath_boolean_mask_ops_real(); + + // Rounding edge cases. + if (PacketTraits::HasRound || PacketTraits::HasCeil || PacketTraits::HasFloor || PacketTraits::HasRint) { + typedef typename internal::make_integer::type IntType; + // Start with values that cannot fit inside an integer, work down to less than one. + Scalar val = numext::mini( + Scalar(2) * static_cast(NumTraits::highest()), + NumTraits::highest()); + std::vector values; + while (val > Scalar(0.25)) { + // Cover both even and odd, positive and negative cases. + values.push_back(val); + values.push_back(val + Scalar(0.3)); + values.push_back(val + Scalar(0.5)); + values.push_back(val + Scalar(0.8)); + values.push_back(val + Scalar(1)); + values.push_back(val + Scalar(1.3)); + values.push_back(val + Scalar(1.5)); + values.push_back(val + Scalar(1.8)); + values.push_back(-val); + values.push_back(-val - Scalar(0.3)); + values.push_back(-val - Scalar(0.5)); + values.push_back(-val - Scalar(0.8)); + values.push_back(-val - Scalar(1)); + values.push_back(-val - Scalar(1.3)); + values.push_back(-val - Scalar(1.5)); + values.push_back(-val - Scalar(1.8)); + values.push_back(Scalar(-1.5) + val); // Bug 1785. + val = val / Scalar(2); + } + values.push_back(NumTraits::infinity()); + values.push_back(-NumTraits::infinity()); + values.push_back(NumTraits::quiet_NaN()); + + for (size_t k=0; k(-1, 1)); + data2[i] = Scalar(internal::random(-1, 1)); + } + CHECK_CWISE1_IF(PacketTraits::HasASin, std::asin, internal::pasin); + CHECK_CWISE1_IF(PacketTraits::HasACos, std::acos, internal::pacos); + + for (int i = 0; i < size; ++i) { + data1[i] = Scalar(internal::random(-87, 88)); + data2[i] = Scalar(internal::random(-87, 88)); + } + CHECK_CWISE1_IF(PacketTraits::HasExp, std::exp, internal::pexp); + + CHECK_CWISE1_BYREF1_IF(PacketTraits::HasExp, REF_FREXP, internal::pfrexp); + if (PacketTraits::HasExp) { + // Check denormals: + #if !EIGEN_ARCH_ARM + for (int j=0; j<3; ++j) { + data1[0] = Scalar(std::ldexp(1, NumTraits::min_exponent()-j)); + CHECK_CWISE1_BYREF1_IF(PacketTraits::HasExp, REF_FREXP, internal::pfrexp); + data1[0] = -data1[0]; + CHECK_CWISE1_BYREF1_IF(PacketTraits::HasExp, REF_FREXP, internal::pfrexp); + } + #endif + + // zero + data1[0] = Scalar(0); + CHECK_CWISE1_BYREF1_IF(PacketTraits::HasExp, REF_FREXP, internal::pfrexp); + + // inf and NaN only compare output fraction, not exponent. + test::packet_helper h; + Packet pout; + Scalar sout; + Scalar special[] = { NumTraits::infinity(), + -NumTraits::infinity(), + NumTraits::quiet_NaN()}; + for (int i=0; i<3; ++i) { + data1[0] = special[i]; + ref[0] = Scalar(REF_FREXP(data1[0], ref[PacketSize])); + h.store(data2, internal::pfrexp(h.load(data1), h.forward_reference(pout, sout))); + VERIFY(test::areApprox(ref, data2, 1) && "internal::pfrexp"); + } + } + + for (int i = 0; i < PacketSize; ++i) { + data1[i] = Scalar(internal::random(-1, 1)); + data2[i] = Scalar(internal::random(-1, 1)); + } + for (int i = 0; i < PacketSize; ++i) { + data1[i+PacketSize] = Scalar(internal::random(-4, 4)); + data2[i+PacketSize] = Scalar(internal::random(-4, 4)); + } + CHECK_CWISE2_IF(PacketTraits::HasExp, REF_LDEXP, internal::pldexp); + if (PacketTraits::HasExp) { + data1[0] = Scalar(-1); + // underflow to zero + data1[PacketSize] = Scalar(NumTraits::min_exponent()-55); + CHECK_CWISE2_IF(PacketTraits::HasExp, REF_LDEXP, internal::pldexp); + // overflow to inf + data1[PacketSize] = Scalar(NumTraits::max_exponent()+10); + CHECK_CWISE2_IF(PacketTraits::HasExp, REF_LDEXP, internal::pldexp); + // NaN stays NaN + data1[0] = NumTraits::quiet_NaN(); + CHECK_CWISE2_IF(PacketTraits::HasExp, REF_LDEXP, internal::pldexp); + VERIFY((numext::isnan)(data2[0])); + // inf stays inf + data1[0] = NumTraits::infinity(); + data1[PacketSize] = Scalar(NumTraits::min_exponent()-10); + CHECK_CWISE2_IF(PacketTraits::HasExp, REF_LDEXP, internal::pldexp); + // zero stays zero + data1[0] = Scalar(0); + data1[PacketSize] = Scalar(NumTraits::max_exponent()+10); + CHECK_CWISE2_IF(PacketTraits::HasExp, REF_LDEXP, internal::pldexp); + // Small number big exponent. + data1[0] = Scalar(std::ldexp(Scalar(1.0), NumTraits::min_exponent()-1)); + data1[PacketSize] = Scalar(-NumTraits::min_exponent() + +NumTraits::max_exponent()); + CHECK_CWISE2_IF(PacketTraits::HasExp, REF_LDEXP, internal::pldexp); + // Big number small exponent. + data1[0] = Scalar(std::ldexp(Scalar(1.0), NumTraits::max_exponent()-1)); + data1[PacketSize] = Scalar(+NumTraits::min_exponent() + -NumTraits::max_exponent()); + CHECK_CWISE2_IF(PacketTraits::HasExp, REF_LDEXP, internal::pldexp); + } + + for (int i = 0; i < size; ++i) { + data1[i] = Scalar(internal::random(-1, 1) * std::pow(10., internal::random(-6, 6))); + data2[i] = Scalar(internal::random(-1, 1) * std::pow(10., internal::random(-6, 6))); + } + data1[0] = Scalar(1e-20); + CHECK_CWISE1_IF(PacketTraits::HasTanh, std::tanh, internal::ptanh); + if (PacketTraits::HasExp && PacketSize >= 2) { + const Scalar small = NumTraits::epsilon(); + data1[0] = NumTraits::quiet_NaN(); + data1[1] = small; + test::packet_helper h; + h.store(data2, internal::pexp(h.load(data1))); + VERIFY((numext::isnan)(data2[0])); + // TODO(rmlarsen): Re-enable for bfloat16. + if (!internal::is_same::value) { + VERIFY_IS_APPROX(std::exp(small), data2[1]); + } + + data1[0] = -small; + data1[1] = Scalar(0); + h.store(data2, internal::pexp(h.load(data1))); + // TODO(rmlarsen): Re-enable for bfloat16. + if (!internal::is_same::value) { + VERIFY_IS_APPROX(std::exp(-small), data2[0]); + } + VERIFY_IS_EQUAL(std::exp(Scalar(0)), data2[1]); + + data1[0] = (std::numeric_limits::min)(); + data1[1] = -(std::numeric_limits::min)(); + h.store(data2, internal::pexp(h.load(data1))); + VERIFY_IS_APPROX(std::exp((std::numeric_limits::min)()), data2[0]); + VERIFY_IS_APPROX(std::exp(-(std::numeric_limits::min)()), data2[1]); + + data1[0] = std::numeric_limits::denorm_min(); + data1[1] = -std::numeric_limits::denorm_min(); + h.store(data2, internal::pexp(h.load(data1))); + VERIFY_IS_APPROX(std::exp(std::numeric_limits::denorm_min()), data2[0]); + VERIFY_IS_APPROX(std::exp(-std::numeric_limits::denorm_min()), data2[1]); + } + + if (PacketTraits::HasTanh) { + // NOTE this test migh fail with GCC prior to 6.3, see MathFunctionsImpl.h for details. + data1[0] = NumTraits::quiet_NaN(); + test::packet_helper::HasTanh, Packet> h; + h.store(data2, internal::ptanh(h.load(data1))); + VERIFY((numext::isnan)(data2[0])); + } + + if (PacketTraits::HasExp) { + internal::scalar_logistic_op logistic; + for (int i = 0; i < size; ++i) { + data1[i] = Scalar(internal::random(-20, 20)); + } + + test::packet_helper h; + h.store(data2, logistic.packetOp(h.load(data1))); + for (int i = 0; i < PacketSize; ++i) { + VERIFY_IS_APPROX(data2[i], logistic(data1[i])); + } + } + +#if EIGEN_HAS_C99_MATH && (EIGEN_COMP_CXXVER >= 11) + data1[0] = NumTraits::infinity(); + data1[1] = Scalar(-1); + CHECK_CWISE1_IF(PacketTraits::HasLog1p, std::log1p, internal::plog1p); + data1[0] = NumTraits::infinity(); + data1[1] = -NumTraits::infinity(); + CHECK_CWISE1_IF(PacketTraits::HasExpm1, std::expm1, internal::pexpm1); +#endif + + if (PacketSize >= 2) { + data1[0] = NumTraits::quiet_NaN(); + data1[1] = NumTraits::epsilon(); + if (PacketTraits::HasLog) { + test::packet_helper h; + h.store(data2, internal::plog(h.load(data1))); + VERIFY((numext::isnan)(data2[0])); + // TODO(cantonios): Re-enable for bfloat16. + if (!internal::is_same::value) { + VERIFY_IS_APPROX(std::log(data1[1]), data2[1]); + } + + data1[0] = -NumTraits::epsilon(); + data1[1] = Scalar(0); + h.store(data2, internal::plog(h.load(data1))); + VERIFY((numext::isnan)(data2[0])); + VERIFY_IS_EQUAL(std::log(Scalar(0)), data2[1]); + + data1[0] = (std::numeric_limits::min)(); + data1[1] = -(std::numeric_limits::min)(); + h.store(data2, internal::plog(h.load(data1))); + // TODO(cantonios): Re-enable for bfloat16. + if (!internal::is_same::value) { + VERIFY_IS_APPROX(std::log((std::numeric_limits::min)()), data2[0]); + } + VERIFY((numext::isnan)(data2[1])); + + // Note: 32-bit arm always flushes denorms to zero. +#if !EIGEN_ARCH_ARM + if (std::numeric_limits::has_denorm == std::denorm_present) { + data1[0] = std::numeric_limits::denorm_min(); + data1[1] = -std::numeric_limits::denorm_min(); + h.store(data2, internal::plog(h.load(data1))); + // TODO(rmlarsen): Reenable. + // VERIFY_IS_EQUAL(std::log(std::numeric_limits::denorm_min()), data2[0]); + VERIFY((numext::isnan)(data2[1])); + } +#endif + + data1[0] = Scalar(-1.0f); + h.store(data2, internal::plog(h.load(data1))); + VERIFY((numext::isnan)(data2[0])); + + data1[0] = NumTraits::infinity(); + h.store(data2, internal::plog(h.load(data1))); + VERIFY((numext::isinf)(data2[0])); + } + if (PacketTraits::HasLog1p) { + test::packet_helper h; + data1[0] = Scalar(-2); + data1[1] = -NumTraits::infinity(); + h.store(data2, internal::plog1p(h.load(data1))); + VERIFY((numext::isnan)(data2[0])); + VERIFY((numext::isnan)(data2[1])); + } + if (PacketTraits::HasSqrt) { + test::packet_helper h; + data1[0] = Scalar(-1.0f); +#if !EIGEN_ARCH_ARM + + if (std::numeric_limits::has_denorm == std::denorm_present) { + data1[1] = -std::numeric_limits::denorm_min(); + } else { + data1[1] = -NumTraits::epsilon(); + } +#else + data1[1] = -NumTraits::epsilon(); +#endif + h.store(data2, internal::psqrt(h.load(data1))); + VERIFY((numext::isnan)(data2[0])); + VERIFY((numext::isnan)(data2[1])); + } + // TODO(rmlarsen): Re-enable for half and bfloat16. + if (PacketTraits::HasCos + && !internal::is_same::value + && !internal::is_same::value) { + test::packet_helper h; + for (Scalar k = Scalar(1); k < Scalar(10000) / NumTraits::epsilon(); k *= Scalar(2)) { + for (int k1 = 0; k1 <= 1; ++k1) { + data1[0] = Scalar((2 * double(k) + k1) * double(EIGEN_PI) / 2 * internal::random(0.8, 1.2)); + data1[1] = Scalar((2 * double(k) + 2 + k1) * double(EIGEN_PI) / 2 * internal::random(0.8, 1.2)); + h.store(data2, internal::pcos(h.load(data1))); + h.store(data2 + PacketSize, internal::psin(h.load(data1))); + VERIFY(data2[0] <= Scalar(1.) && data2[0] >= Scalar(-1.)); + VERIFY(data2[1] <= Scalar(1.) && data2[1] >= Scalar(-1.)); + VERIFY(data2[PacketSize + 0] <= Scalar(1.) && data2[PacketSize + 0] >= Scalar(-1.)); + VERIFY(data2[PacketSize + 1] <= Scalar(1.) && data2[PacketSize + 1] >= Scalar(-1.)); + + VERIFY_IS_APPROX(data2[0], std::cos(data1[0])); + VERIFY_IS_APPROX(data2[1], std::cos(data1[1])); + VERIFY_IS_APPROX(data2[PacketSize + 0], std::sin(data1[0])); + VERIFY_IS_APPROX(data2[PacketSize + 1], std::sin(data1[1])); + + VERIFY_IS_APPROX(numext::abs2(data2[0]) + numext::abs2(data2[PacketSize + 0]), Scalar(1)); + VERIFY_IS_APPROX(numext::abs2(data2[1]) + numext::abs2(data2[PacketSize + 1]), Scalar(1)); + } + } + + data1[0] = NumTraits::infinity(); + data1[1] = -NumTraits::infinity(); + h.store(data2, internal::psin(h.load(data1))); + VERIFY((numext::isnan)(data2[0])); + VERIFY((numext::isnan)(data2[1])); + + h.store(data2, internal::pcos(h.load(data1))); + VERIFY((numext::isnan)(data2[0])); + VERIFY((numext::isnan)(data2[1])); + + data1[0] = NumTraits::quiet_NaN(); + h.store(data2, internal::psin(h.load(data1))); + VERIFY((numext::isnan)(data2[0])); + h.store(data2, internal::pcos(h.load(data1))); + VERIFY((numext::isnan)(data2[0])); + + data1[0] = -Scalar(0.); + h.store(data2, internal::psin(h.load(data1))); + VERIFY(internal::biteq(data2[0], data1[0])); + h.store(data2, internal::pcos(h.load(data1))); + VERIFY_IS_EQUAL(data2[0], Scalar(1)); + } + } +} + +#define CAST_CHECK_CWISE1_IF(COND, REFOP, POP, SCALAR, REFTYPE) if(COND) { \ + test::packet_helper h; \ + for (int i=0; i(data1[i]))); \ + h.store(data2, POP(h.load(data1))); \ + VERIFY(test::areApprox(ref, data2, PacketSize) && #POP); \ +} + +template +Scalar propagate_nan_max(const Scalar& a, const Scalar& b) { + if ((numext::isnan)(a)) return a; + if ((numext::isnan)(b)) return b; + return (numext::maxi)(a,b); +} + +template +Scalar propagate_nan_min(const Scalar& a, const Scalar& b) { + if ((numext::isnan)(a)) return a; + if ((numext::isnan)(b)) return b; + return (numext::mini)(a,b); +} + +template +Scalar propagate_number_max(const Scalar& a, const Scalar& b) { + if ((numext::isnan)(a)) return b; + if ((numext::isnan)(b)) return a; + return (numext::maxi)(a,b); +} + +template +Scalar propagate_number_min(const Scalar& a, const Scalar& b) { + if ((numext::isnan)(a)) return b; + if ((numext::isnan)(b)) return a; + return (numext::mini)(a,b); +} + +template +void packetmath_notcomplex() { + typedef internal::packet_traits PacketTraits; + const int PacketSize = internal::unpacket_traits::size; + + EIGEN_ALIGN_MAX Scalar data1[PacketSize * 4]; + EIGEN_ALIGN_MAX Scalar data2[PacketSize * 4]; + EIGEN_ALIGN_MAX Scalar ref[PacketSize * 4]; + + Array::Map(data1, PacketSize * 4).setRandom(); + + VERIFY((!PacketTraits::Vectorizable) || PacketTraits::HasMin); + VERIFY((!PacketTraits::Vectorizable) || PacketTraits::HasMax); + + CHECK_CWISE2_IF(PacketTraits::HasMin, (std::min), internal::pmin); + CHECK_CWISE2_IF(PacketTraits::HasMax, (std::max), internal::pmax); + + CHECK_CWISE2_IF(PacketTraits::HasMin, propagate_number_min, internal::pmin); + CHECK_CWISE2_IF(PacketTraits::HasMax, propagate_number_max, internal::pmax); + CHECK_CWISE1(numext::abs, internal::pabs); + CHECK_CWISE2_IF(PacketTraits::HasAbsDiff, REF_ABS_DIFF, internal::pabsdiff); + + ref[0] = data1[0]; + for (int i = 0; i < PacketSize; ++i) ref[0] = internal::pmin(ref[0], data1[i]); + VERIFY(internal::isApprox(ref[0], internal::predux_min(internal::pload(data1))) && "internal::predux_min"); + ref[0] = data1[0]; + for (int i = 0; i < PacketSize; ++i) ref[0] = internal::pmax(ref[0], data1[i]); + VERIFY(internal::isApprox(ref[0], internal::predux_max(internal::pload(data1))) && "internal::predux_max"); + + for (int i = 0; i < PacketSize; ++i) ref[i] = data1[0] + Scalar(i); + internal::pstore(data2, internal::plset(data1[0])); + VERIFY(test::areApprox(ref, data2, PacketSize) && "internal::plset"); + + { + unsigned char* data1_bits = reinterpret_cast(data1); + // predux_all - not needed yet + // for (unsigned int i=0; i(data1)) && "internal::predux_all(1111)"); + // for(int k=0; k(data1))) && "internal::predux_all(0101)"); + // for (unsigned int i=0; i(data1))) && "internal::predux_any(0000)"); + for (int k = 0; k < PacketSize; ++k) { + for (unsigned int i = 0; i < sizeof(Scalar); ++i) data1_bits[k * sizeof(Scalar) + i] = 0xff; + VERIFY(internal::predux_any(internal::pload(data1)) && "internal::predux_any(0101)"); + for (unsigned int i = 0; i < sizeof(Scalar); ++i) data1_bits[k * sizeof(Scalar) + i] = 0x00; + } + } + + + // Test NaN propagation. + if (!NumTraits::IsInteger) { + // Test reductions with no NaNs. + ref[0] = data1[0]; + for (int i = 0; i < PacketSize; ++i) ref[0] = internal::pmin(ref[0], data1[i]); + VERIFY(internal::isApprox(ref[0], internal::predux_min(internal::pload(data1))) && "internal::predux_min"); + ref[0] = data1[0]; + for (int i = 0; i < PacketSize; ++i) ref[0] = internal::pmin(ref[0], data1[i]); + VERIFY(internal::isApprox(ref[0], internal::predux_min(internal::pload(data1))) && "internal::predux_min"); + ref[0] = data1[0]; + for (int i = 0; i < PacketSize; ++i) ref[0] = internal::pmax(ref[0], data1[i]); + VERIFY(internal::isApprox(ref[0], internal::predux_max(internal::pload(data1))) && "internal::predux_max"); + ref[0] = data1[0]; + for (int i = 0; i < PacketSize; ++i) ref[0] = internal::pmax(ref[0], data1[i]); + VERIFY(internal::isApprox(ref[0], internal::predux_max(internal::pload(data1))) && "internal::predux_max"); + // A single NaN. + const size_t index = std::numeric_limits::quiet_NaN() % PacketSize; + data1[index] = NumTraits::quiet_NaN(); + VERIFY(PacketSize==1 || !(numext::isnan)(internal::predux_min(internal::pload(data1)))); + VERIFY((numext::isnan)(internal::predux_min(internal::pload(data1)))); + VERIFY(PacketSize==1 || !(numext::isnan)(internal::predux_max(internal::pload(data1)))); + VERIFY((numext::isnan)(internal::predux_max(internal::pload(data1)))); + // All NaNs. + for (int i = 0; i < 4 * PacketSize; ++i) data1[i] = NumTraits::quiet_NaN(); + VERIFY((numext::isnan)(internal::predux_min(internal::pload(data1)))); + VERIFY((numext::isnan)(internal::predux_min(internal::pload(data1)))); + VERIFY((numext::isnan)(internal::predux_max(internal::pload(data1)))); + VERIFY((numext::isnan)(internal::predux_max(internal::pload(data1)))); + + // Test NaN propagation for coefficient-wise min and max. + for (int i = 0; i < PacketSize; ++i) { + data1[i] = internal::random() ? NumTraits::quiet_NaN() : Scalar(0); + data1[i + PacketSize] = internal::random() ? NumTraits::quiet_NaN() : Scalar(0); + } + // Note: NaN propagation is implementation defined for pmin/pmax, so we do not test it here. + CHECK_CWISE2_IF(PacketTraits::HasMin, propagate_number_min, (internal::pmin)); + CHECK_CWISE2_IF(PacketTraits::HasMax, propagate_number_max, internal::pmax); + CHECK_CWISE2_IF(PacketTraits::HasMin, propagate_nan_min, (internal::pmin)); + CHECK_CWISE2_IF(PacketTraits::HasMax, propagate_nan_max, internal::pmax); + } + + packetmath_boolean_mask_ops_notcomplex(); +} + +template +void test_conj_helper(Scalar* data1, Scalar* data2, Scalar* ref, Scalar* pval) { + const int PacketSize = internal::unpacket_traits::size; + + internal::conj_if cj0; + internal::conj_if cj1; + internal::conj_helper cj; + internal::conj_helper pcj; + + for (int i = 0; i < PacketSize; ++i) { + ref[i] = cj0(data1[i]) * cj1(data2[i]); + VERIFY(internal::isApprox(ref[i], cj.pmul(data1[i], data2[i])) && "conj_helper pmul"); + } + internal::pstore(pval, pcj.pmul(internal::pload(data1), internal::pload(data2))); + VERIFY(test::areApprox(ref, pval, PacketSize) && "conj_helper pmul"); + + for (int i = 0; i < PacketSize; ++i) { + Scalar tmp = ref[i]; + ref[i] += cj0(data1[i]) * cj1(data2[i]); + VERIFY(internal::isApprox(ref[i], cj.pmadd(data1[i], data2[i], tmp)) && "conj_helper pmadd"); + } + internal::pstore( + pval, pcj.pmadd(internal::pload(data1), internal::pload(data2), internal::pload(pval))); + VERIFY(test::areApprox(ref, pval, PacketSize) && "conj_helper pmadd"); +} + +template +void packetmath_complex() { + typedef internal::packet_traits PacketTraits; + typedef typename Scalar::value_type RealScalar; + const int PacketSize = internal::unpacket_traits::size; + + const int size = PacketSize * 4; + EIGEN_ALIGN_MAX Scalar data1[PacketSize * 4]; + EIGEN_ALIGN_MAX Scalar data2[PacketSize * 4]; + EIGEN_ALIGN_MAX Scalar ref[PacketSize * 4]; + EIGEN_ALIGN_MAX Scalar pval[PacketSize * 4]; + + for (int i = 0; i < size; ++i) { + data1[i] = internal::random() * Scalar(1e2); + data2[i] = internal::random() * Scalar(1e2); + } + + test_conj_helper(data1, data2, ref, pval); + test_conj_helper(data1, data2, ref, pval); + test_conj_helper(data1, data2, ref, pval); + test_conj_helper(data1, data2, ref, pval); + + // Test pcplxflip. + { + for (int i = 0; i < PacketSize; ++i) ref[i] = Scalar(std::imag(data1[i]), std::real(data1[i])); + internal::pstore(pval, internal::pcplxflip(internal::pload(data1))); + VERIFY(test::areApprox(ref, pval, PacketSize) && "pcplxflip"); + } + + if (PacketTraits::HasSqrt) { + for (int i = 0; i < size; ++i) { + data1[i] = Scalar(internal::random(), internal::random()); + } + CHECK_CWISE1_N(numext::sqrt, internal::psqrt, size); + + // Test misc. corner cases. + const RealScalar zero = RealScalar(0); + const RealScalar one = RealScalar(1); + const RealScalar inf = std::numeric_limits::infinity(); + const RealScalar nan = std::numeric_limits::quiet_NaN(); + data1[0] = Scalar(zero, zero); + data1[1] = Scalar(-zero, zero); + data1[2] = Scalar(one, zero); + data1[3] = Scalar(zero, one); + CHECK_CWISE1_N(numext::sqrt, internal::psqrt, 4); + data1[0] = Scalar(-one, zero); + data1[1] = Scalar(zero, -one); + data1[2] = Scalar(one, one); + data1[3] = Scalar(-one, -one); + CHECK_CWISE1_N(numext::sqrt, internal::psqrt, 4); + data1[0] = Scalar(inf, zero); + data1[1] = Scalar(zero, inf); + data1[2] = Scalar(-inf, zero); + data1[3] = Scalar(zero, -inf); + CHECK_CWISE1_N(numext::sqrt, internal::psqrt, 4); + data1[0] = Scalar(inf, inf); + data1[1] = Scalar(-inf, inf); + data1[2] = Scalar(inf, -inf); + data1[3] = Scalar(-inf, -inf); + CHECK_CWISE1_N(numext::sqrt, internal::psqrt, 4); + data1[0] = Scalar(nan, zero); + data1[1] = Scalar(zero, nan); + data1[2] = Scalar(nan, one); + data1[3] = Scalar(one, nan); + CHECK_CWISE1_N(numext::sqrt, internal::psqrt, 4); + data1[0] = Scalar(nan, nan); + data1[1] = Scalar(inf, nan); + data1[2] = Scalar(nan, inf); + data1[3] = Scalar(-inf, nan); + CHECK_CWISE1_N(numext::sqrt, internal::psqrt, 4); + } +} + +template +void packetmath_scatter_gather() { + typedef typename NumTraits::Real RealScalar; + const int PacketSize = internal::unpacket_traits::size; + EIGEN_ALIGN_MAX Scalar data1[PacketSize]; + RealScalar refvalue = RealScalar(0); + for (int i = 0; i < PacketSize; ++i) { + data1[i] = internal::random() / RealScalar(PacketSize); + } + + int stride = internal::random(1, 20); + + // Buffer of zeros. + EIGEN_ALIGN_MAX Scalar buffer[PacketSize * 20] = {}; + + Packet packet = internal::pload(data1); + internal::pscatter(buffer, packet, stride); + + for (int i = 0; i < PacketSize * 20; ++i) { + if ((i % stride) == 0 && i < stride * PacketSize) { + VERIFY(test::isApproxAbs(buffer[i], data1[i / stride], refvalue) && "pscatter"); + } else { + VERIFY(test::isApproxAbs(buffer[i], Scalar(0), refvalue) && "pscatter"); + } + } + + for (int i = 0; i < PacketSize * 7; ++i) { + buffer[i] = internal::random() / RealScalar(PacketSize); + } + packet = internal::pgather(buffer, 7); + internal::pstore(data1, packet); + for (int i = 0; i < PacketSize; ++i) { + VERIFY(test::isApproxAbs(data1[i], buffer[i * 7], refvalue) && "pgather"); + } +} + +namespace Eigen { +namespace test { + +template +struct runall { // i.e. float or double + static void run() { + packetmath(); + packetmath_scatter_gather(); + packetmath_notcomplex(); + packetmath_real(); + } +}; + +template +struct runall { // i.e. int + static void run() { + packetmath(); + packetmath_scatter_gather(); + packetmath_notcomplex(); + } +}; + +template +struct runall { // i.e. complex + static void run() { + packetmath(); + packetmath_scatter_gather(); + packetmath_complex(); + } +}; + +} // namespace test +} // namespace Eigen + +EIGEN_DECLARE_TEST(packetmath) { + g_first_pass = true; + for (int i = 0; i < g_repeat; i++) { + CALL_SUBTEST_1(test::runner::run()); + CALL_SUBTEST_2(test::runner::run()); + CALL_SUBTEST_3(test::runner::run()); + CALL_SUBTEST_4(test::runner::run()); + CALL_SUBTEST_5(test::runner::run()); + CALL_SUBTEST_6(test::runner::run()); + CALL_SUBTEST_7(test::runner::run()); + CALL_SUBTEST_8(test::runner::run()); + CALL_SUBTEST_9(test::runner::run()); + CALL_SUBTEST_10(test::runner::run()); + CALL_SUBTEST_11(test::runner >::run()); + CALL_SUBTEST_12(test::runner >::run()); + CALL_SUBTEST_13(test::runner::run()); + CALL_SUBTEST_14((packetmath::type>())); + CALL_SUBTEST_15(test::runner::run()); + g_first_pass = false; + } +} diff --git a/include/eigen/test/pardiso_support.cpp b/include/eigen/test/pardiso_support.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9c16ded5bcfc6427c35158455d4a6f4bdf853b3a --- /dev/null +++ b/include/eigen/test/pardiso_support.cpp @@ -0,0 +1,29 @@ +/* + Intel Copyright (C) .... +*/ + +#include "sparse_solver.h" +#include + +template void test_pardiso_T() +{ + PardisoLLT < SparseMatrix, Lower> pardiso_llt_lower; + PardisoLLT < SparseMatrix, Upper> pardiso_llt_upper; + PardisoLDLT < SparseMatrix, Lower> pardiso_ldlt_lower; + PardisoLDLT < SparseMatrix, Upper> pardiso_ldlt_upper; + PardisoLU < SparseMatrix > pardiso_lu; + + check_sparse_spd_solving(pardiso_llt_lower); + check_sparse_spd_solving(pardiso_llt_upper); + check_sparse_spd_solving(pardiso_ldlt_lower); + check_sparse_spd_solving(pardiso_ldlt_upper); + check_sparse_square_solving(pardiso_lu); +} + +EIGEN_DECLARE_TEST(pardiso_support) +{ + CALL_SUBTEST_1(test_pardiso_T()); + CALL_SUBTEST_2(test_pardiso_T()); + CALL_SUBTEST_3(test_pardiso_T< std::complex >()); + CALL_SUBTEST_4(test_pardiso_T< std::complex >()); +} diff --git a/include/eigen/test/permutationmatrices.cpp b/include/eigen/test/permutationmatrices.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d4b68b2d488390c67030280a3e1b125d37620a57 --- /dev/null +++ b/include/eigen/test/permutationmatrices.cpp @@ -0,0 +1,181 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2009 Benoit Jacob +// +// 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/. + +#define TEST_ENABLE_TEMPORARY_TRACKING + +#include "main.h" + +using namespace std; +template void permutationmatrices(const MatrixType& m) +{ + typedef typename MatrixType::Scalar Scalar; + enum { Rows = MatrixType::RowsAtCompileTime, Cols = MatrixType::ColsAtCompileTime, + Options = MatrixType::Options }; + typedef PermutationMatrix LeftPermutationType; + typedef Transpositions LeftTranspositionsType; + typedef Matrix LeftPermutationVectorType; + typedef Map MapLeftPerm; + typedef PermutationMatrix RightPermutationType; + typedef Transpositions RightTranspositionsType; + typedef Matrix RightPermutationVectorType; + typedef Map MapRightPerm; + + Index rows = m.rows(); + Index cols = m.cols(); + + MatrixType m_original = MatrixType::Random(rows,cols); + LeftPermutationVectorType lv; + randomPermutationVector(lv, rows); + LeftPermutationType lp(lv); + RightPermutationVectorType rv; + randomPermutationVector(rv, cols); + RightPermutationType rp(rv); + LeftTranspositionsType lt(lv); + RightTranspositionsType rt(rv); + MatrixType m_permuted = MatrixType::Random(rows,cols); + + VERIFY_EVALUATION_COUNT(m_permuted = lp * m_original * rp, 1); // 1 temp for sub expression "lp * m_original" + + for (int i=0; i lm(lp); + Matrix rm(rp); + + VERIFY_IS_APPROX(m_permuted, lm*m_original*rm); + + m_permuted = m_original; + VERIFY_EVALUATION_COUNT(m_permuted = lp * m_permuted * rp, 1); + VERIFY_IS_APPROX(m_permuted, lm*m_original*rm); + + LeftPermutationType lpi; + lpi = lp.inverse(); + VERIFY_IS_APPROX(lpi*m_permuted,lp.inverse()*m_permuted); + + VERIFY_IS_APPROX(lp.inverse()*m_permuted*rp.inverse(), m_original); + VERIFY_IS_APPROX(lv.asPermutation().inverse()*m_permuted*rv.asPermutation().inverse(), m_original); + VERIFY_IS_APPROX(MapLeftPerm(lv.data(),lv.size()).inverse()*m_permuted*MapRightPerm(rv.data(),rv.size()).inverse(), m_original); + + VERIFY((lp*lp.inverse()).toDenseMatrix().isIdentity()); + VERIFY((lv.asPermutation()*lv.asPermutation().inverse()).toDenseMatrix().isIdentity()); + VERIFY((MapLeftPerm(lv.data(),lv.size())*MapLeftPerm(lv.data(),lv.size()).inverse()).toDenseMatrix().isIdentity()); + + LeftPermutationVectorType lv2; + randomPermutationVector(lv2, rows); + LeftPermutationType lp2(lv2); + Matrix lm2(lp2); + VERIFY_IS_APPROX((lp*lp2).toDenseMatrix().template cast(), lm*lm2); + VERIFY_IS_APPROX((lv.asPermutation()*lv2.asPermutation()).toDenseMatrix().template cast(), lm*lm2); + VERIFY_IS_APPROX((MapLeftPerm(lv.data(),lv.size())*MapLeftPerm(lv2.data(),lv2.size())).toDenseMatrix().template cast(), lm*lm2); + + LeftPermutationType identityp; + identityp.setIdentity(rows); + VERIFY_IS_APPROX(m_original, identityp*m_original); + + // check inplace permutations + m_permuted = m_original; + VERIFY_EVALUATION_COUNT(m_permuted.noalias()= lp.inverse() * m_permuted, 1); // 1 temp to allocate the mask + VERIFY_IS_APPROX(m_permuted, lp.inverse()*m_original); + + m_permuted = m_original; + VERIFY_EVALUATION_COUNT(m_permuted.noalias() = m_permuted * rp.inverse(), 1); // 1 temp to allocate the mask + VERIFY_IS_APPROX(m_permuted, m_original*rp.inverse()); + + m_permuted = m_original; + VERIFY_EVALUATION_COUNT(m_permuted.noalias() = lp * m_permuted, 1); // 1 temp to allocate the mask + VERIFY_IS_APPROX(m_permuted, lp*m_original); + + m_permuted = m_original; + VERIFY_EVALUATION_COUNT(m_permuted.noalias() = m_permuted * rp, 1); // 1 temp to allocate the mask + VERIFY_IS_APPROX(m_permuted, m_original*rp); + + if(rows>1 && cols>1) + { + lp2 = lp; + Index i = internal::random(0, rows-1); + Index j; + do j = internal::random(0, rows-1); while(j==i); + lp2.applyTranspositionOnTheLeft(i, j); + lm = lp; + lm.row(i).swap(lm.row(j)); + VERIFY_IS_APPROX(lm, lp2.toDenseMatrix().template cast()); + + RightPermutationType rp2 = rp; + i = internal::random(0, cols-1); + do j = internal::random(0, cols-1); while(j==i); + rp2.applyTranspositionOnTheRight(i, j); + rm = rp; + rm.col(i).swap(rm.col(j)); + VERIFY_IS_APPROX(rm, rp2.toDenseMatrix().template cast()); + } + + { + // simple compilation check + Matrix A = rp; + Matrix B = rp.transpose(); + VERIFY_IS_APPROX(A, B.transpose()); + } + + m_permuted = m_original; + lp = lt; + rp = rt; + VERIFY_EVALUATION_COUNT(m_permuted = lt * m_permuted * rt, 1); + VERIFY_IS_APPROX(m_permuted, lp*m_original*rp.transpose()); + + VERIFY_IS_APPROX(lt.inverse()*m_permuted*rt.inverse(), m_original); + + // Check inplace transpositions + m_permuted = m_original; + VERIFY_IS_APPROX(m_permuted = lt * m_permuted, lp * m_original); + m_permuted = m_original; + VERIFY_IS_APPROX(m_permuted = lt.inverse() * m_permuted, lp.inverse() * m_original); + m_permuted = m_original; + VERIFY_IS_APPROX(m_permuted = m_permuted * rt, m_original * rt); + m_permuted = m_original; + VERIFY_IS_APPROX(m_permuted = m_permuted * rt.inverse(), m_original * rt.inverse()); +} + +template +void bug890() +{ + typedef Matrix MatrixType; + typedef Matrix VectorType; + typedef Stride S; + typedef Map MapType; + typedef PermutationMatrix Perm; + + VectorType v1(2), v2(2), op(4), rhs(2); + v1 << 666,667; + op << 1,0,0,1; + rhs << 42,42; + + Perm P(2); + P.indices() << 1, 0; + + MapType(v1.data(),2,1,S(1,1)) = P * MapType(rhs.data(),2,1,S(1,1)); + VERIFY_IS_APPROX(v1, (P * rhs).eval()); + + MapType(v1.data(),2,1,S(1,1)) = P.inverse() * MapType(rhs.data(),2,1,S(1,1)); + VERIFY_IS_APPROX(v1, (P.inverse() * rhs).eval()); +} + +EIGEN_DECLARE_TEST(permutationmatrices) +{ + for(int i = 0; i < g_repeat; i++) { + CALL_SUBTEST_1( permutationmatrices(Matrix()) ); + CALL_SUBTEST_2( permutationmatrices(Matrix3f()) ); + CALL_SUBTEST_3( permutationmatrices(Matrix()) ); + CALL_SUBTEST_4( permutationmatrices(Matrix4d()) ); + CALL_SUBTEST_5( permutationmatrices(Matrix()) ); + CALL_SUBTEST_6( permutationmatrices(Matrix(internal::random(1,EIGEN_TEST_MAX_SIZE), internal::random(1,EIGEN_TEST_MAX_SIZE))) ); + CALL_SUBTEST_7( permutationmatrices(MatrixXcf(internal::random(1,EIGEN_TEST_MAX_SIZE), internal::random(1,EIGEN_TEST_MAX_SIZE))) ); + } + CALL_SUBTEST_5( bug890() ); +} diff --git a/include/eigen/test/prec_inverse_4x4.cpp b/include/eigen/test/prec_inverse_4x4.cpp new file mode 100644 index 0000000000000000000000000000000000000000..86f057118cf1c3ba1e906eb7fd6160c4cbd4636f --- /dev/null +++ b/include/eigen/test/prec_inverse_4x4.cpp @@ -0,0 +1,82 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2009 Benoit Jacob +// +// 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/. + +#include "main.h" +#include +#include + +template void inverse_permutation_4x4() +{ + typedef typename MatrixType::Scalar Scalar; + Vector4i indices(0,1,2,3); + for(int i = 0; i < 24; ++i) + { + MatrixType m = PermutationMatrix<4>(indices); + MatrixType inv = m.inverse(); + double error = double( (m*inv-MatrixType::Identity()).norm() / NumTraits::epsilon() ); + EIGEN_DEBUG_VAR(error) + VERIFY(error == 0.0); + std::next_permutation(indices.data(),indices.data()+4); + } +} + +template void inverse_general_4x4(int repeat) +{ + using std::abs; + typedef typename MatrixType::Scalar Scalar; + double error_sum = 0., error_max = 0.; + for(int i = 0; i < repeat; ++i) + { + MatrixType m; + bool is_invertible; + do { + m = MatrixType::Random(); + is_invertible = Eigen::FullPivLU(m).isInvertible(); + } while(!is_invertible); + MatrixType inv = m.inverse(); + double error = double( (m*inv-MatrixType::Identity()).norm()); + error_sum += error; + error_max = (std::max)(error_max, error); + } + std::cerr << "inverse_general_4x4, Scalar = " << type_name() << std::endl; + double error_avg = error_sum / repeat; + EIGEN_DEBUG_VAR(error_avg); + EIGEN_DEBUG_VAR(error_max); + // FIXME that 1.25 used to be a 1.0 until the NumTraits changes on 28 April 2010, what's going wrong?? + // FIXME that 1.25 used to be 1.2 until we tested gcc 4.1 on 30 June 2010 and got 1.21. + VERIFY(error_avg < (NumTraits::IsComplex ? 8.0 : 1.25)); + VERIFY(error_max < (NumTraits::IsComplex ? 64.0 : 20.0)); + + { + int s = 5;//internal::random(4,10); + int i = 0;//internal::random(0,s-4); + int j = 0;//internal::random(0,s-4); + Matrix mat(s,s); + mat.setRandom(); + MatrixType submat = mat.template block<4,4>(i,j); + MatrixType mat_inv = mat.template block<4,4>(i,j).inverse(); + VERIFY_IS_APPROX(mat_inv, submat.inverse()); + mat.template block<4,4>(i,j) = submat.inverse(); + VERIFY_IS_APPROX(mat_inv, (mat.template block<4,4>(i,j))); + } +} + +EIGEN_DECLARE_TEST(prec_inverse_4x4) +{ + CALL_SUBTEST_1((inverse_permutation_4x4())); + CALL_SUBTEST_1(( inverse_general_4x4(200000 * g_repeat) )); + CALL_SUBTEST_1(( inverse_general_4x4 >(200000 * g_repeat) )); + + CALL_SUBTEST_2((inverse_permutation_4x4 >())); + CALL_SUBTEST_2(( inverse_general_4x4 >(200000 * g_repeat) )); + CALL_SUBTEST_2(( inverse_general_4x4 >(200000 * g_repeat) )); + + CALL_SUBTEST_3((inverse_permutation_4x4())); + CALL_SUBTEST_3((inverse_general_4x4(50000 * g_repeat))); +} diff --git a/include/eigen/test/product_extra.cpp b/include/eigen/test/product_extra.cpp new file mode 100644 index 0000000000000000000000000000000000000000..15c69896e00dd3746df16cad2d7144c75e9a205c --- /dev/null +++ b/include/eigen/test/product_extra.cpp @@ -0,0 +1,390 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2006-2008 Benoit Jacob +// +// 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/. + +#include "main.h" + +template void product_extra(const MatrixType& m) +{ + typedef typename MatrixType::Scalar Scalar; + typedef Matrix RowVectorType; + typedef Matrix ColVectorType; + typedef Matrix OtherMajorMatrixType; + + Index rows = m.rows(); + Index cols = m.cols(); + + MatrixType m1 = MatrixType::Random(rows, cols), + m2 = MatrixType::Random(rows, cols), + m3(rows, cols), + mzero = MatrixType::Zero(rows, cols), + identity = MatrixType::Identity(rows, rows), + square = MatrixType::Random(rows, rows), + res = MatrixType::Random(rows, rows), + square2 = MatrixType::Random(cols, cols), + res2 = MatrixType::Random(cols, cols); + RowVectorType v1 = RowVectorType::Random(rows), vrres(rows); + ColVectorType vc2 = ColVectorType::Random(cols), vcres(cols); + OtherMajorMatrixType tm1 = m1; + + Scalar s1 = internal::random(), + s2 = internal::random(), + s3 = internal::random(); + + VERIFY_IS_APPROX(m3.noalias() = m1 * m2.adjoint(), m1 * m2.adjoint().eval()); + VERIFY_IS_APPROX(m3.noalias() = m1.adjoint() * square.adjoint(), m1.adjoint().eval() * square.adjoint().eval()); + VERIFY_IS_APPROX(m3.noalias() = m1.adjoint() * m2, m1.adjoint().eval() * m2); + VERIFY_IS_APPROX(m3.noalias() = (s1 * m1.adjoint()) * m2, (s1 * m1.adjoint()).eval() * m2); + VERIFY_IS_APPROX(m3.noalias() = ((s1 * m1).adjoint()) * m2, (numext::conj(s1) * m1.adjoint()).eval() * m2); + VERIFY_IS_APPROX(m3.noalias() = (- m1.adjoint() * s1) * (s3 * m2), (- m1.adjoint() * s1).eval() * (s3 * m2).eval()); + VERIFY_IS_APPROX(m3.noalias() = (s2 * m1.adjoint() * s1) * m2, (s2 * m1.adjoint() * s1).eval() * m2); + VERIFY_IS_APPROX(m3.noalias() = (-m1*s2) * s1*m2.adjoint(), (-m1*s2).eval() * (s1*m2.adjoint()).eval()); + + // a very tricky case where a scale factor has to be automatically conjugated: + VERIFY_IS_APPROX( m1.adjoint() * (s1*m2).conjugate(), (m1.adjoint()).eval() * ((s1*m2).conjugate()).eval()); + + + // test all possible conjugate combinations for the four matrix-vector product cases: + + VERIFY_IS_APPROX((-m1.conjugate() * s2) * (s1 * vc2), + (-m1.conjugate()*s2).eval() * (s1 * vc2).eval()); + VERIFY_IS_APPROX((-m1 * s2) * (s1 * vc2.conjugate()), + (-m1*s2).eval() * (s1 * vc2.conjugate()).eval()); + VERIFY_IS_APPROX((-m1.conjugate() * s2) * (s1 * vc2.conjugate()), + (-m1.conjugate()*s2).eval() * (s1 * vc2.conjugate()).eval()); + + VERIFY_IS_APPROX((s1 * vc2.transpose()) * (-m1.adjoint() * s2), + (s1 * vc2.transpose()).eval() * (-m1.adjoint()*s2).eval()); + VERIFY_IS_APPROX((s1 * vc2.adjoint()) * (-m1.transpose() * s2), + (s1 * vc2.adjoint()).eval() * (-m1.transpose()*s2).eval()); + VERIFY_IS_APPROX((s1 * vc2.adjoint()) * (-m1.adjoint() * s2), + (s1 * vc2.adjoint()).eval() * (-m1.adjoint()*s2).eval()); + + VERIFY_IS_APPROX((-m1.adjoint() * s2) * (s1 * v1.transpose()), + (-m1.adjoint()*s2).eval() * (s1 * v1.transpose()).eval()); + VERIFY_IS_APPROX((-m1.transpose() * s2) * (s1 * v1.adjoint()), + (-m1.transpose()*s2).eval() * (s1 * v1.adjoint()).eval()); + VERIFY_IS_APPROX((-m1.adjoint() * s2) * (s1 * v1.adjoint()), + (-m1.adjoint()*s2).eval() * (s1 * v1.adjoint()).eval()); + + VERIFY_IS_APPROX((s1 * v1) * (-m1.conjugate() * s2), + (s1 * v1).eval() * (-m1.conjugate()*s2).eval()); + VERIFY_IS_APPROX((s1 * v1.conjugate()) * (-m1 * s2), + (s1 * v1.conjugate()).eval() * (-m1*s2).eval()); + VERIFY_IS_APPROX((s1 * v1.conjugate()) * (-m1.conjugate() * s2), + (s1 * v1.conjugate()).eval() * (-m1.conjugate()*s2).eval()); + + VERIFY_IS_APPROX((-m1.adjoint() * s2) * (s1 * v1.adjoint()), + (-m1.adjoint()*s2).eval() * (s1 * v1.adjoint()).eval()); + + // test the vector-matrix product with non aligned starts + Index i = internal::random(0,m1.rows()-2); + Index j = internal::random(0,m1.cols()-2); + Index r = internal::random(1,m1.rows()-i); + Index c = internal::random(1,m1.cols()-j); + Index i2 = internal::random(0,m1.rows()-1); + Index j2 = internal::random(0,m1.cols()-1); + + VERIFY_IS_APPROX(m1.col(j2).adjoint() * m1.block(0,j,m1.rows(),c), m1.col(j2).adjoint().eval() * m1.block(0,j,m1.rows(),c).eval()); + VERIFY_IS_APPROX(m1.block(i,0,r,m1.cols()) * m1.row(i2).adjoint(), m1.block(i,0,r,m1.cols()).eval() * m1.row(i2).adjoint().eval()); + + // test negative strides + { + Map > map1(&m1(rows-1,cols-1), rows, cols, Stride(-m1.outerStride(),-1)); + Map > map2(&m2(rows-1,cols-1), rows, cols, Stride(-m2.outerStride(),-1)); + Map > mapv1(&v1(v1.size()-1), v1.size(), InnerStride<-1>(-1)); + Map > mapvc2(&vc2(vc2.size()-1), vc2.size(), InnerStride<-1>(-1)); + VERIFY_IS_APPROX(MatrixType(map1), m1.reverse()); + VERIFY_IS_APPROX(MatrixType(map2), m2.reverse()); + VERIFY_IS_APPROX(m3.noalias() = MatrixType(map1) * MatrixType(map2).adjoint(), m1.reverse() * m2.reverse().adjoint()); + VERIFY_IS_APPROX(m3.noalias() = map1 * map2.adjoint(), m1.reverse() * m2.reverse().adjoint()); + VERIFY_IS_APPROX(map1 * vc2, m1.reverse() * vc2); + VERIFY_IS_APPROX(m1 * mapvc2, m1 * mapvc2); + VERIFY_IS_APPROX(map1.adjoint() * v1.transpose(), m1.adjoint().reverse() * v1.transpose()); + VERIFY_IS_APPROX(m1.adjoint() * mapv1.transpose(), m1.adjoint() * v1.reverse().transpose()); + } + + // regression test + MatrixType tmp = m1 * m1.adjoint() * s1; + VERIFY_IS_APPROX(tmp, m1 * m1.adjoint() * s1); + + // regression test for bug 1343, assignment to arrays + Array a1 = m1 * vc2; + VERIFY_IS_APPROX(a1.matrix(),m1*vc2); + Array a2 = s1 * (m1 * vc2); + VERIFY_IS_APPROX(a2.matrix(),s1*m1*vc2); + Array a3 = v1 * m1; + VERIFY_IS_APPROX(a3.matrix(),v1*m1); + Array a4 = m1 * m2.adjoint(); + VERIFY_IS_APPROX(a4.matrix(),m1*m2.adjoint()); +} + +// Regression test for bug reported at http://forum.kde.org/viewtopic.php?f=74&t=96947 +void mat_mat_scalar_scalar_product() +{ + Eigen::Matrix2Xd dNdxy(2, 3); + dNdxy << -0.5, 0.5, 0, + -0.3, 0, 0.3; + double det = 6.0, wt = 0.5; + VERIFY_IS_APPROX(dNdxy.transpose()*dNdxy*det*wt, det*wt*dNdxy.transpose()*dNdxy); +} + +template +void zero_sized_objects(const MatrixType& m) +{ + typedef typename MatrixType::Scalar Scalar; + const int PacketSize = internal::packet_traits::size; + const int PacketSize1 = PacketSize>1 ? PacketSize-1 : 1; + Index rows = m.rows(); + Index cols = m.cols(); + + { + MatrixType res, a(rows,0), b(0,cols); + VERIFY_IS_APPROX( (res=a*b), MatrixType::Zero(rows,cols) ); + VERIFY_IS_APPROX( (res=a*a.transpose()), MatrixType::Zero(rows,rows) ); + VERIFY_IS_APPROX( (res=b.transpose()*b), MatrixType::Zero(cols,cols) ); + VERIFY_IS_APPROX( (res=b.transpose()*a.transpose()), MatrixType::Zero(cols,rows) ); + } + + { + MatrixType res, a(rows,cols), b(cols,0); + res = a*b; + VERIFY(res.rows()==rows && res.cols()==0); + b.resize(0,rows); + res = b*a; + VERIFY(res.rows()==0 && res.cols()==cols); + } + + { + Matrix a; + Matrix b; + Matrix res; + VERIFY_IS_APPROX( (res=a*b), MatrixType::Zero(PacketSize,1) ); + VERIFY_IS_APPROX( (res=a.lazyProduct(b)), MatrixType::Zero(PacketSize,1) ); + } + + { + Matrix a; + Matrix b; + Matrix res; + VERIFY_IS_APPROX( (res=a*b), MatrixType::Zero(PacketSize1,1) ); + VERIFY_IS_APPROX( (res=a.lazyProduct(b)), MatrixType::Zero(PacketSize1,1) ); + } + + { + Matrix a(PacketSize,0); + Matrix b(0,1); + Matrix res; + VERIFY_IS_APPROX( (res=a*b), MatrixType::Zero(PacketSize,1) ); + VERIFY_IS_APPROX( (res=a.lazyProduct(b)), MatrixType::Zero(PacketSize,1) ); + } + + { + Matrix a(PacketSize1,0); + Matrix b(0,1); + Matrix res; + VERIFY_IS_APPROX( (res=a*b), MatrixType::Zero(PacketSize1,1) ); + VERIFY_IS_APPROX( (res=a.lazyProduct(b)), MatrixType::Zero(PacketSize1,1) ); + } +} + +template +void bug_127() +{ + // Bug 127 + // + // a product of the form lhs*rhs with + // + // lhs: + // rows = 1, cols = 4 + // RowsAtCompileTime = 1, ColsAtCompileTime = -1 + // MaxRowsAtCompileTime = 1, MaxColsAtCompileTime = 5 + // + // rhs: + // rows = 4, cols = 0 + // RowsAtCompileTime = -1, ColsAtCompileTime = -1 + // MaxRowsAtCompileTime = 5, MaxColsAtCompileTime = 1 + // + // was failing on a runtime assertion, because it had been mis-compiled as a dot product because Product.h was using the + // max-sizes to detect size 1 indicating vectors, and that didn't account for 0-sized object with max-size 1. + + Matrix a(1,4); + Matrix b(4,0); + a*b; +} + +template void bug_817() +{ + ArrayXXf B = ArrayXXf::Random(10,10), C; + VectorXf x = VectorXf::Random(10); + C = (x.transpose()*B.matrix()); + B = (x.transpose()*B.matrix()); + VERIFY_IS_APPROX(B,C); +} + +template +void unaligned_objects() +{ + // Regression test for the bug reported here: + // http://forum.kde.org/viewtopic.php?f=74&t=107541 + // Recall the matrix*vector kernel avoid unaligned loads by loading two packets and then reassemble then. + // There was a mistake in the computation of the valid range for fully unaligned objects: in some rare cases, + // memory was read outside the allocated matrix memory. Though the values were not used, this might raise segfault. + for(int m=450;m<460;++m) + { + for(int n=8;n<12;++n) + { + MatrixXf M(m, n); + VectorXf v1(n), r1(500); + RowVectorXf v2(m), r2(16); + + M.setRandom(); + v1.setRandom(); + v2.setRandom(); + for(int o=0; o<4; ++o) + { + r1.segment(o,m).noalias() = M * v1; + VERIFY_IS_APPROX(r1.segment(o,m), M * MatrixXf(v1)); + r2.segment(o,n).noalias() = v2 * M; + VERIFY_IS_APPROX(r2.segment(o,n), MatrixXf(v2) * M); + } + } + } +} + +template +EIGEN_DONT_INLINE +Index test_compute_block_size(Index m, Index n, Index k) +{ + Index mc(m), nc(n), kc(k); + internal::computeProductBlockingSizes(kc, mc, nc); + return kc+mc+nc; +} + +template +Index compute_block_size() +{ + Index ret = 0; + ret += test_compute_block_size(0,1,1); + ret += test_compute_block_size(1,0,1); + ret += test_compute_block_size(1,1,0); + ret += test_compute_block_size(0,0,1); + ret += test_compute_block_size(0,1,0); + ret += test_compute_block_size(1,0,0); + ret += test_compute_block_size(0,0,0); + return ret; +} + +template +void aliasing_with_resize() +{ + Index m = internal::random(10,50); + Index n = internal::random(10,50); + MatrixXd A, B, C(m,n), D(m,m); + VectorXd a, b, c(n); + C.setRandom(); + D.setRandom(); + c.setRandom(); + double s = internal::random(1,10); + + A = C; + B = A * A.transpose(); + A = A * A.transpose(); + VERIFY_IS_APPROX(A,B); + + A = C; + B = (A * A.transpose())/s; + A = (A * A.transpose())/s; + VERIFY_IS_APPROX(A,B); + + A = C; + B = (A * A.transpose()) + D; + A = (A * A.transpose()) + D; + VERIFY_IS_APPROX(A,B); + + A = C; + B = D + (A * A.transpose()); + A = D + (A * A.transpose()); + VERIFY_IS_APPROX(A,B); + + A = C; + B = s * (A * A.transpose()); + A = s * (A * A.transpose()); + VERIFY_IS_APPROX(A,B); + + A = C; + a = c; + b = (A * a)/s; + a = (A * a)/s; + VERIFY_IS_APPROX(a,b); +} + +template +void bug_1308() +{ + int n = 10; + MatrixXd r(n,n); + VectorXd v = VectorXd::Random(n); + r = v * RowVectorXd::Ones(n); + VERIFY_IS_APPROX(r, v.rowwise().replicate(n)); + r = VectorXd::Ones(n) * v.transpose(); + VERIFY_IS_APPROX(r, v.rowwise().replicate(n).transpose()); + + Matrix4d ones44 = Matrix4d::Ones(); + Matrix4d m44 = Matrix4d::Ones() * Matrix4d::Ones(); + VERIFY_IS_APPROX(m44,Matrix4d::Constant(4)); + VERIFY_IS_APPROX(m44.noalias()=ones44*Matrix4d::Ones(), Matrix4d::Constant(4)); + VERIFY_IS_APPROX(m44.noalias()=ones44.transpose()*Matrix4d::Ones(), Matrix4d::Constant(4)); + VERIFY_IS_APPROX(m44.noalias()=Matrix4d::Ones()*ones44, Matrix4d::Constant(4)); + VERIFY_IS_APPROX(m44.noalias()=Matrix4d::Ones()*ones44.transpose(), Matrix4d::Constant(4)); + + typedef Matrix RMatrix4d; + RMatrix4d r44 = Matrix4d::Ones() * Matrix4d::Ones(); + VERIFY_IS_APPROX(r44,Matrix4d::Constant(4)); + VERIFY_IS_APPROX(r44.noalias()=ones44*Matrix4d::Ones(), Matrix4d::Constant(4)); + VERIFY_IS_APPROX(r44.noalias()=ones44.transpose()*Matrix4d::Ones(), Matrix4d::Constant(4)); + VERIFY_IS_APPROX(r44.noalias()=Matrix4d::Ones()*ones44, Matrix4d::Constant(4)); + VERIFY_IS_APPROX(r44.noalias()=Matrix4d::Ones()*ones44.transpose(), Matrix4d::Constant(4)); + VERIFY_IS_APPROX(r44.noalias()=ones44*RMatrix4d::Ones(), Matrix4d::Constant(4)); + VERIFY_IS_APPROX(r44.noalias()=ones44.transpose()*RMatrix4d::Ones(), Matrix4d::Constant(4)); + VERIFY_IS_APPROX(r44.noalias()=RMatrix4d::Ones()*ones44, Matrix4d::Constant(4)); + VERIFY_IS_APPROX(r44.noalias()=RMatrix4d::Ones()*ones44.transpose(), Matrix4d::Constant(4)); + +// RowVector4d r4; + m44.setOnes(); + r44.setZero(); + VERIFY_IS_APPROX(r44.noalias() += m44.row(0).transpose() * RowVector4d::Ones(), ones44); + r44.setZero(); + VERIFY_IS_APPROX(r44.noalias() += m44.col(0) * RowVector4d::Ones(), ones44); + r44.setZero(); + VERIFY_IS_APPROX(r44.noalias() += Vector4d::Ones() * m44.row(0), ones44); + r44.setZero(); + VERIFY_IS_APPROX(r44.noalias() += Vector4d::Ones() * m44.col(0).transpose(), ones44); +} + +EIGEN_DECLARE_TEST(product_extra) +{ + for(int i = 0; i < g_repeat; i++) { + CALL_SUBTEST_1( product_extra(MatrixXf(internal::random(1,EIGEN_TEST_MAX_SIZE), internal::random(1,EIGEN_TEST_MAX_SIZE))) ); + CALL_SUBTEST_2( product_extra(MatrixXd(internal::random(1,EIGEN_TEST_MAX_SIZE), internal::random(1,EIGEN_TEST_MAX_SIZE))) ); + CALL_SUBTEST_2( mat_mat_scalar_scalar_product() ); + CALL_SUBTEST_3( product_extra(MatrixXcf(internal::random(1,EIGEN_TEST_MAX_SIZE/2), internal::random(1,EIGEN_TEST_MAX_SIZE/2))) ); + CALL_SUBTEST_4( product_extra(MatrixXcd(internal::random(1,EIGEN_TEST_MAX_SIZE/2), internal::random(1,EIGEN_TEST_MAX_SIZE/2))) ); + CALL_SUBTEST_1( zero_sized_objects(MatrixXf(internal::random(1,EIGEN_TEST_MAX_SIZE), internal::random(1,EIGEN_TEST_MAX_SIZE))) ); + } + CALL_SUBTEST_5( bug_127<0>() ); + CALL_SUBTEST_5( bug_817<0>() ); + CALL_SUBTEST_5( bug_1308<0>() ); + CALL_SUBTEST_6( unaligned_objects<0>() ); + CALL_SUBTEST_7( compute_block_size() ); + CALL_SUBTEST_7( compute_block_size() ); + CALL_SUBTEST_7( compute_block_size >() ); + CALL_SUBTEST_8( aliasing_with_resize() ); + +} diff --git a/include/eigen/test/product_large.cpp b/include/eigen/test/product_large.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3d0204b5fba4f16c3c5dbe386dcbc34e21ff9e50 --- /dev/null +++ b/include/eigen/test/product_large.cpp @@ -0,0 +1,131 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2006-2008 Benoit Jacob +// +// 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/. + +#include "product.h" +#include + +template +void test_aliasing() +{ + int rows = internal::random(1,12); + int cols = internal::random(1,12); + typedef Matrix MatrixType; + typedef Matrix VectorType; + VectorType x(cols); x.setRandom(); + VectorType z(x); + VectorType y(rows); y.setZero(); + MatrixType A(rows,cols); A.setRandom(); + // CwiseBinaryOp + VERIFY_IS_APPROX(x = y + A*x, A*z); // OK because "y + A*x" is marked as "assume-aliasing" + x = z; + // CwiseUnaryOp + VERIFY_IS_APPROX(x = T(1.)*(A*x), A*z); // OK because 1*(A*x) is replaced by (1*A*x) which is a Product<> expression + x = z; + // VERIFY_IS_APPROX(x = y-A*x, -A*z); // Not OK in 3.3 because x is resized before A*x gets evaluated + x = z; +} + +template +void product_large_regressions() +{ + { + // test a specific issue in DiagonalProduct + int N = 1000000; + VectorXf v = VectorXf::Ones(N); + MatrixXf m = MatrixXf::Ones(N,3); + m = (v+v).asDiagonal() * m; + VERIFY_IS_APPROX(m, MatrixXf::Constant(N,3,2)); + } + + { + // test deferred resizing in Matrix::operator= + MatrixXf a = MatrixXf::Random(10,4), b = MatrixXf::Random(4,10), c = a; + VERIFY_IS_APPROX((a = a * b), (c * b).eval()); + } + + { + // check the functions to setup blocking sizes compile and do not segfault + // FIXME check they do what they are supposed to do !! + std::ptrdiff_t l1 = internal::random(10000,20000); + std::ptrdiff_t l2 = internal::random(100000,200000); + std::ptrdiff_t l3 = internal::random(1000000,2000000); + setCpuCacheSizes(l1,l2,l3); + VERIFY(l1==l1CacheSize()); + VERIFY(l2==l2CacheSize()); + std::ptrdiff_t k1 = internal::random(10,100)*16; + std::ptrdiff_t m1 = internal::random(10,100)*16; + std::ptrdiff_t n1 = internal::random(10,100)*16; + // only makes sure it compiles fine + internal::computeProductBlockingSizes(k1,m1,n1,1); + } + + { + // test regression in row-vector by matrix (bad Map type) + MatrixXf mat1(10,32); mat1.setRandom(); + MatrixXf mat2(32,32); mat2.setRandom(); + MatrixXf r1 = mat1.row(2)*mat2.transpose(); + VERIFY_IS_APPROX(r1, (mat1.row(2)*mat2.transpose()).eval()); + + MatrixXf r2 = mat1.row(2)*mat2; + VERIFY_IS_APPROX(r2, (mat1.row(2)*mat2).eval()); + } + + { + Eigen::MatrixXd A(10,10), B, C; + A.setRandom(); + C = A; + for(int k=0; k<79; ++k) + C = C * A; + B.noalias() = (((A*A)*(A*A))*((A*A)*(A*A))*((A*A)*(A*A))*((A*A)*(A*A))*((A*A)*(A*A)) * ((A*A)*(A*A))*((A*A)*(A*A))*((A*A)*(A*A))*((A*A)*(A*A))*((A*A)*(A*A))) + * (((A*A)*(A*A))*((A*A)*(A*A))*((A*A)*(A*A))*((A*A)*(A*A))*((A*A)*(A*A)) * ((A*A)*(A*A))*((A*A)*(A*A))*((A*A)*(A*A))*((A*A)*(A*A))*((A*A)*(A*A))); + VERIFY_IS_APPROX(B,C); + } +} + +template +void bug_1622() { + typedef Matrix Mat2X; + Mat2X x(2,2); x.setRandom(); + MatrixXd y(2,2); y.setRandom(); + const Mat2X K1 = x * y.inverse(); + const Matrix2d K2 = x * y.inverse(); + VERIFY_IS_APPROX(K1,K2); +} + +EIGEN_DECLARE_TEST(product_large) +{ + for(int i = 0; i < g_repeat; i++) { + CALL_SUBTEST_1( product(MatrixXf(internal::random(1,EIGEN_TEST_MAX_SIZE), internal::random(1,EIGEN_TEST_MAX_SIZE))) ); + CALL_SUBTEST_2( product(MatrixXd(internal::random(1,EIGEN_TEST_MAX_SIZE), internal::random(1,EIGEN_TEST_MAX_SIZE))) ); + CALL_SUBTEST_2( product(MatrixXd(internal::random(1,10), internal::random(1,10))) ); + + CALL_SUBTEST_3( product(MatrixXi(internal::random(1,EIGEN_TEST_MAX_SIZE), internal::random(1,EIGEN_TEST_MAX_SIZE))) ); + CALL_SUBTEST_4( product(MatrixXcf(internal::random(1,EIGEN_TEST_MAX_SIZE/2), internal::random(1,EIGEN_TEST_MAX_SIZE/2))) ); + CALL_SUBTEST_5( product(Matrix(internal::random(1,EIGEN_TEST_MAX_SIZE), internal::random(1,EIGEN_TEST_MAX_SIZE))) ); + + CALL_SUBTEST_1( test_aliasing() ); + + CALL_SUBTEST_6( bug_1622<1>() ); + + CALL_SUBTEST_7( product(MatrixXcd(internal::random(1,EIGEN_TEST_MAX_SIZE/2), internal::random(1,EIGEN_TEST_MAX_SIZE/2))) ); + CALL_SUBTEST_8( product(Matrix(internal::random(1,EIGEN_TEST_MAX_SIZE), internal::random(1,EIGEN_TEST_MAX_SIZE))) ); + CALL_SUBTEST_9( product(Matrix,Dynamic,Dynamic,RowMajor>(internal::random(1,EIGEN_TEST_MAX_SIZE), internal::random(1,EIGEN_TEST_MAX_SIZE))) ); + CALL_SUBTEST_10( product(Matrix,Dynamic,Dynamic,RowMajor>(internal::random(1,EIGEN_TEST_MAX_SIZE), internal::random(1,EIGEN_TEST_MAX_SIZE))) ); + } + + CALL_SUBTEST_6( product_large_regressions<0>() ); + + // Regression test for bug 714: +#if defined EIGEN_HAS_OPENMP + omp_set_dynamic(1); + for(int i = 0; i < g_repeat; i++) { + CALL_SUBTEST_6( product(Matrix(internal::random(1,EIGEN_TEST_MAX_SIZE), internal::random(1,EIGEN_TEST_MAX_SIZE))) ); + } +#endif +} diff --git a/include/eigen/test/product_mmtr.cpp b/include/eigen/test/product_mmtr.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8f8c5fe1f9c96eb0f8f53dfccbaf34353eb84c0d --- /dev/null +++ b/include/eigen/test/product_mmtr.cpp @@ -0,0 +1,106 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2010-2017 Gael Guennebaud +// +// 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/. + +#include "main.h" + +#define CHECK_MMTR(DEST, TRI, OP) { \ + ref3 = DEST; \ + ref2 = ref1 = DEST; \ + DEST.template triangularView() OP; \ + ref1 OP; \ + ref2.template triangularView() \ + = ref1.template triangularView(); \ + VERIFY_IS_APPROX(DEST,ref2); \ + \ + DEST = ref3; \ + ref3 = ref2; \ + ref3.diagonal() = DEST.diagonal(); \ + DEST.template triangularView() OP; \ + VERIFY_IS_APPROX(DEST,ref3); \ + } + +template void mmtr(int size) +{ + typedef Matrix MatrixColMaj; + typedef Matrix MatrixRowMaj; + + DenseIndex othersize = internal::random(1,200); + + MatrixColMaj matc = MatrixColMaj::Zero(size, size); + MatrixRowMaj matr = MatrixRowMaj::Zero(size, size); + MatrixColMaj ref1(size, size), ref2(size, size), ref3(size,size); + + MatrixColMaj soc(size,othersize); soc.setRandom(); + MatrixColMaj osc(othersize,size); osc.setRandom(); + MatrixRowMaj sor(size,othersize); sor.setRandom(); + MatrixRowMaj osr(othersize,size); osr.setRandom(); + MatrixColMaj sqc(size,size); sqc.setRandom(); + MatrixRowMaj sqr(size,size); sqr.setRandom(); + + Scalar s = internal::random(); + + CHECK_MMTR(matc, Lower, = s*soc*sor.adjoint()); + CHECK_MMTR(matc, Upper, = s*(soc*soc.adjoint())); + CHECK_MMTR(matr, Lower, = s*soc*soc.adjoint()); + CHECK_MMTR(matr, Upper, = soc*(s*sor.adjoint())); + + CHECK_MMTR(matc, Lower, += s*soc*soc.adjoint()); + CHECK_MMTR(matc, Upper, += s*(soc*sor.transpose())); + CHECK_MMTR(matr, Lower, += s*sor*soc.adjoint()); + CHECK_MMTR(matr, Upper, += soc*(s*soc.adjoint())); + + CHECK_MMTR(matc, Lower, -= s*soc*soc.adjoint()); + CHECK_MMTR(matc, Upper, -= s*(osc.transpose()*osc.conjugate())); + CHECK_MMTR(matr, Lower, -= s*soc*soc.adjoint()); + CHECK_MMTR(matr, Upper, -= soc*(s*soc.adjoint())); + + CHECK_MMTR(matc, Lower, -= s*sqr*sqc.template triangularView()); + CHECK_MMTR(matc, Upper, = s*sqc*sqr.template triangularView()); + CHECK_MMTR(matc, Lower, += s*sqr*sqc.template triangularView()); + CHECK_MMTR(matc, Upper, = s*sqc*sqc.template triangularView()); + + CHECK_MMTR(matc, Lower, = (s*sqr).template triangularView()*sqc); + CHECK_MMTR(matc, Upper, -= (s*sqc).template triangularView()*sqc); + CHECK_MMTR(matc, Lower, = (s*sqr).template triangularView()*sqc); + CHECK_MMTR(matc, Upper, += (s*sqc).template triangularView()*sqc); + + // check aliasing + ref2 = ref1 = matc; + ref1 = sqc.adjoint() * matc * sqc; + ref2.template triangularView() = ref1.template triangularView(); + matc.template triangularView() = sqc.adjoint() * matc * sqc; + VERIFY_IS_APPROX(matc, ref2); + + ref2 = ref1 = matc; + ref1 = sqc * matc * sqc.adjoint(); + ref2.template triangularView() = ref1.template triangularView(); + matc.template triangularView() = sqc * matc * sqc.adjoint(); + VERIFY_IS_APPROX(matc, ref2); + + // destination with a non-default inner-stride + // see bug 1741 + { + typedef Matrix MatrixX; + MatrixX buffer(2*size,2*size); + Map > map1(buffer.data(),size,size,Stride(2*size,2)); + buffer.setZero(); + CHECK_MMTR(map1, Lower, = s*soc*sor.adjoint()); + } +} + +EIGEN_DECLARE_TEST(product_mmtr) +{ + for(int i = 0; i < g_repeat ; i++) + { + CALL_SUBTEST_1((mmtr(internal::random(1,EIGEN_TEST_MAX_SIZE)))); + CALL_SUBTEST_2((mmtr(internal::random(1,EIGEN_TEST_MAX_SIZE)))); + CALL_SUBTEST_3((mmtr >(internal::random(1,EIGEN_TEST_MAX_SIZE/2)))); + CALL_SUBTEST_4((mmtr >(internal::random(1,EIGEN_TEST_MAX_SIZE/2)))); + } +} diff --git a/include/eigen/test/product_notemporary.cpp b/include/eigen/test/product_notemporary.cpp new file mode 100644 index 0000000000000000000000000000000000000000..20cb7c0801bb468296afd468e20fa1e57b189db2 --- /dev/null +++ b/include/eigen/test/product_notemporary.cpp @@ -0,0 +1,209 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2006-2008 Benoit Jacob +// +// 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/. + +#define TEST_ENABLE_TEMPORARY_TRACKING + +#include "main.h" + +template +void check_scalar_multiple3(Dst &dst, const Lhs& A, const Rhs& B) +{ + VERIFY_EVALUATION_COUNT( (dst.noalias() = A * B), 0); + VERIFY_IS_APPROX( dst, (A.eval() * B.eval()).eval() ); + VERIFY_EVALUATION_COUNT( (dst.noalias() += A * B), 0); + VERIFY_IS_APPROX( dst, 2*(A.eval() * B.eval()).eval() ); + VERIFY_EVALUATION_COUNT( (dst.noalias() -= A * B), 0); + VERIFY_IS_APPROX( dst, (A.eval() * B.eval()).eval() ); +} + +template +void check_scalar_multiple2(Dst &dst, const Lhs& A, const Rhs& B, S2 s2) +{ + CALL_SUBTEST( check_scalar_multiple3(dst, A, B) ); + CALL_SUBTEST( check_scalar_multiple3(dst, A, -B) ); + CALL_SUBTEST( check_scalar_multiple3(dst, A, s2*B) ); + CALL_SUBTEST( check_scalar_multiple3(dst, A, B*s2) ); + CALL_SUBTEST( check_scalar_multiple3(dst, A, (B*s2).conjugate()) ); +} + +template +void check_scalar_multiple1(Dst &dst, const Lhs& A, const Rhs& B, S1 s1, S2 s2) +{ + CALL_SUBTEST( check_scalar_multiple2(dst, A, B, s2) ); + CALL_SUBTEST( check_scalar_multiple2(dst, -A, B, s2) ); + CALL_SUBTEST( check_scalar_multiple2(dst, s1*A, B, s2) ); + CALL_SUBTEST( check_scalar_multiple2(dst, A*s1, B, s2) ); + CALL_SUBTEST( check_scalar_multiple2(dst, (A*s1).conjugate(), B, s2) ); +} + +template void product_notemporary(const MatrixType& m) +{ + /* This test checks the number of temporaries created + * during the evaluation of a complex expression */ + typedef typename MatrixType::Scalar Scalar; + typedef typename MatrixType::RealScalar RealScalar; + typedef Matrix RowVectorType; + typedef Matrix ColVectorType; + typedef Matrix ColMajorMatrixType; + typedef Matrix RowMajorMatrixType; + + Index rows = m.rows(); + Index cols = m.cols(); + + ColMajorMatrixType m1 = MatrixType::Random(rows, cols), + m2 = MatrixType::Random(rows, cols), + m3(rows, cols); + RowVectorType rv1 = RowVectorType::Random(rows), rvres(rows); + ColVectorType cv1 = ColVectorType::Random(cols), cvres(cols); + RowMajorMatrixType rm3(rows, cols); + + Scalar s1 = internal::random(), + s2 = internal::random(), + s3 = internal::random(); + + Index c0 = internal::random(4,cols-8), + c1 = internal::random(8,cols-c0), + r0 = internal::random(4,cols-8), + r1 = internal::random(8,rows-r0); + + VERIFY_EVALUATION_COUNT( m3 = (m1 * m2.adjoint()), 1); + VERIFY_EVALUATION_COUNT( m3 = (m1 * m2.adjoint()).transpose(), 1); + VERIFY_EVALUATION_COUNT( m3.noalias() = m1 * m2.adjoint(), 0); + + VERIFY_EVALUATION_COUNT( m3 = s1 * (m1 * m2.transpose()), 1); +// VERIFY_EVALUATION_COUNT( m3 = m3 + s1 * (m1 * m2.transpose()), 1); + VERIFY_EVALUATION_COUNT( m3.noalias() = s1 * (m1 * m2.transpose()), 0); + + VERIFY_EVALUATION_COUNT( m3 = m3 + (m1 * m2.adjoint()), 1); + VERIFY_EVALUATION_COUNT( m3 = m3 - (m1 * m2.adjoint()), 1); + + VERIFY_EVALUATION_COUNT( m3 = m3 + (m1 * m2.adjoint()).transpose(), 1); + VERIFY_EVALUATION_COUNT( m3.noalias() = m3 + m1 * m2.transpose(), 0); + VERIFY_EVALUATION_COUNT( m3.noalias() += m3 + m1 * m2.transpose(), 0); + VERIFY_EVALUATION_COUNT( m3.noalias() -= m3 + m1 * m2.transpose(), 0); + VERIFY_EVALUATION_COUNT( m3.noalias() = m3 - m1 * m2.transpose(), 0); + VERIFY_EVALUATION_COUNT( m3.noalias() += m3 - m1 * m2.transpose(), 0); + VERIFY_EVALUATION_COUNT( m3.noalias() -= m3 - m1 * m2.transpose(), 0); + + VERIFY_EVALUATION_COUNT( m3.noalias() = s1 * m1 * s2 * m2.adjoint(), 0); + VERIFY_EVALUATION_COUNT( m3.noalias() = s1 * m1 * s2 * (m1*s3+m2*s2).adjoint(), 1); + VERIFY_EVALUATION_COUNT( m3.noalias() = (s1 * m1).adjoint() * s2 * m2, 0); + VERIFY_EVALUATION_COUNT( m3.noalias() += s1 * (-m1*s3).adjoint() * (s2 * m2 * s3), 0); + VERIFY_EVALUATION_COUNT( m3.noalias() -= s1 * (m1.transpose() * m2), 0); + + VERIFY_EVALUATION_COUNT(( m3.block(r0,r0,r1,r1).noalias() += -m1.block(r0,c0,r1,c1) * (s2*m2.block(r0,c0,r1,c1)).adjoint() ), 0); + VERIFY_EVALUATION_COUNT(( m3.block(r0,r0,r1,r1).noalias() -= s1 * m1.block(r0,c0,r1,c1) * m2.block(c0,r0,c1,r1) ), 0); + + // NOTE this is because the Block expression is not handled yet by our expression analyser + VERIFY_EVALUATION_COUNT(( m3.block(r0,r0,r1,r1).noalias() = s1 * m1.block(r0,c0,r1,c1) * (s1*m2).block(c0,r0,c1,r1) ), 1); + + VERIFY_EVALUATION_COUNT( m3.noalias() -= (s1 * m1).template triangularView() * m2, 0); + VERIFY_EVALUATION_COUNT( rm3.noalias() = (s1 * m1.adjoint()).template triangularView() * (m2+m2), 1); + VERIFY_EVALUATION_COUNT( rm3.noalias() = (s1 * m1.adjoint()).template triangularView() * m2.adjoint(), 0); + + VERIFY_EVALUATION_COUNT( m3.template triangularView() = (m1 * m2.adjoint()), 0); + VERIFY_EVALUATION_COUNT( m3.template triangularView() -= (m1 * m2.adjoint()), 0); + + // NOTE this is because the blas_traits require innerstride==1 to avoid a temporary, but that doesn't seem to be actually needed for the triangular products + VERIFY_EVALUATION_COUNT( rm3.col(c0).noalias() = (s1 * m1.adjoint()).template triangularView() * (s2*m2.row(c0)).adjoint(), 1); + + VERIFY_EVALUATION_COUNT( m1.template triangularView().solveInPlace(m3), 0); + VERIFY_EVALUATION_COUNT( m1.adjoint().template triangularView().solveInPlace(m3.transpose()), 0); + + VERIFY_EVALUATION_COUNT( m3.noalias() -= (s1 * m1).adjoint().template selfadjointView() * (-m2*s3).adjoint(), 0); + VERIFY_EVALUATION_COUNT( m3.noalias() = s2 * m2.adjoint() * (s1 * m1.adjoint()).template selfadjointView(), 0); + VERIFY_EVALUATION_COUNT( rm3.noalias() = (s1 * m1.adjoint()).template selfadjointView() * m2.adjoint(), 0); + + // NOTE this is because the blas_traits require innerstride==1 to avoid a temporary, but that doesn't seem to be actually needed for the triangular products + VERIFY_EVALUATION_COUNT( m3.col(c0).noalias() = (s1 * m1).adjoint().template selfadjointView() * (-m2.row(c0)*s3).adjoint(), 1); + VERIFY_EVALUATION_COUNT( m3.col(c0).noalias() -= (s1 * m1).adjoint().template selfadjointView() * (-m2.row(c0)*s3).adjoint(), 1); + + VERIFY_EVALUATION_COUNT( m3.block(r0,c0,r1,c1).noalias() += m1.block(r0,r0,r1,r1).template selfadjointView() * (s1*m2.block(r0,c0,r1,c1)), 0); + VERIFY_EVALUATION_COUNT( m3.block(r0,c0,r1,c1).noalias() = m1.block(r0,r0,r1,r1).template selfadjointView() * m2.block(r0,c0,r1,c1), 0); + + VERIFY_EVALUATION_COUNT( m3.template selfadjointView().rankUpdate(m2.adjoint()), 0); + + // Here we will get 1 temporary for each resize operation of the lhs operator; resize(r1,c1) would lead to zero temporaries + m3.resize(1,1); + VERIFY_EVALUATION_COUNT( m3.noalias() = m1.block(r0,r0,r1,r1).template selfadjointView() * m2.block(r0,c0,r1,c1), 1); + m3.resize(1,1); + VERIFY_EVALUATION_COUNT( m3.noalias() = m1.block(r0,r0,r1,r1).template triangularView() * m2.block(r0,c0,r1,c1), 1); + + // Zero temporaries for lazy products ... + m3.setRandom(rows,cols); + VERIFY_EVALUATION_COUNT( Scalar tmp = 0; tmp += Scalar(RealScalar(1)) / (m3.transpose().lazyProduct(m3)).diagonal().sum(), 0 ); + VERIFY_EVALUATION_COUNT( m3.noalias() = m1.conjugate().lazyProduct(m2.conjugate()), 0); + + // ... and even no temporary for even deeply (>=2) nested products + VERIFY_EVALUATION_COUNT( Scalar tmp = 0; tmp += Scalar(RealScalar(1)) / (m3.transpose() * m3).diagonal().sum(), 0 ); + VERIFY_EVALUATION_COUNT( Scalar tmp = 0; tmp += Scalar(RealScalar(1)) / (m3.transpose() * m3).diagonal().array().abs().sum(), 0 ); + + // Zero temporaries for ... CoeffBasedProductMode + VERIFY_EVALUATION_COUNT( m3.col(0).template head<5>() * m3.col(0).transpose() + m3.col(0).template head<5>() * m3.col(0).transpose(), 0 ); + + // Check matrix * vectors + VERIFY_EVALUATION_COUNT( cvres.noalias() = m1 * cv1, 0 ); + VERIFY_EVALUATION_COUNT( cvres.noalias() -= m1 * cv1, 0 ); + VERIFY_EVALUATION_COUNT( cvres.noalias() -= m1 * m2.col(0), 0 ); + VERIFY_EVALUATION_COUNT( cvres.noalias() -= m1 * rv1.adjoint(), 0 ); + VERIFY_EVALUATION_COUNT( cvres.noalias() -= m1 * m2.row(0).transpose(), 0 ); + + VERIFY_EVALUATION_COUNT( cvres.noalias() = (m1+m1) * cv1, 0 ); + VERIFY_EVALUATION_COUNT( cvres.noalias() = (rm3+rm3) * cv1, 0 ); + VERIFY_EVALUATION_COUNT( cvres.noalias() = (m1+m1) * (m1*cv1), 1 ); + VERIFY_EVALUATION_COUNT( cvres.noalias() = (rm3+rm3) * (m1*cv1), 1 ); + + // Check outer products + #ifdef EIGEN_ALLOCA + bool temp_via_alloca = m3.rows()*sizeof(Scalar) <= EIGEN_STACK_ALLOCATION_LIMIT; + #else + bool temp_via_alloca = false; + #endif + m3 = cv1 * rv1; + VERIFY_EVALUATION_COUNT( m3.noalias() = cv1 * rv1, 0 ); + VERIFY_EVALUATION_COUNT( m3.noalias() = (cv1+cv1) * (rv1+rv1), temp_via_alloca ? 0 : 1 ); + VERIFY_EVALUATION_COUNT( m3.noalias() = (m1*cv1) * (rv1), 1 ); + VERIFY_EVALUATION_COUNT( m3.noalias() += (m1*cv1) * (rv1), 1 ); + rm3 = cv1 * rv1; + VERIFY_EVALUATION_COUNT( rm3.noalias() = cv1 * rv1, 0 ); + VERIFY_EVALUATION_COUNT( rm3.noalias() = (cv1+cv1) * (rv1+rv1), temp_via_alloca ? 0 : 1 ); + VERIFY_EVALUATION_COUNT( rm3.noalias() = (cv1) * (rv1 * m1), 1 ); + VERIFY_EVALUATION_COUNT( rm3.noalias() -= (cv1) * (rv1 * m1), 1 ); + VERIFY_EVALUATION_COUNT( rm3.noalias() = (m1*cv1) * (rv1 * m1), 2 ); + VERIFY_EVALUATION_COUNT( rm3.noalias() += (m1*cv1) * (rv1 * m1), 2 ); + + // Check nested products + VERIFY_EVALUATION_COUNT( cvres.noalias() = m1.adjoint() * m1 * cv1, 1 ); + VERIFY_EVALUATION_COUNT( rvres.noalias() = rv1 * (m1 * m2.adjoint()), 1 ); + + // exhaustively check all scalar multiple combinations: + { + // Generic path: + check_scalar_multiple1(m3, m1, m2, s1, s2); + // Force fall back to coeff-based: + typename ColMajorMatrixType::BlockXpr m3_blck = m3.block(r0,r0,1,1); + check_scalar_multiple1(m3_blck, m1.block(r0,c0,1,1), m2.block(c0,r0,1,1), s1, s2); + } +} + +EIGEN_DECLARE_TEST(product_notemporary) +{ + int s; + for(int i = 0; i < g_repeat; i++) { + s = internal::random(16,EIGEN_TEST_MAX_SIZE); + CALL_SUBTEST_1( product_notemporary(MatrixXf(s, s)) ); + CALL_SUBTEST_2( product_notemporary(MatrixXd(s, s)) ); + TEST_SET_BUT_UNUSED_VARIABLE(s) + + s = internal::random(16,EIGEN_TEST_MAX_SIZE/2); + CALL_SUBTEST_3( product_notemporary(MatrixXcf(s,s)) ); + CALL_SUBTEST_4( product_notemporary(MatrixXcd(s,s)) ); + TEST_SET_BUT_UNUSED_VARIABLE(s) + } +} diff --git a/include/eigen/test/product_small.cpp b/include/eigen/test/product_small.cpp new file mode 100644 index 0000000000000000000000000000000000000000..fec7f5658f9b6c920740e5ac8aec7a91a3beddda --- /dev/null +++ b/include/eigen/test/product_small.cpp @@ -0,0 +1,323 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2006-2008 Benoit Jacob +// +// 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/. + +#define EIGEN_NO_STATIC_ASSERT +#include "product.h" +#include + +// regression test for bug 447 +template +void product1x1() +{ + Matrix matAstatic; + Matrix matBstatic; + matAstatic.setRandom(); + matBstatic.setRandom(); + VERIFY_IS_APPROX( (matAstatic * matBstatic).coeff(0,0), + matAstatic.cwiseProduct(matBstatic.transpose()).sum() ); + + MatrixXf matAdynamic(1,3); + MatrixXf matBdynamic(3,1); + matAdynamic.setRandom(); + matBdynamic.setRandom(); + VERIFY_IS_APPROX( (matAdynamic * matBdynamic).coeff(0,0), + matAdynamic.cwiseProduct(matBdynamic.transpose()).sum() ); +} + +template +const TC& ref_prod(TC &C, const TA &A, const TB &B) +{ + for(Index i=0;i +typename internal::enable_if::type +test_lazy_single(int rows, int cols, int depth) +{ + Matrix A(rows,depth); A.setRandom(); + Matrix B(depth,cols); B.setRandom(); + Matrix C(rows,cols); C.setRandom(); + Matrix D(C); + VERIFY_IS_APPROX(C+=A.lazyProduct(B), ref_prod(D,A,B)); +} + +void test_dynamic_bool() +{ + int rows = internal::random(1,64); + int cols = internal::random(1,64); + int depth = internal::random(1,65); + + typedef Matrix MatrixX; + MatrixX A(rows,depth); A.setRandom(); + MatrixX B(depth,cols); B.setRandom(); + MatrixX C(rows,cols); C.setRandom(); + MatrixX D(C); + for(Index i=0;i +typename internal::enable_if< ( (Rows ==1&&Depth!=1&&OA==ColMajor) + || (Depth==1&&Rows !=1&&OA==RowMajor) + || (Cols ==1&&Depth!=1&&OB==RowMajor) + || (Depth==1&&Cols !=1&&OB==ColMajor) + || (Rows ==1&&Cols !=1&&OC==ColMajor) + || (Cols ==1&&Rows !=1&&OC==RowMajor)),void>::type +test_lazy_single(int, int, int) +{ +} + +template +void test_lazy_all_layout(int rows=Rows, int cols=Cols, int depth=Depth) +{ + CALL_SUBTEST(( test_lazy_single(rows,cols,depth) )); + CALL_SUBTEST(( test_lazy_single(rows,cols,depth) )); + CALL_SUBTEST(( test_lazy_single(rows,cols,depth) )); + CALL_SUBTEST(( test_lazy_single(rows,cols,depth) )); + CALL_SUBTEST(( test_lazy_single(rows,cols,depth) )); + CALL_SUBTEST(( test_lazy_single(rows,cols,depth) )); + CALL_SUBTEST(( test_lazy_single(rows,cols,depth) )); + CALL_SUBTEST(( test_lazy_single(rows,cols,depth) )); +} + +template +void test_lazy_l1() +{ + int rows = internal::random(1,12); + int cols = internal::random(1,12); + int depth = internal::random(1,12); + + // Inner + CALL_SUBTEST(( test_lazy_all_layout() )); + CALL_SUBTEST(( test_lazy_all_layout() )); + CALL_SUBTEST(( test_lazy_all_layout() )); + CALL_SUBTEST(( test_lazy_all_layout() )); + CALL_SUBTEST(( test_lazy_all_layout() )); + CALL_SUBTEST(( test_lazy_all_layout(1,1,depth) )); + + // Outer + CALL_SUBTEST(( test_lazy_all_layout() )); + CALL_SUBTEST(( test_lazy_all_layout() )); + CALL_SUBTEST(( test_lazy_all_layout() )); + CALL_SUBTEST(( test_lazy_all_layout() )); + CALL_SUBTEST(( test_lazy_all_layout() )); + CALL_SUBTEST(( test_lazy_all_layout() )); + CALL_SUBTEST(( test_lazy_all_layout(4,cols) )); + CALL_SUBTEST(( test_lazy_all_layout(7,cols) )); + CALL_SUBTEST(( test_lazy_all_layout(rows) )); + CALL_SUBTEST(( test_lazy_all_layout(rows) )); + CALL_SUBTEST(( test_lazy_all_layout(rows,cols) )); +} + +template +void test_lazy_l2() +{ + int rows = internal::random(1,12); + int cols = internal::random(1,12); + int depth = internal::random(1,12); + + // mat-vec + CALL_SUBTEST(( test_lazy_all_layout() )); + CALL_SUBTEST(( test_lazy_all_layout() )); + CALL_SUBTEST(( test_lazy_all_layout() )); + CALL_SUBTEST(( test_lazy_all_layout() )); + CALL_SUBTEST(( test_lazy_all_layout() )); + CALL_SUBTEST(( test_lazy_all_layout() )); + CALL_SUBTEST(( test_lazy_all_layout() )); + CALL_SUBTEST(( test_lazy_all_layout() )); + CALL_SUBTEST(( test_lazy_all_layout() )); + CALL_SUBTEST(( test_lazy_all_layout(rows) )); + CALL_SUBTEST(( test_lazy_all_layout(4,1,depth) )); + CALL_SUBTEST(( test_lazy_all_layout(rows,1,depth) )); + + // vec-mat + CALL_SUBTEST(( test_lazy_all_layout() )); + CALL_SUBTEST(( test_lazy_all_layout() )); + CALL_SUBTEST(( test_lazy_all_layout() )); + CALL_SUBTEST(( test_lazy_all_layout() )); + CALL_SUBTEST(( test_lazy_all_layout() )); + CALL_SUBTEST(( test_lazy_all_layout() )); + CALL_SUBTEST(( test_lazy_all_layout() )); + CALL_SUBTEST(( test_lazy_all_layout() )); + CALL_SUBTEST(( test_lazy_all_layout() )); + CALL_SUBTEST(( test_lazy_all_layout(1,cols) )); + CALL_SUBTEST(( test_lazy_all_layout(1,4,depth) )); + CALL_SUBTEST(( test_lazy_all_layout(1,cols,depth) )); +} + +template +void test_lazy_l3() +{ + int rows = internal::random(1,12); + int cols = internal::random(1,12); + int depth = internal::random(1,12); + // mat-mat + CALL_SUBTEST(( test_lazy_all_layout() )); + CALL_SUBTEST(( test_lazy_all_layout() )); + CALL_SUBTEST(( test_lazy_all_layout() )); + CALL_SUBTEST(( test_lazy_all_layout() )); + CALL_SUBTEST(( test_lazy_all_layout() )); + CALL_SUBTEST(( test_lazy_all_layout() )); + CALL_SUBTEST(( test_lazy_all_layout() )); + CALL_SUBTEST(( test_lazy_all_layout() )); + CALL_SUBTEST(( test_lazy_all_layout() )); + CALL_SUBTEST(( test_lazy_all_layout(rows) )); + CALL_SUBTEST(( test_lazy_all_layout(4,3,depth) )); + CALL_SUBTEST(( test_lazy_all_layout(rows,6,depth) )); + CALL_SUBTEST(( test_lazy_all_layout() )); + CALL_SUBTEST(( test_lazy_all_layout() )); + CALL_SUBTEST(( test_lazy_all_layout() )); + CALL_SUBTEST(( test_lazy_all_layout() )); + CALL_SUBTEST(( test_lazy_all_layout() )); + CALL_SUBTEST(( test_lazy_all_layout() )); + CALL_SUBTEST(( test_lazy_all_layout() )); + CALL_SUBTEST(( test_lazy_all_layout() )); + CALL_SUBTEST(( test_lazy_all_layout() )); + CALL_SUBTEST(( test_lazy_all_layout(8,cols) )); + CALL_SUBTEST(( test_lazy_all_layout(3,4,depth) )); + CALL_SUBTEST(( test_lazy_all_layout(4,cols,depth) )); +} + +template +void test_linear_but_not_vectorizable() +{ + // Check tricky cases for which the result of the product is a vector and thus must exhibit the LinearBit flag, + // but is not vectorizable along the linear dimension. + Index n = N==Dynamic ? internal::random(1,32) : N; + Index m = M==Dynamic ? internal::random(1,32) : M; + Index k = K==Dynamic ? internal::random(1,32) : K; + + { + Matrix A; A.setRandom(n,m+1); + Matrix B; B.setRandom(m*2,k); + Matrix C; + Matrix R; + + C.noalias() = A.template topLeftCorner<1,M>() * (B.template topRows()+B.template bottomRows()); + R.noalias() = A.template topLeftCorner<1,M>() * (B.template topRows()+B.template bottomRows()).eval(); + VERIFY_IS_APPROX(C,R); + } + + { + Matrix A; A.setRandom(m+1,n); + Matrix B; B.setRandom(k,m*2); + Matrix C; + Matrix R; + + C.noalias() = (B.template leftCols()+B.template rightCols()) * A.template topLeftCorner(); + R.noalias() = (B.template leftCols()+B.template rightCols()).eval() * A.template topLeftCorner(); + VERIFY_IS_APPROX(C,R); + } +} + +template +void bug_1311() +{ + Matrix< double, Rows, 2 > A; A.setRandom(); + Vector2d b = Vector2d::Random() ; + Matrix res; + res.noalias() = 1. * (A * b); + VERIFY_IS_APPROX(res, A*b); + res.noalias() = 1.*A * b; + VERIFY_IS_APPROX(res, A*b); + res.noalias() = (1.*A).lazyProduct(b); + VERIFY_IS_APPROX(res, A*b); + res.noalias() = (1.*A).lazyProduct(1.*b); + VERIFY_IS_APPROX(res, A*b); + res.noalias() = (A).lazyProduct(1.*b); + VERIFY_IS_APPROX(res, A*b); +} + +template +void product_small_regressions() +{ + { + // test compilation of (outer_product) * vector + Vector3f v = Vector3f::Random(); + VERIFY_IS_APPROX( (v * v.transpose()) * v, (v * v.transpose()).eval() * v); + } + + { + // regression test for pull-request #93 + Eigen::Matrix A; A.setRandom(); + Eigen::Matrix B; B.setRandom(); + Eigen::Matrix C; C.setRandom(); + VERIFY_IS_APPROX(B * A.inverse(), B * A.inverse()[0]); + VERIFY_IS_APPROX(A.inverse() * C, A.inverse()[0] * C); + } + + { + Eigen::Matrix A, B, C; + A.setRandom(); + C = A; + for(int k=0; k<79; ++k) + C = C * A; + B.noalias() = (((A*A)*(A*A))*((A*A)*(A*A))*((A*A)*(A*A))*((A*A)*(A*A))*((A*A)*(A*A)) * ((A*A)*(A*A))*((A*A)*(A*A))*((A*A)*(A*A))*((A*A)*(A*A))*((A*A)*(A*A))) + * (((A*A)*(A*A))*((A*A)*(A*A))*((A*A)*(A*A))*((A*A)*(A*A))*((A*A)*(A*A)) * ((A*A)*(A*A))*((A*A)*(A*A))*((A*A)*(A*A))*((A*A)*(A*A))*((A*A)*(A*A))); + VERIFY_IS_APPROX(B,C); + } +} + +EIGEN_DECLARE_TEST(product_small) +{ + for(int i = 0; i < g_repeat; i++) { + CALL_SUBTEST_1( product(Matrix()) ); + CALL_SUBTEST_2( product(Matrix()) ); + CALL_SUBTEST_8( product(Matrix()) ); + CALL_SUBTEST_3( product(Matrix3d()) ); + CALL_SUBTEST_4( product(Matrix4d()) ); + CALL_SUBTEST_5( product(Matrix4f()) ); + CALL_SUBTEST_6( product1x1<0>() ); + + CALL_SUBTEST_11( test_lazy_l1() ); + CALL_SUBTEST_12( test_lazy_l2() ); + CALL_SUBTEST_13( test_lazy_l3() ); + + CALL_SUBTEST_21( test_lazy_l1() ); + CALL_SUBTEST_22( test_lazy_l2() ); + CALL_SUBTEST_23( test_lazy_l3() ); + + CALL_SUBTEST_31( test_lazy_l1 >() ); + CALL_SUBTEST_32( test_lazy_l2 >() ); + CALL_SUBTEST_33( test_lazy_l3 >() ); + + CALL_SUBTEST_41( test_lazy_l1 >() ); + CALL_SUBTEST_42( test_lazy_l2 >() ); + CALL_SUBTEST_43( test_lazy_l3 >() ); + + CALL_SUBTEST_7(( test_linear_but_not_vectorizable() )); + CALL_SUBTEST_7(( test_linear_but_not_vectorizable() )); + CALL_SUBTEST_7(( test_linear_but_not_vectorizable() )); + + CALL_SUBTEST_6( bug_1311<3>() ); + CALL_SUBTEST_6( bug_1311<5>() ); + + CALL_SUBTEST_9( test_dynamic_bool() ); + } + + CALL_SUBTEST_6( product_small_regressions<0>() ); +} diff --git a/include/eigen/test/product_syrk.cpp b/include/eigen/test/product_syrk.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8becd37fc21be55d8d59cff62339c597f308d4df --- /dev/null +++ b/include/eigen/test/product_syrk.cpp @@ -0,0 +1,146 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2008-2009 Gael Guennebaud +// +// 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/. + +#include "main.h" + +template void syrk(const MatrixType& m) +{ + typedef typename MatrixType::Scalar Scalar; + typedef Matrix RMatrixType; + typedef Matrix Rhs1; + typedef Matrix Rhs2; + typedef Matrix Rhs3; + + Index rows = m.rows(); + Index cols = m.cols(); + + MatrixType m1 = MatrixType::Random(rows, cols), + m2 = MatrixType::Random(rows, cols), + m3 = MatrixType::Random(rows, cols); + RMatrixType rm2 = MatrixType::Random(rows, cols); + + Rhs1 rhs1 = Rhs1::Random(internal::random(1,320), cols); Rhs1 rhs11 = Rhs1::Random(rhs1.rows(), cols); + Rhs2 rhs2 = Rhs2::Random(rows, internal::random(1,320)); Rhs2 rhs22 = Rhs2::Random(rows, rhs2.cols()); + Rhs3 rhs3 = Rhs3::Random(internal::random(1,320), rows); + + Scalar s1 = internal::random(); + + Index c = internal::random(0,cols-1); + + m2.setZero(); + VERIFY_IS_APPROX((m2.template selfadjointView().rankUpdate(rhs2,s1)._expression()), + ((s1 * rhs2 * rhs2.adjoint()).eval().template triangularView().toDenseMatrix())); + m2.setZero(); + VERIFY_IS_APPROX(((m2.template triangularView() += s1 * rhs2 * rhs22.adjoint()).nestedExpression()), + ((s1 * rhs2 * rhs22.adjoint()).eval().template triangularView().toDenseMatrix())); + + + m2.setZero(); + VERIFY_IS_APPROX(m2.template selfadjointView().rankUpdate(rhs2,s1)._expression(), + (s1 * rhs2 * rhs2.adjoint()).eval().template triangularView().toDenseMatrix()); + m2.setZero(); + VERIFY_IS_APPROX((m2.template triangularView() += s1 * rhs22 * rhs2.adjoint()).nestedExpression(), + (s1 * rhs22 * rhs2.adjoint()).eval().template triangularView().toDenseMatrix()); + + + m2.setZero(); + VERIFY_IS_APPROX(m2.template selfadjointView().rankUpdate(rhs1.adjoint(),s1)._expression(), + (s1 * rhs1.adjoint() * rhs1).eval().template triangularView().toDenseMatrix()); + m2.setZero(); + VERIFY_IS_APPROX((m2.template triangularView() += s1 * rhs11.adjoint() * rhs1).nestedExpression(), + (s1 * rhs11.adjoint() * rhs1).eval().template triangularView().toDenseMatrix()); + + + m2.setZero(); + VERIFY_IS_APPROX(m2.template selfadjointView().rankUpdate(rhs1.adjoint(),s1)._expression(), + (s1 * rhs1.adjoint() * rhs1).eval().template triangularView().toDenseMatrix()); + VERIFY_IS_APPROX((m2.template triangularView() = s1 * rhs1.adjoint() * rhs11).nestedExpression(), + (s1 * rhs1.adjoint() * rhs11).eval().template triangularView().toDenseMatrix()); + + + m2.setZero(); + VERIFY_IS_APPROX(m2.template selfadjointView().rankUpdate(rhs3.adjoint(),s1)._expression(), + (s1 * rhs3.adjoint() * rhs3).eval().template triangularView().toDenseMatrix()); + + m2.setZero(); + VERIFY_IS_APPROX(m2.template selfadjointView().rankUpdate(rhs3.adjoint(),s1)._expression(), + (s1 * rhs3.adjoint() * rhs3).eval().template triangularView().toDenseMatrix()); + + m2.setZero(); + VERIFY_IS_APPROX((m2.template selfadjointView().rankUpdate(m1.col(c),s1)._expression()), + ((s1 * m1.col(c) * m1.col(c).adjoint()).eval().template triangularView().toDenseMatrix())); + + m2.setZero(); + VERIFY_IS_APPROX((m2.template selfadjointView().rankUpdate(m1.col(c),s1)._expression()), + ((s1 * m1.col(c) * m1.col(c).adjoint()).eval().template triangularView().toDenseMatrix())); + rm2.setZero(); + VERIFY_IS_APPROX((rm2.template selfadjointView().rankUpdate(m1.col(c),s1)._expression()), + ((s1 * m1.col(c) * m1.col(c).adjoint()).eval().template triangularView().toDenseMatrix())); + m2.setZero(); + VERIFY_IS_APPROX((m2.template triangularView() += s1 * m3.col(c) * m1.col(c).adjoint()).nestedExpression(), + ((s1 * m3.col(c) * m1.col(c).adjoint()).eval().template triangularView().toDenseMatrix())); + rm2.setZero(); + VERIFY_IS_APPROX((rm2.template triangularView() += s1 * m1.col(c) * m3.col(c).adjoint()).nestedExpression(), + ((s1 * m1.col(c) * m3.col(c).adjoint()).eval().template triangularView().toDenseMatrix())); + + m2.setZero(); + VERIFY_IS_APPROX((m2.template selfadjointView().rankUpdate(m1.col(c).conjugate(),s1)._expression()), + ((s1 * m1.col(c).conjugate() * m1.col(c).conjugate().adjoint()).eval().template triangularView().toDenseMatrix())); + + m2.setZero(); + VERIFY_IS_APPROX((m2.template selfadjointView().rankUpdate(m1.col(c).conjugate(),s1)._expression()), + ((s1 * m1.col(c).conjugate() * m1.col(c).conjugate().adjoint()).eval().template triangularView().toDenseMatrix())); + + + m2.setZero(); + VERIFY_IS_APPROX((m2.template selfadjointView().rankUpdate(m1.row(c),s1)._expression()), + ((s1 * m1.row(c).transpose() * m1.row(c).transpose().adjoint()).eval().template triangularView().toDenseMatrix())); + rm2.setZero(); + VERIFY_IS_APPROX((rm2.template selfadjointView().rankUpdate(m1.row(c),s1)._expression()), + ((s1 * m1.row(c).transpose() * m1.row(c).transpose().adjoint()).eval().template triangularView().toDenseMatrix())); + m2.setZero(); + VERIFY_IS_APPROX((m2.template triangularView() += s1 * m3.row(c).transpose() * m1.row(c).transpose().adjoint()).nestedExpression(), + ((s1 * m3.row(c).transpose() * m1.row(c).transpose().adjoint()).eval().template triangularView().toDenseMatrix())); + rm2.setZero(); + VERIFY_IS_APPROX((rm2.template triangularView() += s1 * m3.row(c).transpose() * m1.row(c).transpose().adjoint()).nestedExpression(), + ((s1 * m3.row(c).transpose() * m1.row(c).transpose().adjoint()).eval().template triangularView().toDenseMatrix())); + + + m2.setZero(); + VERIFY_IS_APPROX((m2.template selfadjointView().rankUpdate(m1.row(c).adjoint(),s1)._expression()), + ((s1 * m1.row(c).adjoint() * m1.row(c).adjoint().adjoint()).eval().template triangularView().toDenseMatrix())); + + // destination with a non-default inner-stride + // see bug 1741 + { + typedef Matrix MatrixX; + MatrixX buffer(2*rows,2*cols); + Map > map1(buffer.data(),rows,cols,Stride(2*rows,2)); + buffer.setZero(); + VERIFY_IS_APPROX((map1.template selfadjointView().rankUpdate(rhs2,s1)._expression()), + ((s1 * rhs2 * rhs2.adjoint()).eval().template triangularView().toDenseMatrix())); + } +} + +EIGEN_DECLARE_TEST(product_syrk) +{ + for(int i = 0; i < g_repeat ; i++) + { + int s; + s = internal::random(1,EIGEN_TEST_MAX_SIZE); + CALL_SUBTEST_1( syrk(MatrixXf(s, s)) ); + CALL_SUBTEST_2( syrk(MatrixXd(s, s)) ); + TEST_SET_BUT_UNUSED_VARIABLE(s) + + s = internal::random(1,EIGEN_TEST_MAX_SIZE/2); + CALL_SUBTEST_3( syrk(MatrixXcf(s, s)) ); + CALL_SUBTEST_4( syrk(MatrixXcd(s, s)) ); + TEST_SET_BUT_UNUSED_VARIABLE(s) + } +} diff --git a/include/eigen/test/product_trmv.cpp b/include/eigen/test/product_trmv.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5eb1b5ac0855885fdf02c36b49568d2019a68dc3 --- /dev/null +++ b/include/eigen/test/product_trmv.cpp @@ -0,0 +1,90 @@ +// This file is triangularView of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2008-2009 Gael Guennebaud +// +// 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/. + +#include "main.h" + +template void trmv(const MatrixType& m) +{ + typedef typename MatrixType::Scalar Scalar; + typedef typename NumTraits::Real RealScalar; + typedef Matrix VectorType; + + RealScalar largerEps = 10*test_precision(); + + Index rows = m.rows(); + Index cols = m.cols(); + + MatrixType m1 = MatrixType::Random(rows, cols), + m3(rows, cols); + VectorType v1 = VectorType::Random(rows); + + Scalar s1 = internal::random(); + + m1 = MatrixType::Random(rows, cols); + + // check with a column-major matrix + m3 = m1.template triangularView(); + VERIFY((m3 * v1).isApprox(m1.template triangularView() * v1, largerEps)); + m3 = m1.template triangularView(); + VERIFY((m3 * v1).isApprox(m1.template triangularView() * v1, largerEps)); + m3 = m1.template triangularView(); + VERIFY((m3 * v1).isApprox(m1.template triangularView() * v1, largerEps)); + m3 = m1.template triangularView(); + VERIFY((m3 * v1).isApprox(m1.template triangularView() * v1, largerEps)); + + // check conjugated and scalar multiple expressions (col-major) + m3 = m1.template triangularView(); + VERIFY(((s1*m3).conjugate() * v1).isApprox((s1*m1).conjugate().template triangularView() * v1, largerEps)); + m3 = m1.template triangularView(); + VERIFY((m3.conjugate() * v1.conjugate()).isApprox(m1.conjugate().template triangularView() * v1.conjugate(), largerEps)); + + // check with a row-major matrix + m3 = m1.template triangularView(); + VERIFY((m3.transpose() * v1).isApprox(m1.transpose().template triangularView() * v1, largerEps)); + m3 = m1.template triangularView(); + VERIFY((m3.transpose() * v1).isApprox(m1.transpose().template triangularView() * v1, largerEps)); + m3 = m1.template triangularView(); + VERIFY((m3.transpose() * v1).isApprox(m1.transpose().template triangularView() * v1, largerEps)); + m3 = m1.template triangularView(); + VERIFY((m3.transpose() * v1).isApprox(m1.transpose().template triangularView() * v1, largerEps)); + + // check conjugated and scalar multiple expressions (row-major) + m3 = m1.template triangularView(); + VERIFY((m3.adjoint() * v1).isApprox(m1.adjoint().template triangularView() * v1, largerEps)); + m3 = m1.template triangularView(); + VERIFY((m3.adjoint() * (s1*v1.conjugate())).isApprox(m1.adjoint().template triangularView() * (s1*v1.conjugate()), largerEps)); + m3 = m1.template triangularView(); + + // check transposed cases: + m3 = m1.template triangularView(); + VERIFY((v1.transpose() * m3).isApprox(v1.transpose() * m1.template triangularView(), largerEps)); + VERIFY((v1.adjoint() * m3).isApprox(v1.adjoint() * m1.template triangularView(), largerEps)); + VERIFY((v1.adjoint() * m3.adjoint()).isApprox(v1.adjoint() * m1.template triangularView().adjoint(), largerEps)); + + // TODO check with sub-matrices +} + +EIGEN_DECLARE_TEST(product_trmv) +{ + int s = 0; + for(int i = 0; i < g_repeat ; i++) { + CALL_SUBTEST_1( trmv(Matrix()) ); + CALL_SUBTEST_2( trmv(Matrix()) ); + CALL_SUBTEST_3( trmv(Matrix3d()) ); + + s = internal::random(1,EIGEN_TEST_MAX_SIZE/2); + CALL_SUBTEST_4( trmv(MatrixXcf(s,s)) ); + CALL_SUBTEST_5( trmv(MatrixXcd(s,s)) ); + TEST_SET_BUT_UNUSED_VARIABLE(s) + + s = internal::random(1,EIGEN_TEST_MAX_SIZE); + CALL_SUBTEST_6( trmv(Matrix(s, s)) ); + TEST_SET_BUT_UNUSED_VARIABLE(s) + } +} diff --git a/include/eigen/test/product_trsolve.cpp b/include/eigen/test/product_trsolve.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c59748c5b16814bb7b3204c63f3026a70ccb0f7d --- /dev/null +++ b/include/eigen/test/product_trsolve.cpp @@ -0,0 +1,127 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2008-2009 Gael Guennebaud +// +// 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/. + +#include "main.h" + +#define VERIFY_TRSM(TRI,XB) { \ + (XB).setRandom(); ref = (XB); \ + (TRI).solveInPlace(XB); \ + VERIFY_IS_APPROX((TRI).toDenseMatrix() * (XB), ref); \ + (XB).setRandom(); ref = (XB); \ + (XB) = (TRI).solve(XB); \ + VERIFY_IS_APPROX((TRI).toDenseMatrix() * (XB), ref); \ + } + +#define VERIFY_TRSM_ONTHERIGHT(TRI,XB) { \ + (XB).setRandom(); ref = (XB); \ + (TRI).transpose().template solveInPlace(XB.transpose()); \ + VERIFY_IS_APPROX((XB).transpose() * (TRI).transpose().toDenseMatrix(), ref.transpose()); \ + (XB).setRandom(); ref = (XB); \ + (XB).transpose() = (TRI).transpose().template solve(XB.transpose()); \ + VERIFY_IS_APPROX((XB).transpose() * (TRI).transpose().toDenseMatrix(), ref.transpose()); \ + } + +template void trsolve(int size=Size,int cols=Cols) +{ + typedef typename NumTraits::Real RealScalar; + + Matrix cmLhs(size,size); + Matrix rmLhs(size,size); + + enum { colmajor = Size==1 ? RowMajor : ColMajor, + rowmajor = Cols==1 ? ColMajor : RowMajor }; + Matrix cmRhs(size,cols); + Matrix rmRhs(size,cols); + Matrix ref(size,cols); + + cmLhs.setRandom(); cmLhs *= static_cast(0.1); cmLhs.diagonal().array() += static_cast(1); + rmLhs.setRandom(); rmLhs *= static_cast(0.1); rmLhs.diagonal().array() += static_cast(1); + + VERIFY_TRSM(cmLhs.conjugate().template triangularView(), cmRhs); + VERIFY_TRSM(cmLhs.adjoint() .template triangularView(), cmRhs); + VERIFY_TRSM(cmLhs .template triangularView(), cmRhs); + VERIFY_TRSM(cmLhs .template triangularView(), rmRhs); + VERIFY_TRSM(cmLhs.conjugate().template triangularView(), rmRhs); + VERIFY_TRSM(cmLhs.adjoint() .template triangularView(), rmRhs); + + VERIFY_TRSM(cmLhs.conjugate().template triangularView(), cmRhs); + VERIFY_TRSM(cmLhs .template triangularView(), rmRhs); + + VERIFY_TRSM(rmLhs .template triangularView(), cmRhs); + VERIFY_TRSM(rmLhs.conjugate().template triangularView(), rmRhs); + + + VERIFY_TRSM_ONTHERIGHT(cmLhs.conjugate().template triangularView(), cmRhs); + VERIFY_TRSM_ONTHERIGHT(cmLhs .template triangularView(), cmRhs); + VERIFY_TRSM_ONTHERIGHT(cmLhs .template triangularView(), rmRhs); + VERIFY_TRSM_ONTHERIGHT(cmLhs.conjugate().template triangularView(), rmRhs); + + VERIFY_TRSM_ONTHERIGHT(cmLhs.conjugate().template triangularView(), cmRhs); + VERIFY_TRSM_ONTHERIGHT(cmLhs .template triangularView(), rmRhs); + + VERIFY_TRSM_ONTHERIGHT(rmLhs .template triangularView(), cmRhs); + VERIFY_TRSM_ONTHERIGHT(rmLhs.conjugate().template triangularView(), rmRhs); + + int c = internal::random(0,cols-1); + VERIFY_TRSM(rmLhs.template triangularView(), rmRhs.col(c)); + VERIFY_TRSM(cmLhs.template triangularView(), rmRhs.col(c)); + + // destination with a non-default inner-stride + // see bug 1741 + { + typedef Matrix MatrixX; + MatrixX buffer(2*cmRhs.rows(),2*cmRhs.cols()); + Map,0,Stride > map1(buffer.data(),cmRhs.rows(),cmRhs.cols(),Stride(2*cmRhs.outerStride(),2)); + Map,0,Stride > map2(buffer.data(),rmRhs.rows(),rmRhs.cols(),Stride(2*rmRhs.outerStride(),2)); + buffer.setZero(); + VERIFY_TRSM(cmLhs.conjugate().template triangularView(), map1); + buffer.setZero(); + VERIFY_TRSM(cmLhs .template triangularView(), map2); + } + + if(Size==Dynamic) + { + cmLhs.resize(0,0); + cmRhs.resize(0,cmRhs.cols()); + Matrix res = cmLhs.template triangularView().solve(cmRhs); + VERIFY_IS_EQUAL(res.rows(),0); + VERIFY_IS_EQUAL(res.cols(),cmRhs.cols()); + res = cmRhs; + cmLhs.template triangularView().solveInPlace(res); + VERIFY_IS_EQUAL(res.rows(),0); + VERIFY_IS_EQUAL(res.cols(),cmRhs.cols()); + } +} + +EIGEN_DECLARE_TEST(product_trsolve) +{ + for(int i = 0; i < g_repeat ; i++) + { + // matrices + CALL_SUBTEST_1((trsolve(internal::random(1,EIGEN_TEST_MAX_SIZE),internal::random(1,EIGEN_TEST_MAX_SIZE)))); + CALL_SUBTEST_2((trsolve(internal::random(1,EIGEN_TEST_MAX_SIZE),internal::random(1,EIGEN_TEST_MAX_SIZE)))); + CALL_SUBTEST_3((trsolve,Dynamic,Dynamic>(internal::random(1,EIGEN_TEST_MAX_SIZE/2),internal::random(1,EIGEN_TEST_MAX_SIZE/2)))); + CALL_SUBTEST_4((trsolve,Dynamic,Dynamic>(internal::random(1,EIGEN_TEST_MAX_SIZE/2),internal::random(1,EIGEN_TEST_MAX_SIZE/2)))); + + // vectors + CALL_SUBTEST_5((trsolve(internal::random(1,EIGEN_TEST_MAX_SIZE)))); + CALL_SUBTEST_6((trsolve(internal::random(1,EIGEN_TEST_MAX_SIZE)))); + CALL_SUBTEST_7((trsolve,Dynamic,1>(internal::random(1,EIGEN_TEST_MAX_SIZE)))); + CALL_SUBTEST_8((trsolve,Dynamic,1>(internal::random(1,EIGEN_TEST_MAX_SIZE)))); + + // meta-unrollers + CALL_SUBTEST_9((trsolve())); + CALL_SUBTEST_10((trsolve())); + CALL_SUBTEST_11((trsolve,4,1>())); + CALL_SUBTEST_12((trsolve())); + CALL_SUBTEST_13((trsolve())); + CALL_SUBTEST_14((trsolve())); + + } +} diff --git a/include/eigen/test/qtvector.cpp b/include/eigen/test/qtvector.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4ec79b1e609ee7f0d8bffa7d3f9834ef73cf1e36 --- /dev/null +++ b/include/eigen/test/qtvector.cpp @@ -0,0 +1,156 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2008 Gael Guennebaud +// Copyright (C) 2008 Benoit Jacob +// +// 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/. + +#define EIGEN_WORK_AROUND_QT_BUG_CALLING_WRONG_OPERATOR_NEW_FIXED_IN_QT_4_5 + +#include "main.h" +#include +#include +#include + +template +void check_qtvector_matrix(const MatrixType& m) +{ + Index rows = m.rows(); + Index cols = m.cols(); + MatrixType x = MatrixType::Random(rows,cols), y = MatrixType::Random(rows,cols); + QVector v(10, MatrixType(rows,cols)), w(20, y); + for(int i = 0; i < 20; i++) + { + VERIFY_IS_APPROX(w[i], y); + } + v[5] = x; + w[6] = v[5]; + VERIFY_IS_APPROX(w[6], v[5]); + v = w; + for(int i = 0; i < 20; i++) + { + VERIFY_IS_APPROX(w[i], v[i]); + } + + v.resize(21); + v[20] = x; + VERIFY_IS_APPROX(v[20], x); + v.fill(y,22); + VERIFY_IS_APPROX(v[21], y); + v.push_back(x); + VERIFY_IS_APPROX(v[22], x); + VERIFY((size_t)&(v[22]) == (size_t)&(v[21]) + sizeof(MatrixType)); + + // do a lot of push_back such that the vector gets internally resized + // (with memory reallocation) + MatrixType* ref = &w[0]; + for(int i=0; i<30 || ((ref==&w[0]) && i<300); ++i) + v.push_back(w[i%w.size()]); + for(int i=23; i +void check_qtvector_transform(const TransformType&) +{ + typedef typename TransformType::MatrixType MatrixType; + TransformType x(MatrixType::Random()), y(MatrixType::Random()); + QVector v(10), w(20, y); + v[5] = x; + w[6] = v[5]; + VERIFY_IS_APPROX(w[6], v[5]); + v = w; + for(int i = 0; i < 20; i++) + { + VERIFY_IS_APPROX(w[i], v[i]); + } + + v.resize(21); + v[20] = x; + VERIFY_IS_APPROX(v[20], x); + v.fill(y,22); + VERIFY_IS_APPROX(v[21], y); + v.push_back(x); + VERIFY_IS_APPROX(v[22], x); + VERIFY((size_t)&(v[22]) == (size_t)&(v[21]) + sizeof(TransformType)); + + // do a lot of push_back such that the vector gets internally resized + // (with memory reallocation) + TransformType* ref = &w[0]; + for(int i=0; i<30 || ((ref==&w[0]) && i<300); ++i) + v.push_back(w[i%w.size()]); + for(unsigned int i=23; int(i) +void check_qtvector_quaternion(const QuaternionType&) +{ + typedef typename QuaternionType::Coefficients Coefficients; + QuaternionType x(Coefficients::Random()), y(Coefficients::Random()); + QVector v(10), w(20, y); + v[5] = x; + w[6] = v[5]; + VERIFY_IS_APPROX(w[6], v[5]); + v = w; + for(int i = 0; i < 20; i++) + { + VERIFY_IS_APPROX(w[i], v[i]); + } + + v.resize(21); + v[20] = x; + VERIFY_IS_APPROX(v[20], x); + v.fill(y,22); + VERIFY_IS_APPROX(v[21], y); + v.push_back(x); + VERIFY_IS_APPROX(v[22], x); + VERIFY((size_t)&(v[22]) == (size_t)&(v[21]) + sizeof(QuaternionType)); + + // do a lot of push_back such that the vector gets internally resized + // (with memory reallocation) + QuaternionType* ref = &w[0]; + for(int i=0; i<30 || ((ref==&w[0]) && i<300); ++i) + v.push_back(w[i%w.size()]); + for(unsigned int i=23; int(i) +// +// 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/. + +#include "main.h" + +typedef long long int64; + +template Scalar check_in_range(Scalar x, Scalar y) +{ + Scalar r = internal::random(x,y); + VERIFY(r>=x); + if(y>=x) + { + VERIFY(r<=y); + } + return r; +} + +template void check_all_in_range(Scalar x, Scalar y) +{ + Array mask(y-x+1); + mask.fill(0); + long n = (y-x+1)*32; + for(long k=0; k0).all() ); +} + +template void check_histogram(Scalar x, Scalar y, int bins) +{ + Array hist(bins); + hist.fill(0); + int f = 100000; + int n = bins*f; + int64 range = int64(y)-int64(x); + int divisor = int((range+1)/bins); + assert(((range+1)%bins)==0); + for(int k=0; k()/double(f))-1.0).abs()<0.03).all() ); +} + +EIGEN_DECLARE_TEST(rand) +{ + long long_ref = NumTraits::highest()/10; + signed char char_offset = (std::min)(g_repeat,64); + signed char short_offset = (std::min)(g_repeat,16000); + + for(int i = 0; i < g_repeat*10000; i++) { + CALL_SUBTEST(check_in_range(10,11)); + CALL_SUBTEST(check_in_range(1.24234523,1.24234523)); + CALL_SUBTEST(check_in_range(-1,1)); + CALL_SUBTEST(check_in_range(-1432.2352,-1432.2352)); + + CALL_SUBTEST(check_in_range(10,11)); + CALL_SUBTEST(check_in_range(1.24234523,1.24234523)); + CALL_SUBTEST(check_in_range(-1,1)); + CALL_SUBTEST(check_in_range(-1432.2352,-1432.2352)); + + CALL_SUBTEST(check_in_range(0,-1)); + CALL_SUBTEST(check_in_range(0,-1)); + CALL_SUBTEST(check_in_range(0,-1)); + CALL_SUBTEST(check_in_range(-673456,673456)); + CALL_SUBTEST(check_in_range(-RAND_MAX+10,RAND_MAX-10)); + CALL_SUBTEST(check_in_range(-24345,24345)); + CALL_SUBTEST(check_in_range(-long_ref,long_ref)); + } + + CALL_SUBTEST(check_all_in_range(11,11)); + CALL_SUBTEST(check_all_in_range(11,11+char_offset)); + CALL_SUBTEST(check_all_in_range(-5,5)); + CALL_SUBTEST(check_all_in_range(-11-char_offset,-11)); + CALL_SUBTEST(check_all_in_range(-126,-126+char_offset)); + CALL_SUBTEST(check_all_in_range(126-char_offset,126)); + CALL_SUBTEST(check_all_in_range(-126,126)); + + CALL_SUBTEST(check_all_in_range(11,11)); + CALL_SUBTEST(check_all_in_range(11,11+short_offset)); + CALL_SUBTEST(check_all_in_range(-5,5)); + CALL_SUBTEST(check_all_in_range(-11-short_offset,-11)); + CALL_SUBTEST(check_all_in_range(-24345,-24345+short_offset)); + CALL_SUBTEST(check_all_in_range(24345,24345+short_offset)); + + CALL_SUBTEST(check_all_in_range(11,11)); + CALL_SUBTEST(check_all_in_range(11,11+g_repeat)); + CALL_SUBTEST(check_all_in_range(-5,5)); + CALL_SUBTEST(check_all_in_range(-11-g_repeat,-11)); + CALL_SUBTEST(check_all_in_range(-673456,-673456+g_repeat)); + CALL_SUBTEST(check_all_in_range(673456,673456+g_repeat)); + + CALL_SUBTEST(check_all_in_range(11,11)); + CALL_SUBTEST(check_all_in_range(11,11+g_repeat)); + CALL_SUBTEST(check_all_in_range(-5,5)); + CALL_SUBTEST(check_all_in_range(-11-g_repeat,-11)); + CALL_SUBTEST(check_all_in_range(-long_ref,-long_ref+g_repeat)); + CALL_SUBTEST(check_all_in_range( long_ref, long_ref+g_repeat)); + + CALL_SUBTEST(check_histogram(-5,5,11)); + int bins = 100; + CALL_SUBTEST(check_histogram(-3333,-3333+bins*(3333/bins)-1,bins)); + bins = 1000; + CALL_SUBTEST(check_histogram(-RAND_MAX+10,-RAND_MAX+10+bins*(RAND_MAX/bins)-1,bins)); + CALL_SUBTEST(check_histogram(-RAND_MAX+10,-int64(RAND_MAX)+10+bins*(2*int64(RAND_MAX)/bins)-1,bins)); +} diff --git a/include/eigen/test/random_without_cast_overflow.h b/include/eigen/test/random_without_cast_overflow.h new file mode 100644 index 0000000000000000000000000000000000000000..0003451108b24f4bbcec6bd9eda4d2cd1cd13423 --- /dev/null +++ b/include/eigen/test/random_without_cast_overflow.h @@ -0,0 +1,152 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2020 C. Antonio Sanchez +// +// 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/. + +// Utilities for generating random numbers without overflows, which might +// otherwise result in undefined behavior. + +namespace Eigen { +namespace internal { + +// Default implementation assuming SrcScalar fits into TgtScalar. +template +struct random_without_cast_overflow { + static SrcScalar value() { return internal::random(); } +}; + +// Signed to unsigned integer widening cast. +template +struct random_without_cast_overflow< + SrcScalar, TgtScalar, + typename internal::enable_if::IsInteger && NumTraits::IsInteger && + !NumTraits::IsSigned && + (std::numeric_limits::digits < std::numeric_limits::digits || + (std::numeric_limits::digits == std::numeric_limits::digits && + NumTraits::IsSigned))>::type> { + static SrcScalar value() { + SrcScalar a = internal::random(); + return a < SrcScalar(0) ? -(a + 1) : a; + } +}; + +// Integer to unsigned narrowing cast. +template +struct random_without_cast_overflow< + SrcScalar, TgtScalar, + typename internal::enable_if< + NumTraits::IsInteger && NumTraits::IsInteger && !NumTraits::IsSigned && + (std::numeric_limits::digits > std::numeric_limits::digits)>::type> { + static SrcScalar value() { + TgtScalar b = internal::random(); + return static_cast(b < TgtScalar(0) ? -(b + 1) : b); + } +}; + +// Integer to signed narrowing cast. +template +struct random_without_cast_overflow< + SrcScalar, TgtScalar, + typename internal::enable_if< + NumTraits::IsInteger && NumTraits::IsInteger && NumTraits::IsSigned && + (std::numeric_limits::digits > std::numeric_limits::digits)>::type> { + static SrcScalar value() { return static_cast(internal::random()); } +}; + +// Unsigned to signed integer narrowing cast. +template +struct random_without_cast_overflow< + SrcScalar, TgtScalar, + typename internal::enable_if::IsInteger && NumTraits::IsInteger && + !NumTraits::IsSigned && NumTraits::IsSigned && + (std::numeric_limits::digits == + std::numeric_limits::digits)>::type> { + static SrcScalar value() { return internal::random() / 2; } +}; + +// Floating-point to integer, full precision. +template +struct random_without_cast_overflow< + SrcScalar, TgtScalar, + typename internal::enable_if< + !NumTraits::IsInteger && !NumTraits::IsComplex && NumTraits::IsInteger && + (std::numeric_limits::digits <= std::numeric_limits::digits)>::type> { + static SrcScalar value() { return static_cast(internal::random()); } +}; + +// Floating-point to integer, narrowing precision. +template +struct random_without_cast_overflow< + SrcScalar, TgtScalar, + typename internal::enable_if< + !NumTraits::IsInteger && !NumTraits::IsComplex && NumTraits::IsInteger && + (std::numeric_limits::digits > std::numeric_limits::digits)>::type> { + static SrcScalar value() { + // NOTE: internal::random() is limited by RAND_MAX, so random is always within that range. + // This prevents us from simply shifting bits, which would result in only 0 or -1. + // Instead, keep least-significant K bits and sign. + static const TgtScalar KeepMask = (static_cast(1) << std::numeric_limits::digits) - 1; + const TgtScalar a = internal::random(); + return static_cast(a > TgtScalar(0) ? (a & KeepMask) : -(a & KeepMask)); + } +}; + +// Integer to floating-point, re-use above logic. +template +struct random_without_cast_overflow< + SrcScalar, TgtScalar, + typename internal::enable_if::IsInteger && !NumTraits::IsInteger && + !NumTraits::IsComplex>::type> { + static SrcScalar value() { + return static_cast(random_without_cast_overflow::value()); + } +}; + +// Floating-point narrowing conversion. +template +struct random_without_cast_overflow< + SrcScalar, TgtScalar, + typename internal::enable_if::IsInteger && !NumTraits::IsComplex && + !NumTraits::IsInteger && !NumTraits::IsComplex && + (std::numeric_limits::digits > + std::numeric_limits::digits)>::type> { + static SrcScalar value() { return static_cast(internal::random()); } +}; + +// Complex to non-complex. +template +struct random_without_cast_overflow< + SrcScalar, TgtScalar, + typename internal::enable_if::IsComplex && !NumTraits::IsComplex>::type> { + typedef typename NumTraits::Real SrcReal; + static SrcScalar value() { return SrcScalar(random_without_cast_overflow::value(), 0); } +}; + +// Non-complex to complex. +template +struct random_without_cast_overflow< + SrcScalar, TgtScalar, + typename internal::enable_if::IsComplex && NumTraits::IsComplex>::type> { + typedef typename NumTraits::Real TgtReal; + static SrcScalar value() { return random_without_cast_overflow::value(); } +}; + +// Complex to complex. +template +struct random_without_cast_overflow< + SrcScalar, TgtScalar, + typename internal::enable_if::IsComplex && NumTraits::IsComplex>::type> { + typedef typename NumTraits::Real SrcReal; + typedef typename NumTraits::Real TgtReal; + static SrcScalar value() { + return SrcScalar(random_without_cast_overflow::value(), + random_without_cast_overflow::value()); + } +}; + +} // namespace internal +} // namespace Eigen diff --git a/include/eigen/test/real_qz.cpp b/include/eigen/test/real_qz.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1cf7aba2d3d0106d5f9ccb4c5f6332b21356a068 --- /dev/null +++ b/include/eigen/test/real_qz.cpp @@ -0,0 +1,94 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2012 Alexey Korepanov +// +// 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/. + +#define EIGEN_RUNTIME_NO_MALLOC +#include "main.h" +#include +#include + +template void real_qz(const MatrixType& m) +{ + /* this test covers the following files: + RealQZ.h + */ + using std::abs; + typedef typename MatrixType::Scalar Scalar; + + Index dim = m.cols(); + + MatrixType A = MatrixType::Random(dim,dim), + B = MatrixType::Random(dim,dim); + + + // Regression test for bug 985: Randomly set rows or columns to zero + Index k=internal::random(0, dim-1); + switch(internal::random(0,10)) { + case 0: + A.row(k).setZero(); break; + case 1: + A.col(k).setZero(); break; + case 2: + B.row(k).setZero(); break; + case 3: + B.col(k).setZero(); break; + default: + break; + } + + RealQZ qz(dim); + // TODO enable full-prealocation of required memory, this probably requires an in-place mode for HessenbergDecomposition + //Eigen::internal::set_is_malloc_allowed(false); + qz.compute(A,B); + //Eigen::internal::set_is_malloc_allowed(true); + + VERIFY_IS_EQUAL(qz.info(), Success); + // check for zeros + bool all_zeros = true; + for (Index i=0; i void matrixRedux(const MatrixType& m) +{ + typedef typename MatrixType::Scalar Scalar; + typedef typename MatrixType::RealScalar RealScalar; + + Index rows = m.rows(); + Index cols = m.cols(); + + MatrixType m1 = MatrixType::Random(rows, cols); + + // The entries of m1 are uniformly distributed in [0,1], so m1.prod() is very small. This may lead to test + // failures if we underflow into denormals. Thus, we scale so that entries are close to 1. + MatrixType m1_for_prod = MatrixType::Ones(rows, cols) + RealScalar(0.2) * m1; + + Matrix m2(rows,rows); + m2.setRandom(); + + VERIFY_IS_MUCH_SMALLER_THAN(MatrixType::Zero(rows, cols).sum(), Scalar(1)); + VERIFY_IS_APPROX(MatrixType::Ones(rows, cols).sum(), Scalar(float(rows*cols))); // the float() here to shut up excessive MSVC warning about int->complex conversion being lossy + Scalar s(0), p(1), minc(numext::real(m1.coeff(0))), maxc(numext::real(m1.coeff(0))); + for(int j = 0; j < cols; j++) + for(int i = 0; i < rows; i++) + { + s += m1(i,j); + p *= m1_for_prod(i,j); + minc = (std::min)(numext::real(minc), numext::real(m1(i,j))); + maxc = (std::max)(numext::real(maxc), numext::real(m1(i,j))); + } + const Scalar mean = s/Scalar(RealScalar(rows*cols)); + + VERIFY_IS_APPROX(m1.sum(), s); + VERIFY_IS_APPROX(m1.mean(), mean); + VERIFY_IS_APPROX(m1_for_prod.prod(), p); + VERIFY_IS_APPROX(m1.real().minCoeff(), numext::real(minc)); + VERIFY_IS_APPROX(m1.real().maxCoeff(), numext::real(maxc)); + + // test that partial reduction works if nested expressions is forced to evaluate early + VERIFY_IS_APPROX((m1.matrix() * m1.matrix().transpose()) .cwiseProduct(m2.matrix()).rowwise().sum().sum(), + (m1.matrix() * m1.matrix().transpose()).eval().cwiseProduct(m2.matrix()).rowwise().sum().sum()); + + // test slice vectorization assuming assign is ok + Index r0 = internal::random(0,rows-1); + Index c0 = internal::random(0,cols-1); + Index r1 = internal::random(r0+1,rows)-r0; + Index c1 = internal::random(c0+1,cols)-c0; + VERIFY_IS_APPROX(m1.block(r0,c0,r1,c1).sum(), m1.block(r0,c0,r1,c1).eval().sum()); + VERIFY_IS_APPROX(m1.block(r0,c0,r1,c1).mean(), m1.block(r0,c0,r1,c1).eval().mean()); + VERIFY_IS_APPROX(m1_for_prod.block(r0,c0,r1,c1).prod(), m1_for_prod.block(r0,c0,r1,c1).eval().prod()); + VERIFY_IS_APPROX(m1.block(r0,c0,r1,c1).real().minCoeff(), m1.block(r0,c0,r1,c1).real().eval().minCoeff()); + VERIFY_IS_APPROX(m1.block(r0,c0,r1,c1).real().maxCoeff(), m1.block(r0,c0,r1,c1).real().eval().maxCoeff()); + + // regression for bug 1090 + const int R1 = MatrixType::RowsAtCompileTime>=2 ? MatrixType::RowsAtCompileTime/2 : 6; + const int C1 = MatrixType::ColsAtCompileTime>=2 ? MatrixType::ColsAtCompileTime/2 : 6; + if(R1<=rows-r0 && C1<=cols-c0) + { + VERIFY_IS_APPROX( (m1.template block(r0,c0).sum()), m1.block(r0,c0,R1,C1).sum() ); + } + + // test empty objects + VERIFY_IS_APPROX(m1.block(r0,c0,0,0).sum(), Scalar(0)); + VERIFY_IS_APPROX(m1.block(r0,c0,0,0).prod(), Scalar(1)); + + // test nesting complex expression + VERIFY_EVALUATION_COUNT( (m1.matrix()*m1.matrix().transpose()).sum(), (MatrixType::IsVectorAtCompileTime && MatrixType::SizeAtCompileTime!=1 ? 0 : 1) ); + VERIFY_EVALUATION_COUNT( ((m1.matrix()*m1.matrix().transpose())+m2).sum(),(MatrixType::IsVectorAtCompileTime && MatrixType::SizeAtCompileTime!=1 ? 0 : 1)); +} + +template void vectorRedux(const VectorType& w) +{ + using std::abs; + typedef typename VectorType::Scalar Scalar; + typedef typename NumTraits::Real RealScalar; + Index size = w.size(); + + VectorType v = VectorType::Random(size); + VectorType v_for_prod = VectorType::Ones(size) + Scalar(0.2) * v; // see comment above declaration of m1_for_prod + + for(int i = 1; i < size; i++) + { + Scalar s(0), p(1); + RealScalar minc(numext::real(v.coeff(0))), maxc(numext::real(v.coeff(0))); + for(int j = 0; j < i; j++) + { + s += v[j]; + p *= v_for_prod[j]; + minc = (std::min)(minc, numext::real(v[j])); + maxc = (std::max)(maxc, numext::real(v[j])); + } + VERIFY_IS_MUCH_SMALLER_THAN(abs(s - v.head(i).sum()), Scalar(1)); + VERIFY_IS_APPROX(p, v_for_prod.head(i).prod()); + VERIFY_IS_APPROX(minc, v.real().head(i).minCoeff()); + VERIFY_IS_APPROX(maxc, v.real().head(i).maxCoeff()); + } + + for(int i = 0; i < size-1; i++) + { + Scalar s(0), p(1); + RealScalar minc(numext::real(v.coeff(i))), maxc(numext::real(v.coeff(i))); + for(int j = i; j < size; j++) + { + s += v[j]; + p *= v_for_prod[j]; + minc = (std::min)(minc, numext::real(v[j])); + maxc = (std::max)(maxc, numext::real(v[j])); + } + VERIFY_IS_MUCH_SMALLER_THAN(abs(s - v.tail(size-i).sum()), Scalar(1)); + VERIFY_IS_APPROX(p, v_for_prod.tail(size-i).prod()); + VERIFY_IS_APPROX(minc, v.real().tail(size-i).minCoeff()); + VERIFY_IS_APPROX(maxc, v.real().tail(size-i).maxCoeff()); + } + + for(int i = 0; i < size/2; i++) + { + Scalar s(0), p(1); + RealScalar minc(numext::real(v.coeff(i))), maxc(numext::real(v.coeff(i))); + for(int j = i; j < size-i; j++) + { + s += v[j]; + p *= v_for_prod[j]; + minc = (std::min)(minc, numext::real(v[j])); + maxc = (std::max)(maxc, numext::real(v[j])); + } + VERIFY_IS_MUCH_SMALLER_THAN(abs(s - v.segment(i, size-2*i).sum()), Scalar(1)); + VERIFY_IS_APPROX(p, v_for_prod.segment(i, size-2*i).prod()); + VERIFY_IS_APPROX(minc, v.real().segment(i, size-2*i).minCoeff()); + VERIFY_IS_APPROX(maxc, v.real().segment(i, size-2*i).maxCoeff()); + } + + // test empty objects + VERIFY_IS_APPROX(v.head(0).sum(), Scalar(0)); + VERIFY_IS_APPROX(v.tail(0).prod(), Scalar(1)); + VERIFY_RAISES_ASSERT(v.head(0).mean()); + VERIFY_RAISES_ASSERT(v.head(0).minCoeff()); + VERIFY_RAISES_ASSERT(v.head(0).maxCoeff()); +} + +EIGEN_DECLARE_TEST(redux) +{ + // the max size cannot be too large, otherwise reduxion operations obviously generate large errors. + int maxsize = (std::min)(100,EIGEN_TEST_MAX_SIZE); + TEST_SET_BUT_UNUSED_VARIABLE(maxsize); + for(int i = 0; i < g_repeat; i++) { + CALL_SUBTEST_1( matrixRedux(Matrix()) ); + CALL_SUBTEST_1( matrixRedux(Array()) ); + CALL_SUBTEST_2( matrixRedux(Matrix2f()) ); + CALL_SUBTEST_2( matrixRedux(Array2f()) ); + CALL_SUBTEST_2( matrixRedux(Array22f()) ); + CALL_SUBTEST_3( matrixRedux(Matrix4d()) ); + CALL_SUBTEST_3( matrixRedux(Array4d()) ); + CALL_SUBTEST_3( matrixRedux(Array44d()) ); + CALL_SUBTEST_4( matrixRedux(MatrixXcf(internal::random(1,maxsize), internal::random(1,maxsize))) ); + CALL_SUBTEST_4( matrixRedux(ArrayXXcf(internal::random(1,maxsize), internal::random(1,maxsize))) ); + CALL_SUBTEST_5( matrixRedux(MatrixXd (internal::random(1,maxsize), internal::random(1,maxsize))) ); + CALL_SUBTEST_5( matrixRedux(ArrayXXd (internal::random(1,maxsize), internal::random(1,maxsize))) ); + CALL_SUBTEST_6( matrixRedux(MatrixXi (internal::random(1,maxsize), internal::random(1,maxsize))) ); + CALL_SUBTEST_6( matrixRedux(ArrayXXi (internal::random(1,maxsize), internal::random(1,maxsize))) ); + } + for(int i = 0; i < g_repeat; i++) { + CALL_SUBTEST_7( vectorRedux(Vector4f()) ); + CALL_SUBTEST_7( vectorRedux(Array4f()) ); + CALL_SUBTEST_5( vectorRedux(VectorXd(internal::random(1,maxsize))) ); + CALL_SUBTEST_5( vectorRedux(ArrayXd(internal::random(1,maxsize))) ); + CALL_SUBTEST_8( vectorRedux(VectorXf(internal::random(1,maxsize))) ); + CALL_SUBTEST_8( vectorRedux(ArrayXf(internal::random(1,maxsize))) ); + } +} diff --git a/include/eigen/test/ref.cpp b/include/eigen/test/ref.cpp new file mode 100644 index 0000000000000000000000000000000000000000..63eb65e27c87f5b7b56b6f8452c367f2113aa375 --- /dev/null +++ b/include/eigen/test/ref.cpp @@ -0,0 +1,360 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2013 Gael Guennebaud +// +// 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/. + +// This unit test cannot be easily written to work with EIGEN_DEFAULT_TO_ROW_MAJOR +#ifdef EIGEN_DEFAULT_TO_ROW_MAJOR +#undef EIGEN_DEFAULT_TO_ROW_MAJOR +#endif + +#define TEST_ENABLE_TEMPORARY_TRACKING +#define TEST_CHECK_STATIC_ASSERTIONS +#include "main.h" + +// test Ref.h + +// Deal with i387 extended precision +#if EIGEN_ARCH_i386 && !(EIGEN_ARCH_x86_64) + +#if EIGEN_COMP_GNUC_STRICT && EIGEN_GNUC_AT_LEAST(4,4) +#pragma GCC optimize ("-ffloat-store") +#else +#undef VERIFY_IS_EQUAL +#define VERIFY_IS_EQUAL(X,Y) VERIFY_IS_APPROX(X,Y) +#endif + +#endif + +template void ref_matrix(const MatrixType& m) +{ + typedef typename MatrixType::Scalar Scalar; + typedef typename MatrixType::RealScalar RealScalar; + typedef Matrix DynMatrixType; + typedef Matrix RealDynMatrixType; + + typedef Ref RefMat; + typedef Ref RefDynMat; + typedef Ref ConstRefDynMat; + typedef Ref > RefRealMatWithStride; + + Index rows = m.rows(), cols = m.cols(); + + MatrixType m1 = MatrixType::Random(rows, cols), + m2 = m1; + + Index i = internal::random(0,rows-1); + Index j = internal::random(0,cols-1); + Index brows = internal::random(1,rows-i); + Index bcols = internal::random(1,cols-j); + + RefMat rm0 = m1; + VERIFY_IS_EQUAL(rm0, m1); + RefDynMat rm1 = m1; + VERIFY_IS_EQUAL(rm1, m1); + RefDynMat rm2 = m1.block(i,j,brows,bcols); + VERIFY_IS_EQUAL(rm2, m1.block(i,j,brows,bcols)); + rm2.setOnes(); + m2.block(i,j,brows,bcols).setOnes(); + VERIFY_IS_EQUAL(m1, m2); + + m2.block(i,j,brows,bcols).setRandom(); + rm2 = m2.block(i,j,brows,bcols); + VERIFY_IS_EQUAL(m1, m2); + + ConstRefDynMat rm3 = m1.block(i,j,brows,bcols); + m1.block(i,j,brows,bcols) *= 2; + m2.block(i,j,brows,bcols) *= 2; + VERIFY_IS_EQUAL(rm3, m2.block(i,j,brows,bcols)); + RefRealMatWithStride rm4 = m1.real(); + VERIFY_IS_EQUAL(rm4, m2.real()); + rm4.array() += 1; + m2.real().array() += 1; + VERIFY_IS_EQUAL(m1, m2); +} + +template void ref_vector(const VectorType& m) +{ + typedef typename VectorType::Scalar Scalar; + typedef typename VectorType::RealScalar RealScalar; + typedef Matrix DynMatrixType; + typedef Matrix MatrixType; + typedef Matrix RealDynMatrixType; + + typedef Ref RefMat; + typedef Ref RefDynMat; + typedef Ref ConstRefDynMat; + typedef Ref > RefRealMatWithStride; + typedef Ref > RefMatWithStride; + + Index size = m.size(); + + VectorType v1 = VectorType::Random(size), + v2 = v1; + MatrixType mat1 = MatrixType::Random(size,size), + mat2 = mat1, + mat3 = MatrixType::Random(size,size); + + Index i = internal::random(0,size-1); + Index bsize = internal::random(1,size-i); + + { RefMat rm0 = v1; VERIFY_IS_EQUAL(rm0, v1); } + { RefMat rm0 = v1.block(0,0,size,1); VERIFY_IS_EQUAL(rm0, v1); } + { RefDynMat rv1 = v1; VERIFY_IS_EQUAL(rv1, v1); } + { RefDynMat rv1 = v1.block(0,0,size,1); VERIFY_IS_EQUAL(rv1, v1); } + { VERIFY_RAISES_ASSERT( RefMat rm0 = v1.block(0, 0, size, 0); EIGEN_UNUSED_VARIABLE(rm0); ); } + if(VectorType::SizeAtCompileTime!=1) + { VERIFY_RAISES_ASSERT( RefDynMat rv1 = v1.block(0, 0, size, 0); EIGEN_UNUSED_VARIABLE(rv1); ); } + + RefDynMat rv2 = v1.segment(i,bsize); + VERIFY_IS_EQUAL(rv2, v1.segment(i,bsize)); + rv2.setOnes(); + v2.segment(i,bsize).setOnes(); + VERIFY_IS_EQUAL(v1, v2); + + v2.segment(i,bsize).setRandom(); + rv2 = v2.segment(i,bsize); + VERIFY_IS_EQUAL(v1, v2); + + ConstRefDynMat rm3 = v1.segment(i,bsize); + v1.segment(i,bsize) *= 2; + v2.segment(i,bsize) *= 2; + VERIFY_IS_EQUAL(rm3, v2.segment(i,bsize)); + + RefRealMatWithStride rm4 = v1.real(); + VERIFY_IS_EQUAL(rm4, v2.real()); + rm4.array() += 1; + v2.real().array() += 1; + VERIFY_IS_EQUAL(v1, v2); + + RefMatWithStride rm5 = mat1.row(i).transpose(); + VERIFY_IS_EQUAL(rm5, mat1.row(i).transpose()); + rm5.array() += 1; + mat2.row(i).array() += 1; + VERIFY_IS_EQUAL(mat1, mat2); + rm5.noalias() = rm4.transpose() * mat3; + mat2.row(i) = v2.real().transpose() * mat3; + VERIFY_IS_APPROX(mat1, mat2); +} + +template +void ref_vector_fixed_sizes() +{ + typedef Matrix RowMajorMatrixType; + typedef Matrix ColMajorMatrixType; + typedef Matrix RowVectorType; + typedef Matrix ColVectorType; + typedef Matrix RowVectorTransposeType; + typedef Matrix ColVectorTransposeType; + typedef Stride DynamicStride; + + RowMajorMatrixType mr = RowMajorMatrixType::Random(); + ColMajorMatrixType mc = ColMajorMatrixType::Random(); + + Index i = internal::random(0,Rows-1); + Index j = internal::random(0,Cols-1); + + // Reference ith row. + Ref mr_ri = mr.row(i); + VERIFY_IS_EQUAL(mr_ri, mr.row(i)); + Ref mc_ri = mc.row(i); + VERIFY_IS_EQUAL(mc_ri, mc.row(i)); + + // Reference jth col. + Ref mr_cj = mr.col(j); + VERIFY_IS_EQUAL(mr_cj, mr.col(j)); + Ref mc_cj = mc.col(j); + VERIFY_IS_EQUAL(mc_cj, mc.col(j)); + + // Reference the transpose of row i. + Ref mr_rit = mr.row(i); + VERIFY_IS_EQUAL(mr_rit, mr.row(i).transpose()); + Ref mc_rit = mc.row(i); + VERIFY_IS_EQUAL(mc_rit, mc.row(i).transpose()); + + // Reference the transpose of col j. + Ref mr_cjt = mr.col(j); + VERIFY_IS_EQUAL(mr_cjt, mr.col(j).transpose()); + Ref mc_cjt = mc.col(j); + VERIFY_IS_EQUAL(mc_cjt, mc.col(j).transpose()); + + // Const references without strides. + Ref cmr_ri = mr.row(i); + VERIFY_IS_EQUAL(cmr_ri, mr.row(i)); + Ref cmc_ri = mc.row(i); + VERIFY_IS_EQUAL(cmc_ri, mc.row(i)); + + Ref cmr_cj = mr.col(j); + VERIFY_IS_EQUAL(cmr_cj, mr.col(j)); + Ref cmc_cj = mc.col(j); + VERIFY_IS_EQUAL(cmc_cj, mc.col(j)); + + Ref cmr_rit = mr.row(i); + VERIFY_IS_EQUAL(cmr_rit, mr.row(i).transpose()); + Ref cmc_rit = mc.row(i); + VERIFY_IS_EQUAL(cmc_rit, mc.row(i).transpose()); + + Ref cmr_cjt = mr.col(j); + VERIFY_IS_EQUAL(cmr_cjt, mr.col(j).transpose()); + Ref cmc_cjt = mc.col(j); + VERIFY_IS_EQUAL(cmc_cjt, mc.col(j).transpose()); +} + +template void check_const_correctness(const PlainObjectType&) +{ + // verify that ref-to-const don't have LvalueBit + typedef typename internal::add_const::type ConstPlainObjectType; + VERIFY( !(internal::traits >::Flags & LvalueBit) ); + VERIFY( !(internal::traits >::Flags & LvalueBit) ); + VERIFY( !(Ref::Flags & LvalueBit) ); + VERIFY( !(Ref::Flags & LvalueBit) ); +} + +template +EIGEN_DONT_INLINE void call_ref_1(Ref a, const B &b) { VERIFY_IS_EQUAL(a,b); } +template +EIGEN_DONT_INLINE void call_ref_2(const Ref& a, const B &b) { VERIFY_IS_EQUAL(a,b); } +template +EIGEN_DONT_INLINE void call_ref_3(Ref > a, const B &b) { VERIFY_IS_EQUAL(a,b); } +template +EIGEN_DONT_INLINE void call_ref_4(const Ref >& a, const B &b) { VERIFY_IS_EQUAL(a,b); } +template +EIGEN_DONT_INLINE void call_ref_5(Ref > a, const B &b) { VERIFY_IS_EQUAL(a,b); } +template +EIGEN_DONT_INLINE void call_ref_6(const Ref >& a, const B &b) { VERIFY_IS_EQUAL(a,b); } +template +EIGEN_DONT_INLINE void call_ref_7(Ref > a, const B &b) { VERIFY_IS_EQUAL(a,b); } + +void call_ref() +{ + VectorXcf ca = VectorXcf::Random(10); + VectorXf a = VectorXf::Random(10); + RowVectorXf b = RowVectorXf::Random(10); + MatrixXf A = MatrixXf::Random(10,10); + RowVector3f c = RowVector3f::Random(); + const VectorXf& ac(a); + VectorBlock ab(a,0,3); + const VectorBlock abc(a,0,3); + + + VERIFY_EVALUATION_COUNT( call_ref_1(a,a), 0); + VERIFY_EVALUATION_COUNT( call_ref_1(b,b.transpose()), 0); +// call_ref_1(ac,a RowMatrixXd; +int test_ref_overload_fun1(Ref ) { return 1; } +int test_ref_overload_fun1(Ref ) { return 2; } +int test_ref_overload_fun1(Ref ) { return 3; } + +int test_ref_overload_fun2(Ref ) { return 4; } +int test_ref_overload_fun2(Ref ) { return 5; } + +void test_ref_ambiguous(const Ref &A, Ref B) +{ + B = A; + B = A - A; +} + +// See also bug 969 +void test_ref_overloads() +{ + MatrixXd Ad, Bd; + RowMatrixXd rAd, rBd; + VERIFY( test_ref_overload_fun1(Ad)==1 ); + VERIFY( test_ref_overload_fun1(rAd)==2 ); + + MatrixXf Af, Bf; + VERIFY( test_ref_overload_fun2(Ad)==4 ); + VERIFY( test_ref_overload_fun2(Ad+Bd)==4 ); + VERIFY( test_ref_overload_fun2(Af+Bf)==5 ); + + ArrayXd A, B; + test_ref_ambiguous(A, B); +} + +void test_ref_fixed_size_assert() +{ + Vector4f v4 = Vector4f::Random(); + VectorXf vx = VectorXf::Random(10); + VERIFY_RAISES_STATIC_ASSERT( Ref y = v4; (void)y; ); + VERIFY_RAISES_STATIC_ASSERT( Ref y = vx.head<4>(); (void)y; ); + VERIFY_RAISES_STATIC_ASSERT( Ref y = v4; (void)y; ); + VERIFY_RAISES_STATIC_ASSERT( Ref y = vx.head<4>(); (void)y; ); + VERIFY_RAISES_STATIC_ASSERT( Ref y = 2*v4; (void)y; ); +} + +EIGEN_DECLARE_TEST(ref) +{ + for(int i = 0; i < g_repeat; i++) { + CALL_SUBTEST_1( ref_vector(Matrix()) ); + CALL_SUBTEST_1( check_const_correctness(Matrix()) ); + CALL_SUBTEST_2( ref_vector(Vector4d()) ); + CALL_SUBTEST_2( check_const_correctness(Matrix4d()) ); + CALL_SUBTEST_3( ref_vector(Vector4cf()) ); + CALL_SUBTEST_4( ref_vector(VectorXcf(8)) ); + CALL_SUBTEST_5( ref_vector(VectorXi(12)) ); + CALL_SUBTEST_5( check_const_correctness(VectorXi(12)) ); + + CALL_SUBTEST_1( ref_matrix(Matrix()) ); + CALL_SUBTEST_2( ref_matrix(Matrix4d()) ); + CALL_SUBTEST_1( ref_matrix(Matrix()) ); + CALL_SUBTEST_4( ref_matrix(MatrixXcf(internal::random(1,10),internal::random(1,10))) ); + CALL_SUBTEST_4( ref_matrix(Matrix,10,15>()) ); + CALL_SUBTEST_5( ref_matrix(MatrixXi(internal::random(1,10),internal::random(1,10))) ); + CALL_SUBTEST_6( call_ref() ); + + CALL_SUBTEST_8( (ref_vector_fixed_sizes()) ); + CALL_SUBTEST_8( (ref_vector_fixed_sizes()) ); + } + + CALL_SUBTEST_7( test_ref_overloads() ); + CALL_SUBTEST_7( test_ref_fixed_size_assert() ); +} diff --git a/include/eigen/test/resize.cpp b/include/eigen/test/resize.cpp new file mode 100644 index 0000000000000000000000000000000000000000..646a75b8f126eed916fb9b8f62bce424e4b7e252 --- /dev/null +++ b/include/eigen/test/resize.cpp @@ -0,0 +1,41 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2009 Keir Mierle +// +// 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/. + +#include "main.h" + +template +void resizeLikeTest() +{ + MatrixXf A(rows, cols); + MatrixXf B; + Matrix C; + B.resizeLike(A); + C.resizeLike(B); // Shouldn't crash. + VERIFY(B.rows() == rows && B.cols() == cols); + + VectorXf x(rows); + RowVectorXf y; + y.resizeLike(x); + VERIFY(y.rows() == 1 && y.cols() == rows); + + y.resize(cols); + x.resizeLike(y); + VERIFY(x.rows() == cols && x.cols() == 1); +} + +void resizeLikeTest12() { resizeLikeTest<1,2>(); } +void resizeLikeTest1020() { resizeLikeTest<10,20>(); } +void resizeLikeTest31() { resizeLikeTest<3,1>(); } + +EIGEN_DECLARE_TEST(resize) +{ + CALL_SUBTEST(resizeLikeTest12() ); + CALL_SUBTEST(resizeLikeTest1020() ); + CALL_SUBTEST(resizeLikeTest31() ); +} diff --git a/include/eigen/test/schur_complex.cpp b/include/eigen/test/schur_complex.cpp new file mode 100644 index 0000000000000000000000000000000000000000..26acb8c3ac3f67618bfe6363a76fe205e77eb9d3 --- /dev/null +++ b/include/eigen/test/schur_complex.cpp @@ -0,0 +1,92 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2010,2012 Jitse Niesen +// +// 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/. + +#include "main.h" +#include +#include + +template void schur(int size = MatrixType::ColsAtCompileTime) +{ + typedef typename ComplexSchur::ComplexScalar ComplexScalar; + typedef typename ComplexSchur::ComplexMatrixType ComplexMatrixType; + + // Test basic functionality: T is triangular and A = U T U* + for(int counter = 0; counter < g_repeat; ++counter) { + MatrixType A = MatrixType::Random(size, size); + ComplexSchur schurOfA(A); + VERIFY_IS_EQUAL(schurOfA.info(), Success); + ComplexMatrixType U = schurOfA.matrixU(); + ComplexMatrixType T = schurOfA.matrixT(); + for(int row = 1; row < size; ++row) { + for(int col = 0; col < row; ++col) { + VERIFY(T(row,col) == (typename MatrixType::Scalar)0); + } + } + VERIFY_IS_APPROX(A.template cast(), U * T * U.adjoint()); + } + + // Test asserts when not initialized + ComplexSchur csUninitialized; + VERIFY_RAISES_ASSERT(csUninitialized.matrixT()); + VERIFY_RAISES_ASSERT(csUninitialized.matrixU()); + VERIFY_RAISES_ASSERT(csUninitialized.info()); + + // Test whether compute() and constructor returns same result + MatrixType A = MatrixType::Random(size, size); + ComplexSchur cs1; + cs1.compute(A); + ComplexSchur cs2(A); + VERIFY_IS_EQUAL(cs1.info(), Success); + VERIFY_IS_EQUAL(cs2.info(), Success); + VERIFY_IS_EQUAL(cs1.matrixT(), cs2.matrixT()); + VERIFY_IS_EQUAL(cs1.matrixU(), cs2.matrixU()); + + // Test maximum number of iterations + ComplexSchur cs3; + cs3.setMaxIterations(ComplexSchur::m_maxIterationsPerRow * size).compute(A); + VERIFY_IS_EQUAL(cs3.info(), Success); + VERIFY_IS_EQUAL(cs3.matrixT(), cs1.matrixT()); + VERIFY_IS_EQUAL(cs3.matrixU(), cs1.matrixU()); + cs3.setMaxIterations(1).compute(A); + // The schur decomposition does often converge with a single iteration. + // VERIFY_IS_EQUAL(cs3.info(), size > 1 ? NoConvergence : Success); + VERIFY_IS_EQUAL(cs3.getMaxIterations(), 1); + + MatrixType Atriangular = A; + Atriangular.template triangularView().setZero(); + cs3.setMaxIterations(1).compute(Atriangular); // triangular matrices do not need any iterations + VERIFY_IS_EQUAL(cs3.info(), Success); + VERIFY_IS_EQUAL(cs3.matrixT(), Atriangular.template cast()); + VERIFY_IS_EQUAL(cs3.matrixU(), ComplexMatrixType::Identity(size, size)); + + // Test computation of only T, not U + ComplexSchur csOnlyT(A, false); + VERIFY_IS_EQUAL(csOnlyT.info(), Success); + VERIFY_IS_EQUAL(cs1.matrixT(), csOnlyT.matrixT()); + VERIFY_RAISES_ASSERT(csOnlyT.matrixU()); + + if (size > 1 && size < 20) + { + // Test matrix with NaN + A(0,0) = std::numeric_limits::quiet_NaN(); + ComplexSchur csNaN(A); + VERIFY_IS_EQUAL(csNaN.info(), NoConvergence); + } +} + +EIGEN_DECLARE_TEST(schur_complex) +{ + CALL_SUBTEST_1(( schur() )); + CALL_SUBTEST_2(( schur(internal::random(1,EIGEN_TEST_MAX_SIZE/4)) )); + CALL_SUBTEST_3(( schur, 1, 1> >() )); + CALL_SUBTEST_4(( schur >() )); + + // Test problem size constructors + CALL_SUBTEST_5(ComplexSchur(10)); +} diff --git a/include/eigen/test/schur_real.cpp b/include/eigen/test/schur_real.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7097fbae3cdc5095ca5f57e6f69d217a19b5abf2 --- /dev/null +++ b/include/eigen/test/schur_real.cpp @@ -0,0 +1,122 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2010,2012 Jitse Niesen +// +// 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/. + +#include "main.h" +#include +#include + +template void verifyIsQuasiTriangular(const MatrixType& T) +{ + const Index size = T.cols(); + typedef typename MatrixType::Scalar Scalar; + + // Check T is lower Hessenberg + for(int row = 2; row < size; ++row) { + for(int col = 0; col < row - 1; ++col) { + VERIFY(T(row,col) == Scalar(0)); + } + } + + // Check that any non-zero on the subdiagonal is followed by a zero and is + // part of a 2x2 diagonal block with imaginary eigenvalues. + for(int row = 1; row < size; ++row) { + if (T(row,row-1) != Scalar(0)) { + VERIFY(row == size-1 || T(row+1,row) == 0); + Scalar tr = T(row-1,row-1) + T(row,row); + Scalar det = T(row-1,row-1) * T(row,row) - T(row-1,row) * T(row,row-1); + VERIFY(4 * det > tr * tr); + } + } +} + +template void schur(int size = MatrixType::ColsAtCompileTime) +{ + // Test basic functionality: T is quasi-triangular and A = U T U* + for(int counter = 0; counter < g_repeat; ++counter) { + MatrixType A = MatrixType::Random(size, size); + RealSchur schurOfA(A); + VERIFY_IS_EQUAL(schurOfA.info(), Success); + MatrixType U = schurOfA.matrixU(); + MatrixType T = schurOfA.matrixT(); + verifyIsQuasiTriangular(T); + VERIFY_IS_APPROX(A, U * T * U.transpose()); + } + + // Test asserts when not initialized + RealSchur rsUninitialized; + VERIFY_RAISES_ASSERT(rsUninitialized.matrixT()); + VERIFY_RAISES_ASSERT(rsUninitialized.matrixU()); + VERIFY_RAISES_ASSERT(rsUninitialized.info()); + + // Test whether compute() and constructor returns same result + MatrixType A = MatrixType::Random(size, size); + RealSchur rs1; + rs1.compute(A); + RealSchur rs2(A); + VERIFY_IS_EQUAL(rs1.info(), Success); + VERIFY_IS_EQUAL(rs2.info(), Success); + VERIFY_IS_EQUAL(rs1.matrixT(), rs2.matrixT()); + VERIFY_IS_EQUAL(rs1.matrixU(), rs2.matrixU()); + + // Test maximum number of iterations + RealSchur rs3; + rs3.setMaxIterations(RealSchur::m_maxIterationsPerRow * size).compute(A); + VERIFY_IS_EQUAL(rs3.info(), Success); + VERIFY_IS_EQUAL(rs3.matrixT(), rs1.matrixT()); + VERIFY_IS_EQUAL(rs3.matrixU(), rs1.matrixU()); + if (size > 2) { + rs3.setMaxIterations(1).compute(A); + VERIFY_IS_EQUAL(rs3.info(), NoConvergence); + VERIFY_IS_EQUAL(rs3.getMaxIterations(), 1); + } + + MatrixType Atriangular = A; + Atriangular.template triangularView().setZero(); + rs3.setMaxIterations(1).compute(Atriangular); // triangular matrices do not need any iterations + VERIFY_IS_EQUAL(rs3.info(), Success); + VERIFY_IS_APPROX(rs3.matrixT(), Atriangular); // approx because of scaling... + VERIFY_IS_EQUAL(rs3.matrixU(), MatrixType::Identity(size, size)); + + // Test computation of only T, not U + RealSchur rsOnlyT(A, false); + VERIFY_IS_EQUAL(rsOnlyT.info(), Success); + VERIFY_IS_EQUAL(rs1.matrixT(), rsOnlyT.matrixT()); + VERIFY_RAISES_ASSERT(rsOnlyT.matrixU()); + + if (size > 2 && size < 20) + { + // Test matrix with NaN + A(0,0) = std::numeric_limits::quiet_NaN(); + RealSchur rsNaN(A); + VERIFY_IS_EQUAL(rsNaN.info(), NoConvergence); + } +} + +void test_bug2633() { + Eigen::MatrixXd A(4, 4); + A << 0, 0, 0, -2, + 1, 0, 0, -0, + 0, 1, 0, 2, + 0, 0, 2, -0; + RealSchur schur(A); + VERIFY(schur.info() == Eigen::Success); +} + +EIGEN_DECLARE_TEST(schur_real) +{ + CALL_SUBTEST_1(( schur() )); + CALL_SUBTEST_2(( schur(internal::random(1,EIGEN_TEST_MAX_SIZE/4)) )); + CALL_SUBTEST_3(( schur >() )); + CALL_SUBTEST_4(( schur >() )); + + // Test problem size constructors + CALL_SUBTEST_5(RealSchur(10)); + + CALL_SUBTEST_6(( test_bug2633() )); +} diff --git a/include/eigen/test/selfadjoint.cpp b/include/eigen/test/selfadjoint.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9ca9cef9e11aafc5279dc56a59b0987eea0ce696 --- /dev/null +++ b/include/eigen/test/selfadjoint.cpp @@ -0,0 +1,75 @@ +// This file is triangularView of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2010 Gael Guennebaud +// +// 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/. + +#define TEST_CHECK_STATIC_ASSERTIONS +#include "main.h" + +// This file tests the basic selfadjointView API, +// the related products and decompositions are tested in specific files. + +template void selfadjoint(const MatrixType& m) +{ + typedef typename MatrixType::Scalar Scalar; + + Index rows = m.rows(); + Index cols = m.cols(); + + MatrixType m1 = MatrixType::Random(rows, cols), + m2 = MatrixType::Random(rows, cols), + m3(rows, cols), + m4(rows, cols); + + m1.diagonal() = m1.diagonal().real().template cast(); + + // check selfadjoint to dense + m3 = m1.template selfadjointView(); + VERIFY_IS_APPROX(MatrixType(m3.template triangularView()), MatrixType(m1.template triangularView())); + VERIFY_IS_APPROX(m3, m3.adjoint()); + + m3 = m1.template selfadjointView(); + VERIFY_IS_APPROX(MatrixType(m3.template triangularView()), MatrixType(m1.template triangularView())); + VERIFY_IS_APPROX(m3, m3.adjoint()); + + m3 = m1.template selfadjointView(); + m4 = m2; + m4 += m1.template selfadjointView(); + VERIFY_IS_APPROX(m4, m2+m3); + + m3 = m1.template selfadjointView(); + m4 = m2; + m4 -= m1.template selfadjointView(); + VERIFY_IS_APPROX(m4, m2-m3); + + VERIFY_RAISES_STATIC_ASSERT(m2.template selfadjointView()); + VERIFY_RAISES_STATIC_ASSERT(m2.template selfadjointView()); +} + +void bug_159() +{ + Matrix3d m = Matrix3d::Random().selfadjointView(); + EIGEN_UNUSED_VARIABLE(m) +} + +EIGEN_DECLARE_TEST(selfadjoint) +{ + for(int i = 0; i < g_repeat ; i++) + { + int s = internal::random(1,EIGEN_TEST_MAX_SIZE); + + CALL_SUBTEST_1( selfadjoint(Matrix()) ); + CALL_SUBTEST_2( selfadjoint(Matrix()) ); + CALL_SUBTEST_3( selfadjoint(Matrix3cf()) ); + CALL_SUBTEST_4( selfadjoint(MatrixXcd(s,s)) ); + CALL_SUBTEST_5( selfadjoint(Matrix(s, s)) ); + + TEST_SET_BUT_UNUSED_VARIABLE(s) + } + + CALL_SUBTEST_1( bug_159() ); +} diff --git a/include/eigen/test/simplicial_cholesky.cpp b/include/eigen/test/simplicial_cholesky.cpp new file mode 100644 index 0000000000000000000000000000000000000000..538d01ab5223fb0c4cfb0703e4ff8cf0123c08b9 --- /dev/null +++ b/include/eigen/test/simplicial_cholesky.cpp @@ -0,0 +1,50 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2011 Gael Guennebaud +// +// 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/. + +#include "sparse_solver.h" + +template void test_simplicial_cholesky_T() +{ + typedef SparseMatrix SparseMatrixType; + SimplicialCholesky chol_colmajor_lower_amd; + SimplicialCholesky chol_colmajor_upper_amd; + SimplicialLLT< SparseMatrixType, Lower> llt_colmajor_lower_amd; + SimplicialLLT< SparseMatrixType, Upper> llt_colmajor_upper_amd; + SimplicialLDLT< SparseMatrixType, Lower> ldlt_colmajor_lower_amd; + SimplicialLDLT< SparseMatrixType, Upper> ldlt_colmajor_upper_amd; + SimplicialLDLT< SparseMatrixType, Lower, NaturalOrdering > ldlt_colmajor_lower_nat; + SimplicialLDLT< SparseMatrixType, Upper, NaturalOrdering > ldlt_colmajor_upper_nat; + + check_sparse_spd_solving(chol_colmajor_lower_amd); + check_sparse_spd_solving(chol_colmajor_upper_amd); + check_sparse_spd_solving(llt_colmajor_lower_amd); + check_sparse_spd_solving(llt_colmajor_upper_amd); + check_sparse_spd_solving(ldlt_colmajor_lower_amd); + check_sparse_spd_solving(ldlt_colmajor_upper_amd); + + check_sparse_spd_determinant(chol_colmajor_lower_amd); + check_sparse_spd_determinant(chol_colmajor_upper_amd); + check_sparse_spd_determinant(llt_colmajor_lower_amd); + check_sparse_spd_determinant(llt_colmajor_upper_amd); + check_sparse_spd_determinant(ldlt_colmajor_lower_amd); + check_sparse_spd_determinant(ldlt_colmajor_upper_amd); + + check_sparse_spd_solving(ldlt_colmajor_lower_nat, (std::min)(300,EIGEN_TEST_MAX_SIZE), 1000); + check_sparse_spd_solving(ldlt_colmajor_upper_nat, (std::min)(300,EIGEN_TEST_MAX_SIZE), 1000); +} + +EIGEN_DECLARE_TEST(simplicial_cholesky) +{ + CALL_SUBTEST_11(( test_simplicial_cholesky_T() )); + CALL_SUBTEST_12(( test_simplicial_cholesky_T, int, ColMajor>() )); + CALL_SUBTEST_13(( test_simplicial_cholesky_T() )); + CALL_SUBTEST_21(( test_simplicial_cholesky_T() )); + CALL_SUBTEST_22(( test_simplicial_cholesky_T, int, RowMajor>() )); + CALL_SUBTEST_23(( test_simplicial_cholesky_T() )); +} diff --git a/include/eigen/test/sizeoverflow.cpp b/include/eigen/test/sizeoverflow.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4213512335d7f91d6ef8dc2cc1d7928b8b678521 --- /dev/null +++ b/include/eigen/test/sizeoverflow.cpp @@ -0,0 +1,64 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2011 Benoit Jacob +// +// 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/. + +#include "main.h" + +#define VERIFY_THROWS_BADALLOC(a) { \ + bool threw = false; \ + try { \ + a; \ + } \ + catch (std::bad_alloc&) { threw = true; } \ + VERIFY(threw && "should have thrown bad_alloc: " #a); \ + } + +template +void triggerMatrixBadAlloc(Index rows, Index cols) +{ + VERIFY_THROWS_BADALLOC( MatrixType m(rows, cols) ); + VERIFY_THROWS_BADALLOC( MatrixType m; m.resize(rows, cols) ); + VERIFY_THROWS_BADALLOC( MatrixType m; m.conservativeResize(rows, cols) ); +} + +template +void triggerVectorBadAlloc(Index size) +{ + VERIFY_THROWS_BADALLOC( VectorType v(size) ); + VERIFY_THROWS_BADALLOC( VectorType v; v.resize(size) ); + VERIFY_THROWS_BADALLOC( VectorType v; v.conservativeResize(size) ); +} + +EIGEN_DECLARE_TEST(sizeoverflow) +{ + // there are 2 levels of overflow checking. first in PlainObjectBase.h we check for overflow in rows*cols computations. + // this is tested in tests of the form times_itself_gives_0 * times_itself_gives_0 + // Then in Memory.h we check for overflow in size * sizeof(T) computations. + // this is tested in tests of the form times_4_gives_0 * sizeof(float) + + size_t times_itself_gives_0 = size_t(1) << (8 * sizeof(Index) / 2); + VERIFY(times_itself_gives_0 * times_itself_gives_0 == 0); + + size_t times_4_gives_0 = size_t(1) << (8 * sizeof(Index) - 2); + VERIFY(times_4_gives_0 * 4 == 0); + + size_t times_8_gives_0 = size_t(1) << (8 * sizeof(Index) - 3); + VERIFY(times_8_gives_0 * 8 == 0); + + triggerMatrixBadAlloc(times_itself_gives_0, times_itself_gives_0); + triggerMatrixBadAlloc(times_itself_gives_0 / 4, times_itself_gives_0); + triggerMatrixBadAlloc(times_4_gives_0, 1); + + triggerMatrixBadAlloc(times_itself_gives_0, times_itself_gives_0); + triggerMatrixBadAlloc(times_itself_gives_0 / 8, times_itself_gives_0); + triggerMatrixBadAlloc(times_8_gives_0, 1); + + triggerVectorBadAlloc(times_4_gives_0); + + triggerVectorBadAlloc(times_8_gives_0); +} diff --git a/include/eigen/test/sparse.h b/include/eigen/test/sparse.h new file mode 100644 index 0000000000000000000000000000000000000000..6cd07fc0aa6fd942aa64623ff66303ad644727c2 --- /dev/null +++ b/include/eigen/test/sparse.h @@ -0,0 +1,204 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2008-2011 Gael Guennebaud +// +// 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/. + +#ifndef EIGEN_TESTSPARSE_H +#define EIGEN_TESTSPARSE_H + +#define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET + +#include "main.h" + +#if EIGEN_HAS_CXX11 + +#ifdef min +#undef min +#endif + +#ifdef max +#undef max +#endif + +#include +#define EIGEN_UNORDERED_MAP_SUPPORT + +#endif + +#include +#include +#include + +enum { + ForceNonZeroDiag = 1, + MakeLowerTriangular = 2, + MakeUpperTriangular = 4, + ForceRealDiag = 8 +}; + +/* Initializes both a sparse and dense matrix with same random values, + * and a ratio of \a density non zero entries. + * \param flags is a union of ForceNonZeroDiag, MakeLowerTriangular and MakeUpperTriangular + * allowing to control the shape of the matrix. + * \param zeroCoords and nonzeroCoords allows to get the coordinate lists of the non zero, + * and zero coefficients respectively. + */ +template void +initSparse(double density, + Matrix& refMat, + SparseMatrix& sparseMat, + int flags = 0, + std::vector >* zeroCoords = 0, + std::vector >* nonzeroCoords = 0) +{ + enum { IsRowMajor = SparseMatrix::IsRowMajor }; + sparseMat.setZero(); + //sparseMat.reserve(int(refMat.rows()*refMat.cols()*density)); + sparseMat.reserve(VectorXi::Constant(IsRowMajor ? refMat.rows() : refMat.cols(), int((1.5*density)*(IsRowMajor?refMat.cols():refMat.rows())))); + + for(Index j=0; j(0,1) < density) ? internal::random() : Scalar(0); + if ((flags&ForceNonZeroDiag) && (i==j)) + { + // FIXME: the following is too conservative + v = internal::random()*Scalar(3.); + v = v*v; + if(numext::real(v)>0) v += Scalar(5); + else v -= Scalar(5); + } + if ((flags & MakeLowerTriangular) && aj>ai) + v = Scalar(0); + else if ((flags & MakeUpperTriangular) && ajpush_back(Matrix (ai,aj)); + } + else if (zeroCoords) + { + zeroCoords->push_back(Matrix (ai,aj)); + } + refMat(ai,aj) = v; + } + } + //sparseMat.finalize(); +} + +template void +initSparse(double density, + Matrix& refMat, + DynamicSparseMatrix& sparseMat, + int flags = 0, + std::vector >* zeroCoords = 0, + std::vector >* nonzeroCoords = 0) +{ + enum { IsRowMajor = DynamicSparseMatrix::IsRowMajor }; + sparseMat.setZero(); + sparseMat.reserve(int(refMat.rows()*refMat.cols()*density)); + for(int j=0; j(0,1) < density) ? internal::random() : Scalar(0); + if ((flags&ForceNonZeroDiag) && (i==j)) + { + v = internal::random()*Scalar(3.); + v = v*v + Scalar(5.); + } + if ((flags & MakeLowerTriangular) && aj>ai) + v = Scalar(0); + else if ((flags & MakeUpperTriangular) && ajpush_back(Matrix (ai,aj)); + } + else if (zeroCoords) + { + zeroCoords->push_back(Matrix (ai,aj)); + } + refMat(ai,aj) = v; + } + } + sparseMat.finalize(); +} + +template void +initSparse(double density, + Matrix& refVec, + SparseVector& sparseVec, + std::vector* zeroCoords = 0, + std::vector* nonzeroCoords = 0) +{ + sparseVec.reserve(int(refVec.size()*density)); + sparseVec.setZero(); + for(int i=0; i(0,1) < density) ? internal::random() : Scalar(0); + if (v!=Scalar(0)) + { + sparseVec.insertBack(i) = v; + if (nonzeroCoords) + nonzeroCoords->push_back(i); + } + else if (zeroCoords) + zeroCoords->push_back(i); + refVec[i] = v; + } +} + +template void +initSparse(double density, + Matrix& refVec, + SparseVector& sparseVec, + std::vector* zeroCoords = 0, + std::vector* nonzeroCoords = 0) +{ + sparseVec.reserve(int(refVec.size()*density)); + sparseVec.setZero(); + for(int i=0; i(0,1) < density) ? internal::random() : Scalar(0); + if (v!=Scalar(0)) + { + sparseVec.insertBack(i) = v; + if (nonzeroCoords) + nonzeroCoords->push_back(i); + } + else if (zeroCoords) + zeroCoords->push_back(i); + refVec[i] = v; + } +} + + +#include +#endif // EIGEN_TESTSPARSE_H diff --git a/include/eigen/test/sparse_basic.cpp b/include/eigen/test/sparse_basic.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9453111b7f8294d8c85938368153e35bbe5e8c71 --- /dev/null +++ b/include/eigen/test/sparse_basic.cpp @@ -0,0 +1,760 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2008-2011 Gael Guennebaud +// Copyright (C) 2008 Daniel Gomez Ferro +// Copyright (C) 2013 Désiré Nuentsa-Wakam +// +// 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/. + +#ifndef EIGEN_SPARSE_TEST_INCLUDED_FROM_SPARSE_EXTRA +static long g_realloc_count = 0; +#define EIGEN_SPARSE_COMPRESSED_STORAGE_REALLOCATE_PLUGIN g_realloc_count++; + +static long g_dense_op_sparse_count = 0; +#define EIGEN_SPARSE_ASSIGNMENT_FROM_DENSE_OP_SPARSE_PLUGIN g_dense_op_sparse_count++; +#define EIGEN_SPARSE_ASSIGNMENT_FROM_SPARSE_ADD_DENSE_PLUGIN g_dense_op_sparse_count+=10; +#define EIGEN_SPARSE_ASSIGNMENT_FROM_SPARSE_SUB_DENSE_PLUGIN g_dense_op_sparse_count+=20; +#endif + +#include "sparse.h" + +template void sparse_basic(const SparseMatrixType& ref) +{ + typedef typename SparseMatrixType::StorageIndex StorageIndex; + typedef Matrix Vector2; + + const Index rows = ref.rows(); + const Index cols = ref.cols(); + //const Index inner = ref.innerSize(); + //const Index outer = ref.outerSize(); + + typedef typename SparseMatrixType::Scalar Scalar; + typedef typename SparseMatrixType::RealScalar RealScalar; + enum { Flags = SparseMatrixType::Flags }; + + double density = (std::max)(8./(rows*cols), 0.01); + typedef Matrix DenseMatrix; + typedef Matrix DenseVector; + Scalar eps = 1e-6; + + Scalar s1 = internal::random(); + { + SparseMatrixType m(rows, cols); + DenseMatrix refMat = DenseMatrix::Zero(rows, cols); + DenseVector vec1 = DenseVector::Random(rows); + + std::vector zeroCoords; + std::vector nonzeroCoords; + initSparse(density, refMat, m, 0, &zeroCoords, &nonzeroCoords); + + // test coeff and coeffRef + for (std::size_t i=0; i >::value) + VERIFY_RAISES_ASSERT( m.coeffRef(zeroCoords[i].x(),zeroCoords[i].y()) = 5 ); + } + VERIFY_IS_APPROX(m, refMat); + + if(!nonzeroCoords.empty()) { + m.coeffRef(nonzeroCoords[0].x(), nonzeroCoords[0].y()) = Scalar(5); + refMat.coeffRef(nonzeroCoords[0].x(), nonzeroCoords[0].y()) = Scalar(5); + } + + VERIFY_IS_APPROX(m, refMat); + + // test assertion + VERIFY_RAISES_ASSERT( m.coeffRef(-1,1) = 0 ); + VERIFY_RAISES_ASSERT( m.coeffRef(0,m.cols()) = 0 ); + } + + // test insert (inner random) + { + DenseMatrix m1(rows,cols); + m1.setZero(); + SparseMatrixType m2(rows,cols); + bool call_reserve = internal::random()%2; + Index nnz = internal::random(1,int(rows)/2); + if(call_reserve) + { + if(internal::random()%2) + m2.reserve(VectorXi::Constant(m2.outerSize(), int(nnz))); + else + m2.reserve(m2.outerSize() * nnz); + } + g_realloc_count = 0; + for (Index j=0; j(0,rows-1); + if (m1.coeff(i,j)==Scalar(0)) + m2.insert(i,j) = m1(i,j) = internal::random(); + } + } + + if(call_reserve && !SparseMatrixType::IsRowMajor) + { + VERIFY(g_realloc_count==0); + } + + m2.finalize(); + VERIFY_IS_APPROX(m2,m1); + } + + // test insert (fully random) + { + DenseMatrix m1(rows,cols); + m1.setZero(); + SparseMatrixType m2(rows,cols); + if(internal::random()%2) + m2.reserve(VectorXi::Constant(m2.outerSize(), 2)); + for (int k=0; k(0,rows-1); + Index j = internal::random(0,cols-1); + if ((m1.coeff(i,j)==Scalar(0)) && (internal::random()%2)) + m2.insert(i,j) = m1(i,j) = internal::random(); + else + { + Scalar v = internal::random(); + m2.coeffRef(i,j) += v; + m1(i,j) += v; + } + } + VERIFY_IS_APPROX(m2,m1); + } + + // test insert (un-compressed) + for(int mode=0;mode<4;++mode) + { + DenseMatrix m1(rows,cols); + m1.setZero(); + SparseMatrixType m2(rows,cols); + VectorXi r(VectorXi::Constant(m2.outerSize(), ((mode%2)==0) ? int(m2.innerSize()) : std::max(1,int(m2.innerSize())/8))); + m2.reserve(r); + for (Index k=0; k(0,rows-1); + Index j = internal::random(0,cols-1); + if (m1.coeff(i,j)==Scalar(0)) + m2.insert(i,j) = m1(i,j) = internal::random(); + if(mode==3) + m2.reserve(r); + } + if(internal::random()%2) + m2.makeCompressed(); + VERIFY_IS_APPROX(m2,m1); + } + + // test basic computations + { + DenseMatrix refM1 = DenseMatrix::Zero(rows, cols); + DenseMatrix refM2 = DenseMatrix::Zero(rows, cols); + DenseMatrix refM3 = DenseMatrix::Zero(rows, cols); + DenseMatrix refM4 = DenseMatrix::Zero(rows, cols); + SparseMatrixType m1(rows, cols); + SparseMatrixType m2(rows, cols); + SparseMatrixType m3(rows, cols); + SparseMatrixType m4(rows, cols); + initSparse(density, refM1, m1); + initSparse(density, refM2, m2); + initSparse(density, refM3, m3); + initSparse(density, refM4, m4); + + if(internal::random()) + m1.makeCompressed(); + + Index m1_nnz = m1.nonZeros(); + + VERIFY_IS_APPROX(m1*s1, refM1*s1); + VERIFY_IS_APPROX(m1+m2, refM1+refM2); + VERIFY_IS_APPROX(m1+m2+m3, refM1+refM2+refM3); + VERIFY_IS_APPROX(m3.cwiseProduct(m1+m2), refM3.cwiseProduct(refM1+refM2)); + VERIFY_IS_APPROX(m1*s1-m2, refM1*s1-refM2); + VERIFY_IS_APPROX(m4=m1/s1, refM1/s1); + VERIFY_IS_EQUAL(m4.nonZeros(), m1_nnz); + + if(SparseMatrixType::IsRowMajor) + VERIFY_IS_APPROX(m1.innerVector(0).dot(refM2.row(0)), refM1.row(0).dot(refM2.row(0))); + else + VERIFY_IS_APPROX(m1.innerVector(0).dot(refM2.col(0)), refM1.col(0).dot(refM2.col(0))); + + DenseVector rv = DenseVector::Random(m1.cols()); + DenseVector cv = DenseVector::Random(m1.rows()); + Index r = internal::random(0,m1.rows()-2); + Index c = internal::random(0,m1.cols()-1); + VERIFY_IS_APPROX(( m1.template block<1,Dynamic>(r,0,1,m1.cols()).dot(rv)) , refM1.row(r).dot(rv)); + VERIFY_IS_APPROX(m1.row(r).dot(rv), refM1.row(r).dot(rv)); + VERIFY_IS_APPROX(m1.col(c).dot(cv), refM1.col(c).dot(cv)); + + VERIFY_IS_APPROX(m1.conjugate(), refM1.conjugate()); + VERIFY_IS_APPROX(m1.real(), refM1.real()); + + refM4.setRandom(); + // sparse cwise* dense + VERIFY_IS_APPROX(m3.cwiseProduct(refM4), refM3.cwiseProduct(refM4)); + // dense cwise* sparse + VERIFY_IS_APPROX(refM4.cwiseProduct(m3), refM4.cwiseProduct(refM3)); +// VERIFY_IS_APPROX(m3.cwise()/refM4, refM3.cwise()/refM4); + + // mixed sparse-dense + VERIFY_IS_APPROX(refM4 + m3, refM4 + refM3); + VERIFY_IS_APPROX(m3 + refM4, refM3 + refM4); + VERIFY_IS_APPROX(refM4 - m3, refM4 - refM3); + VERIFY_IS_APPROX(m3 - refM4, refM3 - refM4); + VERIFY_IS_APPROX((RealScalar(0.5)*refM4 + RealScalar(0.5)*m3).eval(), RealScalar(0.5)*refM4 + RealScalar(0.5)*refM3); + VERIFY_IS_APPROX((RealScalar(0.5)*refM4 + m3*RealScalar(0.5)).eval(), RealScalar(0.5)*refM4 + RealScalar(0.5)*refM3); + VERIFY_IS_APPROX((RealScalar(0.5)*refM4 + m3.cwiseProduct(m3)).eval(), RealScalar(0.5)*refM4 + refM3.cwiseProduct(refM3)); + + VERIFY_IS_APPROX((RealScalar(0.5)*refM4 + RealScalar(0.5)*m3).eval(), RealScalar(0.5)*refM4 + RealScalar(0.5)*refM3); + VERIFY_IS_APPROX((RealScalar(0.5)*refM4 + m3*RealScalar(0.5)).eval(), RealScalar(0.5)*refM4 + RealScalar(0.5)*refM3); + VERIFY_IS_APPROX((RealScalar(0.5)*refM4 + (m3+m3)).eval(), RealScalar(0.5)*refM4 + (refM3+refM3)); + VERIFY_IS_APPROX(((refM3+m3)+RealScalar(0.5)*m3).eval(), RealScalar(0.5)*refM3 + (refM3+refM3)); + VERIFY_IS_APPROX((RealScalar(0.5)*refM4 + (refM3+m3)).eval(), RealScalar(0.5)*refM4 + (refM3+refM3)); + VERIFY_IS_APPROX((RealScalar(0.5)*refM4 + (m3+refM3)).eval(), RealScalar(0.5)*refM4 + (refM3+refM3)); + + + VERIFY_IS_APPROX(m1.sum(), refM1.sum()); + + m4 = m1; refM4 = m4; + + VERIFY_IS_APPROX(m1*=s1, refM1*=s1); + VERIFY_IS_EQUAL(m1.nonZeros(), m1_nnz); + VERIFY_IS_APPROX(m1/=s1, refM1/=s1); + VERIFY_IS_EQUAL(m1.nonZeros(), m1_nnz); + + VERIFY_IS_APPROX(m1+=m2, refM1+=refM2); + VERIFY_IS_APPROX(m1-=m2, refM1-=refM2); + + refM3 = refM1; + + VERIFY_IS_APPROX(refM1+=m2, refM3+=refM2); + VERIFY_IS_APPROX(refM1-=m2, refM3-=refM2); + + g_dense_op_sparse_count=0; VERIFY_IS_APPROX(refM1 =m2+refM4, refM3 =refM2+refM4); VERIFY_IS_EQUAL(g_dense_op_sparse_count,10); + g_dense_op_sparse_count=0; VERIFY_IS_APPROX(refM1+=m2+refM4, refM3+=refM2+refM4); VERIFY_IS_EQUAL(g_dense_op_sparse_count,1); + g_dense_op_sparse_count=0; VERIFY_IS_APPROX(refM1-=m2+refM4, refM3-=refM2+refM4); VERIFY_IS_EQUAL(g_dense_op_sparse_count,1); + g_dense_op_sparse_count=0; VERIFY_IS_APPROX(refM1 =refM4+m2, refM3 =refM2+refM4); VERIFY_IS_EQUAL(g_dense_op_sparse_count,1); + g_dense_op_sparse_count=0; VERIFY_IS_APPROX(refM1+=refM4+m2, refM3+=refM2+refM4); VERIFY_IS_EQUAL(g_dense_op_sparse_count,1); + g_dense_op_sparse_count=0; VERIFY_IS_APPROX(refM1-=refM4+m2, refM3-=refM2+refM4); VERIFY_IS_EQUAL(g_dense_op_sparse_count,1); + + g_dense_op_sparse_count=0; VERIFY_IS_APPROX(refM1 =m2-refM4, refM3 =refM2-refM4); VERIFY_IS_EQUAL(g_dense_op_sparse_count,20); + g_dense_op_sparse_count=0; VERIFY_IS_APPROX(refM1+=m2-refM4, refM3+=refM2-refM4); VERIFY_IS_EQUAL(g_dense_op_sparse_count,1); + g_dense_op_sparse_count=0; VERIFY_IS_APPROX(refM1-=m2-refM4, refM3-=refM2-refM4); VERIFY_IS_EQUAL(g_dense_op_sparse_count,1); + g_dense_op_sparse_count=0; VERIFY_IS_APPROX(refM1 =refM4-m2, refM3 =refM4-refM2); VERIFY_IS_EQUAL(g_dense_op_sparse_count,1); + g_dense_op_sparse_count=0; VERIFY_IS_APPROX(refM1+=refM4-m2, refM3+=refM4-refM2); VERIFY_IS_EQUAL(g_dense_op_sparse_count,1); + g_dense_op_sparse_count=0; VERIFY_IS_APPROX(refM1-=refM4-m2, refM3-=refM4-refM2); VERIFY_IS_EQUAL(g_dense_op_sparse_count,1); + refM3 = m3; + + if (rows>=2 && cols>=2) + { + VERIFY_RAISES_ASSERT( m1 += m1.innerVector(0) ); + VERIFY_RAISES_ASSERT( m1 -= m1.innerVector(0) ); + VERIFY_RAISES_ASSERT( refM1 -= m1.innerVector(0) ); + VERIFY_RAISES_ASSERT( refM1 += m1.innerVector(0) ); + } + m1 = m4; refM1 = refM4; + + // test aliasing + VERIFY_IS_APPROX((m1 = -m1), (refM1 = -refM1)); + VERIFY_IS_EQUAL(m1.nonZeros(), m1_nnz); + m1 = m4; refM1 = refM4; + VERIFY_IS_APPROX((m1 = m1.transpose()), (refM1 = refM1.transpose().eval())); + VERIFY_IS_EQUAL(m1.nonZeros(), m1_nnz); + m1 = m4; refM1 = refM4; + VERIFY_IS_APPROX((m1 = -m1.transpose()), (refM1 = -refM1.transpose().eval())); + VERIFY_IS_EQUAL(m1.nonZeros(), m1_nnz); + m1 = m4; refM1 = refM4; + VERIFY_IS_APPROX((m1 += -m1), (refM1 += -refM1)); + VERIFY_IS_EQUAL(m1.nonZeros(), m1_nnz); + m1 = m4; refM1 = refM4; + + if(m1.isCompressed()) + { + VERIFY_IS_APPROX(m1.coeffs().sum(), m1.sum()); + m1.coeffs() += s1; + for(Index j = 0; j SpBool; + SpBool mb1 = m1.real().template cast(); + SpBool mb2 = m2.real().template cast(); + VERIFY_IS_EQUAL(mb1.template cast().sum(), refM1.real().template cast().count()); + VERIFY_IS_EQUAL((mb1 && mb2).template cast().sum(), (refM1.real().template cast() && refM2.real().template cast()).count()); + VERIFY_IS_EQUAL((mb1 || mb2).template cast().sum(), (refM1.real().template cast() || refM2.real().template cast()).count()); + SpBool mb3 = mb1 && mb2; + if(mb1.coeffs().all() && mb2.coeffs().all()) + { + VERIFY_IS_EQUAL(mb3.nonZeros(), (refM1.real().template cast() && refM2.real().template cast()).count()); + } + } + } + + // test reverse iterators + { + DenseMatrix refMat2 = DenseMatrix::Zero(rows, cols); + SparseMatrixType m2(rows, cols); + initSparse(density, refMat2, m2); + std::vector ref_value(m2.innerSize()); + std::vector ref_index(m2.innerSize()); + if(internal::random()) + m2.makeCompressed(); + for(Index j = 0; j(density, refMat2, m2); + VERIFY_IS_APPROX(m2.transpose().eval(), refMat2.transpose().eval()); + VERIFY_IS_APPROX(m2.transpose(), refMat2.transpose()); + + VERIFY_IS_APPROX(SparseMatrixType(m2.adjoint()), refMat2.adjoint()); + + // check isApprox handles opposite storage order + typename Transpose::PlainObject m3(m2); + VERIFY(m2.isApprox(m3)); + } + + // test prune + { + SparseMatrixType m2(rows, cols); + DenseMatrix refM2(rows, cols); + refM2.setZero(); + int countFalseNonZero = 0; + int countTrueNonZero = 0; + m2.reserve(VectorXi::Constant(m2.outerSize(), int(m2.innerSize()))); + for (Index j=0; j(0,1); + if (x<0.1f) + { + // do nothing + } + else if (x<0.5f) + { + countFalseNonZero++; + m2.insert(i,j) = Scalar(0); + } + else + { + countTrueNonZero++; + m2.insert(i,j) = Scalar(1); + refM2(i,j) = Scalar(1); + } + } + } + if(internal::random()) + m2.makeCompressed(); + VERIFY(countFalseNonZero+countTrueNonZero == m2.nonZeros()); + if(countTrueNonZero>0) + VERIFY_IS_APPROX(m2, refM2); + m2.prune(Scalar(1)); + VERIFY(countTrueNonZero==m2.nonZeros()); + VERIFY_IS_APPROX(m2, refM2); + } + + // test setFromTriplets + { + typedef Triplet TripletType; + std::vector triplets; + Index ntriplets = rows*cols; + triplets.reserve(ntriplets); + DenseMatrix refMat_sum = DenseMatrix::Zero(rows,cols); + DenseMatrix refMat_prod = DenseMatrix::Zero(rows,cols); + DenseMatrix refMat_last = DenseMatrix::Zero(rows,cols); + + for(Index i=0;i(0,StorageIndex(rows-1)); + StorageIndex c = internal::random(0,StorageIndex(cols-1)); + Scalar v = internal::random(); + triplets.push_back(TripletType(r,c,v)); + refMat_sum(r,c) += v; + if(std::abs(refMat_prod(r,c))==0) + refMat_prod(r,c) = v; + else + refMat_prod(r,c) *= v; + refMat_last(r,c) = v; + } + SparseMatrixType m(rows,cols); + m.setFromTriplets(triplets.begin(), triplets.end()); + VERIFY_IS_APPROX(m, refMat_sum); + + m.setFromTriplets(triplets.begin(), triplets.end(), std::multiplies()); + VERIFY_IS_APPROX(m, refMat_prod); +#if (EIGEN_COMP_CXXVER >= 11) + m.setFromTriplets(triplets.begin(), triplets.end(), [] (Scalar,Scalar b) { return b; }); + VERIFY_IS_APPROX(m, refMat_last); +#endif + } + + // test Map + { + DenseMatrix refMat2(rows, cols), refMat3(rows, cols); + SparseMatrixType m2(rows, cols), m3(rows, cols); + initSparse(density, refMat2, m2); + initSparse(density, refMat3, m3); + { + Map mapMat2(m2.rows(), m2.cols(), m2.nonZeros(), m2.outerIndexPtr(), m2.innerIndexPtr(), m2.valuePtr(), m2.innerNonZeroPtr()); + Map mapMat3(m3.rows(), m3.cols(), m3.nonZeros(), m3.outerIndexPtr(), m3.innerIndexPtr(), m3.valuePtr(), m3.innerNonZeroPtr()); + VERIFY_IS_APPROX(mapMat2+mapMat3, refMat2+refMat3); + VERIFY_IS_APPROX(mapMat2+mapMat3, refMat2+refMat3); + } + { + MappedSparseMatrix mapMat2(m2.rows(), m2.cols(), m2.nonZeros(), m2.outerIndexPtr(), m2.innerIndexPtr(), m2.valuePtr(), m2.innerNonZeroPtr()); + MappedSparseMatrix mapMat3(m3.rows(), m3.cols(), m3.nonZeros(), m3.outerIndexPtr(), m3.innerIndexPtr(), m3.valuePtr(), m3.innerNonZeroPtr()); + VERIFY_IS_APPROX(mapMat2+mapMat3, refMat2+refMat3); + VERIFY_IS_APPROX(mapMat2+mapMat3, refMat2+refMat3); + } + + Index i = internal::random(0,rows-1); + Index j = internal::random(0,cols-1); + m2.coeffRef(i,j) = 123; + if(internal::random()) + m2.makeCompressed(); + Map mapMat2(rows, cols, m2.nonZeros(), m2.outerIndexPtr(), m2.innerIndexPtr(), m2.valuePtr(), m2.innerNonZeroPtr()); + VERIFY_IS_EQUAL(m2.coeff(i,j),Scalar(123)); + VERIFY_IS_EQUAL(mapMat2.coeff(i,j),Scalar(123)); + mapMat2.coeffRef(i,j) = -123; + VERIFY_IS_EQUAL(m2.coeff(i,j),Scalar(-123)); + } + + // test triangularView + { + DenseMatrix refMat2(rows, cols), refMat3(rows, cols); + SparseMatrixType m2(rows, cols), m3(rows, cols); + initSparse(density, refMat2, m2); + refMat3 = refMat2.template triangularView(); + m3 = m2.template triangularView(); + VERIFY_IS_APPROX(m3, refMat3); + + refMat3 = refMat2.template triangularView(); + m3 = m2.template triangularView(); + VERIFY_IS_APPROX(m3, refMat3); + + { + refMat3 = refMat2.template triangularView(); + m3 = m2.template triangularView(); + VERIFY_IS_APPROX(m3, refMat3); + + refMat3 = refMat2.template triangularView(); + m3 = m2.template triangularView(); + VERIFY_IS_APPROX(m3, refMat3); + } + + refMat3 = refMat2.template triangularView(); + m3 = m2.template triangularView(); + VERIFY_IS_APPROX(m3, refMat3); + + refMat3 = refMat2.template triangularView(); + m3 = m2.template triangularView(); + VERIFY_IS_APPROX(m3, refMat3); + + // check sparse-triangular to dense + refMat3 = m2.template triangularView(); + VERIFY_IS_APPROX(refMat3, DenseMatrix(refMat2.template triangularView())); + } + + // test selfadjointView + if(!SparseMatrixType::IsRowMajor) + { + DenseMatrix refMat2(rows, rows), refMat3(rows, rows); + SparseMatrixType m2(rows, rows), m3(rows, rows); + initSparse(density, refMat2, m2); + refMat3 = refMat2.template selfadjointView(); + m3 = m2.template selfadjointView(); + VERIFY_IS_APPROX(m3, refMat3); + + refMat3 += refMat2.template selfadjointView(); + m3 += m2.template selfadjointView(); + VERIFY_IS_APPROX(m3, refMat3); + + refMat3 -= refMat2.template selfadjointView(); + m3 -= m2.template selfadjointView(); + VERIFY_IS_APPROX(m3, refMat3); + + // selfadjointView only works for square matrices: + SparseMatrixType m4(rows, rows+1); + VERIFY_RAISES_ASSERT(m4.template selfadjointView()); + VERIFY_RAISES_ASSERT(m4.template selfadjointView()); + } + + // test sparseView + { + DenseMatrix refMat2 = DenseMatrix::Zero(rows, rows); + SparseMatrixType m2(rows, rows); + initSparse(density, refMat2, m2); + VERIFY_IS_APPROX(m2.eval(), refMat2.sparseView().eval()); + + // sparse view on expressions: + VERIFY_IS_APPROX((s1*m2).eval(), (s1*refMat2).sparseView().eval()); + VERIFY_IS_APPROX((m2+m2).eval(), (refMat2+refMat2).sparseView().eval()); + VERIFY_IS_APPROX((m2*m2).eval(), (refMat2.lazyProduct(refMat2)).sparseView().eval()); + VERIFY_IS_APPROX((m2*m2).eval(), (refMat2*refMat2).sparseView().eval()); + } + + // test diagonal + { + DenseMatrix refMat2 = DenseMatrix::Zero(rows, cols); + SparseMatrixType m2(rows, cols); + initSparse(density, refMat2, m2); + VERIFY_IS_APPROX(m2.diagonal(), refMat2.diagonal().eval()); + DenseVector d = m2.diagonal(); + VERIFY_IS_APPROX(d, refMat2.diagonal().eval()); + d = m2.diagonal().array(); + VERIFY_IS_APPROX(d, refMat2.diagonal().eval()); + VERIFY_IS_APPROX(const_cast(m2).diagonal(), refMat2.diagonal().eval()); + + initSparse(density, refMat2, m2, ForceNonZeroDiag); + m2.diagonal() += refMat2.diagonal(); + refMat2.diagonal() += refMat2.diagonal(); + VERIFY_IS_APPROX(m2, refMat2); + } + + // test diagonal to sparse + { + DenseVector d = DenseVector::Random(rows); + DenseMatrix refMat2 = d.asDiagonal(); + SparseMatrixType m2; + m2 = d.asDiagonal(); + VERIFY_IS_APPROX(m2, refMat2); + SparseMatrixType m3(d.asDiagonal()); + VERIFY_IS_APPROX(m3, refMat2); + refMat2 += d.asDiagonal(); + m2 += d.asDiagonal(); + VERIFY_IS_APPROX(m2, refMat2); + m2.setZero(); m2 += d.asDiagonal(); + refMat2.setZero(); refMat2 += d.asDiagonal(); + VERIFY_IS_APPROX(m2, refMat2); + m2.setZero(); m2 -= d.asDiagonal(); + refMat2.setZero(); refMat2 -= d.asDiagonal(); + VERIFY_IS_APPROX(m2, refMat2); + + initSparse(density, refMat2, m2); + m2.makeCompressed(); + m2 += d.asDiagonal(); + refMat2 += d.asDiagonal(); + VERIFY_IS_APPROX(m2, refMat2); + + initSparse(density, refMat2, m2); + m2.makeCompressed(); + VectorXi res(rows); + for(Index i=0; i(0,3); + m2.reserve(res); + m2 -= d.asDiagonal(); + refMat2 -= d.asDiagonal(); + VERIFY_IS_APPROX(m2, refMat2); + } + + // test conservative resize + { + std::vector< std::pair > inc; + if(rows > 3 && cols > 2) + inc.push_back(std::pair(-3,-2)); + inc.push_back(std::pair(0,0)); + inc.push_back(std::pair(3,2)); + inc.push_back(std::pair(3,0)); + inc.push_back(std::pair(0,3)); + inc.push_back(std::pair(0,-1)); + inc.push_back(std::pair(-1,0)); + inc.push_back(std::pair(-1,-1)); + + for(size_t i = 0; i< inc.size(); i++) { + StorageIndex incRows = inc[i].first; + StorageIndex incCols = inc[i].second; + SparseMatrixType m1(rows, cols); + DenseMatrix refMat1 = DenseMatrix::Zero(rows, cols); + initSparse(density, refMat1, m1); + + SparseMatrixType m2 = m1; + m2.makeCompressed(); + + m1.conservativeResize(rows+incRows, cols+incCols); + m2.conservativeResize(rows+incRows, cols+incCols); + refMat1.conservativeResize(rows+incRows, cols+incCols); + if (incRows > 0) refMat1.bottomRows(incRows).setZero(); + if (incCols > 0) refMat1.rightCols(incCols).setZero(); + + VERIFY_IS_APPROX(m1, refMat1); + VERIFY_IS_APPROX(m2, refMat1); + + // Insert new values + if (incRows > 0) + m1.insert(m1.rows()-1, 0) = refMat1(refMat1.rows()-1, 0) = 1; + if (incCols > 0) + m1.insert(0, m1.cols()-1) = refMat1(0, refMat1.cols()-1) = 1; + + VERIFY_IS_APPROX(m1, refMat1); + + + } + } + + // test Identity matrix + { + DenseMatrix refMat1 = DenseMatrix::Identity(rows, rows); + SparseMatrixType m1(rows, rows); + m1.setIdentity(); + VERIFY_IS_APPROX(m1, refMat1); + for(int k=0; k(0,rows-1); + Index j = internal::random(0,rows-1); + Scalar v = internal::random(); + m1.coeffRef(i,j) = v; + refMat1.coeffRef(i,j) = v; + VERIFY_IS_APPROX(m1, refMat1); + if(internal::random(0,10)<2) + m1.makeCompressed(); + } + m1.setIdentity(); + refMat1.setIdentity(); + VERIFY_IS_APPROX(m1, refMat1); + } + + // test array/vector of InnerIterator + { + typedef typename SparseMatrixType::InnerIterator IteratorType; + + DenseMatrix refMat2 = DenseMatrix::Zero(rows, cols); + SparseMatrixType m2(rows, cols); + initSparse(density, refMat2, m2); + IteratorType static_array[2]; + static_array[0] = IteratorType(m2,0); + static_array[1] = IteratorType(m2,m2.outerSize()-1); + VERIFY( static_array[0] || m2.innerVector(static_array[0].outer()).nonZeros() == 0 ); + VERIFY( static_array[1] || m2.innerVector(static_array[1].outer()).nonZeros() == 0 ); + if(static_array[0] && static_array[1]) + { + ++(static_array[1]); + static_array[1] = IteratorType(m2,0); + VERIFY( static_array[1] ); + VERIFY( static_array[1].index() == static_array[0].index() ); + VERIFY( static_array[1].outer() == static_array[0].outer() ); + VERIFY( static_array[1].value() == static_array[0].value() ); + } + + std::vector iters(2); + iters[0] = IteratorType(m2,0); + iters[1] = IteratorType(m2,m2.outerSize()-1); + } + + // test reserve with empty rows/columns + { + SparseMatrixType m1(0,cols); + m1.reserve(ArrayXi::Constant(m1.outerSize(),1)); + SparseMatrixType m2(rows,0); + m2.reserve(ArrayXi::Constant(m2.outerSize(),1)); + } +} + + +template +void big_sparse_triplet(Index rows, Index cols, double density) { + typedef typename SparseMatrixType::StorageIndex StorageIndex; + typedef typename SparseMatrixType::Scalar Scalar; + typedef Triplet TripletType; + std::vector triplets; + double nelements = density * rows*cols; + VERIFY(nelements>=0 && nelements < static_cast(NumTraits::highest())); + Index ntriplets = Index(nelements); + triplets.reserve(ntriplets); + Scalar sum = Scalar(0); + for(Index i=0;i(0,rows-1); + Index c = internal::random(0,cols-1); + // use positive values to prevent numerical cancellation errors in sum + Scalar v = numext::abs(internal::random()); + triplets.push_back(TripletType(r,c,v)); + sum += v; + } + SparseMatrixType m(rows,cols); + m.setFromTriplets(triplets.begin(), triplets.end()); + VERIFY(m.nonZeros() <= ntriplets); + VERIFY_IS_APPROX(sum, m.sum()); +} + +template +void bug1105() +{ + // Regression test for bug 1105 + int n = Eigen::internal::random(200,600); + SparseMatrix,0, long> mat(n, n); + std::complex val; + + for(int i=0; i(1,200), c = Eigen::internal::random(1,200); + if(Eigen::internal::random(0,4) == 0) { + r = c; // check square matrices in 25% of tries + } + EIGEN_UNUSED_VARIABLE(r+c); + CALL_SUBTEST_1(( sparse_basic(SparseMatrix(1, 1)) )); + CALL_SUBTEST_1(( sparse_basic(SparseMatrix(8, 8)) )); + CALL_SUBTEST_2(( sparse_basic(SparseMatrix, ColMajor>(r, c)) )); + CALL_SUBTEST_2(( sparse_basic(SparseMatrix, RowMajor>(r, c)) )); + CALL_SUBTEST_1(( sparse_basic(SparseMatrix(r, c)) )); + CALL_SUBTEST_5(( sparse_basic(SparseMatrix(r, c)) )); + CALL_SUBTEST_5(( sparse_basic(SparseMatrix(r, c)) )); + + r = Eigen::internal::random(1,100); + c = Eigen::internal::random(1,100); + if(Eigen::internal::random(0,4) == 0) { + r = c; // check square matrices in 25% of tries + } + + CALL_SUBTEST_6(( sparse_basic(SparseMatrix(short(r), short(c))) )); + CALL_SUBTEST_6(( sparse_basic(SparseMatrix(short(r), short(c))) )); + } + + // Regression test for bug 900: (manually insert higher values here, if you have enough RAM): + CALL_SUBTEST_3((big_sparse_triplet >(10000, 10000, 0.125))); + CALL_SUBTEST_4((big_sparse_triplet >(10000, 10000, 0.125))); + + CALL_SUBTEST_7( bug1105<0>() ); +} +#endif diff --git a/include/eigen/test/sparse_product.cpp b/include/eigen/test/sparse_product.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6e85f6914810e7bbf7285dfb57662fd483f44eb9 --- /dev/null +++ b/include/eigen/test/sparse_product.cpp @@ -0,0 +1,477 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2008-2011 Gael Guennebaud +// +// 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/. + +#if defined(_MSC_VER) && (_MSC_VER==1800) +// This unit test takes forever to compile in Release mode with MSVC 2013, +// multiple hours. So let's switch off optimization for this one. +#pragma optimize("",off) +#endif + +static long int nb_temporaries; + +inline void on_temporary_creation() { + // here's a great place to set a breakpoint when debugging failures in this test! + nb_temporaries++; +} + +#define EIGEN_SPARSE_CREATE_TEMPORARY_PLUGIN { on_temporary_creation(); } + +#include "sparse.h" + +#define VERIFY_EVALUATION_COUNT(XPR,N) {\ + nb_temporaries = 0; \ + CALL_SUBTEST( XPR ); \ + if(nb_temporaries!=N) std::cerr << "nb_temporaries == " << nb_temporaries << "\n"; \ + VERIFY( (#XPR) && nb_temporaries==N ); \ + } + + + +template void sparse_product() +{ + typedef typename SparseMatrixType::StorageIndex StorageIndex; + Index n = 100; + const Index rows = internal::random(1,n); + const Index cols = internal::random(1,n); + const Index depth = internal::random(1,n); + typedef typename SparseMatrixType::Scalar Scalar; + enum { Flags = SparseMatrixType::Flags }; + + double density = (std::max)(8./(rows*cols), 0.2); + typedef Matrix DenseMatrix; + typedef Matrix DenseVector; + typedef Matrix RowDenseVector; + typedef SparseVector ColSpVector; + typedef SparseVector RowSpVector; + + Scalar s1 = internal::random(); + Scalar s2 = internal::random(); + + // test matrix-matrix product + { + DenseMatrix refMat2 = DenseMatrix::Zero(rows, depth); + DenseMatrix refMat2t = DenseMatrix::Zero(depth, rows); + DenseMatrix refMat3 = DenseMatrix::Zero(depth, cols); + DenseMatrix refMat3t = DenseMatrix::Zero(cols, depth); + DenseMatrix refMat4 = DenseMatrix::Zero(rows, cols); + DenseMatrix refMat4t = DenseMatrix::Zero(cols, rows); + DenseMatrix refMat5 = DenseMatrix::Random(depth, cols); + DenseMatrix refMat6 = DenseMatrix::Random(rows, rows); + DenseMatrix dm4 = DenseMatrix::Zero(rows, rows); +// DenseVector dv1 = DenseVector::Random(rows); + SparseMatrixType m2 (rows, depth); + SparseMatrixType m2t(depth, rows); + SparseMatrixType m3 (depth, cols); + SparseMatrixType m3t(cols, depth); + SparseMatrixType m4 (rows, cols); + SparseMatrixType m4t(cols, rows); + SparseMatrixType m6(rows, rows); + initSparse(density, refMat2, m2); + initSparse(density, refMat2t, m2t); + initSparse(density, refMat3, m3); + initSparse(density, refMat3t, m3t); + initSparse(density, refMat4, m4); + initSparse(density, refMat4t, m4t); + initSparse(density, refMat6, m6); + +// int c = internal::random(0,depth-1); + + // sparse * sparse + VERIFY_IS_APPROX(m4=m2*m3, refMat4=refMat2*refMat3); + VERIFY_IS_APPROX(m4=m2t.transpose()*m3, refMat4=refMat2t.transpose()*refMat3); + VERIFY_IS_APPROX(m4=m2t.transpose()*m3t.transpose(), refMat4=refMat2t.transpose()*refMat3t.transpose()); + VERIFY_IS_APPROX(m4=m2*m3t.transpose(), refMat4=refMat2*refMat3t.transpose()); + + VERIFY_IS_APPROX(m4 = m2*m3/s1, refMat4 = refMat2*refMat3/s1); + VERIFY_IS_APPROX(m4 = m2*m3*s1, refMat4 = refMat2*refMat3*s1); + VERIFY_IS_APPROX(m4 = s2*m2*m3*s1, refMat4 = s2*refMat2*refMat3*s1); + VERIFY_IS_APPROX(m4 = (m2+m2)*m3, refMat4 = (refMat2+refMat2)*refMat3); + VERIFY_IS_APPROX(m4 = m2*m3.leftCols(cols/2), refMat4 = refMat2*refMat3.leftCols(cols/2)); + VERIFY_IS_APPROX(m4 = m2*(m3+m3).leftCols(cols/2), refMat4 = refMat2*(refMat3+refMat3).leftCols(cols/2)); + + VERIFY_IS_APPROX(m4=(m2*m3).pruned(0), refMat4=refMat2*refMat3); + VERIFY_IS_APPROX(m4=(m2t.transpose()*m3).pruned(0), refMat4=refMat2t.transpose()*refMat3); + VERIFY_IS_APPROX(m4=(m2t.transpose()*m3t.transpose()).pruned(0), refMat4=refMat2t.transpose()*refMat3t.transpose()); + VERIFY_IS_APPROX(m4=(m2*m3t.transpose()).pruned(0), refMat4=refMat2*refMat3t.transpose()); + +#ifndef EIGEN_SPARSE_PRODUCT_IGNORE_TEMPORARY_COUNT + // make sure the right product implementation is called: + if((!SparseMatrixType::IsRowMajor) && m2.rows()<=m3.cols()) + { + VERIFY_EVALUATION_COUNT(m4 = m2*m3, 2); // 2 for transposing and get a sorted result. + VERIFY_EVALUATION_COUNT(m4 = (m2*m3).pruned(0), 1); + VERIFY_EVALUATION_COUNT(m4 = (m2*m3).eval().pruned(0), 4); + } +#endif + + // and that pruning is effective: + { + DenseMatrix Ad(2,2); + Ad << -1, 1, 1, 1; + SparseMatrixType As(Ad.sparseView()), B(2,2); + VERIFY_IS_EQUAL( (As*As.transpose()).eval().nonZeros(), 4); + VERIFY_IS_EQUAL( (Ad*Ad.transpose()).eval().sparseView().eval().nonZeros(), 2); + VERIFY_IS_EQUAL( (As*As.transpose()).pruned(1e-6).eval().nonZeros(), 2); + } + + // dense ?= sparse * sparse + VERIFY_IS_APPROX(dm4 =m2*m3, refMat4 =refMat2*refMat3); + VERIFY_IS_APPROX(dm4+=m2*m3, refMat4+=refMat2*refMat3); + VERIFY_IS_APPROX(dm4-=m2*m3, refMat4-=refMat2*refMat3); + VERIFY_IS_APPROX(dm4 =m2t.transpose()*m3, refMat4 =refMat2t.transpose()*refMat3); + VERIFY_IS_APPROX(dm4+=m2t.transpose()*m3, refMat4+=refMat2t.transpose()*refMat3); + VERIFY_IS_APPROX(dm4-=m2t.transpose()*m3, refMat4-=refMat2t.transpose()*refMat3); + VERIFY_IS_APPROX(dm4 =m2t.transpose()*m3t.transpose(), refMat4 =refMat2t.transpose()*refMat3t.transpose()); + VERIFY_IS_APPROX(dm4+=m2t.transpose()*m3t.transpose(), refMat4+=refMat2t.transpose()*refMat3t.transpose()); + VERIFY_IS_APPROX(dm4-=m2t.transpose()*m3t.transpose(), refMat4-=refMat2t.transpose()*refMat3t.transpose()); + VERIFY_IS_APPROX(dm4 =m2*m3t.transpose(), refMat4 =refMat2*refMat3t.transpose()); + VERIFY_IS_APPROX(dm4+=m2*m3t.transpose(), refMat4+=refMat2*refMat3t.transpose()); + VERIFY_IS_APPROX(dm4-=m2*m3t.transpose(), refMat4-=refMat2*refMat3t.transpose()); + VERIFY_IS_APPROX(dm4 = m2*m3*s1, refMat4 = refMat2*refMat3*s1); + + // test aliasing + m4 = m2; refMat4 = refMat2; + VERIFY_IS_APPROX(m4=m4*m3, refMat4=refMat4*refMat3); + + // sparse * dense matrix + VERIFY_IS_APPROX(dm4=m2*refMat3, refMat4=refMat2*refMat3); + VERIFY_IS_APPROX(dm4=m2*refMat3t.transpose(), refMat4=refMat2*refMat3t.transpose()); + VERIFY_IS_APPROX(dm4=m2t.transpose()*refMat3, refMat4=refMat2t.transpose()*refMat3); + VERIFY_IS_APPROX(dm4=m2t.transpose()*refMat3t.transpose(), refMat4=refMat2t.transpose()*refMat3t.transpose()); + + VERIFY_IS_APPROX(dm4=m2*refMat3, refMat4=refMat2*refMat3); + VERIFY_IS_APPROX(dm4=dm4+m2*refMat3, refMat4=refMat4+refMat2*refMat3); + VERIFY_IS_APPROX(dm4+=m2*refMat3, refMat4+=refMat2*refMat3); + VERIFY_IS_APPROX(dm4-=m2*refMat3, refMat4-=refMat2*refMat3); + VERIFY_IS_APPROX(dm4.noalias()+=m2*refMat3, refMat4+=refMat2*refMat3); + VERIFY_IS_APPROX(dm4.noalias()-=m2*refMat3, refMat4-=refMat2*refMat3); + VERIFY_IS_APPROX(dm4=m2*(refMat3+refMat3), refMat4=refMat2*(refMat3+refMat3)); + VERIFY_IS_APPROX(dm4=m2t.transpose()*(refMat3+refMat5)*0.5, refMat4=refMat2t.transpose()*(refMat3+refMat5)*0.5); + + // sparse * dense vector + VERIFY_IS_APPROX(dm4.col(0)=m2*refMat3.col(0), refMat4.col(0)=refMat2*refMat3.col(0)); + VERIFY_IS_APPROX(dm4.col(0)=m2*refMat3t.transpose().col(0), refMat4.col(0)=refMat2*refMat3t.transpose().col(0)); + VERIFY_IS_APPROX(dm4.col(0)=m2t.transpose()*refMat3.col(0), refMat4.col(0)=refMat2t.transpose()*refMat3.col(0)); + VERIFY_IS_APPROX(dm4.col(0)=m2t.transpose()*refMat3t.transpose().col(0), refMat4.col(0)=refMat2t.transpose()*refMat3t.transpose().col(0)); + + // dense * sparse + VERIFY_IS_APPROX(dm4=refMat2*m3, refMat4=refMat2*refMat3); + VERIFY_IS_APPROX(dm4=dm4+refMat2*m3, refMat4=refMat4+refMat2*refMat3); + VERIFY_IS_APPROX(dm4+=refMat2*m3, refMat4+=refMat2*refMat3); + VERIFY_IS_APPROX(dm4-=refMat2*m3, refMat4-=refMat2*refMat3); + VERIFY_IS_APPROX(dm4.noalias()+=refMat2*m3, refMat4+=refMat2*refMat3); + VERIFY_IS_APPROX(dm4.noalias()-=refMat2*m3, refMat4-=refMat2*refMat3); + VERIFY_IS_APPROX(dm4=refMat2*m3t.transpose(), refMat4=refMat2*refMat3t.transpose()); + VERIFY_IS_APPROX(dm4=refMat2t.transpose()*m3, refMat4=refMat2t.transpose()*refMat3); + VERIFY_IS_APPROX(dm4=refMat2t.transpose()*m3t.transpose(), refMat4=refMat2t.transpose()*refMat3t.transpose()); + + // sparse * dense and dense * sparse outer product + { + Index c = internal::random(0,depth-1); + Index r = internal::random(0,rows-1); + Index c1 = internal::random(0,cols-1); + Index r1 = internal::random(0,depth-1); + DenseMatrix dm5 = DenseMatrix::Random(depth, cols); + + VERIFY_IS_APPROX( m4=m2.col(c)*dm5.col(c1).transpose(), refMat4=refMat2.col(c)*dm5.col(c1).transpose()); + VERIFY_IS_EQUAL(m4.nonZeros(), (refMat4.array()!=0).count()); + VERIFY_IS_APPROX( m4=m2.middleCols(c,1)*dm5.col(c1).transpose(), refMat4=refMat2.col(c)*dm5.col(c1).transpose()); + VERIFY_IS_EQUAL(m4.nonZeros(), (refMat4.array()!=0).count()); + VERIFY_IS_APPROX(dm4=m2.col(c)*dm5.col(c1).transpose(), refMat4=refMat2.col(c)*dm5.col(c1).transpose()); + + VERIFY_IS_APPROX(m4=dm5.col(c1)*m2.col(c).transpose(), refMat4=dm5.col(c1)*refMat2.col(c).transpose()); + VERIFY_IS_EQUAL(m4.nonZeros(), (refMat4.array()!=0).count()); + VERIFY_IS_APPROX(m4=dm5.col(c1)*m2.middleCols(c,1).transpose(), refMat4=dm5.col(c1)*refMat2.col(c).transpose()); + VERIFY_IS_EQUAL(m4.nonZeros(), (refMat4.array()!=0).count()); + VERIFY_IS_APPROX(dm4=dm5.col(c1)*m2.col(c).transpose(), refMat4=dm5.col(c1)*refMat2.col(c).transpose()); + + VERIFY_IS_APPROX( m4=dm5.row(r1).transpose()*m2.col(c).transpose(), refMat4=dm5.row(r1).transpose()*refMat2.col(c).transpose()); + VERIFY_IS_EQUAL(m4.nonZeros(), (refMat4.array()!=0).count()); + VERIFY_IS_APPROX(dm4=dm5.row(r1).transpose()*m2.col(c).transpose(), refMat4=dm5.row(r1).transpose()*refMat2.col(c).transpose()); + + VERIFY_IS_APPROX( m4=m2.row(r).transpose()*dm5.col(c1).transpose(), refMat4=refMat2.row(r).transpose()*dm5.col(c1).transpose()); + VERIFY_IS_EQUAL(m4.nonZeros(), (refMat4.array()!=0).count()); + VERIFY_IS_APPROX( m4=m2.middleRows(r,1).transpose()*dm5.col(c1).transpose(), refMat4=refMat2.row(r).transpose()*dm5.col(c1).transpose()); + VERIFY_IS_EQUAL(m4.nonZeros(), (refMat4.array()!=0).count()); + VERIFY_IS_APPROX(dm4=m2.row(r).transpose()*dm5.col(c1).transpose(), refMat4=refMat2.row(r).transpose()*dm5.col(c1).transpose()); + + VERIFY_IS_APPROX( m4=dm5.col(c1)*m2.row(r), refMat4=dm5.col(c1)*refMat2.row(r)); + VERIFY_IS_EQUAL(m4.nonZeros(), (refMat4.array()!=0).count()); + VERIFY_IS_APPROX( m4=dm5.col(c1)*m2.middleRows(r,1), refMat4=dm5.col(c1)*refMat2.row(r)); + VERIFY_IS_EQUAL(m4.nonZeros(), (refMat4.array()!=0).count()); + VERIFY_IS_APPROX(dm4=dm5.col(c1)*m2.row(r), refMat4=dm5.col(c1)*refMat2.row(r)); + + VERIFY_IS_APPROX( m4=dm5.row(r1).transpose()*m2.row(r), refMat4=dm5.row(r1).transpose()*refMat2.row(r)); + VERIFY_IS_EQUAL(m4.nonZeros(), (refMat4.array()!=0).count()); + VERIFY_IS_APPROX(dm4=dm5.row(r1).transpose()*m2.row(r), refMat4=dm5.row(r1).transpose()*refMat2.row(r)); + } + + VERIFY_IS_APPROX(m6=m6*m6, refMat6=refMat6*refMat6); + + // sparse matrix * sparse vector + ColSpVector cv0(cols), cv1; + DenseVector dcv0(cols), dcv1; + initSparse(2*density,dcv0, cv0); + + RowSpVector rv0(depth), rv1; + RowDenseVector drv0(depth), drv1(rv1); + initSparse(2*density,drv0, rv0); + + VERIFY_IS_APPROX(cv1=m3*cv0, dcv1=refMat3*dcv0); + VERIFY_IS_APPROX(rv1=rv0*m3, drv1=drv0*refMat3); + VERIFY_IS_APPROX(cv1=m3t.adjoint()*cv0, dcv1=refMat3t.adjoint()*dcv0); + VERIFY_IS_APPROX(cv1=rv0*m3, dcv1=drv0*refMat3); + VERIFY_IS_APPROX(rv1=m3*cv0, drv1=refMat3*dcv0); + } + + // test matrix - diagonal product + { + DenseMatrix refM2 = DenseMatrix::Zero(rows, cols); + DenseMatrix refM3 = DenseMatrix::Zero(rows, cols); + DenseMatrix d3 = DenseMatrix::Zero(rows, cols); + DiagonalMatrix d1(DenseVector::Random(cols)); + DiagonalMatrix d2(DenseVector::Random(rows)); + SparseMatrixType m2(rows, cols); + SparseMatrixType m3(rows, cols); + initSparse(density, refM2, m2); + initSparse(density, refM3, m3); + VERIFY_IS_APPROX(m3=m2*d1, refM3=refM2*d1); + VERIFY_IS_APPROX(m3=m2.transpose()*d2, refM3=refM2.transpose()*d2); + VERIFY_IS_APPROX(m3=d2*m2, refM3=d2*refM2); + VERIFY_IS_APPROX(m3=d1*m2.transpose(), refM3=d1*refM2.transpose()); + + // also check with a SparseWrapper: + DenseVector v1 = DenseVector::Random(cols); + DenseVector v2 = DenseVector::Random(rows); + DenseVector v3 = DenseVector::Random(rows); + VERIFY_IS_APPROX(m3=m2*v1.asDiagonal(), refM3=refM2*v1.asDiagonal()); + VERIFY_IS_APPROX(m3=m2.transpose()*v2.asDiagonal(), refM3=refM2.transpose()*v2.asDiagonal()); + VERIFY_IS_APPROX(m3=v2.asDiagonal()*m2, refM3=v2.asDiagonal()*refM2); + VERIFY_IS_APPROX(m3=v1.asDiagonal()*m2.transpose(), refM3=v1.asDiagonal()*refM2.transpose()); + + VERIFY_IS_APPROX(m3=v2.asDiagonal()*m2*v1.asDiagonal(), refM3=v2.asDiagonal()*refM2*v1.asDiagonal()); + + VERIFY_IS_APPROX(v2=m2*v1.asDiagonal()*v1, refM2*v1.asDiagonal()*v1); + VERIFY_IS_APPROX(v3=v2.asDiagonal()*m2*v1, v2.asDiagonal()*refM2*v1); + + // evaluate to a dense matrix to check the .row() and .col() iterator functions + VERIFY_IS_APPROX(d3=m2*d1, refM3=refM2*d1); + VERIFY_IS_APPROX(d3=m2.transpose()*d2, refM3=refM2.transpose()*d2); + VERIFY_IS_APPROX(d3=d2*m2, refM3=d2*refM2); + VERIFY_IS_APPROX(d3=d1*m2.transpose(), refM3=d1*refM2.transpose()); + } + + // test self-adjoint and triangular-view products + { + DenseMatrix b = DenseMatrix::Random(rows, rows); + DenseMatrix x = DenseMatrix::Random(rows, rows); + DenseMatrix refX = DenseMatrix::Random(rows, rows); + DenseMatrix refUp = DenseMatrix::Zero(rows, rows); + DenseMatrix refLo = DenseMatrix::Zero(rows, rows); + DenseMatrix refS = DenseMatrix::Zero(rows, rows); + DenseMatrix refA = DenseMatrix::Zero(rows, rows); + SparseMatrixType mUp(rows, rows); + SparseMatrixType mLo(rows, rows); + SparseMatrixType mS(rows, rows); + SparseMatrixType mA(rows, rows); + initSparse(density, refA, mA); + do { + initSparse(density, refUp, mUp, ForceRealDiag|/*ForceNonZeroDiag|*/MakeUpperTriangular); + } while (refUp.isZero()); + refLo = refUp.adjoint(); + mLo = mUp.adjoint(); + refS = refUp + refLo; + refS.diagonal() *= 0.5; + mS = mUp + mLo; + // TODO be able to address the diagonal.... + for (int k=0; k()*b, refX=refS*b); + VERIFY_IS_APPROX(x=mLo.template selfadjointView()*b, refX=refS*b); + VERIFY_IS_APPROX(x=mS.template selfadjointView()*b, refX=refS*b); + + VERIFY_IS_APPROX(x=b * mUp.template selfadjointView(), refX=b*refS); + VERIFY_IS_APPROX(x=b * mLo.template selfadjointView(), refX=b*refS); + VERIFY_IS_APPROX(x=b * mS.template selfadjointView(), refX=b*refS); + + VERIFY_IS_APPROX(x.noalias()+=mUp.template selfadjointView()*b, refX+=refS*b); + VERIFY_IS_APPROX(x.noalias()-=mLo.template selfadjointView()*b, refX-=refS*b); + VERIFY_IS_APPROX(x.noalias()+=mS.template selfadjointView()*b, refX+=refS*b); + + // sparse selfadjointView with sparse matrices + SparseMatrixType mSres(rows,rows); + VERIFY_IS_APPROX(mSres = mLo.template selfadjointView()*mS, + refX = refLo.template selfadjointView()*refS); + VERIFY_IS_APPROX(mSres = mS * mLo.template selfadjointView(), + refX = refS * refLo.template selfadjointView()); + + // sparse triangularView with dense matrices + VERIFY_IS_APPROX(x=mA.template triangularView()*b, refX=refA.template triangularView()*b); + VERIFY_IS_APPROX(x=mA.template triangularView()*b, refX=refA.template triangularView()*b); + VERIFY_IS_APPROX(x=b*mA.template triangularView(), refX=b*refA.template triangularView()); + VERIFY_IS_APPROX(x=b*mA.template triangularView(), refX=b*refA.template triangularView()); + + // sparse triangularView with sparse matrices + VERIFY_IS_APPROX(mSres = mA.template triangularView()*mS, refX = refA.template triangularView()*refS); + VERIFY_IS_APPROX(mSres = mS * mA.template triangularView(), refX = refS * refA.template triangularView()); + VERIFY_IS_APPROX(mSres = mA.template triangularView()*mS, refX = refA.template triangularView()*refS); + VERIFY_IS_APPROX(mSres = mS * mA.template triangularView(), refX = refS * refA.template triangularView()); + } +} + +// New test for Bug in SparseTimeDenseProduct +template void sparse_product_regression_test() +{ + // This code does not compile with afflicted versions of the bug + SparseMatrixType sm1(3,2); + DenseMatrixType m2(2,2); + sm1.setZero(); + m2.setZero(); + + DenseMatrixType m3 = sm1*m2; + + + // This code produces a segfault with afflicted versions of another SparseTimeDenseProduct + // bug + + SparseMatrixType sm2(20000,2); + sm2.setZero(); + DenseMatrixType m4(sm2*m2); + + VERIFY_IS_APPROX( m4(0,0), 0.0 ); +} + +template +void bug_942() +{ + typedef Matrix Vector; + typedef SparseMatrix ColSpMat; + typedef SparseMatrix RowSpMat; + ColSpMat cmA(1,1); + cmA.insert(0,0) = 1; + + RowSpMat rmA(1,1); + rmA.insert(0,0) = 1; + + Vector d(1); + d[0] = 2; + + double res = 2; + + VERIFY_IS_APPROX( ( cmA*d.asDiagonal() ).eval().coeff(0,0), res ); + VERIFY_IS_APPROX( ( d.asDiagonal()*rmA ).eval().coeff(0,0), res ); + VERIFY_IS_APPROX( ( rmA*d.asDiagonal() ).eval().coeff(0,0), res ); + VERIFY_IS_APPROX( ( d.asDiagonal()*cmA ).eval().coeff(0,0), res ); +} + +template +void test_mixing_types() +{ + typedef std::complex Cplx; + typedef SparseMatrix SpMatReal; + typedef SparseMatrix SpMatCplx; + typedef SparseMatrix SpRowMatCplx; + typedef Matrix DenseMatReal; + typedef Matrix DenseMatCplx; + + Index n = internal::random(1,100); + double density = (std::max)(8./(n*n), 0.2); + + SpMatReal sR1(n,n); + SpMatCplx sC1(n,n), sC2(n,n), sC3(n,n); + SpRowMatCplx sCR(n,n); + DenseMatReal dR1(n,n); + DenseMatCplx dC1(n,n), dC2(n,n), dC3(n,n); + + initSparse(density, dR1, sR1); + initSparse(density, dC1, sC1); + initSparse(density, dC2, sC2); + + VERIFY_IS_APPROX( sC2 = (sR1 * sC1), dC3 = dR1.template cast() * dC1 ); + VERIFY_IS_APPROX( sC2 = (sC1 * sR1), dC3 = dC1 * dR1.template cast() ); + VERIFY_IS_APPROX( sC2 = (sR1.transpose() * sC1), dC3 = dR1.template cast().transpose() * dC1 ); + VERIFY_IS_APPROX( sC2 = (sC1.transpose() * sR1), dC3 = dC1.transpose() * dR1.template cast() ); + VERIFY_IS_APPROX( sC2 = (sR1 * sC1.transpose()), dC3 = dR1.template cast() * dC1.transpose() ); + VERIFY_IS_APPROX( sC2 = (sC1 * sR1.transpose()), dC3 = dC1 * dR1.template cast().transpose() ); + VERIFY_IS_APPROX( sC2 = (sR1.transpose() * sC1.transpose()), dC3 = dR1.template cast().transpose() * dC1.transpose() ); + VERIFY_IS_APPROX( sC2 = (sC1.transpose() * sR1.transpose()), dC3 = dC1.transpose() * dR1.template cast().transpose() ); + + VERIFY_IS_APPROX( sCR = (sR1 * sC1), dC3 = dR1.template cast() * dC1 ); + VERIFY_IS_APPROX( sCR = (sC1 * sR1), dC3 = dC1 * dR1.template cast() ); + VERIFY_IS_APPROX( sCR = (sR1.transpose() * sC1), dC3 = dR1.template cast().transpose() * dC1 ); + VERIFY_IS_APPROX( sCR = (sC1.transpose() * sR1), dC3 = dC1.transpose() * dR1.template cast() ); + VERIFY_IS_APPROX( sCR = (sR1 * sC1.transpose()), dC3 = dR1.template cast() * dC1.transpose() ); + VERIFY_IS_APPROX( sCR = (sC1 * sR1.transpose()), dC3 = dC1 * dR1.template cast().transpose() ); + VERIFY_IS_APPROX( sCR = (sR1.transpose() * sC1.transpose()), dC3 = dR1.template cast().transpose() * dC1.transpose() ); + VERIFY_IS_APPROX( sCR = (sC1.transpose() * sR1.transpose()), dC3 = dC1.transpose() * dR1.template cast().transpose() ); + + + VERIFY_IS_APPROX( sC2 = (sR1 * sC1).pruned(), dC3 = dR1.template cast() * dC1 ); + VERIFY_IS_APPROX( sC2 = (sC1 * sR1).pruned(), dC3 = dC1 * dR1.template cast() ); + VERIFY_IS_APPROX( sC2 = (sR1.transpose() * sC1).pruned(), dC3 = dR1.template cast().transpose() * dC1 ); + VERIFY_IS_APPROX( sC2 = (sC1.transpose() * sR1).pruned(), dC3 = dC1.transpose() * dR1.template cast() ); + VERIFY_IS_APPROX( sC2 = (sR1 * sC1.transpose()).pruned(), dC3 = dR1.template cast() * dC1.transpose() ); + VERIFY_IS_APPROX( sC2 = (sC1 * sR1.transpose()).pruned(), dC3 = dC1 * dR1.template cast().transpose() ); + VERIFY_IS_APPROX( sC2 = (sR1.transpose() * sC1.transpose()).pruned(), dC3 = dR1.template cast().transpose() * dC1.transpose() ); + VERIFY_IS_APPROX( sC2 = (sC1.transpose() * sR1.transpose()).pruned(), dC3 = dC1.transpose() * dR1.template cast().transpose() ); + + VERIFY_IS_APPROX( sCR = (sR1 * sC1).pruned(), dC3 = dR1.template cast() * dC1 ); + VERIFY_IS_APPROX( sCR = (sC1 * sR1).pruned(), dC3 = dC1 * dR1.template cast() ); + VERIFY_IS_APPROX( sCR = (sR1.transpose() * sC1).pruned(), dC3 = dR1.template cast().transpose() * dC1 ); + VERIFY_IS_APPROX( sCR = (sC1.transpose() * sR1).pruned(), dC3 = dC1.transpose() * dR1.template cast() ); + VERIFY_IS_APPROX( sCR = (sR1 * sC1.transpose()).pruned(), dC3 = dR1.template cast() * dC1.transpose() ); + VERIFY_IS_APPROX( sCR = (sC1 * sR1.transpose()).pruned(), dC3 = dC1 * dR1.template cast().transpose() ); + VERIFY_IS_APPROX( sCR = (sR1.transpose() * sC1.transpose()).pruned(), dC3 = dR1.template cast().transpose() * dC1.transpose() ); + VERIFY_IS_APPROX( sCR = (sC1.transpose() * sR1.transpose()).pruned(), dC3 = dC1.transpose() * dR1.template cast().transpose() ); + + + VERIFY_IS_APPROX( dC2 = (sR1 * sC1), dC3 = dR1.template cast() * dC1 ); + VERIFY_IS_APPROX( dC2 = (sC1 * sR1), dC3 = dC1 * dR1.template cast() ); + VERIFY_IS_APPROX( dC2 = (sR1.transpose() * sC1), dC3 = dR1.template cast().transpose() * dC1 ); + VERIFY_IS_APPROX( dC2 = (sC1.transpose() * sR1), dC3 = dC1.transpose() * dR1.template cast() ); + VERIFY_IS_APPROX( dC2 = (sR1 * sC1.transpose()), dC3 = dR1.template cast() * dC1.transpose() ); + VERIFY_IS_APPROX( dC2 = (sC1 * sR1.transpose()), dC3 = dC1 * dR1.template cast().transpose() ); + VERIFY_IS_APPROX( dC2 = (sR1.transpose() * sC1.transpose()), dC3 = dR1.template cast().transpose() * dC1.transpose() ); + VERIFY_IS_APPROX( dC2 = (sC1.transpose() * sR1.transpose()), dC3 = dC1.transpose() * dR1.template cast().transpose() ); + + + VERIFY_IS_APPROX( dC2 = dR1 * sC1, dC3 = dR1.template cast() * sC1 ); + VERIFY_IS_APPROX( dC2 = sR1 * dC1, dC3 = sR1.template cast() * dC1 ); + VERIFY_IS_APPROX( dC2 = dC1 * sR1, dC3 = dC1 * sR1.template cast() ); + VERIFY_IS_APPROX( dC2 = sC1 * dR1, dC3 = sC1 * dR1.template cast() ); + + VERIFY_IS_APPROX( dC2 = dR1.row(0) * sC1, dC3 = dR1.template cast().row(0) * sC1 ); + VERIFY_IS_APPROX( dC2 = sR1 * dC1.col(0), dC3 = sR1.template cast() * dC1.col(0) ); + VERIFY_IS_APPROX( dC2 = dC1.row(0) * sR1, dC3 = dC1.row(0) * sR1.template cast() ); + VERIFY_IS_APPROX( dC2 = sC1 * dR1.col(0), dC3 = sC1 * dR1.template cast().col(0) ); +} + +EIGEN_DECLARE_TEST(sparse_product) +{ + for(int i = 0; i < g_repeat; i++) { + CALL_SUBTEST_1( (sparse_product >()) ); + CALL_SUBTEST_1( (sparse_product >()) ); + CALL_SUBTEST_1( (bug_942()) ); + CALL_SUBTEST_2( (sparse_product, ColMajor > >()) ); + CALL_SUBTEST_2( (sparse_product, RowMajor > >()) ); + CALL_SUBTEST_3( (sparse_product >()) ); + CALL_SUBTEST_4( (sparse_product_regression_test, Matrix >()) ); + + CALL_SUBTEST_5( (test_mixing_types()) ); + } +} diff --git a/include/eigen/test/sparse_solver.h b/include/eigen/test/sparse_solver.h new file mode 100644 index 0000000000000000000000000000000000000000..6f95e2fa7a9df00d41aafd890c6073df9100536f --- /dev/null +++ b/include/eigen/test/sparse_solver.h @@ -0,0 +1,706 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2011 Gael Guennebaud +// +// 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/. + +#include "sparse.h" +#include +#include +#include + +template +void solve_with_guess(IterativeSolverBase& solver, const MatrixBase& b, const Guess& g, Result &x) { + if(internal::random()) + { + // With a temporary through evaluator + x = solver.derived().solveWithGuess(b,g) + Result::Zero(x.rows(), x.cols()); + } + else + { + // direct evaluation within x through Assignment + x = solver.derived().solveWithGuess(b.derived(),g); + } +} + +template +void solve_with_guess(SparseSolverBase& solver, const MatrixBase& b, const Guess& , Result& x) { + if(internal::random()) + x = solver.derived().solve(b) + Result::Zero(x.rows(), x.cols()); + else + x = solver.derived().solve(b); +} + +template +void solve_with_guess(SparseSolverBase& solver, const SparseMatrixBase& b, const Guess& , Result& x) { + x = solver.derived().solve(b); +} + +template +void check_sparse_solving(Solver& solver, const typename Solver::MatrixType& A, const Rhs& b, const DenseMat& dA, const DenseRhs& db) +{ + typedef typename Solver::MatrixType Mat; + typedef typename Mat::Scalar Scalar; + typedef typename Mat::StorageIndex StorageIndex; + + DenseRhs refX = dA.householderQr().solve(db); + { + Rhs x(A.cols(), b.cols()); + Rhs oldb = b; + + solver.compute(A); + if (solver.info() != Success) + { + std::cerr << "ERROR | sparse solver testing, factorization failed (" << typeid(Solver).name() << ")\n"; + VERIFY(solver.info() == Success); + } + x = solver.solve(b); + if (solver.info() != Success) + { + std::cerr << "WARNING: sparse solver testing: solving failed (" << typeid(Solver).name() << ")\n"; + // dump call stack: + g_test_level++; + VERIFY(solver.info() == Success); + g_test_level--; + return; + } + VERIFY(oldb.isApprox(b) && "sparse solver testing: the rhs should not be modified!"); + VERIFY(x.isApprox(refX,test_precision())); + + x.setZero(); + solve_with_guess(solver, b, x, x); + VERIFY(solver.info() == Success && "solving failed when using solve_with_guess API"); + VERIFY(oldb.isApprox(b) && "sparse solver testing: the rhs should not be modified!"); + VERIFY(x.isApprox(refX,test_precision())); + + x.setZero(); + // test the analyze/factorize API + solver.analyzePattern(A); + solver.factorize(A); + VERIFY(solver.info() == Success && "factorization failed when using analyzePattern/factorize API"); + x = solver.solve(b); + VERIFY(solver.info() == Success && "solving failed when using analyzePattern/factorize API"); + VERIFY(oldb.isApprox(b) && "sparse solver testing: the rhs should not be modified!"); + VERIFY(x.isApprox(refX,test_precision())); + + x.setZero(); + // test with Map + MappedSparseMatrix Am(A.rows(), A.cols(), A.nonZeros(), const_cast(A.outerIndexPtr()), const_cast(A.innerIndexPtr()), const_cast(A.valuePtr())); + solver.compute(Am); + VERIFY(solver.info() == Success && "factorization failed when using Map"); + DenseRhs dx(refX); + dx.setZero(); + Map xm(dx.data(), dx.rows(), dx.cols()); + Map bm(db.data(), db.rows(), db.cols()); + xm = solver.solve(bm); + VERIFY(solver.info() == Success && "solving failed when using Map"); + VERIFY(oldb.isApprox(bm) && "sparse solver testing: the rhs should not be modified!"); + VERIFY(xm.isApprox(refX,test_precision())); + + // Test with a Map and non-unit stride. + Eigen::Matrix out(2*xm.rows(), 2*xm.cols()); + out.setZero(); + Eigen::Map > outm(out.data(), xm.rows(), xm.cols(), Stride(2 * xm.rows(), 2)); + outm = solver.solve(bm); + VERIFY(outm.isApprox(refX,test_precision())); + } + + // if not too large, do some extra check: + if(A.rows()<2000) + { + // test initialization ctor + { + Rhs x(b.rows(), b.cols()); + Solver solver2(A); + VERIFY(solver2.info() == Success); + x = solver2.solve(b); + VERIFY(x.isApprox(refX,test_precision())); + } + + // test dense Block as the result and rhs: + { + DenseRhs x(refX.rows(), refX.cols()); + DenseRhs oldb(db); + x.setZero(); + x.block(0,0,x.rows(),x.cols()) = solver.solve(db.block(0,0,db.rows(),db.cols())); + VERIFY(oldb.isApprox(db) && "sparse solver testing: the rhs should not be modified!"); + VERIFY(x.isApprox(refX,test_precision())); + } + + // test uncompressed inputs + { + Mat A2 = A; + A2.reserve((ArrayXf::Random(A.outerSize())+2).template cast().eval()); + solver.compute(A2); + Rhs x = solver.solve(b); + VERIFY(x.isApprox(refX,test_precision())); + } + + // test expression as input + { + solver.compute(0.5*(A+A)); + Rhs x = solver.solve(b); + VERIFY(x.isApprox(refX,test_precision())); + + Solver solver2(0.5*(A+A)); + Rhs x2 = solver2.solve(b); + VERIFY(x2.isApprox(refX,test_precision())); + } + } +} + +// specialization of generic check_sparse_solving for SuperLU in order to also test adjoint and transpose solves +template +void check_sparse_solving(Eigen::SparseLU >& solver, const typename Eigen::SparseMatrix& A, const Rhs& b, const DenseMat& dA, const DenseRhs& db) +{ + typedef typename Eigen::SparseMatrix Mat; + typedef typename Mat::StorageIndex StorageIndex; + typedef typename Eigen::SparseLU > Solver; + + // reference solutions computed by dense QR solver + DenseRhs refX1 = dA.householderQr().solve(db); // solution of A x = db + DenseRhs refX2 = dA.transpose().householderQr().solve(db); // solution of A^T * x = db (use transposed matrix A^T) + DenseRhs refX3 = dA.adjoint().householderQr().solve(db); // solution of A^* * x = db (use adjoint matrix A^*) + + + { + Rhs x1(A.cols(), b.cols()); + Rhs x2(A.cols(), b.cols()); + Rhs x3(A.cols(), b.cols()); + Rhs oldb = b; + + solver.compute(A); + if (solver.info() != Success) + { + std::cerr << "ERROR | sparse solver testing, factorization failed (" << typeid(Solver).name() << ")\n"; + VERIFY(solver.info() == Success); + } + x1 = solver.solve(b); + if (solver.info() != Success) + { + std::cerr << "WARNING | sparse solver testing: solving failed (" << typeid(Solver).name() << ")\n"; + return; + } + VERIFY(oldb.isApprox(b,0.0) && "sparse solver testing: the rhs should not be modified!"); + VERIFY(x1.isApprox(refX1,test_precision())); + + // test solve with transposed + x2 = solver.transpose().solve(b); + VERIFY(oldb.isApprox(b) && "sparse solver testing: the rhs should not be modified!"); + VERIFY(x2.isApprox(refX2,test_precision())); + + + // test solve with adjoint + //solver.template _solve_impl_transposed(b, x3); + x3 = solver.adjoint().solve(b); + VERIFY(oldb.isApprox(b,0.0) && "sparse solver testing: the rhs should not be modified!"); + VERIFY(x3.isApprox(refX3,test_precision())); + + x1.setZero(); + solve_with_guess(solver, b, x1, x1); + VERIFY(solver.info() == Success && "solving failed when using analyzePattern/factorize API"); + VERIFY(oldb.isApprox(b,0.0) && "sparse solver testing: the rhs should not be modified!"); + VERIFY(x1.isApprox(refX1,test_precision())); + + x1.setZero(); + x2.setZero(); + x3.setZero(); + // test the analyze/factorize API + solver.analyzePattern(A); + solver.factorize(A); + VERIFY(solver.info() == Success && "factorization failed when using analyzePattern/factorize API"); + x1 = solver.solve(b); + x2 = solver.transpose().solve(b); + x3 = solver.adjoint().solve(b); + + VERIFY(solver.info() == Success && "solving failed when using analyzePattern/factorize API"); + VERIFY(oldb.isApprox(b,0.0) && "sparse solver testing: the rhs should not be modified!"); + VERIFY(x1.isApprox(refX1,test_precision())); + VERIFY(x2.isApprox(refX2,test_precision())); + VERIFY(x3.isApprox(refX3,test_precision())); + + x1.setZero(); + // test with Map + MappedSparseMatrix Am(A.rows(), A.cols(), A.nonZeros(), const_cast(A.outerIndexPtr()), const_cast(A.innerIndexPtr()), const_cast(A.valuePtr())); + solver.compute(Am); + VERIFY(solver.info() == Success && "factorization failed when using Map"); + DenseRhs dx(refX1); + dx.setZero(); + Map xm(dx.data(), dx.rows(), dx.cols()); + Map bm(db.data(), db.rows(), db.cols()); + xm = solver.solve(bm); + VERIFY(solver.info() == Success && "solving failed when using Map"); + VERIFY(oldb.isApprox(bm,0.0) && "sparse solver testing: the rhs should not be modified!"); + VERIFY(xm.isApprox(refX1,test_precision())); + } + + // if not too large, do some extra check: + if(A.rows()<2000) + { + // test initialization ctor + { + Rhs x(b.rows(), b.cols()); + Solver solver2(A); + VERIFY(solver2.info() == Success); + x = solver2.solve(b); + VERIFY(x.isApprox(refX1,test_precision())); + } + + // test dense Block as the result and rhs: + { + DenseRhs x(refX1.rows(), refX1.cols()); + DenseRhs oldb(db); + x.setZero(); + x.block(0,0,x.rows(),x.cols()) = solver.solve(db.block(0,0,db.rows(),db.cols())); + VERIFY(oldb.isApprox(db,0.0) && "sparse solver testing: the rhs should not be modified!"); + VERIFY(x.isApprox(refX1,test_precision())); + } + + // test uncompressed inputs + { + Mat A2 = A; + A2.reserve((ArrayXf::Random(A.outerSize())+2).template cast().eval()); + solver.compute(A2); + Rhs x = solver.solve(b); + VERIFY(x.isApprox(refX1,test_precision())); + } + + // test expression as input + { + solver.compute(0.5*(A+A)); + Rhs x = solver.solve(b); + VERIFY(x.isApprox(refX1,test_precision())); + + Solver solver2(0.5*(A+A)); + Rhs x2 = solver2.solve(b); + VERIFY(x2.isApprox(refX1,test_precision())); + } + } +} + + +template +void check_sparse_solving_real_cases(Solver& solver, const typename Solver::MatrixType& A, const Rhs& b, const typename Solver::MatrixType& fullA, const Rhs& refX) +{ + typedef typename Solver::MatrixType Mat; + typedef typename Mat::Scalar Scalar; + typedef typename Mat::RealScalar RealScalar; + + Rhs x(A.cols(), b.cols()); + + solver.compute(A); + if (solver.info() != Success) + { + std::cerr << "ERROR | sparse solver testing, factorization failed (" << typeid(Solver).name() << ")\n"; + VERIFY(solver.info() == Success); + } + x = solver.solve(b); + + if (solver.info() != Success) + { + std::cerr << "WARNING | sparse solver testing, solving failed (" << typeid(Solver).name() << ")\n"; + return; + } + + RealScalar res_error = (fullA*x-b).norm()/b.norm(); + VERIFY( (res_error <= test_precision() ) && "sparse solver failed without noticing it"); + + + if(refX.size() != 0 && (refX - x).norm()/refX.norm() > test_precision()) + { + std::cerr << "WARNING | found solution is different from the provided reference one\n"; + } + +} +template +void check_sparse_determinant(Solver& solver, const typename Solver::MatrixType& A, const DenseMat& dA) +{ + typedef typename Solver::MatrixType Mat; + typedef typename Mat::Scalar Scalar; + + solver.compute(A); + if (solver.info() != Success) + { + std::cerr << "WARNING | sparse solver testing: factorization failed (check_sparse_determinant)\n"; + return; + } + + Scalar refDet = dA.determinant(); + VERIFY_IS_APPROX(refDet,solver.determinant()); +} +template +void check_sparse_abs_determinant(Solver& solver, const typename Solver::MatrixType& A, const DenseMat& dA) +{ + using std::abs; + typedef typename Solver::MatrixType Mat; + typedef typename Mat::Scalar Scalar; + + solver.compute(A); + if (solver.info() != Success) + { + std::cerr << "WARNING | sparse solver testing: factorization failed (check_sparse_abs_determinant)\n"; + return; + } + + Scalar refDet = abs(dA.determinant()); + VERIFY_IS_APPROX(refDet,solver.absDeterminant()); +} + +template +int generate_sparse_spd_problem(Solver& , typename Solver::MatrixType& A, typename Solver::MatrixType& halfA, DenseMat& dA, int maxSize = 300) +{ + typedef typename Solver::MatrixType Mat; + typedef typename Mat::Scalar Scalar; + typedef Matrix DenseMatrix; + + int size = internal::random(1,maxSize); + double density = (std::max)(8./(size*size), 0.01); + + Mat M(size, size); + DenseMatrix dM(size, size); + + initSparse(density, dM, M, ForceNonZeroDiag); + + A = M * M.adjoint(); + dA = dM * dM.adjoint(); + + halfA.resize(size,size); + if(Solver::UpLo==(Lower|Upper)) + halfA = A; + else + halfA.template selfadjointView().rankUpdate(M); + + return size; +} + + +#ifdef TEST_REAL_CASES +template +inline std::string get_matrixfolder() +{ + std::string mat_folder = TEST_REAL_CASES; + if( internal::is_same >::value || internal::is_same >::value ) + mat_folder = mat_folder + static_cast("/complex/"); + else + mat_folder = mat_folder + static_cast("/real/"); + return mat_folder; +} +std::string sym_to_string(int sym) +{ + if(sym==Symmetric) return "Symmetric "; + if(sym==SPD) return "SPD "; + return ""; +} +template +std::string solver_stats(const IterativeSolverBase &solver) +{ + std::stringstream ss; + ss << solver.iterations() << " iters, error: " << solver.error(); + return ss.str(); +} +template +std::string solver_stats(const SparseSolverBase &/*solver*/) +{ + return ""; +} +#endif + +template void check_sparse_spd_solving(Solver& solver, int maxSize = (std::min)(300,EIGEN_TEST_MAX_SIZE), int maxRealWorldSize = 100000) +{ + typedef typename Solver::MatrixType Mat; + typedef typename Mat::Scalar Scalar; + typedef typename Mat::StorageIndex StorageIndex; + typedef SparseMatrix SpMat; + typedef SparseVector SpVec; + typedef Matrix DenseMatrix; + typedef Matrix DenseVector; + + // generate the problem + Mat A, halfA; + DenseMatrix dA; + for (int i = 0; i < g_repeat; i++) { + int size = generate_sparse_spd_problem(solver, A, halfA, dA, maxSize); + + // generate the right hand sides + int rhsCols = internal::random(1,16); + double density = (std::max)(8./(size*rhsCols), 0.1); + SpMat B(size,rhsCols); + DenseVector b = DenseVector::Random(size); + DenseMatrix dB(size,rhsCols); + initSparse(density, dB, B, ForceNonZeroDiag); + SpVec c = B.col(0); + DenseVector dc = dB.col(0); + + CALL_SUBTEST( check_sparse_solving(solver, A, b, dA, b) ); + CALL_SUBTEST( check_sparse_solving(solver, halfA, b, dA, b) ); + CALL_SUBTEST( check_sparse_solving(solver, A, dB, dA, dB) ); + CALL_SUBTEST( check_sparse_solving(solver, halfA, dB, dA, dB) ); + CALL_SUBTEST( check_sparse_solving(solver, A, B, dA, dB) ); + CALL_SUBTEST( check_sparse_solving(solver, halfA, B, dA, dB) ); + CALL_SUBTEST( check_sparse_solving(solver, A, c, dA, dc) ); + CALL_SUBTEST( check_sparse_solving(solver, halfA, c, dA, dc) ); + + // check only once + if(i==0) + { + b = DenseVector::Zero(size); + check_sparse_solving(solver, A, b, dA, b); + } + } + + // First, get the folder +#ifdef TEST_REAL_CASES + // Test real problems with double precision only + if (internal::is_same::Real, double>::value) + { + std::string mat_folder = get_matrixfolder(); + MatrixMarketIterator it(mat_folder); + for (; it; ++it) + { + if (it.sym() == SPD){ + A = it.matrix(); + if(A.diagonal().size() <= maxRealWorldSize) + { + DenseVector b = it.rhs(); + DenseVector refX = it.refX(); + PermutationMatrix pnull; + halfA.resize(A.rows(), A.cols()); + if(Solver::UpLo == (Lower|Upper)) + halfA = A; + else + halfA.template selfadjointView() = A.template triangularView().twistedBy(pnull); + + std::cout << "INFO | Testing " << sym_to_string(it.sym()) << "sparse problem " << it.matname() + << " (" << A.rows() << "x" << A.cols() << ") using " << typeid(Solver).name() << "..." << std::endl; + CALL_SUBTEST( check_sparse_solving_real_cases(solver, A, b, A, refX) ); + std::string stats = solver_stats(solver); + if(stats.size()>0) + std::cout << "INFO | " << stats << std::endl; + CALL_SUBTEST( check_sparse_solving_real_cases(solver, halfA, b, A, refX) ); + } + else + { + std::cout << "INFO | Skip sparse problem \"" << it.matname() << "\" (too large)" << std::endl; + } + } + } + } +#else + EIGEN_UNUSED_VARIABLE(maxRealWorldSize); +#endif +} + +template void check_sparse_spd_determinant(Solver& solver) +{ + typedef typename Solver::MatrixType Mat; + typedef typename Mat::Scalar Scalar; + typedef Matrix DenseMatrix; + + // generate the problem + Mat A, halfA; + DenseMatrix dA; + generate_sparse_spd_problem(solver, A, halfA, dA, 30); + + for (int i = 0; i < g_repeat; i++) { + check_sparse_determinant(solver, A, dA); + check_sparse_determinant(solver, halfA, dA ); + } +} + +template +Index generate_sparse_square_problem(Solver&, typename Solver::MatrixType& A, DenseMat& dA, int maxSize = 300, int options = ForceNonZeroDiag) +{ + typedef typename Solver::MatrixType Mat; + typedef typename Mat::Scalar Scalar; + + Index size = internal::random(1,maxSize); + double density = (std::max)(8./(size*size), 0.01); + + A.resize(size,size); + dA.resize(size,size); + + initSparse(density, dA, A, options); + + return size; +} + + +struct prune_column { + Index m_col; + prune_column(Index col) : m_col(col) {} + template + bool operator()(Index, Index col, const Scalar&) const { + return col != m_col; + } +}; + + +template void check_sparse_square_solving(Solver& solver, int maxSize = 300, int maxRealWorldSize = 100000, bool checkDeficient = false) +{ + typedef typename Solver::MatrixType Mat; + typedef typename Mat::Scalar Scalar; + typedef SparseMatrix SpMat; + typedef SparseVector SpVec; + typedef Matrix DenseMatrix; + typedef Matrix DenseVector; + + int rhsCols = internal::random(1,16); + + Mat A; + DenseMatrix dA; + for (int i = 0; i < g_repeat; i++) { + Index size = generate_sparse_square_problem(solver, A, dA, maxSize); + + A.makeCompressed(); + DenseVector b = DenseVector::Random(size); + DenseMatrix dB(size,rhsCols); + SpMat B(size,rhsCols); + double density = (std::max)(8./(size*rhsCols), 0.1); + initSparse(density, dB, B, ForceNonZeroDiag); + B.makeCompressed(); + SpVec c = B.col(0); + DenseVector dc = dB.col(0); + CALL_SUBTEST(check_sparse_solving(solver, A, b, dA, b)); + CALL_SUBTEST(check_sparse_solving(solver, A, dB, dA, dB)); + CALL_SUBTEST(check_sparse_solving(solver, A, B, dA, dB)); + CALL_SUBTEST(check_sparse_solving(solver, A, c, dA, dc)); + + // check only once + if(i==0) + { + CALL_SUBTEST(b = DenseVector::Zero(size); check_sparse_solving(solver, A, b, dA, b)); + } + // regression test for Bug 792 (structurally rank deficient matrices): + if(checkDeficient && size>1) { + Index col = internal::random(0,int(size-1)); + A.prune(prune_column(col)); + solver.compute(A); + VERIFY_IS_EQUAL(solver.info(), NumericalIssue); + } + } + + // First, get the folder +#ifdef TEST_REAL_CASES + // Test real problems with double precision only + if (internal::is_same::Real, double>::value) + { + std::string mat_folder = get_matrixfolder(); + MatrixMarketIterator it(mat_folder); + for (; it; ++it) + { + A = it.matrix(); + if(A.diagonal().size() <= maxRealWorldSize) + { + DenseVector b = it.rhs(); + DenseVector refX = it.refX(); + std::cout << "INFO | Testing " << sym_to_string(it.sym()) << "sparse problem " << it.matname() + << " (" << A.rows() << "x" << A.cols() << ") using " << typeid(Solver).name() << "..." << std::endl; + CALL_SUBTEST(check_sparse_solving_real_cases(solver, A, b, A, refX)); + std::string stats = solver_stats(solver); + if(stats.size()>0) + std::cout << "INFO | " << stats << std::endl; + } + else + { + std::cout << "INFO | SKIP sparse problem \"" << it.matname() << "\" (too large)" << std::endl; + } + } + } +#else + EIGEN_UNUSED_VARIABLE(maxRealWorldSize); +#endif + +} + +template void check_sparse_square_determinant(Solver& solver) +{ + typedef typename Solver::MatrixType Mat; + typedef typename Mat::Scalar Scalar; + typedef Matrix DenseMatrix; + + for (int i = 0; i < g_repeat; i++) { + // generate the problem + Mat A; + DenseMatrix dA; + + int size = internal::random(1,30); + dA.setRandom(size,size); + + dA = (dA.array().abs()<0.3).select(0,dA); + dA.diagonal() = (dA.diagonal().array()==0).select(1,dA.diagonal()); + A = dA.sparseView(); + A.makeCompressed(); + + check_sparse_determinant(solver, A, dA); + } +} + +template void check_sparse_square_abs_determinant(Solver& solver) +{ + typedef typename Solver::MatrixType Mat; + typedef typename Mat::Scalar Scalar; + typedef Matrix DenseMatrix; + + for (int i = 0; i < g_repeat; i++) { + // generate the problem + Mat A; + DenseMatrix dA; + generate_sparse_square_problem(solver, A, dA, 30); + A.makeCompressed(); + check_sparse_abs_determinant(solver, A, dA); + } +} + +template +void generate_sparse_leastsquare_problem(Solver&, typename Solver::MatrixType& A, DenseMat& dA, int maxSize = 300, int options = ForceNonZeroDiag) +{ + typedef typename Solver::MatrixType Mat; + typedef typename Mat::Scalar Scalar; + + int rows = internal::random(1,maxSize); + int cols = internal::random(1,rows); + double density = (std::max)(8./(rows*cols), 0.01); + + A.resize(rows,cols); + dA.resize(rows,cols); + + initSparse(density, dA, A, options); +} + +template void check_sparse_leastsquare_solving(Solver& solver) +{ + typedef typename Solver::MatrixType Mat; + typedef typename Mat::Scalar Scalar; + typedef SparseMatrix SpMat; + typedef Matrix DenseMatrix; + typedef Matrix DenseVector; + + int rhsCols = internal::random(1,16); + + Mat A; + DenseMatrix dA; + for (int i = 0; i < g_repeat; i++) { + generate_sparse_leastsquare_problem(solver, A, dA); + + A.makeCompressed(); + DenseVector b = DenseVector::Random(A.rows()); + DenseMatrix dB(A.rows(),rhsCols); + SpMat B(A.rows(),rhsCols); + double density = (std::max)(8./(A.rows()*rhsCols), 0.1); + initSparse(density, dB, B, ForceNonZeroDiag); + B.makeCompressed(); + check_sparse_solving(solver, A, b, dA, b); + check_sparse_solving(solver, A, dB, dA, dB); + check_sparse_solving(solver, A, B, dA, dB); + + // check only once + if(i==0) + { + b = DenseVector::Zero(A.rows()); + check_sparse_solving(solver, A, b, dA, b); + } + } +} diff --git a/include/eigen/test/sparse_solvers.cpp b/include/eigen/test/sparse_solvers.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3b7cd7788848b56183e44f72e2be7b48b0f9102e --- /dev/null +++ b/include/eigen/test/sparse_solvers.cpp @@ -0,0 +1,125 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2008-2010 Gael Guennebaud +// +// 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/. + +#include "sparse.h" + +template void +initSPD(double density, + Matrix& refMat, + SparseMatrix& sparseMat) +{ + Matrix aux(refMat.rows(),refMat.cols()); + initSparse(density,refMat,sparseMat); + refMat = refMat * refMat.adjoint(); + for (int k=0; k<2; ++k) + { + initSparse(density,aux,sparseMat,ForceNonZeroDiag); + refMat += aux * aux.adjoint(); + } + sparseMat.setZero(); + for (int j=0 ; j void sparse_solvers(int rows, int cols) +{ + double density = (std::max)(8./(rows*cols), 0.01); + typedef Matrix DenseMatrix; + typedef Matrix DenseVector; + // Scalar eps = 1e-6; + + DenseVector vec1 = DenseVector::Random(rows); + + std::vector zeroCoords; + std::vector nonzeroCoords; + + // test triangular solver + { + DenseVector vec2 = vec1, vec3 = vec1; + SparseMatrix m2(rows, cols); + DenseMatrix refMat2 = DenseMatrix::Zero(rows, cols); + + // lower - dense + initSparse(density, refMat2, m2, ForceNonZeroDiag|MakeLowerTriangular, &zeroCoords, &nonzeroCoords); + VERIFY_IS_APPROX(refMat2.template triangularView().solve(vec2), + m2.template triangularView().solve(vec3)); + + // upper - dense + initSparse(density, refMat2, m2, ForceNonZeroDiag|MakeUpperTriangular, &zeroCoords, &nonzeroCoords); + VERIFY_IS_APPROX(refMat2.template triangularView().solve(vec2), + m2.template triangularView().solve(vec3)); + VERIFY_IS_APPROX(refMat2.conjugate().template triangularView().solve(vec2), + m2.conjugate().template triangularView().solve(vec3)); + { + SparseMatrix cm2(m2); + //Index rows, Index cols, Index nnz, Index* outerIndexPtr, Index* innerIndexPtr, Scalar* valuePtr + MappedSparseMatrix mm2(rows, cols, cm2.nonZeros(), cm2.outerIndexPtr(), cm2.innerIndexPtr(), cm2.valuePtr()); + VERIFY_IS_APPROX(refMat2.conjugate().template triangularView().solve(vec2), + mm2.conjugate().template triangularView().solve(vec3)); + } + + // lower - transpose + initSparse(density, refMat2, m2, ForceNonZeroDiag|MakeLowerTriangular, &zeroCoords, &nonzeroCoords); + VERIFY_IS_APPROX(refMat2.transpose().template triangularView().solve(vec2), + m2.transpose().template triangularView().solve(vec3)); + + // upper - transpose + initSparse(density, refMat2, m2, ForceNonZeroDiag|MakeUpperTriangular, &zeroCoords, &nonzeroCoords); + VERIFY_IS_APPROX(refMat2.transpose().template triangularView().solve(vec2), + m2.transpose().template triangularView().solve(vec3)); + + SparseMatrix matB(rows, rows); + DenseMatrix refMatB = DenseMatrix::Zero(rows, rows); + + // lower - sparse + initSparse(density, refMat2, m2, ForceNonZeroDiag|MakeLowerTriangular); + initSparse(density, refMatB, matB); + refMat2.template triangularView().solveInPlace(refMatB); + m2.template triangularView().solveInPlace(matB); + VERIFY_IS_APPROX(matB.toDense(), refMatB); + + // upper - sparse + initSparse(density, refMat2, m2, ForceNonZeroDiag|MakeUpperTriangular); + initSparse(density, refMatB, matB); + refMat2.template triangularView().solveInPlace(refMatB); + m2.template triangularView().solveInPlace(matB); + VERIFY_IS_APPROX(matB, refMatB); + + // test deprecated API + initSparse(density, refMat2, m2, ForceNonZeroDiag|MakeLowerTriangular, &zeroCoords, &nonzeroCoords); + VERIFY_IS_APPROX(refMat2.template triangularView().solve(vec2), + m2.template triangularView().solve(vec3)); + + // test empty triangular matrix + { + m2.resize(0,0); + refMatB.resize(0,refMatB.cols()); + DenseMatrix res = m2.template triangularView().solve(refMatB); + VERIFY_IS_EQUAL(res.rows(),0); + VERIFY_IS_EQUAL(res.cols(),refMatB.cols()); + res = refMatB; + m2.template triangularView().solveInPlace(res); + VERIFY_IS_EQUAL(res.rows(),0); + VERIFY_IS_EQUAL(res.cols(),refMatB.cols()); + } + } +} + +EIGEN_DECLARE_TEST(sparse_solvers) +{ + for(int i = 0; i < g_repeat; i++) { + CALL_SUBTEST_1(sparse_solvers(8, 8) ); + int s = internal::random(1,300); + CALL_SUBTEST_2(sparse_solvers >(s,s) ); + CALL_SUBTEST_1(sparse_solvers(s,s) ); + } +} diff --git a/include/eigen/test/sparse_vector.cpp b/include/eigen/test/sparse_vector.cpp new file mode 100644 index 0000000000000000000000000000000000000000..35129278bd7ff3913f0af86395e697f3ab9f01d8 --- /dev/null +++ b/include/eigen/test/sparse_vector.cpp @@ -0,0 +1,163 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2008-2011 Gael Guennebaud +// +// 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/. + +#include "sparse.h" + +template void sparse_vector(int rows, int cols) +{ + double densityMat = (std::max)(8./(rows*cols), 0.01); + double densityVec = (std::max)(8./(rows), 0.1); + typedef Matrix DenseMatrix; + typedef Matrix DenseVector; + typedef SparseVector SparseVectorType; + typedef SparseMatrix SparseMatrixType; + Scalar eps = 1e-6; + + SparseMatrixType m1(rows,rows); + SparseVectorType v1(rows), v2(rows), v3(rows); + DenseMatrix refM1 = DenseMatrix::Zero(rows, rows); + DenseVector refV1 = DenseVector::Random(rows), + refV2 = DenseVector::Random(rows), + refV3 = DenseVector::Random(rows); + + std::vector zerocoords, nonzerocoords; + initSparse(densityVec, refV1, v1, &zerocoords, &nonzerocoords); + initSparse(densityMat, refM1, m1); + + initSparse(densityVec, refV2, v2); + initSparse(densityVec, refV3, v3); + + Scalar s1 = internal::random(); + + // test coeff and coeffRef + for (unsigned int i=0; i(0,rows-1); + Scalar v = internal::random(); + v4.coeffRef(i) += v; + v5.coeffRef(i) += v; + } + VERIFY_IS_APPROX(v4,v5); + } + + v1.coeffRef(nonzerocoords[0]) = Scalar(5); + refV1.coeffRef(nonzerocoords[0]) = Scalar(5); + VERIFY_IS_APPROX(v1, refV1); + + VERIFY_IS_APPROX(v1+v2, refV1+refV2); + VERIFY_IS_APPROX(v1+v2+v3, refV1+refV2+refV3); + + VERIFY_IS_APPROX(v1*s1-v2, refV1*s1-refV2); + + VERIFY_IS_APPROX(v1*=s1, refV1*=s1); + VERIFY_IS_APPROX(v1/=s1, refV1/=s1); + + VERIFY_IS_APPROX(v1+=v2, refV1+=refV2); + VERIFY_IS_APPROX(v1-=v2, refV1-=refV2); + + VERIFY_IS_APPROX(v1.dot(v2), refV1.dot(refV2)); + VERIFY_IS_APPROX(v1.dot(refV2), refV1.dot(refV2)); + + VERIFY_IS_APPROX(m1*v2, refM1*refV2); + VERIFY_IS_APPROX(v1.dot(m1*v2), refV1.dot(refM1*refV2)); + { + int i = internal::random(0,rows-1); + VERIFY_IS_APPROX(v1.dot(m1.col(i)), refV1.dot(refM1.col(i))); + } + + + VERIFY_IS_APPROX(v1.squaredNorm(), refV1.squaredNorm()); + + VERIFY_IS_APPROX(v1.blueNorm(), refV1.blueNorm()); + + // test aliasing + VERIFY_IS_APPROX((v1 = -v1), (refV1 = -refV1)); + VERIFY_IS_APPROX((v1 = v1.transpose()), (refV1 = refV1.transpose().eval())); + VERIFY_IS_APPROX((v1 += -v1), (refV1 += -refV1)); + + // sparse matrix to sparse vector + SparseMatrixType mv1; + VERIFY_IS_APPROX((mv1=v1),v1); + VERIFY_IS_APPROX(mv1,(v1=mv1)); + VERIFY_IS_APPROX(mv1,(v1=mv1.transpose())); + + // check copy to dense vector with transpose + refV3.resize(0); + VERIFY_IS_APPROX(refV3 = v1.transpose(),v1.toDense()); + VERIFY_IS_APPROX(DenseVector(v1),v1.toDense()); + + // test conservative resize + { + std::vector inc; + if(rows > 3) + inc.push_back(-3); + inc.push_back(0); + inc.push_back(3); + inc.push_back(1); + inc.push_back(10); + + for(std::size_t i = 0; i< inc.size(); i++) { + StorageIndex incRows = inc[i]; + SparseVectorType vec1(rows); + DenseVector refVec1 = DenseVector::Zero(rows); + initSparse(densityVec, refVec1, vec1); + + vec1.conservativeResize(rows+incRows); + refVec1.conservativeResize(rows+incRows); + if (incRows > 0) refVec1.tail(incRows).setZero(); + + VERIFY_IS_APPROX(vec1, refVec1); + + // Insert new values + if (incRows > 0) + vec1.insert(vec1.rows()-1) = refVec1(refVec1.rows()-1) = 1; + + VERIFY_IS_APPROX(vec1, refVec1); + } + } + +} + +EIGEN_DECLARE_TEST(sparse_vector) +{ + for(int i = 0; i < g_repeat; i++) { + int r = Eigen::internal::random(1,500), c = Eigen::internal::random(1,500); + if(Eigen::internal::random(0,4) == 0) { + r = c; // check square matrices in 25% of tries + } + EIGEN_UNUSED_VARIABLE(r+c); + + CALL_SUBTEST_1(( sparse_vector(8, 8) )); + CALL_SUBTEST_2(( sparse_vector, int>(r, c) )); + CALL_SUBTEST_1(( sparse_vector(r, c) )); + CALL_SUBTEST_1(( sparse_vector(r, c) )); + } +} + diff --git a/include/eigen/test/sparselu.cpp b/include/eigen/test/sparselu.cpp new file mode 100644 index 0000000000000000000000000000000000000000..84cc6ebe53fba5e74addc3c32596fe2826c92a6d --- /dev/null +++ b/include/eigen/test/sparselu.cpp @@ -0,0 +1,45 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2012 Désiré Nuentsa-Wakam +// +// 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/. + +// SparseLU solve does not accept column major matrices for the destination. +// However, as expected, the generic check_sparse_square_solving routines produces row-major +// rhs and destination matrices when compiled with EIGEN_DEFAULT_TO_ROW_MAJOR + +#ifdef EIGEN_DEFAULT_TO_ROW_MAJOR +#undef EIGEN_DEFAULT_TO_ROW_MAJOR +#endif + +#include "sparse_solver.h" +#include +#include + +template void test_sparselu_T() +{ + SparseLU /*, COLAMDOrdering*/ > sparselu_colamd; // COLAMDOrdering is the default + SparseLU, AMDOrdering > sparselu_amd; + SparseLU, NaturalOrdering > sparselu_natural; + + check_sparse_square_solving(sparselu_colamd, 300, 100000, true); + check_sparse_square_solving(sparselu_amd, 300, 10000, true); + check_sparse_square_solving(sparselu_natural, 300, 2000, true); + + check_sparse_square_abs_determinant(sparselu_colamd); + check_sparse_square_abs_determinant(sparselu_amd); + + check_sparse_square_determinant(sparselu_colamd); + check_sparse_square_determinant(sparselu_amd); +} + +EIGEN_DECLARE_TEST(sparselu) +{ + CALL_SUBTEST_1(test_sparselu_T()); + CALL_SUBTEST_2(test_sparselu_T()); + CALL_SUBTEST_3(test_sparselu_T >()); + CALL_SUBTEST_4(test_sparselu_T >()); +} diff --git a/include/eigen/test/split_test_helper.h b/include/eigen/test/split_test_helper.h new file mode 100644 index 0000000000000000000000000000000000000000..82e82aaefcf532206f97d249777b7af3627401ed --- /dev/null +++ b/include/eigen/test/split_test_helper.h @@ -0,0 +1,5994 @@ +#if defined(EIGEN_TEST_PART_1) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_1(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_1(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_2) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_2(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_2(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_3) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_3(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_3(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_4) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_4(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_4(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_5) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_5(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_5(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_6) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_6(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_6(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_7) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_7(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_7(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_8) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_8(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_8(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_9) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_9(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_9(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_10) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_10(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_10(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_11) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_11(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_11(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_12) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_12(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_12(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_13) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_13(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_13(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_14) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_14(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_14(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_15) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_15(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_15(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_16) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_16(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_16(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_17) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_17(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_17(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_18) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_18(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_18(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_19) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_19(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_19(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_20) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_20(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_20(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_21) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_21(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_21(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_22) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_22(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_22(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_23) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_23(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_23(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_24) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_24(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_24(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_25) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_25(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_25(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_26) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_26(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_26(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_27) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_27(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_27(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_28) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_28(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_28(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_29) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_29(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_29(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_30) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_30(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_30(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_31) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_31(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_31(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_32) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_32(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_32(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_33) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_33(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_33(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_34) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_34(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_34(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_35) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_35(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_35(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_36) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_36(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_36(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_37) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_37(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_37(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_38) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_38(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_38(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_39) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_39(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_39(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_40) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_40(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_40(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_41) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_41(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_41(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_42) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_42(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_42(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_43) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_43(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_43(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_44) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_44(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_44(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_45) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_45(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_45(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_46) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_46(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_46(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_47) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_47(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_47(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_48) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_48(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_48(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_49) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_49(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_49(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_50) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_50(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_50(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_51) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_51(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_51(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_52) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_52(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_52(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_53) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_53(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_53(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_54) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_54(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_54(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_55) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_55(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_55(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_56) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_56(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_56(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_57) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_57(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_57(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_58) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_58(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_58(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_59) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_59(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_59(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_60) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_60(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_60(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_61) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_61(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_61(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_62) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_62(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_62(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_63) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_63(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_63(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_64) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_64(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_64(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_65) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_65(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_65(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_66) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_66(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_66(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_67) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_67(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_67(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_68) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_68(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_68(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_69) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_69(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_69(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_70) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_70(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_70(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_71) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_71(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_71(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_72) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_72(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_72(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_73) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_73(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_73(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_74) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_74(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_74(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_75) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_75(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_75(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_76) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_76(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_76(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_77) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_77(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_77(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_78) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_78(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_78(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_79) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_79(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_79(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_80) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_80(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_80(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_81) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_81(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_81(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_82) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_82(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_82(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_83) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_83(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_83(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_84) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_84(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_84(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_85) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_85(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_85(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_86) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_86(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_86(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_87) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_87(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_87(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_88) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_88(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_88(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_89) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_89(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_89(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_90) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_90(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_90(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_91) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_91(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_91(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_92) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_92(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_92(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_93) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_93(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_93(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_94) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_94(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_94(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_95) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_95(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_95(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_96) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_96(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_96(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_97) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_97(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_97(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_98) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_98(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_98(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_99) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_99(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_99(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_100) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_100(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_100(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_101) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_101(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_101(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_102) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_102(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_102(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_103) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_103(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_103(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_104) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_104(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_104(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_105) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_105(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_105(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_106) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_106(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_106(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_107) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_107(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_107(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_108) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_108(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_108(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_109) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_109(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_109(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_110) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_110(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_110(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_111) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_111(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_111(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_112) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_112(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_112(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_113) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_113(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_113(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_114) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_114(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_114(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_115) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_115(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_115(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_116) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_116(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_116(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_117) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_117(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_117(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_118) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_118(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_118(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_119) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_119(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_119(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_120) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_120(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_120(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_121) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_121(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_121(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_122) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_122(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_122(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_123) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_123(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_123(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_124) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_124(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_124(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_125) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_125(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_125(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_126) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_126(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_126(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_127) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_127(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_127(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_128) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_128(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_128(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_129) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_129(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_129(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_130) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_130(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_130(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_131) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_131(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_131(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_132) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_132(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_132(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_133) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_133(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_133(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_134) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_134(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_134(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_135) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_135(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_135(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_136) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_136(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_136(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_137) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_137(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_137(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_138) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_138(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_138(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_139) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_139(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_139(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_140) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_140(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_140(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_141) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_141(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_141(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_142) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_142(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_142(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_143) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_143(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_143(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_144) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_144(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_144(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_145) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_145(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_145(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_146) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_146(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_146(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_147) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_147(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_147(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_148) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_148(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_148(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_149) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_149(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_149(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_150) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_150(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_150(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_151) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_151(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_151(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_152) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_152(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_152(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_153) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_153(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_153(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_154) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_154(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_154(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_155) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_155(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_155(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_156) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_156(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_156(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_157) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_157(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_157(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_158) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_158(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_158(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_159) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_159(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_159(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_160) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_160(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_160(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_161) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_161(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_161(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_162) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_162(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_162(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_163) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_163(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_163(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_164) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_164(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_164(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_165) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_165(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_165(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_166) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_166(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_166(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_167) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_167(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_167(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_168) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_168(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_168(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_169) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_169(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_169(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_170) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_170(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_170(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_171) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_171(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_171(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_172) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_172(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_172(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_173) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_173(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_173(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_174) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_174(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_174(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_175) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_175(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_175(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_176) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_176(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_176(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_177) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_177(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_177(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_178) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_178(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_178(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_179) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_179(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_179(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_180) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_180(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_180(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_181) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_181(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_181(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_182) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_182(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_182(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_183) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_183(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_183(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_184) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_184(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_184(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_185) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_185(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_185(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_186) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_186(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_186(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_187) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_187(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_187(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_188) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_188(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_188(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_189) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_189(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_189(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_190) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_190(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_190(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_191) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_191(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_191(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_192) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_192(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_192(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_193) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_193(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_193(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_194) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_194(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_194(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_195) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_195(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_195(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_196) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_196(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_196(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_197) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_197(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_197(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_198) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_198(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_198(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_199) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_199(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_199(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_200) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_200(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_200(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_201) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_201(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_201(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_202) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_202(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_202(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_203) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_203(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_203(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_204) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_204(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_204(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_205) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_205(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_205(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_206) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_206(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_206(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_207) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_207(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_207(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_208) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_208(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_208(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_209) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_209(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_209(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_210) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_210(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_210(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_211) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_211(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_211(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_212) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_212(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_212(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_213) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_213(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_213(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_214) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_214(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_214(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_215) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_215(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_215(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_216) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_216(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_216(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_217) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_217(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_217(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_218) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_218(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_218(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_219) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_219(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_219(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_220) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_220(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_220(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_221) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_221(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_221(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_222) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_222(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_222(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_223) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_223(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_223(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_224) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_224(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_224(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_225) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_225(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_225(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_226) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_226(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_226(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_227) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_227(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_227(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_228) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_228(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_228(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_229) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_229(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_229(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_230) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_230(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_230(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_231) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_231(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_231(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_232) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_232(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_232(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_233) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_233(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_233(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_234) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_234(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_234(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_235) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_235(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_235(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_236) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_236(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_236(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_237) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_237(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_237(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_238) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_238(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_238(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_239) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_239(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_239(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_240) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_240(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_240(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_241) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_241(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_241(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_242) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_242(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_242(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_243) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_243(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_243(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_244) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_244(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_244(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_245) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_245(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_245(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_246) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_246(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_246(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_247) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_247(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_247(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_248) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_248(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_248(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_249) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_249(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_249(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_250) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_250(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_250(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_251) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_251(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_251(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_252) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_252(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_252(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_253) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_253(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_253(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_254) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_254(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_254(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_255) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_255(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_255(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_256) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_256(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_256(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_257) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_257(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_257(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_258) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_258(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_258(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_259) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_259(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_259(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_260) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_260(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_260(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_261) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_261(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_261(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_262) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_262(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_262(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_263) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_263(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_263(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_264) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_264(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_264(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_265) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_265(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_265(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_266) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_266(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_266(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_267) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_267(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_267(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_268) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_268(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_268(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_269) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_269(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_269(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_270) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_270(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_270(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_271) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_271(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_271(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_272) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_272(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_272(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_273) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_273(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_273(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_274) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_274(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_274(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_275) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_275(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_275(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_276) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_276(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_276(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_277) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_277(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_277(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_278) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_278(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_278(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_279) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_279(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_279(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_280) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_280(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_280(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_281) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_281(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_281(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_282) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_282(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_282(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_283) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_283(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_283(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_284) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_284(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_284(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_285) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_285(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_285(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_286) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_286(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_286(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_287) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_287(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_287(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_288) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_288(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_288(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_289) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_289(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_289(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_290) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_290(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_290(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_291) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_291(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_291(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_292) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_292(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_292(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_293) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_293(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_293(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_294) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_294(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_294(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_295) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_295(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_295(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_296) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_296(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_296(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_297) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_297(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_297(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_298) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_298(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_298(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_299) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_299(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_299(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_300) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_300(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_300(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_301) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_301(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_301(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_302) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_302(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_302(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_303) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_303(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_303(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_304) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_304(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_304(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_305) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_305(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_305(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_306) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_306(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_306(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_307) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_307(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_307(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_308) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_308(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_308(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_309) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_309(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_309(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_310) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_310(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_310(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_311) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_311(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_311(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_312) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_312(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_312(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_313) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_313(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_313(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_314) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_314(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_314(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_315) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_315(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_315(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_316) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_316(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_316(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_317) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_317(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_317(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_318) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_318(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_318(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_319) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_319(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_319(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_320) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_320(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_320(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_321) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_321(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_321(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_322) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_322(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_322(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_323) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_323(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_323(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_324) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_324(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_324(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_325) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_325(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_325(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_326) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_326(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_326(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_327) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_327(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_327(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_328) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_328(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_328(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_329) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_329(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_329(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_330) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_330(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_330(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_331) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_331(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_331(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_332) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_332(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_332(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_333) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_333(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_333(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_334) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_334(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_334(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_335) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_335(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_335(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_336) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_336(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_336(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_337) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_337(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_337(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_338) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_338(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_338(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_339) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_339(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_339(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_340) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_340(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_340(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_341) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_341(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_341(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_342) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_342(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_342(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_343) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_343(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_343(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_344) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_344(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_344(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_345) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_345(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_345(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_346) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_346(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_346(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_347) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_347(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_347(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_348) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_348(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_348(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_349) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_349(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_349(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_350) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_350(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_350(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_351) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_351(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_351(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_352) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_352(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_352(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_353) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_353(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_353(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_354) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_354(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_354(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_355) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_355(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_355(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_356) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_356(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_356(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_357) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_357(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_357(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_358) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_358(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_358(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_359) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_359(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_359(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_360) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_360(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_360(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_361) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_361(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_361(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_362) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_362(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_362(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_363) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_363(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_363(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_364) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_364(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_364(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_365) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_365(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_365(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_366) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_366(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_366(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_367) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_367(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_367(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_368) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_368(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_368(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_369) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_369(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_369(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_370) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_370(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_370(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_371) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_371(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_371(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_372) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_372(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_372(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_373) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_373(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_373(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_374) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_374(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_374(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_375) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_375(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_375(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_376) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_376(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_376(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_377) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_377(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_377(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_378) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_378(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_378(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_379) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_379(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_379(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_380) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_380(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_380(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_381) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_381(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_381(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_382) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_382(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_382(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_383) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_383(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_383(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_384) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_384(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_384(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_385) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_385(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_385(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_386) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_386(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_386(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_387) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_387(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_387(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_388) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_388(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_388(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_389) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_389(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_389(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_390) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_390(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_390(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_391) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_391(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_391(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_392) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_392(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_392(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_393) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_393(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_393(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_394) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_394(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_394(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_395) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_395(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_395(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_396) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_396(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_396(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_397) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_397(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_397(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_398) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_398(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_398(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_399) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_399(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_399(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_400) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_400(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_400(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_401) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_401(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_401(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_402) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_402(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_402(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_403) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_403(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_403(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_404) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_404(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_404(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_405) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_405(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_405(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_406) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_406(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_406(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_407) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_407(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_407(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_408) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_408(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_408(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_409) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_409(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_409(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_410) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_410(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_410(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_411) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_411(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_411(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_412) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_412(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_412(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_413) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_413(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_413(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_414) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_414(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_414(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_415) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_415(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_415(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_416) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_416(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_416(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_417) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_417(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_417(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_418) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_418(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_418(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_419) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_419(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_419(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_420) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_420(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_420(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_421) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_421(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_421(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_422) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_422(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_422(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_423) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_423(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_423(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_424) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_424(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_424(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_425) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_425(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_425(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_426) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_426(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_426(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_427) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_427(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_427(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_428) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_428(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_428(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_429) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_429(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_429(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_430) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_430(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_430(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_431) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_431(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_431(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_432) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_432(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_432(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_433) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_433(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_433(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_434) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_434(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_434(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_435) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_435(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_435(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_436) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_436(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_436(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_437) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_437(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_437(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_438) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_438(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_438(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_439) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_439(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_439(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_440) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_440(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_440(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_441) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_441(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_441(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_442) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_442(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_442(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_443) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_443(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_443(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_444) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_444(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_444(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_445) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_445(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_445(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_446) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_446(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_446(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_447) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_447(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_447(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_448) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_448(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_448(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_449) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_449(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_449(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_450) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_450(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_450(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_451) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_451(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_451(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_452) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_452(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_452(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_453) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_453(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_453(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_454) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_454(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_454(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_455) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_455(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_455(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_456) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_456(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_456(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_457) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_457(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_457(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_458) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_458(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_458(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_459) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_459(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_459(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_460) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_460(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_460(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_461) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_461(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_461(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_462) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_462(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_462(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_463) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_463(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_463(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_464) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_464(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_464(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_465) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_465(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_465(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_466) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_466(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_466(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_467) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_467(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_467(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_468) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_468(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_468(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_469) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_469(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_469(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_470) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_470(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_470(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_471) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_471(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_471(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_472) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_472(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_472(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_473) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_473(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_473(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_474) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_474(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_474(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_475) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_475(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_475(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_476) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_476(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_476(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_477) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_477(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_477(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_478) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_478(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_478(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_479) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_479(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_479(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_480) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_480(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_480(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_481) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_481(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_481(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_482) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_482(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_482(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_483) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_483(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_483(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_484) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_484(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_484(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_485) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_485(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_485(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_486) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_486(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_486(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_487) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_487(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_487(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_488) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_488(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_488(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_489) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_489(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_489(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_490) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_490(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_490(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_491) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_491(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_491(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_492) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_492(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_492(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_493) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_493(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_493(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_494) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_494(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_494(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_495) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_495(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_495(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_496) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_496(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_496(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_497) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_497(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_497(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_498) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_498(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_498(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_499) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_499(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_499(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_500) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_500(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_500(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_501) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_501(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_501(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_502) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_502(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_502(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_503) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_503(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_503(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_504) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_504(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_504(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_505) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_505(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_505(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_506) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_506(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_506(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_507) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_507(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_507(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_508) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_508(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_508(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_509) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_509(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_509(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_510) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_510(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_510(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_511) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_511(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_511(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_512) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_512(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_512(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_513) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_513(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_513(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_514) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_514(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_514(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_515) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_515(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_515(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_516) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_516(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_516(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_517) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_517(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_517(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_518) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_518(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_518(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_519) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_519(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_519(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_520) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_520(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_520(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_521) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_521(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_521(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_522) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_522(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_522(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_523) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_523(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_523(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_524) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_524(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_524(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_525) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_525(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_525(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_526) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_526(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_526(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_527) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_527(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_527(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_528) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_528(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_528(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_529) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_529(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_529(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_530) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_530(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_530(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_531) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_531(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_531(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_532) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_532(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_532(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_533) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_533(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_533(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_534) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_534(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_534(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_535) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_535(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_535(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_536) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_536(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_536(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_537) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_537(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_537(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_538) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_538(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_538(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_539) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_539(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_539(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_540) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_540(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_540(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_541) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_541(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_541(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_542) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_542(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_542(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_543) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_543(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_543(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_544) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_544(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_544(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_545) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_545(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_545(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_546) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_546(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_546(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_547) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_547(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_547(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_548) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_548(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_548(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_549) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_549(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_549(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_550) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_550(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_550(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_551) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_551(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_551(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_552) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_552(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_552(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_553) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_553(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_553(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_554) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_554(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_554(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_555) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_555(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_555(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_556) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_556(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_556(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_557) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_557(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_557(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_558) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_558(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_558(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_559) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_559(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_559(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_560) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_560(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_560(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_561) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_561(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_561(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_562) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_562(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_562(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_563) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_563(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_563(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_564) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_564(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_564(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_565) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_565(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_565(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_566) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_566(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_566(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_567) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_567(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_567(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_568) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_568(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_568(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_569) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_569(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_569(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_570) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_570(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_570(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_571) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_571(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_571(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_572) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_572(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_572(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_573) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_573(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_573(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_574) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_574(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_574(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_575) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_575(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_575(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_576) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_576(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_576(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_577) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_577(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_577(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_578) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_578(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_578(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_579) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_579(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_579(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_580) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_580(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_580(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_581) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_581(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_581(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_582) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_582(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_582(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_583) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_583(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_583(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_584) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_584(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_584(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_585) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_585(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_585(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_586) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_586(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_586(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_587) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_587(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_587(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_588) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_588(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_588(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_589) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_589(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_589(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_590) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_590(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_590(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_591) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_591(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_591(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_592) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_592(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_592(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_593) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_593(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_593(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_594) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_594(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_594(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_595) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_595(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_595(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_596) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_596(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_596(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_597) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_597(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_597(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_598) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_598(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_598(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_599) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_599(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_599(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_600) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_600(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_600(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_601) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_601(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_601(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_602) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_602(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_602(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_603) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_603(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_603(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_604) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_604(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_604(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_605) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_605(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_605(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_606) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_606(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_606(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_607) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_607(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_607(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_608) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_608(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_608(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_609) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_609(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_609(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_610) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_610(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_610(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_611) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_611(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_611(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_612) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_612(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_612(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_613) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_613(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_613(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_614) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_614(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_614(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_615) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_615(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_615(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_616) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_616(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_616(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_617) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_617(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_617(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_618) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_618(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_618(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_619) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_619(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_619(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_620) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_620(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_620(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_621) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_621(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_621(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_622) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_622(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_622(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_623) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_623(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_623(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_624) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_624(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_624(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_625) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_625(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_625(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_626) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_626(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_626(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_627) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_627(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_627(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_628) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_628(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_628(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_629) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_629(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_629(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_630) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_630(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_630(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_631) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_631(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_631(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_632) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_632(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_632(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_633) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_633(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_633(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_634) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_634(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_634(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_635) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_635(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_635(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_636) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_636(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_636(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_637) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_637(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_637(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_638) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_638(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_638(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_639) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_639(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_639(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_640) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_640(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_640(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_641) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_641(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_641(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_642) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_642(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_642(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_643) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_643(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_643(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_644) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_644(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_644(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_645) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_645(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_645(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_646) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_646(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_646(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_647) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_647(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_647(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_648) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_648(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_648(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_649) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_649(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_649(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_650) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_650(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_650(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_651) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_651(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_651(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_652) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_652(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_652(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_653) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_653(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_653(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_654) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_654(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_654(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_655) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_655(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_655(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_656) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_656(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_656(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_657) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_657(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_657(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_658) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_658(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_658(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_659) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_659(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_659(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_660) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_660(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_660(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_661) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_661(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_661(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_662) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_662(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_662(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_663) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_663(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_663(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_664) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_664(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_664(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_665) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_665(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_665(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_666) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_666(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_666(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_667) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_667(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_667(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_668) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_668(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_668(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_669) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_669(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_669(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_670) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_670(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_670(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_671) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_671(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_671(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_672) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_672(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_672(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_673) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_673(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_673(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_674) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_674(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_674(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_675) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_675(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_675(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_676) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_676(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_676(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_677) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_677(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_677(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_678) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_678(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_678(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_679) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_679(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_679(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_680) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_680(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_680(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_681) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_681(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_681(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_682) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_682(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_682(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_683) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_683(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_683(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_684) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_684(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_684(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_685) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_685(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_685(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_686) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_686(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_686(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_687) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_687(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_687(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_688) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_688(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_688(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_689) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_689(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_689(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_690) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_690(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_690(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_691) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_691(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_691(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_692) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_692(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_692(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_693) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_693(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_693(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_694) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_694(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_694(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_695) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_695(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_695(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_696) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_696(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_696(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_697) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_697(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_697(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_698) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_698(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_698(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_699) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_699(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_699(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_700) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_700(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_700(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_701) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_701(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_701(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_702) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_702(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_702(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_703) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_703(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_703(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_704) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_704(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_704(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_705) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_705(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_705(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_706) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_706(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_706(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_707) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_707(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_707(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_708) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_708(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_708(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_709) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_709(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_709(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_710) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_710(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_710(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_711) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_711(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_711(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_712) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_712(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_712(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_713) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_713(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_713(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_714) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_714(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_714(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_715) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_715(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_715(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_716) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_716(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_716(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_717) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_717(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_717(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_718) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_718(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_718(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_719) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_719(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_719(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_720) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_720(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_720(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_721) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_721(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_721(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_722) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_722(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_722(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_723) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_723(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_723(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_724) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_724(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_724(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_725) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_725(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_725(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_726) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_726(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_726(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_727) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_727(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_727(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_728) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_728(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_728(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_729) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_729(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_729(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_730) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_730(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_730(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_731) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_731(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_731(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_732) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_732(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_732(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_733) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_733(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_733(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_734) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_734(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_734(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_735) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_735(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_735(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_736) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_736(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_736(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_737) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_737(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_737(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_738) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_738(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_738(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_739) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_739(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_739(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_740) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_740(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_740(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_741) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_741(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_741(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_742) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_742(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_742(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_743) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_743(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_743(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_744) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_744(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_744(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_745) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_745(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_745(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_746) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_746(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_746(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_747) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_747(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_747(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_748) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_748(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_748(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_749) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_749(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_749(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_750) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_750(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_750(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_751) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_751(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_751(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_752) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_752(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_752(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_753) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_753(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_753(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_754) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_754(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_754(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_755) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_755(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_755(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_756) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_756(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_756(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_757) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_757(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_757(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_758) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_758(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_758(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_759) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_759(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_759(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_760) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_760(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_760(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_761) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_761(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_761(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_762) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_762(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_762(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_763) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_763(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_763(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_764) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_764(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_764(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_765) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_765(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_765(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_766) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_766(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_766(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_767) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_767(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_767(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_768) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_768(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_768(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_769) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_769(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_769(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_770) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_770(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_770(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_771) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_771(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_771(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_772) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_772(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_772(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_773) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_773(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_773(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_774) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_774(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_774(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_775) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_775(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_775(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_776) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_776(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_776(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_777) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_777(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_777(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_778) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_778(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_778(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_779) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_779(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_779(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_780) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_780(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_780(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_781) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_781(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_781(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_782) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_782(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_782(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_783) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_783(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_783(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_784) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_784(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_784(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_785) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_785(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_785(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_786) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_786(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_786(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_787) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_787(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_787(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_788) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_788(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_788(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_789) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_789(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_789(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_790) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_790(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_790(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_791) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_791(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_791(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_792) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_792(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_792(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_793) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_793(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_793(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_794) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_794(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_794(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_795) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_795(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_795(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_796) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_796(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_796(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_797) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_797(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_797(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_798) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_798(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_798(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_799) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_799(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_799(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_800) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_800(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_800(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_801) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_801(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_801(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_802) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_802(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_802(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_803) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_803(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_803(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_804) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_804(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_804(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_805) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_805(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_805(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_806) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_806(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_806(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_807) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_807(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_807(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_808) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_808(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_808(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_809) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_809(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_809(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_810) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_810(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_810(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_811) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_811(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_811(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_812) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_812(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_812(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_813) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_813(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_813(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_814) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_814(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_814(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_815) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_815(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_815(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_816) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_816(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_816(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_817) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_817(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_817(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_818) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_818(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_818(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_819) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_819(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_819(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_820) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_820(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_820(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_821) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_821(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_821(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_822) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_822(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_822(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_823) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_823(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_823(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_824) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_824(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_824(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_825) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_825(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_825(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_826) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_826(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_826(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_827) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_827(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_827(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_828) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_828(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_828(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_829) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_829(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_829(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_830) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_830(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_830(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_831) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_831(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_831(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_832) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_832(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_832(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_833) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_833(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_833(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_834) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_834(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_834(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_835) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_835(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_835(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_836) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_836(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_836(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_837) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_837(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_837(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_838) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_838(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_838(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_839) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_839(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_839(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_840) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_840(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_840(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_841) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_841(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_841(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_842) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_842(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_842(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_843) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_843(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_843(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_844) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_844(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_844(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_845) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_845(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_845(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_846) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_846(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_846(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_847) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_847(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_847(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_848) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_848(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_848(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_849) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_849(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_849(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_850) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_850(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_850(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_851) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_851(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_851(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_852) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_852(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_852(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_853) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_853(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_853(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_854) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_854(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_854(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_855) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_855(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_855(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_856) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_856(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_856(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_857) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_857(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_857(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_858) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_858(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_858(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_859) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_859(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_859(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_860) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_860(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_860(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_861) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_861(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_861(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_862) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_862(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_862(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_863) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_863(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_863(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_864) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_864(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_864(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_865) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_865(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_865(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_866) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_866(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_866(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_867) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_867(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_867(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_868) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_868(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_868(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_869) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_869(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_869(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_870) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_870(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_870(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_871) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_871(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_871(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_872) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_872(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_872(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_873) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_873(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_873(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_874) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_874(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_874(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_875) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_875(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_875(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_876) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_876(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_876(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_877) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_877(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_877(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_878) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_878(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_878(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_879) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_879(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_879(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_880) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_880(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_880(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_881) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_881(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_881(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_882) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_882(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_882(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_883) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_883(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_883(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_884) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_884(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_884(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_885) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_885(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_885(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_886) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_886(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_886(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_887) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_887(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_887(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_888) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_888(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_888(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_889) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_889(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_889(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_890) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_890(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_890(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_891) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_891(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_891(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_892) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_892(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_892(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_893) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_893(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_893(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_894) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_894(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_894(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_895) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_895(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_895(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_896) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_896(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_896(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_897) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_897(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_897(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_898) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_898(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_898(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_899) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_899(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_899(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_900) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_900(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_900(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_901) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_901(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_901(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_902) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_902(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_902(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_903) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_903(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_903(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_904) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_904(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_904(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_905) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_905(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_905(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_906) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_906(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_906(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_907) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_907(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_907(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_908) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_908(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_908(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_909) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_909(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_909(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_910) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_910(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_910(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_911) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_911(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_911(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_912) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_912(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_912(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_913) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_913(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_913(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_914) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_914(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_914(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_915) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_915(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_915(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_916) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_916(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_916(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_917) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_917(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_917(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_918) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_918(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_918(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_919) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_919(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_919(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_920) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_920(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_920(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_921) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_921(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_921(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_922) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_922(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_922(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_923) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_923(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_923(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_924) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_924(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_924(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_925) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_925(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_925(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_926) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_926(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_926(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_927) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_927(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_927(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_928) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_928(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_928(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_929) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_929(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_929(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_930) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_930(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_930(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_931) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_931(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_931(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_932) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_932(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_932(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_933) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_933(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_933(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_934) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_934(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_934(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_935) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_935(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_935(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_936) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_936(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_936(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_937) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_937(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_937(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_938) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_938(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_938(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_939) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_939(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_939(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_940) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_940(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_940(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_941) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_941(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_941(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_942) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_942(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_942(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_943) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_943(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_943(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_944) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_944(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_944(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_945) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_945(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_945(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_946) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_946(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_946(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_947) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_947(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_947(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_948) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_948(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_948(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_949) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_949(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_949(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_950) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_950(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_950(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_951) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_951(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_951(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_952) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_952(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_952(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_953) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_953(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_953(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_954) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_954(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_954(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_955) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_955(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_955(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_956) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_956(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_956(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_957) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_957(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_957(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_958) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_958(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_958(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_959) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_959(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_959(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_960) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_960(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_960(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_961) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_961(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_961(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_962) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_962(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_962(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_963) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_963(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_963(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_964) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_964(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_964(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_965) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_965(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_965(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_966) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_966(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_966(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_967) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_967(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_967(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_968) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_968(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_968(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_969) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_969(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_969(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_970) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_970(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_970(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_971) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_971(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_971(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_972) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_972(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_972(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_973) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_973(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_973(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_974) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_974(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_974(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_975) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_975(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_975(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_976) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_976(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_976(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_977) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_977(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_977(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_978) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_978(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_978(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_979) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_979(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_979(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_980) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_980(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_980(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_981) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_981(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_981(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_982) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_982(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_982(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_983) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_983(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_983(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_984) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_984(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_984(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_985) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_985(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_985(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_986) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_986(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_986(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_987) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_987(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_987(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_988) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_988(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_988(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_989) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_989(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_989(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_990) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_990(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_990(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_991) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_991(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_991(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_992) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_992(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_992(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_993) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_993(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_993(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_994) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_994(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_994(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_995) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_995(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_995(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_996) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_996(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_996(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_997) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_997(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_997(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_998) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_998(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_998(FUNC) +#endif + +#if defined(EIGEN_TEST_PART_999) || defined(EIGEN_TEST_PART_ALL) +#define CALL_SUBTEST_999(FUNC) CALL_SUBTEST(FUNC) +#else +#define CALL_SUBTEST_999(FUNC) +#endif + diff --git a/include/eigen/test/spqr_support.cpp b/include/eigen/test/spqr_support.cpp new file mode 100644 index 0000000000000000000000000000000000000000..79c2c12fc4751917007f9c56fa17ffe48e65bfb0 --- /dev/null +++ b/include/eigen/test/spqr_support.cpp @@ -0,0 +1,64 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2012 Desire Nuentsa Wakam +// +// 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 + +#define EIGEN_NO_DEBUG_SMALL_PRODUCT_BLOCKS +#include "sparse.h" +#include + + +template +int generate_sparse_rectangular_problem(MatrixType& A, DenseMat& dA, int maxRows = 300, int maxCols = 300) +{ + eigen_assert(maxRows >= maxCols); + typedef typename MatrixType::Scalar Scalar; + int rows = internal::random(1,maxRows); + int cols = internal::random(1,rows); + double density = (std::max)(8./(rows*cols), 0.01); + + A.resize(rows,cols); + dA.resize(rows,cols); + initSparse(density, dA, A,ForceNonZeroDiag); + A.makeCompressed(); + return rows; +} + +template void test_spqr_scalar() +{ + typedef SparseMatrix MatrixType; + MatrixType A; + Matrix dA; + typedef Matrix DenseVector; + DenseVector refX,x,b; + SPQR solver; + generate_sparse_rectangular_problem(A,dA); + + Index m = A.rows(); + b = DenseVector::Random(m); + solver.compute(A); + if (solver.info() != Success) + { + std::cerr << "sparse QR factorization failed\n"; + exit(0); + return; + } + x = solver.solve(b); + if (solver.info() != Success) + { + std::cerr << "sparse QR factorization failed\n"; + exit(0); + return; + } + //Compare with a dense solver + refX = dA.colPivHouseholderQr().solve(b); + VERIFY(x.isApprox(refX,test_precision())); +} +EIGEN_DECLARE_TEST(spqr_support) +{ + CALL_SUBTEST_1(test_spqr_scalar()); + CALL_SUBTEST_2(test_spqr_scalar >()); +} diff --git a/include/eigen/test/stable_norm.cpp b/include/eigen/test/stable_norm.cpp new file mode 100644 index 0000000000000000000000000000000000000000..cb8a80c18da7bbab81465f339a337aaa81424cff --- /dev/null +++ b/include/eigen/test/stable_norm.cpp @@ -0,0 +1,245 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2009-2014 Gael Guennebaud +// +// 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/. + +#include "main.h" + +template EIGEN_DONT_INLINE T copy(const T& x) +{ + return x; +} + +template void stable_norm(const MatrixType& m) +{ + /* this test covers the following files: + StableNorm.h + */ + using std::sqrt; + using std::abs; + typedef typename MatrixType::Scalar Scalar; + typedef typename NumTraits::Real RealScalar; + + bool complex_real_product_ok = true; + + // Check the basic machine-dependent constants. + { + int ibeta, it, iemin, iemax; + + ibeta = std::numeric_limits::radix; // base for floating-point numbers + it = std::numeric_limits::digits; // number of base-beta digits in mantissa + iemin = std::numeric_limits::min_exponent; // minimum exponent + iemax = std::numeric_limits::max_exponent; // maximum exponent + + VERIFY( (!(iemin > 1 - 2*it || 1+it>iemax || (it==2 && ibeta<5) || (it<=4 && ibeta <= 3 ) || it<2)) + && "the stable norm algorithm cannot be guaranteed on this computer"); + + Scalar inf = std::numeric_limits::infinity(); + if(NumTraits::IsComplex && (numext::isnan)(inf*RealScalar(1)) ) + { + complex_real_product_ok = false; + static bool first = true; + if(first) + std::cerr << "WARNING: compiler mess up complex*real product, " << inf << " * " << 1.0 << " = " << inf*RealScalar(1) << std::endl; + first = false; + } + } + + + Index rows = m.rows(); + Index cols = m.cols(); + + // get a non-zero random factor + Scalar factor = internal::random(); + while(numext::abs2(factor)(); + Scalar big = factor * ((std::numeric_limits::max)() * RealScalar(1e-4)); + + factor = internal::random(); + while(numext::abs2(factor)(); + Scalar small = factor * ((std::numeric_limits::min)() * RealScalar(1e4)); + + Scalar one(1); + + MatrixType vzero = MatrixType::Zero(rows, cols), + vrand = MatrixType::Random(rows, cols), + vbig(rows, cols), + vsmall(rows,cols); + + vbig.fill(big); + vsmall.fill(small); + + VERIFY_IS_MUCH_SMALLER_THAN(vzero.norm(), static_cast(1)); + VERIFY_IS_APPROX(vrand.stableNorm(), vrand.norm()); + VERIFY_IS_APPROX(vrand.blueNorm(), vrand.norm()); + VERIFY_IS_APPROX(vrand.hypotNorm(), vrand.norm()); + + // test with expressions as input + VERIFY_IS_APPROX((one*vrand).stableNorm(), vrand.norm()); + VERIFY_IS_APPROX((one*vrand).blueNorm(), vrand.norm()); + VERIFY_IS_APPROX((one*vrand).hypotNorm(), vrand.norm()); + VERIFY_IS_APPROX((one*vrand+one*vrand-one*vrand).stableNorm(), vrand.norm()); + VERIFY_IS_APPROX((one*vrand+one*vrand-one*vrand).blueNorm(), vrand.norm()); + VERIFY_IS_APPROX((one*vrand+one*vrand-one*vrand).hypotNorm(), vrand.norm()); + + RealScalar size = static_cast(m.size()); + + // test numext::isfinite + VERIFY(!(numext::isfinite)( std::numeric_limits::infinity())); + VERIFY(!(numext::isfinite)(sqrt(-abs(big)))); + + // test overflow + VERIFY((numext::isfinite)(sqrt(size)*abs(big))); + VERIFY_IS_NOT_APPROX(sqrt(copy(vbig.squaredNorm())), abs(sqrt(size)*big)); // here the default norm must fail + VERIFY_IS_APPROX(vbig.stableNorm(), sqrt(size)*abs(big)); + VERIFY_IS_APPROX(vbig.blueNorm(), sqrt(size)*abs(big)); + VERIFY_IS_APPROX(vbig.hypotNorm(), sqrt(size)*abs(big)); + + // test underflow + VERIFY((numext::isfinite)(sqrt(size)*abs(small))); + VERIFY_IS_NOT_APPROX(sqrt(copy(vsmall.squaredNorm())), abs(sqrt(size)*small)); // here the default norm must fail + VERIFY_IS_APPROX(vsmall.stableNorm(), sqrt(size)*abs(small)); + VERIFY_IS_APPROX(vsmall.blueNorm(), sqrt(size)*abs(small)); + VERIFY_IS_APPROX(vsmall.hypotNorm(), sqrt(size)*abs(small)); + + // Test compilation of cwise() version + VERIFY_IS_APPROX(vrand.colwise().stableNorm(), vrand.colwise().norm()); + VERIFY_IS_APPROX(vrand.colwise().blueNorm(), vrand.colwise().norm()); + VERIFY_IS_APPROX(vrand.colwise().hypotNorm(), vrand.colwise().norm()); + VERIFY_IS_APPROX(vrand.rowwise().stableNorm(), vrand.rowwise().norm()); + VERIFY_IS_APPROX(vrand.rowwise().blueNorm(), vrand.rowwise().norm()); + VERIFY_IS_APPROX(vrand.rowwise().hypotNorm(), vrand.rowwise().norm()); + + // test NaN, +inf, -inf + MatrixType v; + Index i = internal::random(0,rows-1); + Index j = internal::random(0,cols-1); + + // NaN + { + v = vrand; + v(i,j) = std::numeric_limits::quiet_NaN(); + VERIFY(!(numext::isfinite)(v.squaredNorm())); VERIFY((numext::isnan)(v.squaredNorm())); + VERIFY(!(numext::isfinite)(v.norm())); VERIFY((numext::isnan)(v.norm())); + VERIFY(!(numext::isfinite)(v.stableNorm())); VERIFY((numext::isnan)(v.stableNorm())); + VERIFY(!(numext::isfinite)(v.blueNorm())); VERIFY((numext::isnan)(v.blueNorm())); + VERIFY(!(numext::isfinite)(v.hypotNorm())); VERIFY((numext::isnan)(v.hypotNorm())); + } + + // +inf + { + v = vrand; + v(i,j) = std::numeric_limits::infinity(); + VERIFY(!(numext::isfinite)(v.squaredNorm())); VERIFY(isPlusInf(v.squaredNorm())); + VERIFY(!(numext::isfinite)(v.norm())); VERIFY(isPlusInf(v.norm())); + VERIFY(!(numext::isfinite)(v.stableNorm())); + if(complex_real_product_ok){ + VERIFY(isPlusInf(v.stableNorm())); + } + VERIFY(!(numext::isfinite)(v.blueNorm())); VERIFY(isPlusInf(v.blueNorm())); + VERIFY(!(numext::isfinite)(v.hypotNorm())); VERIFY(isPlusInf(v.hypotNorm())); + } + + // -inf + { + v = vrand; + v(i,j) = -std::numeric_limits::infinity(); + VERIFY(!(numext::isfinite)(v.squaredNorm())); VERIFY(isPlusInf(v.squaredNorm())); + VERIFY(!(numext::isfinite)(v.norm())); VERIFY(isPlusInf(v.norm())); + VERIFY(!(numext::isfinite)(v.stableNorm())); + if(complex_real_product_ok) { + VERIFY(isPlusInf(v.stableNorm())); + } + VERIFY(!(numext::isfinite)(v.blueNorm())); VERIFY(isPlusInf(v.blueNorm())); + VERIFY(!(numext::isfinite)(v.hypotNorm())); VERIFY(isPlusInf(v.hypotNorm())); + } + + // mix + { + Index i2 = internal::random(0,rows-1); + Index j2 = internal::random(0,cols-1); + v = vrand; + v(i,j) = -std::numeric_limits::infinity(); + v(i2,j2) = std::numeric_limits::quiet_NaN(); + VERIFY(!(numext::isfinite)(v.squaredNorm())); VERIFY((numext::isnan)(v.squaredNorm())); + VERIFY(!(numext::isfinite)(v.norm())); VERIFY((numext::isnan)(v.norm())); + VERIFY(!(numext::isfinite)(v.stableNorm())); VERIFY((numext::isnan)(v.stableNorm())); + VERIFY(!(numext::isfinite)(v.blueNorm())); VERIFY((numext::isnan)(v.blueNorm())); + if (i2 != i || j2 != j) { + // hypot propagates inf over NaN. + VERIFY(!(numext::isfinite)(v.hypotNorm())); VERIFY((numext::isinf)(v.hypotNorm())); + } else { + // inf is overwritten by NaN, expect norm to be NaN. + VERIFY(!(numext::isfinite)(v.hypotNorm())); VERIFY((numext::isnan)(v.hypotNorm())); + } + } + + // stableNormalize[d] + { + VERIFY_IS_APPROX(vrand.stableNormalized(), vrand.normalized()); + MatrixType vcopy(vrand); + vcopy.stableNormalize(); + VERIFY_IS_APPROX(vcopy, vrand.normalized()); + VERIFY_IS_APPROX((vrand.stableNormalized()).norm(), RealScalar(1)); + VERIFY_IS_APPROX(vcopy.norm(), RealScalar(1)); + VERIFY_IS_APPROX((vbig.stableNormalized()).norm(), RealScalar(1)); + VERIFY_IS_APPROX((vsmall.stableNormalized()).norm(), RealScalar(1)); + RealScalar big_scaling = ((std::numeric_limits::max)() * RealScalar(1e-4)); + VERIFY_IS_APPROX(vbig/big_scaling, (vbig.stableNorm() * vbig.stableNormalized()).eval()/big_scaling); + VERIFY_IS_APPROX(vsmall, vsmall.stableNorm() * vsmall.stableNormalized()); + } +} + +template +void test_hypot() +{ + typedef typename NumTraits::Real RealScalar; + Scalar factor = internal::random(); + while(numext::abs2(factor)(); + Scalar big = factor * ((std::numeric_limits::max)() * RealScalar(1e-4)); + + factor = internal::random(); + while(numext::abs2(factor)(); + Scalar small = factor * ((std::numeric_limits::min)() * RealScalar(1e4)); + + Scalar one (1), + zero (0), + sqrt2 (std::sqrt(2)), + nan (std::numeric_limits::quiet_NaN()); + + Scalar a = internal::random(-1,1); + Scalar b = internal::random(-1,1); + VERIFY_IS_APPROX(numext::hypot(a,b),std::sqrt(numext::abs2(a)+numext::abs2(b))); + VERIFY_IS_EQUAL(numext::hypot(zero,zero), zero); + VERIFY_IS_APPROX(numext::hypot(one, one), sqrt2); + VERIFY_IS_APPROX(numext::hypot(big,big), sqrt2*numext::abs(big)); + VERIFY_IS_APPROX(numext::hypot(small,small), sqrt2*numext::abs(small)); + VERIFY_IS_APPROX(numext::hypot(small,big), numext::abs(big)); + VERIFY((numext::isnan)(numext::hypot(nan,a))); + VERIFY((numext::isnan)(numext::hypot(a,nan))); +} + +EIGEN_DECLARE_TEST(stable_norm) +{ + for(int i = 0; i < g_repeat; i++) { + CALL_SUBTEST_3( test_hypot() ); + CALL_SUBTEST_4( test_hypot() ); + CALL_SUBTEST_5( test_hypot >() ); + CALL_SUBTEST_6( test_hypot >() ); + + CALL_SUBTEST_1( stable_norm(Matrix()) ); + CALL_SUBTEST_2( stable_norm(Vector4d()) ); + CALL_SUBTEST_3( stable_norm(VectorXd(internal::random(10,2000))) ); + CALL_SUBTEST_3( stable_norm(MatrixXd(internal::random(10,200), internal::random(10,200))) ); + CALL_SUBTEST_4( stable_norm(VectorXf(internal::random(10,2000))) ); + CALL_SUBTEST_5( stable_norm(VectorXcd(internal::random(10,2000))) ); + CALL_SUBTEST_6( stable_norm(VectorXcf(internal::random(10,2000))) ); + } +} diff --git a/include/eigen/test/stddeque.cpp b/include/eigen/test/stddeque.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ea85ea968f2e2f02871e1d93a752c223dbdc5835 --- /dev/null +++ b/include/eigen/test/stddeque.cpp @@ -0,0 +1,130 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2008 Benoit Jacob +// Copyright (C) 2010 Hauke Heibel +// +// 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/. + +#include "main.h" +#include +#include + +template +void check_stddeque_matrix(const MatrixType& m) +{ + Index rows = m.rows(); + Index cols = m.cols(); + MatrixType x = MatrixType::Random(rows,cols), y = MatrixType::Random(rows,cols); + std::deque > v(10, MatrixType::Zero(rows,cols)), w(20, y); + v.front() = x; + w.front() = w.back(); + VERIFY_IS_APPROX(w.front(), w.back()); + v = w; + + typename std::deque >::iterator vi = v.begin(); + typename std::deque >::iterator wi = w.begin(); + for(int i = 0; i < 20; i++) + { + VERIFY_IS_APPROX(*vi, *wi); + ++vi; + ++wi; + } + + v.resize(21,MatrixType::Zero(rows,cols)); + v.back() = x; + VERIFY_IS_APPROX(v.back(), x); + v.resize(22,y); + VERIFY_IS_APPROX(v.back(), y); + v.push_back(x); + VERIFY_IS_APPROX(v.back(), x); +} + +template +void check_stddeque_transform(const TransformType&) +{ + typedef typename TransformType::MatrixType MatrixType; + TransformType x(MatrixType::Random()), y(MatrixType::Random()), ti=TransformType::Identity(); + std::deque > v(10,ti), w(20, y); + v.front() = x; + w.front() = w.back(); + VERIFY_IS_APPROX(w.front(), w.back()); + v = w; + + typename std::deque >::iterator vi = v.begin(); + typename std::deque >::iterator wi = w.begin(); + for(int i = 0; i < 20; i++) + { + VERIFY_IS_APPROX(*vi, *wi); + ++vi; + ++wi; + } + + v.resize(21,ti); + v.back() = x; + VERIFY_IS_APPROX(v.back(), x); + v.resize(22,y); + VERIFY_IS_APPROX(v.back(), y); + v.push_back(x); + VERIFY_IS_APPROX(v.back(), x); +} + +template +void check_stddeque_quaternion(const QuaternionType&) +{ + typedef typename QuaternionType::Coefficients Coefficients; + QuaternionType x(Coefficients::Random()), y(Coefficients::Random()), qi=QuaternionType::Identity(); + std::deque > v(10,qi), w(20, y); + v.front() = x; + w.front() = w.back(); + VERIFY_IS_APPROX(w.front(), w.back()); + v = w; + + typename std::deque >::iterator vi = v.begin(); + typename std::deque >::iterator wi = w.begin(); + for(int i = 0; i < 20; i++) + { + VERIFY_IS_APPROX(*vi, *wi); + ++vi; + ++wi; + } + + v.resize(21,qi); + v.back() = x; + VERIFY_IS_APPROX(v.back(), x); + v.resize(22,y); + VERIFY_IS_APPROX(v.back(), y); + v.push_back(x); + VERIFY_IS_APPROX(v.back(), x); +} + +EIGEN_DECLARE_TEST(stddeque) +{ + // some non vectorizable fixed sizes + CALL_SUBTEST_1(check_stddeque_matrix(Vector2f())); + CALL_SUBTEST_1(check_stddeque_matrix(Matrix3f())); + CALL_SUBTEST_2(check_stddeque_matrix(Matrix3d())); + + // some vectorizable fixed sizes + CALL_SUBTEST_1(check_stddeque_matrix(Matrix2f())); + CALL_SUBTEST_1(check_stddeque_matrix(Vector4f())); + CALL_SUBTEST_1(check_stddeque_matrix(Matrix4f())); + CALL_SUBTEST_2(check_stddeque_matrix(Matrix4d())); + + // some dynamic sizes + CALL_SUBTEST_3(check_stddeque_matrix(MatrixXd(1,1))); + CALL_SUBTEST_3(check_stddeque_matrix(VectorXd(20))); + CALL_SUBTEST_3(check_stddeque_matrix(RowVectorXf(20))); + CALL_SUBTEST_3(check_stddeque_matrix(MatrixXcf(10,10))); + + // some Transform + CALL_SUBTEST_4(check_stddeque_transform(Affine2f())); + CALL_SUBTEST_4(check_stddeque_transform(Affine3f())); + CALL_SUBTEST_4(check_stddeque_transform(Affine3d())); + + // some Quaternion + CALL_SUBTEST_5(check_stddeque_quaternion(Quaternionf())); + CALL_SUBTEST_5(check_stddeque_quaternion(Quaterniond())); +} diff --git a/include/eigen/test/stdlist_overload.cpp b/include/eigen/test/stdlist_overload.cpp new file mode 100644 index 0000000000000000000000000000000000000000..843e28c3cbf87a3e521d07f28c6c5d5fe58d8756 --- /dev/null +++ b/include/eigen/test/stdlist_overload.cpp @@ -0,0 +1,192 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2008 Benoit Jacob +// Copyright (C) 2010 Hauke Heibel +// +// 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/. + +#include "main.h" + +#include +#include + +EIGEN_DEFINE_STL_LIST_SPECIALIZATION(Vector4f) + +EIGEN_DEFINE_STL_LIST_SPECIALIZATION(Matrix2f) +EIGEN_DEFINE_STL_LIST_SPECIALIZATION(Matrix4f) +EIGEN_DEFINE_STL_LIST_SPECIALIZATION(Matrix4d) + +EIGEN_DEFINE_STL_LIST_SPECIALIZATION(Affine3f) +EIGEN_DEFINE_STL_LIST_SPECIALIZATION(Affine3d) + +EIGEN_DEFINE_STL_LIST_SPECIALIZATION(Quaternionf) +EIGEN_DEFINE_STL_LIST_SPECIALIZATION(Quaterniond) + +template +typename Container::iterator get(Container & c, Position position) +{ + typename Container::iterator it = c.begin(); + std::advance(it, position); + return it; +} + +template +void set(Container & c, Position position, const Value & value) +{ + typename Container::iterator it = c.begin(); + std::advance(it, position); + *it = value; +} + +template +void check_stdlist_matrix(const MatrixType& m) +{ + Index rows = m.rows(); + Index cols = m.cols(); + MatrixType x = MatrixType::Random(rows,cols), y = MatrixType::Random(rows,cols); + std::list v(10, MatrixType::Zero(rows,cols)), w(20, y); + typename std::list::iterator itv = get(v, 5); + typename std::list::iterator itw = get(w, 6); + *itv = x; + *itw = *itv; + VERIFY_IS_APPROX(*itw, *itv); + v = w; + itv = v.begin(); + itw = w.begin(); + for(int i = 0; i < 20; i++) + { + VERIFY_IS_APPROX(*itw, *itv); + ++itv; + ++itw; + } + + v.resize(21, MatrixType::Zero(rows, cols)); + set(v, 20, x); + VERIFY_IS_APPROX(*get(v, 20), x); + v.resize(22,y); + VERIFY_IS_APPROX(*get(v, 21), y); + v.push_back(x); + VERIFY_IS_APPROX(*get(v, 22), x); + + // do a lot of push_back such that the list gets internally resized + // (with memory reallocation) + MatrixType* ref = &(*get(w, 0)); + for(int i=0; i<30 || ((ref==&(*get(w, 0))) && i<300); ++i) + v.push_back(*get(w, i%w.size())); + for(unsigned int i=23; i +void check_stdlist_transform(const TransformType&) +{ + typedef typename TransformType::MatrixType MatrixType; + TransformType x(MatrixType::Random()), y(MatrixType::Random()), ti=TransformType::Identity(); + std::list v(10,ti), w(20, y); + typename std::list::iterator itv = get(v, 5); + typename std::list::iterator itw = get(w, 6); + *itv = x; + *itw = *itv; + VERIFY_IS_APPROX(*itw, *itv); + v = w; + itv = v.begin(); + itw = w.begin(); + for(int i = 0; i < 20; i++) + { + VERIFY_IS_APPROX(*itw, *itv); + ++itv; + ++itw; + } + + v.resize(21, ti); + set(v, 20, x); + VERIFY_IS_APPROX(*get(v, 20), x); + v.resize(22,y); + VERIFY_IS_APPROX(*get(v, 21), y); + v.push_back(x); + VERIFY_IS_APPROX(*get(v, 22), x); + + // do a lot of push_back such that the list gets internally resized + // (with memory reallocation) + TransformType* ref = &(*get(w, 0)); + for(int i=0; i<30 || ((ref==&(*get(w, 0))) && i<300); ++i) + v.push_back(*get(w, i%w.size())); + for(unsigned int i=23; imatrix()==get(w, (i-23)%w.size())->matrix()); + } +} + +template +void check_stdlist_quaternion(const QuaternionType&) +{ + typedef typename QuaternionType::Coefficients Coefficients; + QuaternionType x(Coefficients::Random()), y(Coefficients::Random()), qi=QuaternionType::Identity(); + std::list v(10,qi), w(20, y); + typename std::list::iterator itv = get(v, 5); + typename std::list::iterator itw = get(w, 6); + *itv = x; + *itw = *itv; + VERIFY_IS_APPROX(*itw, *itv); + v = w; + itv = v.begin(); + itw = w.begin(); + for(int i = 0; i < 20; i++) + { + VERIFY_IS_APPROX(*itw, *itv); + ++itv; + ++itw; + } + + v.resize(21,qi); + set(v, 20, x); + VERIFY_IS_APPROX(*get(v, 20), x); + v.resize(22,y); + VERIFY_IS_APPROX(*get(v, 21), y); + v.push_back(x); + VERIFY_IS_APPROX(*get(v, 22), x); + + // do a lot of push_back such that the list gets internally resized + // (with memory reallocation) + QuaternionType* ref = &(*get(w, 0)); + for(int i=0; i<30 || ((ref==&(*get(w, 0))) && i<300); ++i) + v.push_back(*get(w, i%w.size())); + for(unsigned int i=23; icoeffs()==get(w, (i-23)%w.size())->coeffs()); + } +} + +EIGEN_DECLARE_TEST(stdlist_overload) +{ + // some non vectorizable fixed sizes + CALL_SUBTEST_1(check_stdlist_matrix(Vector2f())); + CALL_SUBTEST_1(check_stdlist_matrix(Matrix3f())); + CALL_SUBTEST_2(check_stdlist_matrix(Matrix3d())); + + // some vectorizable fixed sizes + CALL_SUBTEST_1(check_stdlist_matrix(Matrix2f())); + CALL_SUBTEST_1(check_stdlist_matrix(Vector4f())); + CALL_SUBTEST_1(check_stdlist_matrix(Matrix4f())); + CALL_SUBTEST_2(check_stdlist_matrix(Matrix4d())); + + // some dynamic sizes + CALL_SUBTEST_3(check_stdlist_matrix(MatrixXd(1,1))); + CALL_SUBTEST_3(check_stdlist_matrix(VectorXd(20))); + CALL_SUBTEST_3(check_stdlist_matrix(RowVectorXf(20))); + CALL_SUBTEST_3(check_stdlist_matrix(MatrixXcf(10,10))); + + // some Transform + CALL_SUBTEST_4(check_stdlist_transform(Affine2f())); // does not need the specialization (2+1)^2 = 9 + CALL_SUBTEST_4(check_stdlist_transform(Affine3f())); + CALL_SUBTEST_4(check_stdlist_transform(Affine3d())); + + // some Quaternion + CALL_SUBTEST_5(check_stdlist_quaternion(Quaternionf())); + CALL_SUBTEST_5(check_stdlist_quaternion(Quaterniond())); +} diff --git a/include/eigen/test/stdvector_overload.cpp b/include/eigen/test/stdvector_overload.cpp new file mode 100644 index 0000000000000000000000000000000000000000..da04f8a8434c84a5a1bcf1aed3b6aa1250b5bc35 --- /dev/null +++ b/include/eigen/test/stdvector_overload.cpp @@ -0,0 +1,161 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2008 Benoit Jacob +// Copyright (C) 2010 Hauke Heibel +// +// 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/. + +#include "main.h" + +#include +#include + +EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Vector4f) + +EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Matrix2f) +EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Matrix4f) +EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Matrix4d) + +EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Affine3f) +EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Affine3d) + +EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Quaternionf) +EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Quaterniond) + +template +void check_stdvector_matrix(const MatrixType& m) +{ + Index rows = m.rows(); + Index cols = m.cols(); + MatrixType x = MatrixType::Random(rows,cols), y = MatrixType::Random(rows,cols); + std::vector v(10, MatrixType::Zero(rows,cols)), w(20, y); + v[5] = x; + w[6] = v[5]; + VERIFY_IS_APPROX(w[6], v[5]); + v = w; + for(int i = 0; i < 20; i++) + { + VERIFY_IS_APPROX(w[i], v[i]); + } + + v.resize(21); + v[20] = x; + VERIFY_IS_APPROX(v[20], x); + v.resize(22,y); + VERIFY_IS_APPROX(v[21], y); + v.push_back(x); + VERIFY_IS_APPROX(v[22], x); + VERIFY((internal::UIntPtr)&(v[22]) == (internal::UIntPtr)&(v[21]) + sizeof(MatrixType)); + + // do a lot of push_back such that the vector gets internally resized + // (with memory reallocation) + MatrixType* ref = &w[0]; + for(int i=0; i<30 || ((ref==&w[0]) && i<300); ++i) + v.push_back(w[i%w.size()]); + for(unsigned int i=23; i +void check_stdvector_transform(const TransformType&) +{ + typedef typename TransformType::MatrixType MatrixType; + TransformType x(MatrixType::Random()), y(MatrixType::Random()); + std::vector v(10), w(20, y); + v[5] = x; + w[6] = v[5]; + VERIFY_IS_APPROX(w[6], v[5]); + v = w; + for(int i = 0; i < 20; i++) + { + VERIFY_IS_APPROX(w[i], v[i]); + } + + v.resize(21); + v[20] = x; + VERIFY_IS_APPROX(v[20], x); + v.resize(22,y); + VERIFY_IS_APPROX(v[21], y); + v.push_back(x); + VERIFY_IS_APPROX(v[22], x); + VERIFY((internal::UIntPtr)&(v[22]) == (internal::UIntPtr)&(v[21]) + sizeof(TransformType)); + + // do a lot of push_back such that the vector gets internally resized + // (with memory reallocation) + TransformType* ref = &w[0]; + for(int i=0; i<30 || ((ref==&w[0]) && i<300); ++i) + v.push_back(w[i%w.size()]); + for(unsigned int i=23; i +void check_stdvector_quaternion(const QuaternionType&) +{ + typedef typename QuaternionType::Coefficients Coefficients; + QuaternionType x(Coefficients::Random()), y(Coefficients::Random()), qi=QuaternionType::Identity(); + std::vector v(10,qi), w(20, y); + v[5] = x; + w[6] = v[5]; + VERIFY_IS_APPROX(w[6], v[5]); + v = w; + for(int i = 0; i < 20; i++) + { + VERIFY_IS_APPROX(w[i], v[i]); + } + + v.resize(21); + v[20] = x; + VERIFY_IS_APPROX(v[20], x); + v.resize(22,y); + VERIFY_IS_APPROX(v[21], y); + v.push_back(x); + VERIFY_IS_APPROX(v[22], x); + VERIFY((internal::UIntPtr)&(v[22]) == (internal::UIntPtr)&(v[21]) + sizeof(QuaternionType)); + + // do a lot of push_back such that the vector gets internally resized + // (with memory reallocation) + QuaternionType* ref = &w[0]; + for(int i=0; i<30 || ((ref==&w[0]) && i<300); ++i) + v.push_back(w[i%w.size()]); + for(unsigned int i=23; i +// +// 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/. + +template +Array four_denorms(); + +template<> +Array4f four_denorms() { return Array4f(5.60844e-39f, -5.60844e-39f, 4.94e-44f, -4.94e-44f); } +template<> +Array4d four_denorms() { return Array4d(5.60844e-313, -5.60844e-313, 4.94e-324, -4.94e-324); } +template +Array four_denorms() { return four_denorms().cast(); } + +template +void svd_fill_random(MatrixType &m, int Option = 0) +{ + using std::pow; + typedef typename MatrixType::Scalar Scalar; + typedef typename MatrixType::RealScalar RealScalar; + Index diagSize = (std::min)(m.rows(), m.cols()); + RealScalar s = std::numeric_limits::max_exponent10/4; + s = internal::random(1,s); + Matrix d = Matrix::Random(diagSize); + for(Index k=0; k(-s,s)); + + bool dup = internal::random(0,10) < 3; + bool unit_uv = internal::random(0,10) < (dup?7:3); // if we duplicate some diagonal entries, then increase the chance to preserve them using unitary U and V factors + + // duplicate some singular values + if(dup) + { + Index n = internal::random(0,d.size()-1); + for(Index i=0; i(0,d.size()-1)) = d(internal::random(0,d.size()-1)); + } + + Matrix U(m.rows(),diagSize); + Matrix VT(diagSize,m.cols()); + if(unit_uv) + { + // in very rare cases let's try with a pure diagonal matrix + if(internal::random(0,10) < 1) + { + U.setIdentity(); + VT.setIdentity(); + } + else + { + createRandomPIMatrixOfRank(diagSize,U.rows(), U.cols(), U); + createRandomPIMatrixOfRank(diagSize,VT.rows(), VT.cols(), VT); + } + } + else + { + U.setRandom(); + VT.setRandom(); + } + + Matrix samples(9); + samples << 0, four_denorms(), + -RealScalar(1)/NumTraits::highest(), RealScalar(1)/NumTraits::highest(), (std::numeric_limits::min)(), pow((std::numeric_limits::min)(),0.8); + + if(Option==Symmetric) + { + m = U * d.asDiagonal() * U.transpose(); + + // randomly nullify some rows/columns + { + Index count = internal::random(-diagSize,diagSize); + for(Index k=0; k(0,diagSize-1); + m.row(i).setZero(); + m.col(i).setZero(); + } + if(count<0) + // (partly) cancel some coeffs + if(!(dup && unit_uv)) + { + + Index n = internal::random(0,m.size()-1); + for(Index k=0; k(0,m.rows()-1); + Index j = internal::random(0,m.cols()-1); + m(j,i) = m(i,j) = samples(internal::random(0,samples.size()-1)); + if(NumTraits::IsComplex) + *(&numext::real_ref(m(j,i))+1) = *(&numext::real_ref(m(i,j))+1) = samples.real()(internal::random(0,samples.size()-1)); + } + } + } + } + else + { + m = U * d.asDiagonal() * VT; + // (partly) cancel some coeffs + if(!(dup && unit_uv)) + { + Index n = internal::random(0,m.size()-1); + for(Index k=0; k(0,m.rows()-1); + Index j = internal::random(0,m.cols()-1); + m(i,j) = samples(internal::random(0,samples.size()-1)); + if(NumTraits::IsComplex) + *(&numext::real_ref(m(i,j))+1) = samples.real()(internal::random(0,samples.size()-1)); + } + } + } +} + diff --git a/include/eigen/test/symbolic_index.cpp b/include/eigen/test/symbolic_index.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a75ca1165ae5888c97714fecf3d3f8408672dc19 --- /dev/null +++ b/include/eigen/test/symbolic_index.cpp @@ -0,0 +1,84 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2017 Gael Guennebaud +// +// 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/. + +#ifdef EIGEN_TEST_PART_2 +#define EIGEN_MAX_CPP_VER 03 + +// see indexed_view.cpp +#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)) + #pragma GCC diagnostic ignored "-Wdeprecated" +#endif + +#endif + +#include "main.h" + +template +bool is_same_symb(const T1& a, const T2& b, Index size) +{ + return a.eval(last=size-1) == b.eval(last=size-1); +} + +template +void check_is_symbolic(const T&) { + STATIC_CHECK(( symbolic::is_symbolic::value )) +} + +template +void check_isnot_symbolic(const T&) { + STATIC_CHECK(( !symbolic::is_symbolic::value )) +} + +#define VERIFY_EQ_INT(A,B) VERIFY_IS_APPROX(int(A),int(B)) + +void check_symbolic_index() +{ + check_is_symbolic(last); + check_is_symbolic(lastp1); + check_is_symbolic(last+1); + check_is_symbolic(last-lastp1); + check_is_symbolic(2*last-lastp1/2); + check_isnot_symbolic(fix<3>()); + + Index size=100; + + // First, let's check FixedInt arithmetic: + VERIFY( is_same_type( (fix<5>()-fix<3>())*fix<9>()/(-fix<3>()), fix<-(5-3)*9/3>() ) ); + VERIFY( is_same_type( (fix<5>()-fix<3>())*fix<9>()/fix<2>(), fix<(5-3)*9/2>() ) ); + VERIFY( is_same_type( fix<9>()/fix<2>(), fix<9/2>() ) ); + VERIFY( is_same_type( fix<9>()%fix<2>(), fix<9%2>() ) ); + VERIFY( is_same_type( fix<9>()&fix<2>(), fix<9&2>() ) ); + VERIFY( is_same_type( fix<9>()|fix<2>(), fix<9|2>() ) ); + VERIFY( is_same_type( fix<9>()/2, int(9/2) ) ); + + VERIFY( is_same_symb( lastp1-1, last, size) ); + VERIFY( is_same_symb( lastp1-fix<1>(), last, size) ); + + VERIFY_IS_EQUAL( ( (last*5-2)/3 ).eval(last=size-1), ((size-1)*5-2)/3 ); + VERIFY_IS_EQUAL( ( (last*fix<5>()-fix<2>())/fix<3>() ).eval(last=size-1), ((size-1)*5-2)/3 ); + VERIFY_IS_EQUAL( ( -last*lastp1 ).eval(last=size-1), -(size-1)*size ); + VERIFY_IS_EQUAL( ( lastp1-3*last ).eval(last=size-1), size- 3*(size-1) ); + VERIFY_IS_EQUAL( ( (lastp1-3*last)/lastp1 ).eval(last=size-1), (size- 3*(size-1))/size ); + +#if EIGEN_HAS_CXX14_VARIABLE_TEMPLATES + { + struct x_tag {}; static const symbolic::SymbolExpr x; + struct y_tag {}; static const symbolic::SymbolExpr y; + struct z_tag {}; static const symbolic::SymbolExpr z; + + VERIFY_IS_APPROX( int(((x+3)/y+z).eval(x=6,y=3,z=-13)), (6+3)/3+(-13) ); + } +#endif +} + +EIGEN_DECLARE_TEST(symbolic_index) +{ + CALL_SUBTEST_1( check_symbolic_index() ); + CALL_SUBTEST_2( check_symbolic_index() ); +} diff --git a/include/eigen/test/type_alias.cpp b/include/eigen/test/type_alias.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9a6616c72c6c2b4e49b9a92a0684587c9a41c993 --- /dev/null +++ b/include/eigen/test/type_alias.cpp @@ -0,0 +1,48 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2019 Gael Guennebaud +// +// 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/. + +#include "main.h" + +EIGEN_DECLARE_TEST(type_alias) +{ + using namespace internal; + + // To warm up, some basic checks: + STATIC_CHECK((is_same >::value)); + STATIC_CHECK((is_same >::value)); + STATIC_CHECK((is_same >::value)); + +#if EIGEN_HAS_CXX11 + + STATIC_CHECK((is_same, MatrixXd>::value)); + STATIC_CHECK((is_same, MatrixXi>::value)); + STATIC_CHECK((is_same, Matrix2i>::value)); + STATIC_CHECK((is_same, Matrix2Xf>::value)); + STATIC_CHECK((is_same, MatrixX4d>::value)); + STATIC_CHECK((is_same, VectorXi>::value)); + STATIC_CHECK((is_same, Vector2f>::value)); + STATIC_CHECK((is_same, RowVectorXi>::value)); + STATIC_CHECK((is_same, RowVector2f>::value)); + + STATIC_CHECK((is_same, ArrayXXf>::value)); + STATIC_CHECK((is_same, Array33i>::value)); + STATIC_CHECK((is_same, Array2Xf>::value)); + STATIC_CHECK((is_same, ArrayX4d>::value)); + STATIC_CHECK((is_same, ArrayXd>::value)); + STATIC_CHECK((is_same, Array4d>::value)); + + STATIC_CHECK((is_same, Vector3f>::value)); + STATIC_CHECK((is_same, VectorXi>::value)); + STATIC_CHECK((is_same, RowVector3f>::value)); + STATIC_CHECK((is_same, RowVectorXi>::value)); + +#else + std::cerr << "WARNING: c++11 type aliases not tested.\n"; +#endif +} diff --git a/include/eigen/test/umeyama.cpp b/include/eigen/test/umeyama.cpp new file mode 100644 index 0000000000000000000000000000000000000000..170c28a6116b2e964e202e6518178f556377786a --- /dev/null +++ b/include/eigen/test/umeyama.cpp @@ -0,0 +1,183 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2009 Hauke Heibel +// +// 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/. + +#include "main.h" + +#include +#include + +#include // required for MatrixBase::determinant +#include // required for SVD + +using namespace Eigen; + +// Constructs a random matrix from the unitary group U(size). +template +Eigen::Matrix randMatrixUnitary(int size) +{ + typedef T Scalar; + typedef Eigen::Matrix MatrixType; + + MatrixType Q; + + int max_tries = 40; + bool is_unitary = false; + + while (!is_unitary && max_tries > 0) + { + // initialize random matrix + Q = MatrixType::Random(size, size); + + // orthogonalize columns using the Gram-Schmidt algorithm + for (int col = 0; col < size; ++col) + { + typename MatrixType::ColXpr colVec = Q.col(col); + for (int prevCol = 0; prevCol < col; ++prevCol) + { + typename MatrixType::ColXpr prevColVec = Q.col(prevCol); + colVec -= colVec.dot(prevColVec)*prevColVec; + } + Q.col(col) = colVec.normalized(); + } + + // this additional orthogonalization is not necessary in theory but should enhance + // the numerical orthogonality of the matrix + for (int row = 0; row < size; ++row) + { + typename MatrixType::RowXpr rowVec = Q.row(row); + for (int prevRow = 0; prevRow < row; ++prevRow) + { + typename MatrixType::RowXpr prevRowVec = Q.row(prevRow); + rowVec -= rowVec.dot(prevRowVec)*prevRowVec; + } + Q.row(row) = rowVec.normalized(); + } + + // final check + is_unitary = Q.isUnitary(); + --max_tries; + } + + if (max_tries == 0) + eigen_assert(false && "randMatrixUnitary: Could not construct unitary matrix!"); + + return Q; +} + +// Constructs a random matrix from the special unitary group SU(size). +template +Eigen::Matrix randMatrixSpecialUnitary(int size) +{ + typedef T Scalar; + + typedef Eigen::Matrix MatrixType; + + // initialize unitary matrix + MatrixType Q = randMatrixUnitary(size); + + // tweak the first column to make the determinant be 1 + Q.col(0) *= numext::conj(Q.determinant()); + + return Q; +} + +template +void run_test(int dim, int num_elements) +{ + using std::abs; + typedef typename internal::traits::Scalar Scalar; + typedef Matrix MatrixX; + typedef Matrix VectorX; + + // MUST be positive because in any other case det(cR_t) may become negative for + // odd dimensions! + const Scalar c = abs(internal::random()); + + MatrixX R = randMatrixSpecialUnitary(dim); + VectorX t = Scalar(50)*VectorX::Random(dim,1); + + MatrixX cR_t = MatrixX::Identity(dim+1,dim+1); + cR_t.block(0,0,dim,dim) = c*R; + cR_t.block(0,dim,dim,1) = t; + + MatrixX src = MatrixX::Random(dim+1, num_elements); + src.row(dim) = Matrix::Constant(num_elements, Scalar(1)); + + MatrixX dst = cR_t*src; + + MatrixX cR_t_umeyama = umeyama(src.block(0,0,dim,num_elements), dst.block(0,0,dim,num_elements)); + + const Scalar error = ( cR_t_umeyama*src - dst ).norm() / dst.norm(); + VERIFY(error < Scalar(40)*std::numeric_limits::epsilon()); +} + +template +void run_fixed_size_test(int num_elements) +{ + using std::abs; + typedef Matrix MatrixX; + typedef Matrix HomMatrix; + typedef Matrix FixedMatrix; + typedef Matrix FixedVector; + + const int dim = Dimension; + + // MUST be positive because in any other case det(cR_t) may become negative for + // odd dimensions! + // Also if c is to small compared to t.norm(), problem is ill-posed (cf. Bug 744) + const Scalar c = internal::random(0.5, 2.0); + + FixedMatrix R = randMatrixSpecialUnitary(dim); + FixedVector t = Scalar(32)*FixedVector::Random(dim,1); + + HomMatrix cR_t = HomMatrix::Identity(dim+1,dim+1); + cR_t.block(0,0,dim,dim) = c*R; + cR_t.block(0,dim,dim,1) = t; + + MatrixX src = MatrixX::Random(dim+1, num_elements); + src.row(dim) = Matrix::Constant(num_elements, Scalar(1)); + + MatrixX dst = cR_t*src; + + Block src_block(src,0,0,dim,num_elements); + Block dst_block(dst,0,0,dim,num_elements); + + HomMatrix cR_t_umeyama = umeyama(src_block, dst_block); + + const Scalar error = ( cR_t_umeyama*src - dst ).squaredNorm(); + + VERIFY(error < Scalar(16)*std::numeric_limits::epsilon()); +} + +EIGEN_DECLARE_TEST(umeyama) +{ + for (int i=0; i(40,500); + + // works also for dimensions bigger than 3... + for (int dim=2; dim<8; ++dim) + { + CALL_SUBTEST_1(run_test(dim, num_elements)); + CALL_SUBTEST_2(run_test(dim, num_elements)); + } + + CALL_SUBTEST_3((run_fixed_size_test(num_elements))); + CALL_SUBTEST_4((run_fixed_size_test(num_elements))); + CALL_SUBTEST_5((run_fixed_size_test(num_elements))); + + CALL_SUBTEST_6((run_fixed_size_test(num_elements))); + CALL_SUBTEST_7((run_fixed_size_test(num_elements))); + CALL_SUBTEST_8((run_fixed_size_test(num_elements))); + } + + // Those two calls don't compile and result in meaningful error messages! + // umeyama(MatrixXcf(),MatrixXcf()); + // umeyama(MatrixXcd(),MatrixXcd()); +} diff --git a/include/eigen/test/unalignedcount.cpp b/include/eigen/test/unalignedcount.cpp new file mode 100644 index 0000000000000000000000000000000000000000..52cdd9e1d163378f4e2d5f870f9ebc2700758be8 --- /dev/null +++ b/include/eigen/test/unalignedcount.cpp @@ -0,0 +1,60 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2009 Gael Guennebaud +// +// 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/. + +static int nb_load; +static int nb_loadu; +static int nb_store; +static int nb_storeu; + +#define EIGEN_DEBUG_ALIGNED_LOAD { nb_load++; } +#define EIGEN_DEBUG_UNALIGNED_LOAD { nb_loadu++; } +#define EIGEN_DEBUG_ALIGNED_STORE { nb_store++; } +#define EIGEN_DEBUG_UNALIGNED_STORE { nb_storeu++; } + +#define VERIFY_ALIGNED_UNALIGNED_COUNT(XPR,AL,UL,AS,US) {\ + nb_load = nb_loadu = nb_store = nb_storeu = 0; \ + XPR; \ + if(!(nb_load==AL && nb_loadu==UL && nb_store==AS && nb_storeu==US)) \ + std::cerr << " >> " << nb_load << ", " << nb_loadu << ", " << nb_store << ", " << nb_storeu << "\n"; \ + VERIFY( (#XPR) && nb_load==AL && nb_loadu==UL && nb_store==AS && nb_storeu==US ); \ + } + + +#include "main.h" + +EIGEN_DECLARE_TEST(unalignedcount) +{ + #if defined(EIGEN_VECTORIZE_AVX512) + VectorXf a(48), b(48); + VERIFY_ALIGNED_UNALIGNED_COUNT(a += b, 6, 0, 3, 0); + VERIFY_ALIGNED_UNALIGNED_COUNT(a.segment(0,48) += b.segment(0,48), 3, 3, 3, 0); + VERIFY_ALIGNED_UNALIGNED_COUNT(a.segment(0,48) -= b.segment(0,48), 3, 3, 3, 0); + VERIFY_ALIGNED_UNALIGNED_COUNT(a.segment(0,48) *= 3.5, 3, 0, 3, 0); + VERIFY_ALIGNED_UNALIGNED_COUNT(a.segment(0,48) /= 3.5, 3, 0, 3, 0); + #elif defined(EIGEN_VECTORIZE_AVX) + VectorXf a(40), b(40); + VERIFY_ALIGNED_UNALIGNED_COUNT(a += b, 10, 0, 5, 0); + VERIFY_ALIGNED_UNALIGNED_COUNT(a.segment(0,40) += b.segment(0,40), 5, 5, 5, 0); + VERIFY_ALIGNED_UNALIGNED_COUNT(a.segment(0,40) -= b.segment(0,40), 5, 5, 5, 0); + VERIFY_ALIGNED_UNALIGNED_COUNT(a.segment(0,40) *= 3.5, 5, 0, 5, 0); + VERIFY_ALIGNED_UNALIGNED_COUNT(a.segment(0,40) /= 3.5, 5, 0, 5, 0); + #elif defined(EIGEN_VECTORIZE_SSE) + VectorXf a(40), b(40); + VERIFY_ALIGNED_UNALIGNED_COUNT(a += b, 20, 0, 10, 0); + VERIFY_ALIGNED_UNALIGNED_COUNT(a.segment(0,40) += b.segment(0,40), 10, 10, 10, 0); + VERIFY_ALIGNED_UNALIGNED_COUNT(a.segment(0,40) -= b.segment(0,40), 10, 10, 10, 0); + VERIFY_ALIGNED_UNALIGNED_COUNT(a.segment(0,40) *= 3.5, 10, 0, 10, 0); + VERIFY_ALIGNED_UNALIGNED_COUNT(a.segment(0,40) /= 3.5, 10, 0, 10, 0); + #else + // The following line is to eliminate "variable not used" warnings + nb_load = nb_loadu = nb_store = nb_storeu = 0; + int a(0), b(0); + VERIFY(a==b); + #endif +} diff --git a/include/eigen/test/vectorwiseop.cpp b/include/eigen/test/vectorwiseop.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8ee58841af161162df62df76b915784c270bfc06 --- /dev/null +++ b/include/eigen/test/vectorwiseop.cpp @@ -0,0 +1,298 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2011 Benoit Jacob +// Copyright (C) 2015 Gael Guennebaud +// +// 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/. + +#define TEST_ENABLE_TEMPORARY_TRACKING +#define EIGEN_NO_STATIC_ASSERT + +#include "main.h" + +template void vectorwiseop_array(const ArrayType& m) +{ + typedef typename ArrayType::Scalar Scalar; + typedef Array ColVectorType; + typedef Array RowVectorType; + + Index rows = m.rows(); + Index cols = m.cols(); + Index r = internal::random(0, rows-1), + c = internal::random(0, cols-1); + + ArrayType m1 = ArrayType::Random(rows, cols), + m2(rows, cols), + m3(rows, cols); + + ColVectorType colvec = ColVectorType::Random(rows); + RowVectorType rowvec = RowVectorType::Random(cols); + + // test addition + + m2 = m1; + m2.colwise() += colvec; + VERIFY_IS_APPROX(m2, m1.colwise() + colvec); + VERIFY_IS_APPROX(m2.col(c), m1.col(c) + colvec); + + VERIFY_RAISES_ASSERT(m2.colwise() += colvec.transpose()); + VERIFY_RAISES_ASSERT(m1.colwise() + colvec.transpose()); + + m2 = m1; + m2.rowwise() += rowvec; + VERIFY_IS_APPROX(m2, m1.rowwise() + rowvec); + VERIFY_IS_APPROX(m2.row(r), m1.row(r) + rowvec); + + VERIFY_RAISES_ASSERT(m2.rowwise() += rowvec.transpose()); + VERIFY_RAISES_ASSERT(m1.rowwise() + rowvec.transpose()); + + // test substraction + + m2 = m1; + m2.colwise() -= colvec; + VERIFY_IS_APPROX(m2, m1.colwise() - colvec); + VERIFY_IS_APPROX(m2.col(c), m1.col(c) - colvec); + + VERIFY_RAISES_ASSERT(m2.colwise() -= colvec.transpose()); + VERIFY_RAISES_ASSERT(m1.colwise() - colvec.transpose()); + + m2 = m1; + m2.rowwise() -= rowvec; + VERIFY_IS_APPROX(m2, m1.rowwise() - rowvec); + VERIFY_IS_APPROX(m2.row(r), m1.row(r) - rowvec); + + VERIFY_RAISES_ASSERT(m2.rowwise() -= rowvec.transpose()); + VERIFY_RAISES_ASSERT(m1.rowwise() - rowvec.transpose()); + + // test multiplication + + m2 = m1; + m2.colwise() *= colvec; + VERIFY_IS_APPROX(m2, m1.colwise() * colvec); + VERIFY_IS_APPROX(m2.col(c), m1.col(c) * colvec); + + VERIFY_RAISES_ASSERT(m2.colwise() *= colvec.transpose()); + VERIFY_RAISES_ASSERT(m1.colwise() * colvec.transpose()); + + m2 = m1; + m2.rowwise() *= rowvec; + VERIFY_IS_APPROX(m2, m1.rowwise() * rowvec); + VERIFY_IS_APPROX(m2.row(r), m1.row(r) * rowvec); + + VERIFY_RAISES_ASSERT(m2.rowwise() *= rowvec.transpose()); + VERIFY_RAISES_ASSERT(m1.rowwise() * rowvec.transpose()); + + // test quotient + + m2 = m1; + m2.colwise() /= colvec; + VERIFY_IS_APPROX(m2, m1.colwise() / colvec); + VERIFY_IS_APPROX(m2.col(c), m1.col(c) / colvec); + + VERIFY_RAISES_ASSERT(m2.colwise() /= colvec.transpose()); + VERIFY_RAISES_ASSERT(m1.colwise() / colvec.transpose()); + + m2 = m1; + m2.rowwise() /= rowvec; + VERIFY_IS_APPROX(m2, m1.rowwise() / rowvec); + VERIFY_IS_APPROX(m2.row(r), m1.row(r) / rowvec); + + VERIFY_RAISES_ASSERT(m2.rowwise() /= rowvec.transpose()); + VERIFY_RAISES_ASSERT(m1.rowwise() / rowvec.transpose()); + + m2 = m1; + // yes, there might be an aliasing issue there but ".rowwise() /=" + // is supposed to evaluate " m2.colwise().sum()" into a temporary to avoid + // evaluating the reduction multiple times + if(ArrayType::RowsAtCompileTime>2 || ArrayType::RowsAtCompileTime==Dynamic) + { + m2.rowwise() /= m2.colwise().sum(); + VERIFY_IS_APPROX(m2, m1.rowwise() / m1.colwise().sum()); + } + + // all/any + Array mb(rows,cols); + mb = (m1.real()<=0.7).colwise().all(); + VERIFY( (mb.col(c) == (m1.real().col(c)<=0.7).all()).all() ); + mb = (m1.real()<=0.7).rowwise().all(); + VERIFY( (mb.row(r) == (m1.real().row(r)<=0.7).all()).all() ); + + mb = (m1.real()>=0.7).colwise().any(); + VERIFY( (mb.col(c) == (m1.real().col(c)>=0.7).any()).all() ); + mb = (m1.real()>=0.7).rowwise().any(); + VERIFY( (mb.row(r) == (m1.real().row(r)>=0.7).any()).all() ); +} + +template void vectorwiseop_matrix(const MatrixType& m) +{ + typedef typename MatrixType::Scalar Scalar; + typedef typename NumTraits::Real RealScalar; + typedef Matrix ColVectorType; + typedef Matrix RowVectorType; + typedef Matrix RealColVectorType; + typedef Matrix RealRowVectorType; + typedef Matrix MatrixX; + + Index rows = m.rows(); + Index cols = m.cols(); + Index r = internal::random(0, rows-1), + c = internal::random(0, cols-1); + + MatrixType m1 = MatrixType::Random(rows, cols), + m2(rows, cols), + m3(rows, cols); + + ColVectorType colvec = ColVectorType::Random(rows); + RowVectorType rowvec = RowVectorType::Random(cols); + RealColVectorType rcres; + RealRowVectorType rrres; + + // test broadcast assignment + m2 = m1; + m2.colwise() = colvec; + for(Index j=0; j1) + VERIFY_RAISES_ASSERT(m2.colwise() = colvec.transpose()); + if(cols>1) + VERIFY_RAISES_ASSERT(m2.rowwise() = rowvec.transpose()); + + // test addition + + m2 = m1; + m2.colwise() += colvec; + VERIFY_IS_APPROX(m2, m1.colwise() + colvec); + VERIFY_IS_APPROX(m2.col(c), m1.col(c) + colvec); + + if(rows>1) + { + VERIFY_RAISES_ASSERT(m2.colwise() += colvec.transpose()); + VERIFY_RAISES_ASSERT(m1.colwise() + colvec.transpose()); + } + + m2 = m1; + m2.rowwise() += rowvec; + VERIFY_IS_APPROX(m2, m1.rowwise() + rowvec); + VERIFY_IS_APPROX(m2.row(r), m1.row(r) + rowvec); + + if(cols>1) + { + VERIFY_RAISES_ASSERT(m2.rowwise() += rowvec.transpose()); + VERIFY_RAISES_ASSERT(m1.rowwise() + rowvec.transpose()); + } + + // test substraction + + m2 = m1; + m2.colwise() -= colvec; + VERIFY_IS_APPROX(m2, m1.colwise() - colvec); + VERIFY_IS_APPROX(m2.col(c), m1.col(c) - colvec); + + if(rows>1) + { + VERIFY_RAISES_ASSERT(m2.colwise() -= colvec.transpose()); + VERIFY_RAISES_ASSERT(m1.colwise() - colvec.transpose()); + } + + m2 = m1; + m2.rowwise() -= rowvec; + VERIFY_IS_APPROX(m2, m1.rowwise() - rowvec); + VERIFY_IS_APPROX(m2.row(r), m1.row(r) - rowvec); + + if(cols>1) + { + VERIFY_RAISES_ASSERT(m2.rowwise() -= rowvec.transpose()); + VERIFY_RAISES_ASSERT(m1.rowwise() - rowvec.transpose()); + } + + // ------ partial reductions ------ + + #define TEST_PARTIAL_REDUX_BASIC(FUNC,ROW,COL,PREPROCESS) { \ + ROW = m1 PREPROCESS .colwise().FUNC ; \ + for(Index k=0; k()),rowvec,colvec,EIGEN_EMPTY); + + VERIFY_IS_APPROX(m1.cwiseAbs().colwise().sum(), m1.colwise().template lpNorm<1>()); + VERIFY_IS_APPROX(m1.cwiseAbs().rowwise().sum(), m1.rowwise().template lpNorm<1>()); + VERIFY_IS_APPROX(m1.cwiseAbs().colwise().maxCoeff(), m1.colwise().template lpNorm()); + VERIFY_IS_APPROX(m1.cwiseAbs().rowwise().maxCoeff(), m1.rowwise().template lpNorm()); + + // regression for bug 1158 + VERIFY_IS_APPROX(m1.cwiseAbs().colwise().sum().x(), m1.col(0).cwiseAbs().sum()); + + // test normalized + m2 = m1.colwise().normalized(); + VERIFY_IS_APPROX(m2.col(c), m1.col(c).normalized()); + m2 = m1.rowwise().normalized(); + VERIFY_IS_APPROX(m2.row(r), m1.row(r).normalized()); + + // test normalize + m2 = m1; + m2.colwise().normalize(); + VERIFY_IS_APPROX(m2.col(c), m1.col(c).normalized()); + m2 = m1; + m2.rowwise().normalize(); + VERIFY_IS_APPROX(m2.row(r), m1.row(r).normalized()); + + // test with partial reduction of products + Matrix m1m1 = m1 * m1.transpose(); + VERIFY_IS_APPROX( (m1 * m1.transpose()).colwise().sum(), m1m1.colwise().sum()); + Matrix tmp(rows); + VERIFY_EVALUATION_COUNT( tmp = (m1 * m1.transpose()).colwise().sum(), 1); + + m2 = m1.rowwise() - (m1.colwise().sum()/RealScalar(m1.rows())).eval(); + m1 = m1.rowwise() - (m1.colwise().sum()/RealScalar(m1.rows())); + VERIFY_IS_APPROX( m1, m2 ); + VERIFY_EVALUATION_COUNT( m2 = (m1.rowwise() - m1.colwise().sum()/RealScalar(m1.rows())), (MatrixType::RowsAtCompileTime!=1 ? 1 : 0) ); + + // test empty expressions + VERIFY_IS_APPROX(m1.matrix().middleCols(0,0).rowwise().sum().eval(), MatrixX::Zero(rows,1)); + VERIFY_IS_APPROX(m1.matrix().middleRows(0,0).colwise().sum().eval(), MatrixX::Zero(1,cols)); + VERIFY_IS_APPROX(m1.matrix().middleCols(0,fix<0>).rowwise().sum().eval(), MatrixX::Zero(rows,1)); + VERIFY_IS_APPROX(m1.matrix().middleRows(0,fix<0>).colwise().sum().eval(), MatrixX::Zero(1,cols)); + + VERIFY_IS_APPROX(m1.matrix().middleCols(0,0).rowwise().prod().eval(), MatrixX::Ones(rows,1)); + VERIFY_IS_APPROX(m1.matrix().middleRows(0,0).colwise().prod().eval(), MatrixX::Ones(1,cols)); + VERIFY_IS_APPROX(m1.matrix().middleCols(0,fix<0>).rowwise().prod().eval(), MatrixX::Ones(rows,1)); + VERIFY_IS_APPROX(m1.matrix().middleRows(0,fix<0>).colwise().prod().eval(), MatrixX::Ones(1,cols)); + + VERIFY_IS_APPROX(m1.matrix().middleCols(0,0).rowwise().squaredNorm().eval(), MatrixX::Zero(rows,1)); + + VERIFY_RAISES_ASSERT(m1.real().middleCols(0,0).rowwise().minCoeff().eval()); + VERIFY_RAISES_ASSERT(m1.real().middleRows(0,0).colwise().maxCoeff().eval()); + VERIFY_IS_EQUAL(m1.real().middleRows(0,0).rowwise().maxCoeff().eval().rows(),0); + VERIFY_IS_EQUAL(m1.real().middleCols(0,0).colwise().maxCoeff().eval().cols(),0); + VERIFY_IS_EQUAL(m1.real().middleRows(0,fix<0>).rowwise().maxCoeff().eval().rows(),0); + VERIFY_IS_EQUAL(m1.real().middleCols(0,fix<0>).colwise().maxCoeff().eval().cols(),0); +} + +EIGEN_DECLARE_TEST(vectorwiseop) +{ + CALL_SUBTEST_1( vectorwiseop_array(Array22cd()) ); + CALL_SUBTEST_2( vectorwiseop_array(Array()) ); + CALL_SUBTEST_3( vectorwiseop_array(ArrayXXf(3, 4)) ); + CALL_SUBTEST_4( vectorwiseop_matrix(Matrix4cf()) ); + CALL_SUBTEST_5( vectorwiseop_matrix(Matrix4f()) ); + CALL_SUBTEST_5( vectorwiseop_matrix(Vector4f()) ); + CALL_SUBTEST_5( vectorwiseop_matrix(Matrix()) ); + CALL_SUBTEST_6( vectorwiseop_matrix(MatrixXd(internal::random(1,EIGEN_TEST_MAX_SIZE), internal::random(1,EIGEN_TEST_MAX_SIZE))) ); + CALL_SUBTEST_7( vectorwiseop_matrix(VectorXd(internal::random(1,EIGEN_TEST_MAX_SIZE))) ); + CALL_SUBTEST_7( vectorwiseop_matrix(RowVectorXd(internal::random(1,EIGEN_TEST_MAX_SIZE))) ); +} diff --git a/include/eigen/test/visitor.cpp b/include/eigen/test/visitor.cpp new file mode 100644 index 0000000000000000000000000000000000000000..20fb2c3ed56baa0e8653d8de126544fb1106e1c1 --- /dev/null +++ b/include/eigen/test/visitor.cpp @@ -0,0 +1,193 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2008 Benoit Jacob +// +// 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/. + +#include "main.h" + +template void matrixVisitor(const MatrixType& p) +{ + typedef typename MatrixType::Scalar Scalar; + + Index rows = p.rows(); + Index cols = p.cols(); + + // construct a random matrix where all coefficients are different + MatrixType m; + m = MatrixType::Random(rows, cols); + for(Index i = 0; i < m.size(); i++) + for(Index i2 = 0; i2 < i; i2++) + while(m(i) == m(i2)) // yes, == + m(i) = internal::random(); + + Scalar minc = Scalar(1000), maxc = Scalar(-1000); + Index minrow=0,mincol=0,maxrow=0,maxcol=0; + for(Index j = 0; j < cols; j++) + for(Index i = 0; i < rows; i++) + { + if(m(i,j) < minc) + { + minc = m(i,j); + minrow = i; + mincol = j; + } + if(m(i,j) > maxc) + { + maxc = m(i,j); + maxrow = i; + maxcol = j; + } + } + Index eigen_minrow, eigen_mincol, eigen_maxrow, eigen_maxcol; + Scalar eigen_minc, eigen_maxc; + eigen_minc = m.minCoeff(&eigen_minrow,&eigen_mincol); + eigen_maxc = m.maxCoeff(&eigen_maxrow,&eigen_maxcol); + VERIFY(minrow == eigen_minrow); + VERIFY(maxrow == eigen_maxrow); + VERIFY(mincol == eigen_mincol); + VERIFY(maxcol == eigen_maxcol); + VERIFY_IS_APPROX(minc, eigen_minc); + VERIFY_IS_APPROX(maxc, eigen_maxc); + VERIFY_IS_APPROX(minc, m.minCoeff()); + VERIFY_IS_APPROX(maxc, m.maxCoeff()); + + eigen_maxc = (m.adjoint()*m).maxCoeff(&eigen_maxrow,&eigen_maxcol); + Index maxrow2=0,maxcol2=0; + eigen_maxc = (m.adjoint()*m).eval().maxCoeff(&maxrow2,&maxcol2); + VERIFY(maxrow2 == eigen_maxrow); + VERIFY(maxcol2 == eigen_maxcol); + + if (!NumTraits::IsInteger && m.size() > 2) { + // Test NaN propagation by replacing an element with NaN. + bool stop = false; + for (Index j = 0; j < cols && !stop; ++j) { + for (Index i = 0; i < rows && !stop; ++i) { + if (!(j == mincol && i == minrow) && + !(j == maxcol && i == maxrow)) { + m(i,j) = NumTraits::quiet_NaN(); + stop = true; + break; + } + } + } + + eigen_minc = m.template minCoeff(&eigen_minrow, &eigen_mincol); + eigen_maxc = m.template maxCoeff(&eigen_maxrow, &eigen_maxcol); + VERIFY(minrow == eigen_minrow); + VERIFY(maxrow == eigen_maxrow); + VERIFY(mincol == eigen_mincol); + VERIFY(maxcol == eigen_maxcol); + VERIFY_IS_APPROX(minc, eigen_minc); + VERIFY_IS_APPROX(maxc, eigen_maxc); + VERIFY_IS_APPROX(minc, m.template minCoeff()); + VERIFY_IS_APPROX(maxc, m.template maxCoeff()); + + eigen_minc = m.template minCoeff(&eigen_minrow, &eigen_mincol); + eigen_maxc = m.template maxCoeff(&eigen_maxrow, &eigen_maxcol); + VERIFY(minrow != eigen_minrow || mincol != eigen_mincol); + VERIFY(maxrow != eigen_maxrow || maxcol != eigen_maxcol); + VERIFY((numext::isnan)(eigen_minc)); + VERIFY((numext::isnan)(eigen_maxc)); + } + +} + +template void vectorVisitor(const VectorType& w) +{ + typedef typename VectorType::Scalar Scalar; + + Index size = w.size(); + + // construct a random vector where all coefficients are different + VectorType v; + v = VectorType::Random(size); + for(Index i = 0; i < size; i++) + for(Index i2 = 0; i2 < i; i2++) + while(v(i) == v(i2)) // yes, == + v(i) = internal::random(); + + Scalar minc = v(0), maxc = v(0); + Index minidx=0, maxidx=0; + for(Index i = 0; i < size; i++) + { + if(v(i) < minc) + { + minc = v(i); + minidx = i; + } + if(v(i) > maxc) + { + maxc = v(i); + maxidx = i; + } + } + Index eigen_minidx, eigen_maxidx; + Scalar eigen_minc, eigen_maxc; + eigen_minc = v.minCoeff(&eigen_minidx); + eigen_maxc = v.maxCoeff(&eigen_maxidx); + VERIFY(minidx == eigen_minidx); + VERIFY(maxidx == eigen_maxidx); + VERIFY_IS_APPROX(minc, eigen_minc); + VERIFY_IS_APPROX(maxc, eigen_maxc); + VERIFY_IS_APPROX(minc, v.minCoeff()); + VERIFY_IS_APPROX(maxc, v.maxCoeff()); + + Index idx0 = internal::random(0,size-1); + Index idx1 = eigen_minidx; + Index idx2 = eigen_maxidx; + VectorType v1(v), v2(v); + v1(idx0) = v1(idx1); + v2(idx0) = v2(idx2); + v1.minCoeff(&eigen_minidx); + v2.maxCoeff(&eigen_maxidx); + VERIFY(eigen_minidx == (std::min)(idx0,idx1)); + VERIFY(eigen_maxidx == (std::min)(idx0,idx2)); + + if (!NumTraits::IsInteger && size > 2) { + // Test NaN propagation by replacing an element with NaN. + for (Index i = 0; i < size; ++i) { + if (i != minidx && i != maxidx) { + v(i) = NumTraits::quiet_NaN(); + break; + } + } + eigen_minc = v.template minCoeff(&eigen_minidx); + eigen_maxc = v.template maxCoeff(&eigen_maxidx); + VERIFY(minidx == eigen_minidx); + VERIFY(maxidx == eigen_maxidx); + VERIFY_IS_APPROX(minc, eigen_minc); + VERIFY_IS_APPROX(maxc, eigen_maxc); + VERIFY_IS_APPROX(minc, v.template minCoeff()); + VERIFY_IS_APPROX(maxc, v.template maxCoeff()); + + eigen_minc = v.template minCoeff(&eigen_minidx); + eigen_maxc = v.template maxCoeff(&eigen_maxidx); + VERIFY(minidx != eigen_minidx); + VERIFY(maxidx != eigen_maxidx); + VERIFY((numext::isnan)(eigen_minc)); + VERIFY((numext::isnan)(eigen_maxc)); + } +} + +EIGEN_DECLARE_TEST(visitor) +{ + for(int i = 0; i < g_repeat; i++) { + CALL_SUBTEST_1( matrixVisitor(Matrix()) ); + CALL_SUBTEST_2( matrixVisitor(Matrix2f()) ); + CALL_SUBTEST_3( matrixVisitor(Matrix4d()) ); + CALL_SUBTEST_4( matrixVisitor(MatrixXd(8, 12)) ); + CALL_SUBTEST_5( matrixVisitor(Matrix(20, 20)) ); + CALL_SUBTEST_6( matrixVisitor(MatrixXi(8, 12)) ); + } + for(int i = 0; i < g_repeat; i++) { + CALL_SUBTEST_7( vectorVisitor(Vector4f()) ); + CALL_SUBTEST_7( vectorVisitor(Matrix()) ); + CALL_SUBTEST_8( vectorVisitor(VectorXd(10)) ); + CALL_SUBTEST_9( vectorVisitor(RowVectorXd(10)) ); + CALL_SUBTEST_10( vectorVisitor(VectorXf(33)) ); + } +}