aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/Core/Product.h
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2014-02-18 14:51:41 +0100
committerGravatar Gael Guennebaud <g.gael@free.fr>2014-02-18 14:51:41 +0100
commit0543cb51b58bfc5130bcb0b83969f2854f30d58e (patch)
tree9b1a7dba4f223afd1c85002b390d9f67bb26356d /Eigen/src/Core/Product.h
parent99e27916cfd1381aab50850611905335c288ee40 (diff)
Product::coeff method are also OK for lazy products (including diagonal products)
Diffstat (limited to 'Eigen/src/Core/Product.h')
-rw-r--r--Eigen/src/Core/Product.h21
1 files changed, 16 insertions, 5 deletions
diff --git a/Eigen/src/Core/Product.h b/Eigen/src/Core/Product.h
index 12726ed12..31730983f 100644
--- a/Eigen/src/Core/Product.h
+++ b/Eigen/src/Core/Product.h
@@ -117,27 +117,38 @@ template<typename Lhs, typename Rhs, int Option>
class ProductImpl<Lhs,Rhs,Option,Dense>
: public internal::dense_product_base<Lhs,Rhs,Option>
{
- typedef Product<Lhs, Rhs> Derived;
+ typedef Product<Lhs, Rhs, Option> Derived;
+
public:
typedef typename internal::dense_product_base<Lhs, Rhs, Option> Base;
EIGEN_DENSE_PUBLIC_INTERFACE(Derived)
+ protected:
+ enum {
+ IsOneByOne = (RowsAtCompileTime == 1 || RowsAtCompileTime == Dynamic) &&
+ (ColsAtCompileTime == 1 || ColsAtCompileTime == Dynamic),
+ EnableCoeff = IsOneByOne || Option==LazyProduct
+ };
+ public:
+
Scalar coeff(Index row, Index col) const
{
- EIGEN_STATIC_ASSERT_SIZE_1x1(Derived)
- eigen_assert(this->rows() == 1 && this->cols() == 1);
+ EIGEN_STATIC_ASSERT(EnableCoeff, THIS_METHOD_IS_ONLY_FOR_INNER_OR_LAZY_PRODUCTS);
+ eigen_assert( (Option==LazyProduct) || (this->rows() == 1 && this->cols() == 1) );
return typename internal::evaluator<Derived>::type(derived()).coeff(row,col);
}
Scalar coeff(Index i) const
{
- EIGEN_STATIC_ASSERT_SIZE_1x1(Derived)
- eigen_assert(this->rows() == 1 && this->cols() == 1);
+ EIGEN_STATIC_ASSERT(EnableCoeff, THIS_METHOD_IS_ONLY_FOR_INNER_OR_LAZY_PRODUCTS);
+ eigen_assert( (Option==LazyProduct) || (this->rows() == 1 && this->cols() == 1) );
return typename internal::evaluator<Derived>::type(derived()).coeff(i);
}
+
+
};
/***************************************************************************