diff options
-rw-r--r-- | Eigen/src/Core/Dot.h | 13 | ||||
-rw-r--r-- | Eigen/src/Core/MatrixBase.h | 2 | ||||
-rw-r--r-- | Eigen/src/Core/OperatorEquals.h | 18 | ||||
-rw-r--r-- | Eigen/src/Core/Product.h | 5 | ||||
-rw-r--r-- | Eigen/src/Core/Trace.h | 13 | ||||
-rw-r--r-- | Eigen/src/Core/Util.h | 20 | ||||
-rw-r--r-- | test/adjoint.cpp | 24 | ||||
-rw-r--r-- | test/basicstuff.cpp | 1 | ||||
-rw-r--r-- | test/product.cpp | 25 |
9 files changed, 76 insertions, 45 deletions
diff --git a/Eigen/src/Core/Dot.h b/Eigen/src/Core/Dot.h index c3ca1e2ac..652514fa3 100644 --- a/Eigen/src/Core/Dot.h +++ b/Eigen/src/Core/Dot.h @@ -5,12 +5,12 @@ // // Eigen is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either +// License as published by the Free Software Foundation; either // version 3 of the License, or (at your option) any later version. // // Alternatively, you can redistribute it and/or // modify it under the terms of the GNU General Public License as -// published by the Free Software Foundation; either version 2 of +// published by the Free Software Foundation; either version 2 of // the License, or (at your option) any later version. // // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY @@ -18,7 +18,7 @@ // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the // GNU General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public +// You should have received a copy of the GNU Lesser General Public // License and a copy of the GNU General Public License along with // Eigen. If not, see <http://www.gnu.org/licenses/>. @@ -60,7 +60,7 @@ struct DotUnroller<Index, 0, Derived1, Derived2> /** \returns the dot product of *this with other. * * \only_for_vectors - * + * * \note If the scalar type is complex numbers, then this function returns the hermitian * (sesquilinear) dot product, linear in the first variable and anti-linear in the * second variable. @@ -77,8 +77,9 @@ Scalar MatrixBase<Scalar, Derived>::dot(const MatrixBase<Scalar, OtherDerived>& Scalar res; if(EIGEN_UNROLLED_LOOPS && Traits::SizeAtCompileTime != Dynamic - && Traits::SizeAtCompileTime <= 16) - DotUnroller<Traits::SizeAtCompileTime-1, Traits::SizeAtCompileTime, + && Traits::SizeAtCompileTime <= EIGEN_UNROLLING_LIMIT_PRODUCT) + DotUnroller<Traits::SizeAtCompileTime-1, + Traits::SizeAtCompileTime <= EIGEN_UNROLLING_LIMIT_PRODUCT ? Traits::SizeAtCompileTime : Dynamic, Derived, MatrixBase<Scalar, OtherDerived> > ::run(*static_cast<const Derived*>(this), other, res); else diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h index 09af4bd8d..f5a2ad178 100644 --- a/Eigen/src/Core/MatrixBase.h +++ b/Eigen/src/Core/MatrixBase.h @@ -49,6 +49,8 @@ cout << x.row(0) << endl; } * \endcode + * + * \nosubgrouping */ template<typename Scalar, typename Derived> class MatrixBase { diff --git a/Eigen/src/Core/OperatorEquals.h b/Eigen/src/Core/OperatorEquals.h index 6ff4402d4..bc1450127 100644 --- a/Eigen/src/Core/OperatorEquals.h +++ b/Eigen/src/Core/OperatorEquals.h @@ -6,12 +6,12 @@ // // Eigen is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either +// License as published by the Free Software Foundation; either // version 3 of the License, or (at your option) any later version. // // Alternatively, you can redistribute it and/or // modify it under the terms of the GNU General Public License as -// published by the Free Software Foundation; either version 2 of +// published by the Free Software Foundation; either version 2 of // the License, or (at your option) any later version. // // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY @@ -19,7 +19,7 @@ // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the // GNU General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public +// You should have received a copy of the GNU Lesser General Public // License and a copy of the GNU General Public License along with // Eigen. If not, see <http://www.gnu.org/licenses/>. @@ -106,9 +106,12 @@ Derived& MatrixBase<Scalar, Derived> // copying a vector expression into a vector { assert(size() == other.size()); - if(EIGEN_UNROLLED_LOOPS && Traits::SizeAtCompileTime != Dynamic && Traits::SizeAtCompileTime <= 25) + if(EIGEN_UNROLLED_LOOPS + && Traits::SizeAtCompileTime != Dynamic + && Traits::SizeAtCompileTime <= EIGEN_UNROLLING_LIMIT_OPEQUAL) VectorOperatorEqualsUnroller - <Derived, OtherDerived, Traits::SizeAtCompileTime>::run + <Derived, OtherDerived, + Traits::SizeAtCompileTime <= EIGEN_UNROLLING_LIMIT_OPEQUAL ? Traits::SizeAtCompileTime : Dynamic>::run (*static_cast<Derived*>(this), *static_cast<const OtherDerived*>(&other)); else for(int i = 0; i < size(); i++) @@ -120,10 +123,11 @@ Derived& MatrixBase<Scalar, Derived> assert(rows() == other.rows() && cols() == other.cols()); if(EIGEN_UNROLLED_LOOPS && Traits::SizeAtCompileTime != Dynamic - && Traits::SizeAtCompileTime <= 25) + && Traits::SizeAtCompileTime <= EIGEN_UNROLLING_LIMIT_OPEQUAL) { MatrixOperatorEqualsUnroller - <Derived, OtherDerived, Traits::SizeAtCompileTime>::run + <Derived, OtherDerived, + Traits::SizeAtCompileTime <= EIGEN_UNROLLING_LIMIT_OPEQUAL ? Traits::SizeAtCompileTime : Dynamic>::run (*static_cast<Derived*>(this), *static_cast<const OtherDerived*>(&other)); } else diff --git a/Eigen/src/Core/Product.h b/Eigen/src/Core/Product.h index 7ca68d76e..4d2db51bd 100644 --- a/Eigen/src/Core/Product.h +++ b/Eigen/src/Core/Product.h @@ -106,9 +106,10 @@ template<typename Lhs, typename Rhs> class Product : NoOperatorEquals, Scalar res; if(EIGEN_UNROLLED_LOOPS && Lhs::Traits::ColsAtCompileTime != Dynamic - && Lhs::Traits::ColsAtCompileTime <= 16) + && Lhs::Traits::ColsAtCompileTime <= EIGEN_UNROLLING_LIMIT_PRODUCT) ProductUnroller<Lhs::Traits::ColsAtCompileTime-1, - Lhs::Traits::ColsAtCompileTime, LhsRef, RhsRef> + Lhs::Traits::ColsAtCompileTime <= EIGEN_UNROLLING_LIMIT_PRODUCT ? Lhs::Traits::ColsAtCompileTime : Dynamic, + LhsRef, RhsRef> ::run(row, col, m_lhs, m_rhs, res); else { diff --git a/Eigen/src/Core/Trace.h b/Eigen/src/Core/Trace.h index 564801221..ff080c595 100644 --- a/Eigen/src/Core/Trace.h +++ b/Eigen/src/Core/Trace.h @@ -5,12 +5,12 @@ // // Eigen is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either +// License as published by the Free Software Foundation; either // version 3 of the License, or (at your option) any later version. // // Alternatively, you can redistribute it and/or // modify it under the terms of the GNU General Public License as -// published by the Free Software Foundation; either version 2 of +// published by the Free Software Foundation; either version 2 of // the License, or (at your option) any later version. // // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY @@ -18,7 +18,7 @@ // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the // GNU General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public +// You should have received a copy of the GNU Lesser General Public // License and a copy of the GNU General Public License along with // Eigen. If not, see <http://www.gnu.org/licenses/>. @@ -61,8 +61,11 @@ Scalar MatrixBase<Scalar, Derived>::trace() const { assert(rows() == cols()); Scalar res; - if(EIGEN_UNROLLED_LOOPS && Traits::RowsAtCompileTime != Dynamic && Traits::RowsAtCompileTime <= 16) - TraceUnroller<Traits::RowsAtCompileTime-1, Traits::RowsAtCompileTime, Derived> + if(EIGEN_UNROLLED_LOOPS + && Traits::RowsAtCompileTime != Dynamic + && Traits::RowsAtCompileTime <= EIGEN_UNROLLING_LIMIT_PRODUCT) + TraceUnroller<Traits::RowsAtCompileTime-1, + Traits::RowsAtCompileTime <= EIGEN_UNROLLING_LIMIT_PRODUCT ? Traits::RowsAtCompileTime : Dynamic, Derived> ::run(*static_cast<const Derived*>(this), res); else { diff --git a/Eigen/src/Core/Util.h b/Eigen/src/Core/Util.h index b11c27653..9d0aa07a0 100644 --- a/Eigen/src/Core/Util.h +++ b/Eigen/src/Core/Util.h @@ -5,12 +5,12 @@ // // Eigen is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either +// License as published by the Free Software Foundation; either // version 3 of the License, or (at your option) any later version. // // Alternatively, you can redistribute it and/or // modify it under the terms of the GNU General Public License as -// published by the Free Software Foundation; either version 2 of +// published by the Free Software Foundation; either version 2 of // the License, or (at your option) any later version. // // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY @@ -18,7 +18,7 @@ // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the // GNU General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public +// You should have received a copy of the GNU Lesser General Public // License and a copy of the GNU General Public License along with // Eigen. If not, see <http://www.gnu.org/licenses/>. @@ -31,6 +31,20 @@ #define EIGEN_UNROLLED_LOOPS (true) #endif +/** Defines the maximal loop size (i.e., the matrix size NxM) to enable + * meta unrolling of operator=. + */ +#ifndef EIGEN_UNROLLING_LIMIT_OPEQUAL +#define EIGEN_UNROLLING_LIMIT_OPEQUAL 25 +#endif + +/** Defines the maximal loop size to enable meta unrolling + * of the matrix product, dot product and trace. + */ +#ifndef EIGEN_UNROLLING_LIMIT_PRODUCT +#define EIGEN_UNROLLING_LIMIT_PRODUCT 16 +#endif + #ifdef EIGEN_DEFAULT_TO_ROW_MAJOR #define EIGEN_DEFAULT_MATRIX_STORAGE_ORDER RowMajor #else diff --git a/test/adjoint.cpp b/test/adjoint.cpp index 7218c43fa..96e3cf6f7 100644 --- a/test/adjoint.cpp +++ b/test/adjoint.cpp @@ -5,12 +5,12 @@ // // Eigen is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either +// License as published by the Free Software Foundation; either // version 3 of the License, or (at your option) any later version. // // Alternatively, you can redistribute it and/or // modify it under the terms of the GNU General Public License as -// published by the Free Software Foundation; either version 2 of +// published by the Free Software Foundation; either version 2 of // the License, or (at your option) any later version. // // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY @@ -18,7 +18,7 @@ // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the // GNU General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public +// You should have received a copy of the GNU Lesser General Public // License and a copy of the GNU General Public License along with // Eigen. If not, see <http://www.gnu.org/licenses/>. @@ -36,7 +36,7 @@ template<typename MatrixType> void adjoint(const MatrixType& m) typedef Matrix<Scalar, MatrixType::Traits::RowsAtCompileTime, 1> VectorType; int rows = m.rows(); int cols = m.cols(); - + MatrixType m1 = MatrixType::random(rows, cols), m2 = MatrixType::random(rows, cols), m3(rows, cols), @@ -52,18 +52,18 @@ template<typename MatrixType> void adjoint(const MatrixType& m) Scalar s1 = ei_random<Scalar>(), s2 = ei_random<Scalar>(); - + // check involutivity of adjoint, transpose, conjugate VERIFY_IS_APPROX(m1.transpose().transpose(), m1); VERIFY_IS_APPROX(m1.conjugate().conjugate(), m1); VERIFY_IS_APPROX(m1.adjoint().adjoint(), m1); - + // check basic compatibility of adjoint, transpose, conjugate VERIFY_IS_APPROX(m1.transpose().conjugate().adjoint(), m1); VERIFY_IS_APPROX(m1.adjoint().conjugate().transpose(), m1); if(!NumTraits<Scalar>::IsComplex) VERIFY_IS_APPROX(m1.adjoint().transpose(), m1); - + // check multiplicative behavior VERIFY_IS_APPROX((m1.transpose() * m2).transpose(), m2.transpose() * m1); VERIFY_IS_APPROX((m1.adjoint() * m2).adjoint(), m2.adjoint() * m1); @@ -71,7 +71,7 @@ template<typename MatrixType> void adjoint(const MatrixType& m) VERIFY_IS_APPROX((s1 * m1).transpose(), s1 * m1.transpose()); VERIFY_IS_APPROX((s1 * m1).conjugate(), ei_conj(s1) * m1.conjugate()); VERIFY_IS_APPROX((s1 * m1).adjoint(), ei_conj(s1) * m1.adjoint()); - + // check basic properties of dot, norm, norm2 typedef typename NumTraits<Scalar>::Real RealScalar; VERIFY_IS_APPROX((s1 * v1 + s2 * v2).dot(v3), s1 * v1.dot(v3) + s2 * v2.dot(v3)); @@ -83,16 +83,16 @@ template<typename MatrixType> void adjoint(const MatrixType& m) VERIFY_IS_MUCH_SMALLER_THAN(ei_abs(vzero.dot(v1)), static_cast<RealScalar>(1)); if(NumTraits<Scalar>::HasFloatingPoint) VERIFY_IS_MUCH_SMALLER_THAN(vzero.norm(), static_cast<RealScalar>(1)); - + // check compatibility of dot and adjoint VERIFY_IS_APPROX(v1.dot(square * v2), (square.adjoint() * v1).dot(v2)); - + // like in testBasicStuff, test operator() to check const-qualification int r = ei_random<int>(0, rows-1), c = ei_random<int>(0, cols-1); VERIFY_IS_APPROX(m1.conjugate()(r,c), ei_conj(m1(r,c))); VERIFY_IS_APPROX(m1.adjoint()(c,r), ei_conj(m1(r,c))); - + } void EigenTest::testAdjoint() @@ -104,6 +104,8 @@ void EigenTest::testAdjoint() adjoint(MatrixXi(8, 12)); adjoint(MatrixXcd(20, 20)); } + // test a large matrix only once + adjoint(Matrix<float, 100, 100>()); } } // namespace Eigen diff --git a/test/basicstuff.cpp b/test/basicstuff.cpp index ec00f2b90..a8fb8db33 100644 --- a/test/basicstuff.cpp +++ b/test/basicstuff.cpp @@ -89,6 +89,7 @@ void EigenTest::testBasicStuff() basicStuff(MatrixXcf(3, 3)); basicStuff(MatrixXi(8, 12)); basicStuff(MatrixXcd(20, 20)); + basicStuff(Matrix<float, 100, 100>()); } } diff --git a/test/product.cpp b/test/product.cpp index af77bb9b0..4d5b5161a 100644 --- a/test/product.cpp +++ b/test/product.cpp @@ -5,12 +5,12 @@ // // Eigen is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either +// License as published by the Free Software Foundation; either // version 3 of the License, or (at your option) any later version. // // Alternatively, you can redistribute it and/or // modify it under the terms of the GNU General Public License as -// published by the Free Software Foundation; either version 2 of +// published by the Free Software Foundation; either version 2 of // the License, or (at your option) any later version. // // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY @@ -18,7 +18,7 @@ // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the // GNU General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public +// You should have received a copy of the GNU Lesser General Public // License and a copy of the GNU General Public License along with // Eigen. If not, see <http://www.gnu.org/licenses/>. @@ -34,10 +34,10 @@ template<typename MatrixType> void product(const MatrixType& m) typedef typename MatrixType::Scalar Scalar; typedef Matrix<Scalar, MatrixType::Traits::RowsAtCompileTime, 1> VectorType; - + int rows = m.rows(); int 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), @@ -53,10 +53,10 @@ template<typename MatrixType> void product(const MatrixType& m) vzero = VectorType::zero(rows); Scalar s1 = ei_random<Scalar>(); - + int r = ei_random<int>(0, rows-1), c = ei_random<int>(0, cols-1); - + // begin testing Product.h: only associativity for now // (we use Transpose.h but this doesn't count as a test for it) VERIFY_IS_APPROX((m1*m1.transpose())*m2, m1*(m1.transpose()*m2)); @@ -64,20 +64,20 @@ template<typename MatrixType> void product(const MatrixType& m) m3 *= (m1.transpose() * m2); VERIFY_IS_APPROX(m3, m1*(m1.transpose()*m2)); VERIFY_IS_APPROX(m3, m1.lazyProduct(m1.transpose()*m2)); - + // continue testing Product.h: distributivity VERIFY_IS_APPROX(square*(m1 + m2), square*m1+square*m2); VERIFY_IS_APPROX(square*(m1 - m2), square*m1-square*m2); - + // continue testing Product.h: compatibility with ScalarMultiple.h VERIFY_IS_APPROX(s1*(square*m1), (s1*square)*m1); VERIFY_IS_APPROX(s1*(square*m1), square*(m1*s1)); - + // continue testing Product.h: lazyProduct VERIFY_IS_APPROX(square.lazyProduct(m1), square*m1); // again, test operator() to check const-qualification s1 += square.lazyProduct(m1)(r,c); - + // test Product.h together with Identity.h VERIFY_IS_APPROX(m1, identity*m1); VERIFY_IS_APPROX(v1, identity*v1); @@ -94,6 +94,9 @@ void EigenTest::testProduct() product(MatrixXi(8, 12)); product(MatrixXcd(20, 20)); } + + // test a large matrix only once + product(Matrix<float, 100, 100>()); } } // namespace Eigen |