From 670e3af5a80ba8148cc52849dcb145276fd08d6a Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Tue, 31 Jan 2012 12:44:59 +0100 Subject: [PATCH] add .data() member to Diagonal<> --- Eigen/src/Core/Diagonal.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Eigen/src/Core/Diagonal.h b/Eigen/src/Core/Diagonal.h index 3a833f678..8d9a423ef 100644 --- a/Eigen/src/Core/Diagonal.h +++ b/Eigen/src/Core/Diagonal.h @@ -101,6 +101,15 @@ template class Diagonal return 0; } + typedef typename internal::conditional< + internal::is_lvalue::value, + Scalar, + const Scalar + >::type ScalarWithConstIfNotLvalue; + + inline ScalarWithConstIfNotLvalue* data() { return &(m_matrix.const_cast_derived().coeffRef(rowOffset(), colOffset())); } + inline const Scalar* data() const { return &(m_matrix.const_cast_derived().coeffRef(rowOffset(), colOffset())); } + inline Scalar& coeffRef(Index row, Index) { EIGEN_STATIC_ASSERT_LVALUE(MatrixType)