Fix nested_eval<Product<> > which wrongly returned a Product<> expression

This commit is contained in:
Gael Guennebaud 2014-09-24 09:39:09 +02:00
parent 13cbc751c9
commit 446001ef51
3 changed files with 12 additions and 6 deletions

View File

@ -25,8 +25,7 @@ struct traits<Inverse<XprType> >
typedef typename XprType::PlainObject PlainObject; typedef typename XprType::PlainObject PlainObject;
typedef traits<PlainObject> BaseTraits; typedef traits<PlainObject> BaseTraits;
enum { enum {
Flags = BaseTraits::Flags & RowMajorBit, Flags = BaseTraits::Flags & RowMajorBit
CoeffReadCost = Dynamic
}; };
}; };

View File

@ -97,11 +97,12 @@ struct product_evaluator<Product<Lhs, Rhs, DefaultProduct>, ProductTag, LhsShape
: public evaluator<typename Product<Lhs, Rhs, DefaultProduct>::PlainObject>::type : public evaluator<typename Product<Lhs, Rhs, DefaultProduct>::PlainObject>::type
{ {
typedef Product<Lhs, Rhs, DefaultProduct> XprType; typedef Product<Lhs, Rhs, DefaultProduct> XprType;
// enum {
// CoeffReadCost = 0 // FIXME why is it needed? (this was already the case before the evaluators, see traits<ProductBase>)
// };
typedef typename XprType::PlainObject PlainObject; typedef typename XprType::PlainObject PlainObject;
typedef typename evaluator<PlainObject>::type Base; typedef typename evaluator<PlainObject>::type Base;
enum {
Flags = Base::Flags | EvalBeforeNestingBit
// CoeffReadCost = 0 // FIXME why is it needed? (this was already the case before the evaluators, see traits<ProductBase>)
};
explicit product_evaluator(const XprType& xpr) explicit product_evaluator(const XprType& xpr)
: m_result(xpr.rows(), xpr.cols()) : m_result(xpr.rows(), xpr.cols())
@ -508,6 +509,9 @@ struct product_evaluator<Product<Lhs, Rhs, DefaultProduct>, LazyCoeffBasedProduc
typedef Product<Lhs, Rhs, DefaultProduct> XprType; typedef Product<Lhs, Rhs, DefaultProduct> XprType;
typedef Product<Lhs, Rhs, LazyProduct> BaseProduct; typedef Product<Lhs, Rhs, LazyProduct> BaseProduct;
typedef product_evaluator<BaseProduct, CoeffBasedProductMode, DenseShape, DenseShape, typename Lhs::Scalar, typename Rhs::Scalar > Base; typedef product_evaluator<BaseProduct, CoeffBasedProductMode, DenseShape, DenseShape, typename Lhs::Scalar, typename Rhs::Scalar > Base;
enum {
Flags = Base::Flags | EvalBeforeNestingBit
};
explicit product_evaluator(const XprType& xpr) explicit product_evaluator(const XprType& xpr)
: Base(BaseProduct(xpr.lhs(),xpr.rhs())) : Base(BaseProduct(xpr.lhs(),xpr.rhs()))
{} {}

View File

@ -40,6 +40,9 @@ template<typename Scalar> void orthomethods_3()
(v0.cross(v1).cross(v0)).normalized(); (v0.cross(v1).cross(v0)).normalized();
VERIFY(mat3.isUnitary()); 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 // colwise/rowwise cross product
mat3.setRandom(); mat3.setRandom();