diff options
author | Jitse Niesen <jitse@maths.leeds.ac.uk> | 2014-04-15 15:21:38 +0100 |
---|---|---|
committer | Jitse Niesen <jitse@maths.leeds.ac.uk> | 2014-04-15 15:21:38 +0100 |
commit | 59f5f155c2d4c6069f61fc3df39c7f6264857488 (patch) | |
tree | 20344d0ded194f27d354a999ec7eb3899a3a4ab5 /Eigen/src/Core/Product.h | |
parent | aceae8314b80fbf96e8dc1b0d45c1e99951e770c (diff) |
Port products with permutation matrices to evaluators.
Diffstat (limited to 'Eigen/src/Core/Product.h')
-rw-r--r-- | Eigen/src/Core/Product.h | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/Eigen/src/Core/Product.h b/Eigen/src/Core/Product.h index 2785847a6..626b737c7 100644 --- a/Eigen/src/Core/Product.h +++ b/Eigen/src/Core/Product.h @@ -29,8 +29,30 @@ template<typename Lhs, typename Rhs, int Option, typename StorageKind> class Pro * */ -// Use ProductReturnType to get correct traits, in particular vectorization flags + namespace internal { + +// Determine the scalar of Product<Lhs, Rhs>. This is normally the same as Lhs::Scalar times +// Rhs::Scalar, but product with permutation matrices inherit the scalar of the other factor. +template<typename Lhs, typename Rhs, typename LhsShape = typename evaluator_traits<Lhs>::Shape, + typename RhsShape = typename evaluator_traits<Rhs>::Shape > +struct product_result_scalar +{ + typedef typename scalar_product_traits<typename Lhs::Scalar, typename Rhs::Scalar>::ReturnType Scalar; +}; + +template<typename Lhs, typename Rhs, typename RhsShape> +struct product_result_scalar<Lhs, Rhs, PermutationShape, RhsShape> +{ + typedef typename Rhs::Scalar Scalar; +}; + +template<typename Lhs, typename Rhs, typename LhsShape> + struct product_result_scalar<Lhs, Rhs, LhsShape, PermutationShape> +{ + typedef typename Lhs::Scalar Scalar; +}; + template<typename Lhs, typename Rhs, int Option> struct traits<Product<Lhs, Rhs, Option> > { @@ -39,7 +61,7 @@ struct traits<Product<Lhs, Rhs, Option> > typedef MatrixXpr XprKind; - typedef typename scalar_product_traits<typename LhsCleaned::Scalar, typename RhsCleaned::Scalar>::ReturnType Scalar; + typedef typename product_result_scalar<LhsCleaned,RhsCleaned>::Scalar Scalar; typedef typename promote_storage_type<typename traits<LhsCleaned>::StorageKind, typename traits<RhsCleaned>::StorageKind>::ret StorageKind; typedef typename promote_index_type<typename traits<LhsCleaned>::Index, |