diff options
author | Gael Guennebaud <g.gael@free.fr> | 2013-11-07 16:38:14 +0100 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2013-11-07 16:38:14 +0100 |
commit | 76c230a84d4857722e4a72e9007302a504af0fb7 (patch) | |
tree | 0565d86ff27ff165bab2e8b0b6c11876a6394bc1 /Eigen/src | |
parent | 57327cc2d5aab1cc51dd1308bd0d000f2ccb623c (diff) |
Add an option to test evaluators globally
Diffstat (limited to 'Eigen/src')
-rw-r--r-- | Eigen/src/Core/Assign.h | 19 | ||||
-rw-r--r-- | Eigen/src/Core/GeneralProduct.h | 35 | ||||
-rw-r--r-- | Eigen/src/Core/MatrixBase.h | 8 | ||||
-rw-r--r-- | Eigen/src/Core/Product.h | 2 | ||||
-rw-r--r-- | Eigen/src/Core/util/ForwardDeclarations.h | 1 |
5 files changed, 62 insertions, 3 deletions
diff --git a/Eigen/src/Core/Assign.h b/Eigen/src/Core/Assign.h index 906adcf82..c0b4bbfe0 100644 --- a/Eigen/src/Core/Assign.h +++ b/Eigen/src/Core/Assign.h @@ -504,12 +504,27 @@ EIGEN_STRONG_INLINE Derived& DenseBase<Derived> EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Derived,OtherDerived) EIGEN_STATIC_ASSERT(SameType,YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY) +#ifdef EIGEN_TEST_EVALUATORS + +#ifdef EIGEN_DEBUG_ASSIGN + internal::copy_using_evaluator_traits<Derived, OtherDerived>::debug(); +#endif + eigen_assert(rows() == other.rows() && cols() == other.cols()); +// internal::copy_using_evaluator_impl<Derived, OtherDerived, int(SameType) ? int(internal::copy_using_evaluator_traits<Derived, OtherDerived>::Traversal) +// : int(InvalidTraversal)>::run(derived(),other.derived()); + internal::call_dense_assignment_loop(derived(),other.derived()); + +#else // EIGEN_TEST_EVALUATORS + #ifdef EIGEN_DEBUG_ASSIGN internal::assign_traits<Derived, OtherDerived>::debug(); #endif eigen_assert(rows() == other.rows() && cols() == other.cols()); - internal::assign_impl<Derived, OtherDerived, int(SameType) ? int(internal::assign_traits<Derived, OtherDerived>::Traversal) - : int(InvalidTraversal)>::run(derived(),other.derived()); + internal::assign_impl<Derived, OtherDerived, int(SameType) ? int(internal::copy_using_evaluator_traits<Derived, OtherDerived>::Traversal) + : int(InvalidTraversal)>::run(derived(),other.derived()); + +#endif // EIGEN_TEST_EVALUATORS + #ifndef EIGEN_NO_DEBUG checkTransposeAliasing(other.derived()); #endif diff --git a/Eigen/src/Core/GeneralProduct.h b/Eigen/src/Core/GeneralProduct.h index 9d7d18427..e3a165ac6 100644 --- a/Eigen/src/Core/GeneralProduct.h +++ b/Eigen/src/Core/GeneralProduct.h @@ -566,6 +566,39 @@ template<> struct gemv_selector<OnTheRight,RowMajor,false> * \sa lazyProduct(), operator*=(const MatrixBase&), Cwise::operator*() */ #ifndef __CUDACC__ + +#ifdef EIGEN_TEST_EVALUATORS +template<typename Derived> +template<typename OtherDerived> +inline const Product<Derived, OtherDerived> +MatrixBase<Derived>::operator*(const MatrixBase<OtherDerived> &other) const +{ + // A note regarding the function declaration: In MSVC, this function will sometimes + // not be inlined since DenseStorage is an unwindable object for dynamic + // matrices and product types are holding a member to store the result. + // Thus it does not help tagging this function with EIGEN_STRONG_INLINE. + enum { + ProductIsValid = Derived::ColsAtCompileTime==Dynamic + || OtherDerived::RowsAtCompileTime==Dynamic + || int(Derived::ColsAtCompileTime)==int(OtherDerived::RowsAtCompileTime), + AreVectors = Derived::IsVectorAtCompileTime && OtherDerived::IsVectorAtCompileTime, + SameSizes = EIGEN_PREDICATE_SAME_MATRIX_SIZE(Derived,OtherDerived) + }; + // note to the lost user: + // * for a dot product use: v1.dot(v2) + // * for a coeff-wise product use: v1.cwiseProduct(v2) + EIGEN_STATIC_ASSERT(ProductIsValid || !(AreVectors && SameSizes), + INVALID_VECTOR_VECTOR_PRODUCT__IF_YOU_WANTED_A_DOT_OR_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTIONS) + EIGEN_STATIC_ASSERT(ProductIsValid || !(SameSizes && !AreVectors), + INVALID_MATRIX_PRODUCT__IF_YOU_WANTED_A_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTION) + EIGEN_STATIC_ASSERT(ProductIsValid || SameSizes, INVALID_MATRIX_PRODUCT) +#ifdef EIGEN_DEBUG_PRODUCT + internal::product_type<Derived,OtherDerived>::debug(); +#endif + + return Product<Derived, OtherDerived>(derived(), other.derived()); +} +#else template<typename Derived> template<typename OtherDerived> inline const typename ProductReturnType<Derived, OtherDerived>::Type @@ -596,6 +629,8 @@ MatrixBase<Derived>::operator*(const MatrixBase<OtherDerived> &other) const return typename ProductReturnType<Derived,OtherDerived>::Type(derived(), other.derived()); } #endif + +#endif /** \returns an expression of the matrix product of \c *this and \a other without implicit evaluation. * * The returned product will behave like any other expressions: the coefficients of the product will be diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h index e77b49627..61798317e 100644 --- a/Eigen/src/Core/MatrixBase.h +++ b/Eigen/src/Core/MatrixBase.h @@ -184,11 +184,19 @@ template<typename Derived> class MatrixBase operator*(const MatrixBase<OtherDerived> &other) const { return this->lazyProduct(other); } #else + +#ifdef EIGEN_TEST_EVALUATORS + template<typename OtherDerived> + const Product<Derived,OtherDerived> + operator*(const MatrixBase<OtherDerived> &other) const; +#else template<typename OtherDerived> const typename ProductReturnType<Derived,OtherDerived>::Type operator*(const MatrixBase<OtherDerived> &other) const; #endif +#endif + template<typename OtherDerived> EIGEN_DEVICE_FUNC const typename LazyProductReturnType<Derived,OtherDerived>::Type diff --git a/Eigen/src/Core/Product.h b/Eigen/src/Core/Product.h index 3a08c027c..5d3789be7 100644 --- a/Eigen/src/Core/Product.h +++ b/Eigen/src/Core/Product.h @@ -36,7 +36,7 @@ struct traits<Product<Lhs, Rhs> > // We want A+B*C to be of type Product<Matrix, Sum> and not Product<Matrix, Matrix> // TODO: This flag should eventually go in a separate evaluator traits class enum { - Flags = traits<typename ProductReturnType<Lhs, Rhs>::Type>::Flags & ~EvalBeforeNestingBit + Flags = traits<typename ProductReturnType<Lhs, Rhs>::Type>::Flags & ~(EvalBeforeNestingBit | DirectAccessBit) }; }; } // end namespace internal diff --git a/Eigen/src/Core/util/ForwardDeclarations.h b/Eigen/src/Core/util/ForwardDeclarations.h index dd0c18ad3..0a2144c69 100644 --- a/Eigen/src/Core/util/ForwardDeclarations.h +++ b/Eigen/src/Core/util/ForwardDeclarations.h @@ -89,6 +89,7 @@ template<typename ViewOp, typename MatrixType> class CwiseUnaryView; template<typename BinaryOp, typename Lhs, typename Rhs> class CwiseBinaryOp; template<typename BinOp, typename Lhs, typename Rhs> class SelfCwiseBinaryOp; template<typename Derived, typename Lhs, typename Rhs> class ProductBase; +template<typename Lhs, typename Rhs> class Product; template<typename Lhs, typename Rhs, int Mode> class GeneralProduct; template<typename Lhs, typename Rhs, int NestingFlags> class CoeffBasedProduct; |