aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/Core/DiagonalProduct.h
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2008-12-10 19:02:13 +0000
committerGravatar Gael Guennebaud <g.gael@free.fr>2008-12-10 19:02:13 +0000
commitbeabf008b04dc9b449b23f082bab76d384983b73 (patch)
treeec4e0ddcbd24bbc2cb8fe5d94cda65f7b38cf622 /Eigen/src/Core/DiagonalProduct.h
parentba9a53f9c69f90ccf7e6d70c6109380d40c6c4e5 (diff)
bugfix in DiagonalProduct: a "DiagonalProduct<SomeXpr>" expression
is now evaluated as a "DiagonalProduct<Matrix<SomeXpr::Eval> >". Note that currently this only happens in DiagonalProduct.
Diffstat (limited to 'Eigen/src/Core/DiagonalProduct.h')
-rw-r--r--Eigen/src/Core/DiagonalProduct.h23
1 files changed, 21 insertions, 2 deletions
diff --git a/Eigen/src/Core/DiagonalProduct.h b/Eigen/src/Core/DiagonalProduct.h
index f30f8d369..ca0b56872 100644
--- a/Eigen/src/Core/DiagonalProduct.h
+++ b/Eigen/src/Core/DiagonalProduct.h
@@ -26,12 +26,31 @@
#ifndef EIGEN_DIAGONALPRODUCT_H
#define EIGEN_DIAGONALPRODUCT_H
+/** \internal Specialization of ei_nested for DiagonalMatrix.
+ * Unlike ei_nested, if the argument is a DiagonalMatrix and if it must be evaluated,
+ * then it evaluated to a DiagonalMatrix having its own argument evaluated.
+ */
+template<typename T, int N> struct ei_nested_diagonal : ei_nested<T,N> {};
+template<typename T, int N> struct ei_nested_diagonal<DiagonalMatrix<T>,N >
+ : ei_nested<DiagonalMatrix<T>, N, DiagonalMatrix<NestByValue<typename ei_eval<T>::type> > >
+{};
+
+// specialization of ProductReturnType
+template<typename Lhs, typename Rhs>
+struct ProductReturnType<Lhs,Rhs,DiagonalProduct>
+{
+ typedef typename ei_nested_diagonal<Lhs,Rhs::ColsAtCompileTime>::type LhsNested;
+ typedef typename ei_nested_diagonal<Rhs,Lhs::RowsAtCompileTime>::type RhsNested;
+
+ typedef Product<LhsNested, RhsNested, DiagonalProduct> Type;
+};
+
template<typename LhsNested, typename RhsNested>
struct ei_traits<Product<LhsNested, RhsNested, DiagonalProduct> >
{
// clean the nested types:
- typedef typename ei_unconst<typename ei_unref<LhsNested>::type>::type _LhsNested;
- typedef typename ei_unconst<typename ei_unref<RhsNested>::type>::type _RhsNested;
+ typedef typename ei_cleantype<LhsNested>::type _LhsNested;
+ typedef typename ei_cleantype<RhsNested>::type _RhsNested;
typedef typename _LhsNested::Scalar Scalar;
enum {