diff options
author | Gael Guennebaud <g.gael@free.fr> | 2014-07-31 13:35:49 +0200 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2014-07-31 13:35:49 +0200 |
commit | bae2e3327b27a21e5024e235255f403cfe1be2c5 (patch) | |
tree | eb4062df08f8321a0dda35eb5492f075c3df642e /Eigen/src/SparseCore/SparseSelfAdjointView.h | |
parent | cd0ff253ec906f0b4604ec084df3d7e7cc6811d1 (diff) |
Call product_generic_impl by default, and remove lot of boilerplate code
Diffstat (limited to 'Eigen/src/SparseCore/SparseSelfAdjointView.h')
-rw-r--r-- | Eigen/src/SparseCore/SparseSelfAdjointView.h | 46 |
1 files changed, 5 insertions, 41 deletions
diff --git a/Eigen/src/SparseCore/SparseSelfAdjointView.h b/Eigen/src/SparseCore/SparseSelfAdjointView.h index 530ff27bf..4235d6c4c 100644 --- a/Eigen/src/SparseCore/SparseSelfAdjointView.h +++ b/Eigen/src/SparseCore/SparseSelfAdjointView.h @@ -441,46 +441,11 @@ struct generic_product_impl<Lhs, RhsView, DenseShape, SparseSelfAdjointShape, Pr } }; -template<typename Lhs, typename Rhs, int ProductTag> -struct product_evaluator<Product<Lhs, Rhs, DefaultProduct>, ProductTag, SparseSelfAdjointShape, DenseShape, typename Lhs::Scalar, typename Rhs::Scalar> - : public evaluator<typename Product<Lhs, Rhs, DefaultProduct>::PlainObject>::type -{ - typedef Product<Lhs, Rhs, DefaultProduct> XprType; - typedef typename XprType::PlainObject PlainObject; - typedef typename evaluator<PlainObject>::type Base; - - product_evaluator(const XprType& xpr) - : m_result(xpr.rows(), xpr.cols()) - { - ::new (static_cast<Base*>(this)) Base(m_result); - generic_product_impl<Lhs, Rhs, SparseSelfAdjointShape, DenseShape, ProductTag>::evalTo(m_result, xpr.lhs(), xpr.rhs()); - } - -protected: - PlainObject m_result; -}; - -template<typename Lhs, typename Rhs, int ProductTag> -struct product_evaluator<Product<Lhs, Rhs, DefaultProduct>, ProductTag, DenseShape, SparseSelfAdjointShape, typename Lhs::Scalar, typename Rhs::Scalar> - : public evaluator<typename Product<Lhs, Rhs, DefaultProduct>::PlainObject>::type -{ - typedef Product<Lhs, Rhs, DefaultProduct> XprType; - typedef typename XprType::PlainObject PlainObject; - typedef typename evaluator<PlainObject>::type Base; - - product_evaluator(const XprType& xpr) - : m_result(xpr.rows(), xpr.cols()) - { - ::new (static_cast<Base*>(this)) Base(m_result); - generic_product_impl<Lhs, Rhs, DenseShape, SparseSelfAdjointShape, ProductTag>::evalTo(m_result, xpr.lhs(), xpr.rhs()); - } - -protected: - PlainObject m_result; -}; +// NOTE: these two overloads are needed to evaluate the sparse sefladjoint view into a full sparse matrix +// TODO: maybe the copy could be handled by generic_product_impl so that these overloads would not be needed anymore template<typename LhsView, typename Rhs, int ProductTag> -struct product_evaluator<Product<LhsView, Rhs, DefaultProduct>, ProductTag, SparseSelfAdjointShape, SparseShape, typename LhsView::Scalar, typename Rhs::Scalar> +struct product_evaluator<Product<LhsView, Rhs, DefaultProduct>, ProductTag, SparseSelfAdjointShape, SparseShape, typename traits<LhsView>::Scalar, typename traits<Rhs>::Scalar> : public evaluator<typename Product<typename Rhs::PlainObject, Rhs, DefaultProduct>::PlainObject>::type { typedef Product<LhsView, Rhs, DefaultProduct> XprType; @@ -488,9 +453,8 @@ struct product_evaluator<Product<LhsView, Rhs, DefaultProduct>, ProductTag, Spar typedef typename evaluator<PlainObject>::type Base; product_evaluator(const XprType& xpr) - : /*m_lhs(xpr.lhs()),*/ m_result(xpr.rows(), xpr.cols()) + : m_lhs(xpr.lhs()), m_result(xpr.rows(), xpr.cols()) { - m_lhs = xpr.lhs(); ::new (static_cast<Base*>(this)) Base(m_result); generic_product_impl<typename Rhs::PlainObject, Rhs, SparseShape, SparseShape, ProductTag>::evalTo(m_result, m_lhs, xpr.rhs()); } @@ -501,7 +465,7 @@ protected: }; template<typename Lhs, typename RhsView, int ProductTag> -struct product_evaluator<Product<Lhs, RhsView, DefaultProduct>, ProductTag, SparseShape, SparseSelfAdjointShape, typename Lhs::Scalar, typename RhsView::Scalar> +struct product_evaluator<Product<Lhs, RhsView, DefaultProduct>, ProductTag, SparseShape, SparseSelfAdjointShape, typename traits<Lhs>::Scalar, typename traits<RhsView>::Scalar> : public evaluator<typename Product<Lhs, typename Lhs::PlainObject, DefaultProduct>::PlainObject>::type { typedef Product<Lhs, RhsView, DefaultProduct> XprType; |