aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2015-06-10 10:09:04 +0200
committerGravatar Gael Guennebaud <g.gael@free.fr>2015-06-10 10:09:04 +0200
commit192bce2795bbfaa0d4e6fdcd270a95d59da82f66 (patch)
treeba6ffffbb6dfd0408e2ded27d8992ed68773044d /Eigen/src
parente6832ce93d47e231dd0a2bbbd080fc4b7b420e93 (diff)
bug #890, add a more general routine to check that two dense object reference to the same data
Diffstat (limited to 'Eigen/src')
-rw-r--r--Eigen/src/Core/PermutationMatrix.h3
-rw-r--r--Eigen/src/Core/util/XprHelper.h12
2 files changed, 14 insertions, 1 deletions
diff --git a/Eigen/src/Core/PermutationMatrix.h b/Eigen/src/Core/PermutationMatrix.h
index 9ec17ca8c..99f5aecdd 100644
--- a/Eigen/src/Core/PermutationMatrix.h
+++ b/Eigen/src/Core/PermutationMatrix.h
@@ -596,7 +596,8 @@ struct permut_matrix_product_retval
const Index n = Side==OnTheLeft ? rows() : cols();
// FIXME we need an is_same for expression that is not sensitive to constness. For instance
// is_same_xpr<Block<const Matrix>, Block<Matrix> >::value should be true.
- if(is_same<MatrixTypeNestedCleaned,Dest>::value && extract_data(dst) == extract_data(m_matrix))
+ //if(is_same<MatrixTypeNestedCleaned,Dest>::value && extract_data(dst) == extract_data(m_matrix))
+ if(is_same_dense(dst, m_matrix))
{
// apply the permutation inplace
Matrix<bool,PermutationType::RowsAtCompileTime,1,0,PermutationType::MaxRowsAtCompileTime> mask(m_permutation.size());
diff --git a/Eigen/src/Core/util/XprHelper.h b/Eigen/src/Core/util/XprHelper.h
index 562f425bd..55132c8cf 100644
--- a/Eigen/src/Core/util/XprHelper.h
+++ b/Eigen/src/Core/util/XprHelper.h
@@ -606,6 +606,18 @@ template<typename T, int S> struct is_diagonal<DiagonalMatrix<T,S> >
template<typename S1, typename S2> struct glue_shapes;
template<> struct glue_shapes<DenseShape,TriangularShape> { typedef TriangularShape type; };
+template<typename T1, typename T2>
+bool is_same_dense(const T1 &mat1, const T2 &mat2, typename enable_if<has_direct_access<T1>::ret&&has_direct_access<T2>::ret, T1>::type * = 0)
+{
+ return (mat1.data()==mat2.data()) && (mat1.innerStride()==mat2.innerStride()) && (mat1.outerStride()==mat2.outerStride());
+}
+
+template<typename T1, typename T2>
+bool is_same_dense(const T1 &, const T2 &, typename enable_if<!(has_direct_access<T1>::ret&&has_direct_access<T2>::ret), T1>::type * = 0)
+{
+ return false;
+}
+
} // end namespace internal
// we require Lhs and Rhs to have the same scalar type. Currently there is no example of a binary functor