diff options
author | Gael Guennebaud <g.gael@free.fr> | 2014-02-18 13:32:30 +0100 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2014-02-18 13:32:30 +0100 |
commit | 7002aa858f3bd42e98ae1c2317aefe39338fab3e (patch) | |
tree | 11bd3370253b9e7bb7f042f468918b7f4012a826 /Eigen | |
parent | 8cfb138e73be76105d4d58bd82e22f921eea75db (diff) |
Support Product::coeff(0,0) even for dynamic matrices
Diffstat (limited to 'Eigen')
-rw-r--r-- | Eigen/src/Core/Product.h | 26 | ||||
-rw-r--r-- | Eigen/src/Core/ProductEvaluators.h | 22 |
2 files changed, 23 insertions, 25 deletions
diff --git a/Eigen/src/Core/Product.h b/Eigen/src/Core/Product.h index d64fbae35..12726ed12 100644 --- a/Eigen/src/Core/Product.h +++ b/Eigen/src/Core/Product.h @@ -109,16 +109,6 @@ public: { return typename internal::evaluator<ProductXpr>::type(derived()).coeff(0,0); } - - Scalar coeff(Index row, Index col) const - { - return typename internal::evaluator<ProductXpr>::type(derived()).coeff(row,col); - } - - Scalar coeff(Index i) const - { - return typename internal::evaluator<ProductXpr>::type(derived()).coeff(i); - } }; } // namespace internal @@ -132,6 +122,22 @@ class ProductImpl<Lhs,Rhs,Option,Dense> typedef typename internal::dense_product_base<Lhs, Rhs, Option> Base; EIGEN_DENSE_PUBLIC_INTERFACE(Derived) + + Scalar coeff(Index row, Index col) const + { + EIGEN_STATIC_ASSERT_SIZE_1x1(Derived) + eigen_assert(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); + + return typename internal::evaluator<Derived>::type(derived()).coeff(i); + } }; /*************************************************************************** diff --git a/Eigen/src/Core/ProductEvaluators.h b/Eigen/src/Core/ProductEvaluators.h index d991ff8b5..e0cfb56bb 100644 --- a/Eigen/src/Core/ProductEvaluators.h +++ b/Eigen/src/Core/ProductEvaluators.h @@ -270,7 +270,7 @@ struct generic_product_impl<Lhs,Rhs,DenseShape,DenseShape,GemmProduct> template<typename Dest> static void scaleAndAddTo(Dest& dst, const Lhs& lhs, const Rhs& rhs, const Scalar& alpha) - { + {TRACK; // TODO bypass GeneralProduct class GeneralProduct<Lhs, Rhs, GemmProduct>(lhs,rhs).scaleAndAddTo(dst, alpha); } @@ -705,7 +705,7 @@ struct generic_product_impl<Lhs,Rhs,SelfAdjointShape,DenseShape,ProductTag> template<typename Dest> static void scaleAndAddTo(Dest& dst, const Lhs& lhs, const Rhs& rhs, const Scalar& alpha) - {// SelfadjointProductMatrix<MatrixType,Mode,false,OtherDerived,0,OtherDerived::IsVectorAtCompileTime> + { // TODO bypass SelfadjointProductMatrix class SelfadjointProductMatrix<typename Lhs::MatrixType,Lhs::Mode,false,Rhs,0,Rhs::IsVectorAtCompileTime>(lhs.nestedExpression(),rhs).scaleAndAddTo(dst, alpha); } @@ -739,7 +739,7 @@ struct generic_product_impl<Lhs,Rhs,DenseShape,SelfAdjointShape,ProductTag> template<typename Dest> static void scaleAndAddTo(Dest& dst, const Lhs& lhs, const Rhs& rhs, const Scalar& alpha) - {//SelfadjointProductMatrix<OtherDerived,0,OtherDerived::IsVectorAtCompileTime,MatrixType,Mode,false> + { // TODO bypass SelfadjointProductMatrix class SelfadjointProductMatrix<Lhs,0,Lhs::IsVectorAtCompileTime,typename Rhs::MatrixType,Rhs::Mode,false>(lhs,rhs.nestedExpression()).scaleAndAddTo(dst, alpha); } @@ -825,6 +825,8 @@ struct product_evaluator<Product<Lhs, Rhs, ProductKind>, ProductTag, DiagonalSha typedef Product<Lhs, Rhs, ProductKind> XprType; typedef typename XprType::PlainObject PlainObject; + + enum { StorageOrder = int(Rhs::Flags) & RowMajorBit ? RowMajor : ColMajor }; product_evaluator(const XprType& xpr) : Base(xpr.rhs(), xpr.lhs().diagonal()) @@ -839,9 +841,6 @@ struct product_evaluator<Product<Lhs, Rhs, ProductKind>, ProductTag, DiagonalSha template<int LoadMode> EIGEN_STRONG_INLINE PacketScalar packet(Index row, Index col) const { - enum { - StorageOrder = Rhs::Flags & RowMajorBit ? RowMajor : ColMajor - }; return this->template packet_impl<LoadMode>(row,col, row, typename internal::conditional<int(StorageOrder)==RowMajor, internal::true_type, internal::false_type>::type()); } @@ -849,9 +848,6 @@ struct product_evaluator<Product<Lhs, Rhs, ProductKind>, ProductTag, DiagonalSha template<int LoadMode> EIGEN_STRONG_INLINE PacketScalar packet(Index idx) const { - enum { - StorageOrder = int(Rhs::Flags) & RowMajorBit ? RowMajor : ColMajor - }; return packet<LoadMode>(int(StorageOrder)==ColMajor?idx:0,int(StorageOrder)==ColMajor?0:idx); } @@ -873,6 +869,8 @@ struct product_evaluator<Product<Lhs, Rhs, ProductKind>, ProductTag, DenseShape, typedef Product<Lhs, Rhs, ProductKind> XprType; typedef typename XprType::PlainObject PlainObject; + + enum { StorageOrder = int(Rhs::Flags) & RowMajorBit ? RowMajor : ColMajor }; product_evaluator(const XprType& xpr) : Base(xpr.lhs(), xpr.rhs().diagonal()) @@ -887,9 +885,6 @@ struct product_evaluator<Product<Lhs, Rhs, ProductKind>, ProductTag, DenseShape, template<int LoadMode> EIGEN_STRONG_INLINE PacketScalar packet(Index row, Index col) const { - enum { - StorageOrder = Rhs::Flags & RowMajorBit ? RowMajor : ColMajor - }; return this->template packet_impl<LoadMode>(row,col, col, typename internal::conditional<int(StorageOrder)==ColMajor, internal::true_type, internal::false_type>::type()); } @@ -897,9 +892,6 @@ struct product_evaluator<Product<Lhs, Rhs, ProductKind>, ProductTag, DenseShape, template<int LoadMode> EIGEN_STRONG_INLINE PacketScalar packet(Index idx) const { - enum { - StorageOrder = int(Rhs::Flags) & RowMajorBit ? RowMajor : ColMajor - }; return packet<LoadMode>(int(StorageOrder)==ColMajor?idx:0,int(StorageOrder)==ColMajor?0:idx); } |