bug #54 - really fix const correctness except in Sparse

This commit is contained in:
Benoit Jacob
2010-12-22 17:45:37 -05:00
parent 3b6d97b51a
commit 75b7d98665
47 changed files with 483 additions and 326 deletions

View File

@@ -66,15 +66,14 @@ class PlainObjectBase : public internal::dense_xpr_base<Derived>::type
using Base::IsVectorAtCompileTime;
using Base::Flags;
typedef typename internal::add_const<Derived>::type ConstDerived;
friend class Eigen::Map<Derived, Unaligned>;
typedef class Eigen::Map<Derived, Unaligned> MapType;
friend class Eigen::Map<ConstDerived, Unaligned>;
typedef class Eigen::Map<ConstDerived, Unaligned> ConstMapType;
typedef Eigen::Map<Derived, Unaligned> MapType;
friend class Eigen::Map<const Derived, Unaligned>;
typedef const Eigen::Map<const Derived, Unaligned> ConstMapType;
friend class Eigen::Map<Derived, Aligned>;
typedef class Eigen::Map<Derived, Aligned> AlignedMapType;
friend class Eigen::Map<ConstDerived, Aligned>;
typedef class Eigen::Map<ConstDerived, Aligned> ConstAlignedMapType;
typedef Eigen::Map<Derived, Aligned> AlignedMapType;
friend class Eigen::Map<const Derived, Aligned>;
typedef const Eigen::Map<const Derived, Aligned> ConstAlignedMapType;
protected:
DenseStorage<Scalar, Base::MaxSizeAtCompileTime, Base::RowsAtCompileTime, Base::ColsAtCompileTime, Options> m_storage;
@@ -116,6 +115,19 @@ class PlainObjectBase : public internal::dense_xpr_base<Derived>::type
return m_storage.data()[index];
}
EIGEN_STRONG_INLINE const Scalar& coeffRef(Index row, Index col) const
{
if(Flags & RowMajorBit)
return m_storage.data()[col + row * m_storage.cols()];
else // column-major
return m_storage.data()[row + col * m_storage.rows()];
}
EIGEN_STRONG_INLINE const Scalar& coeffRef(Index index) const
{
return m_storage.data()[index];
}
template<int LoadMode>
EIGEN_STRONG_INLINE PacketScalar packet(Index row, Index col) const
{
@@ -381,28 +393,28 @@ class PlainObjectBase : public internal::dense_xpr_base<Derived>::type
* \see class Map
*/
//@{
inline static const ConstMapType Map(const Scalar* data)
inline static ConstMapType Map(const Scalar* data)
{ return ConstMapType(data); }
inline static MapType Map(Scalar* data)
{ return MapType(data); }
inline static const ConstMapType Map(const Scalar* data, Index size)
inline static ConstMapType Map(const Scalar* data, Index size)
{ return ConstMapType(data, size); }
inline static MapType Map(Scalar* data, Index size)
{ return MapType(data, size); }
inline static const ConstMapType Map(const Scalar* data, Index rows, Index cols)
inline static ConstMapType Map(const Scalar* data, Index rows, Index cols)
{ return ConstMapType(data, rows, cols); }
inline static MapType Map(Scalar* data, Index rows, Index cols)
{ return MapType(data, rows, cols); }
inline static const ConstAlignedMapType MapAligned(const Scalar* data)
inline static ConstAlignedMapType MapAligned(const Scalar* data)
{ return ConstAlignedMapType(data); }
inline static AlignedMapType MapAligned(Scalar* data)
{ return AlignedMapType(data); }
inline static const ConstAlignedMapType MapAligned(const Scalar* data, Index size)
inline static ConstAlignedMapType MapAligned(const Scalar* data, Index size)
{ return ConstAlignedMapType(data, size); }
inline static AlignedMapType MapAligned(Scalar* data, Index size)
{ return AlignedMapType(data, size); }
inline static const ConstAlignedMapType MapAligned(const Scalar* data, Index rows, Index cols)
inline static ConstAlignedMapType MapAligned(const Scalar* data, Index rows, Index cols)
{ return ConstAlignedMapType(data, rows, cols); }
inline static AlignedMapType MapAligned(Scalar* data, Index rows, Index cols)
{ return AlignedMapType(data, rows, cols); }
@@ -536,6 +548,9 @@ class PlainObjectBase : public internal::dense_xpr_base<Derived>::type
INVALID_MATRIX_TEMPLATE_PARAMETERS)
}
#endif
private:
enum { ThisConstantIsPrivateInPlainObjectBase };
};
template <typename Derived, typename OtherDerived, bool IsVector>