diff options
author | Benoit Jacob <jacob.benoit.1@gmail.com> | 2010-12-22 17:45:37 -0500 |
---|---|---|
committer | Benoit Jacob <jacob.benoit.1@gmail.com> | 2010-12-22 17:45:37 -0500 |
commit | 75b7d98665dd144c44d7a113c6613f5f998be626 (patch) | |
tree | bc75d316e2ed8e679e744bc34f159dcb0f285243 /Eigen/src/Core/util/BlasUtil.h | |
parent | 3b6d97b51a7e7a4b0c69ae6be44b1c16d72c2e80 (diff) |
bug #54 - really fix const correctness except in Sparse
Diffstat (limited to 'Eigen/src/Core/util/BlasUtil.h')
-rw-r--r-- | Eigen/src/Core/util/BlasUtil.h | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/Eigen/src/Core/util/BlasUtil.h b/Eigen/src/Core/util/BlasUtil.h index d776c4507..b15110baa 100644 --- a/Eigen/src/Core/util/BlasUtil.h +++ b/Eigen/src/Core/util/BlasUtil.h @@ -177,8 +177,8 @@ template<typename XprType> struct blas_traits ExtractType, typename _ExtractType::PlainObject >::type DirectLinearAccessType; - static inline ExtractType extract(const XprType& x) { return x; } - static inline Scalar extractScalarFactor(const XprType&) { return Scalar(1); } + static inline const ExtractType extract(const XprType& x) { return x; } + static inline const Scalar extractScalarFactor(const XprType&) { return Scalar(1); } }; // pop conjugate @@ -194,7 +194,7 @@ struct blas_traits<CwiseUnaryOp<scalar_conjugate_op<Scalar>, NestedXpr> > IsComplex = NumTraits<Scalar>::IsComplex, NeedToConjugate = Base::NeedToConjugate ? 0 : IsComplex }; - static inline ExtractType extract(const XprType& x) { return Base::extract(x.nestedExpression()); } + static inline const ExtractType extract(const XprType& x) { return Base::extract(x.nestedExpression()); } static inline Scalar extractScalarFactor(const XprType& x) { return conj(Base::extractScalarFactor(x.nestedExpression())); } }; @@ -206,7 +206,7 @@ struct blas_traits<CwiseUnaryOp<scalar_multiple_op<Scalar>, NestedXpr> > typedef blas_traits<NestedXpr> Base; typedef CwiseUnaryOp<scalar_multiple_op<Scalar>, NestedXpr> XprType; typedef typename Base::ExtractType ExtractType; - static inline ExtractType extract(const XprType& x) { return Base::extract(x.nestedExpression()); } + static inline const ExtractType extract(const XprType& x) { return Base::extract(x.nestedExpression()); } static inline Scalar extractScalarFactor(const XprType& x) { return x.functor().m_other * Base::extractScalarFactor(x.nestedExpression()); } }; @@ -219,7 +219,7 @@ struct blas_traits<CwiseUnaryOp<scalar_opposite_op<Scalar>, NestedXpr> > typedef blas_traits<NestedXpr> Base; typedef CwiseUnaryOp<scalar_opposite_op<Scalar>, NestedXpr> XprType; typedef typename Base::ExtractType ExtractType; - static inline ExtractType extract(const XprType& x) { return Base::extract(x.nestedExpression()); } + static inline const ExtractType extract(const XprType& x) { return Base::extract(x.nestedExpression()); } static inline Scalar extractScalarFactor(const XprType& x) { return - Base::extractScalarFactor(x.nestedExpression()); } }; @@ -245,11 +245,16 @@ struct blas_traits<Transpose<NestedXpr> > static inline Scalar extractScalarFactor(const XprType& x) { return Base::extractScalarFactor(x.nestedExpression()); } }; +template<typename T> +struct blas_traits<const T> + : blas_traits<T> +{}; + template<typename T, bool HasUsableDirectAccess=blas_traits<T>::HasUsableDirectAccess> struct extract_data_selector { static const typename T::Scalar* run(const T& m) { - return &blas_traits<T>::extract(m).const_cast_derived().coeffRef(0,0); // FIXME this should be .data() + return const_cast<typename T::Scalar*>(&blas_traits<T>::extract(m).coeffRef(0,0)); // FIXME this should be .data() } }; |