mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-07-18 10:54:26 +08:00
now if Derived has the DirectAccess flag, then MatrixBase<Derived>::coeff() const returns a const Scalar& and not a Scalar as before.
useful for people doing direct access. + 1 bugfix thanks to Patrick Mihelich, forgot a & in MapBase::coeff(int).
This commit is contained in:
parent
2f45eeb0c6
commit
113fc3a260
@ -40,7 +40,7 @@
|
|||||||
* \sa operator()(int,int) const, coeffRef(int,int), coeff(int) const
|
* \sa operator()(int,int) const, coeffRef(int,int), coeff(int) const
|
||||||
*/
|
*/
|
||||||
template<typename Derived>
|
template<typename Derived>
|
||||||
EIGEN_STRONG_INLINE const typename ei_traits<Derived>::Scalar MatrixBase<Derived>
|
EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::CoeffReturnType MatrixBase<Derived>
|
||||||
::coeff(int row, int col) const
|
::coeff(int row, int col) const
|
||||||
{
|
{
|
||||||
ei_internal_assert(row >= 0 && row < rows()
|
ei_internal_assert(row >= 0 && row < rows()
|
||||||
@ -53,7 +53,7 @@ EIGEN_STRONG_INLINE const typename ei_traits<Derived>::Scalar MatrixBase<Derived
|
|||||||
* \sa operator()(int,int), operator[](int) const
|
* \sa operator()(int,int), operator[](int) const
|
||||||
*/
|
*/
|
||||||
template<typename Derived>
|
template<typename Derived>
|
||||||
EIGEN_STRONG_INLINE const typename ei_traits<Derived>::Scalar MatrixBase<Derived>
|
EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::CoeffReturnType MatrixBase<Derived>
|
||||||
::operator()(int row, int col) const
|
::operator()(int row, int col) const
|
||||||
{
|
{
|
||||||
ei_assert(row >= 0 && row < rows()
|
ei_assert(row >= 0 && row < rows()
|
||||||
@ -112,7 +112,7 @@ EIGEN_STRONG_INLINE typename ei_traits<Derived>::Scalar& MatrixBase<Derived>
|
|||||||
* \sa operator[](int) const, coeffRef(int), coeff(int,int) const
|
* \sa operator[](int) const, coeffRef(int), coeff(int,int) const
|
||||||
*/
|
*/
|
||||||
template<typename Derived>
|
template<typename Derived>
|
||||||
EIGEN_STRONG_INLINE const typename ei_traits<Derived>::Scalar MatrixBase<Derived>
|
EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::CoeffReturnType MatrixBase<Derived>
|
||||||
::coeff(int index) const
|
::coeff(int index) const
|
||||||
{
|
{
|
||||||
ei_internal_assert(index >= 0 && index < size());
|
ei_internal_assert(index >= 0 && index < size());
|
||||||
@ -127,7 +127,7 @@ EIGEN_STRONG_INLINE const typename ei_traits<Derived>::Scalar MatrixBase<Derived
|
|||||||
* z() const, w() const
|
* z() const, w() const
|
||||||
*/
|
*/
|
||||||
template<typename Derived>
|
template<typename Derived>
|
||||||
EIGEN_STRONG_INLINE const typename ei_traits<Derived>::Scalar MatrixBase<Derived>
|
EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::CoeffReturnType MatrixBase<Derived>
|
||||||
::operator[](int index) const
|
::operator[](int index) const
|
||||||
{
|
{
|
||||||
ei_assert(index >= 0 && index < size());
|
ei_assert(index >= 0 && index < size());
|
||||||
@ -144,7 +144,7 @@ EIGEN_STRONG_INLINE const typename ei_traits<Derived>::Scalar MatrixBase<Derived
|
|||||||
* z() const, w() const
|
* z() const, w() const
|
||||||
*/
|
*/
|
||||||
template<typename Derived>
|
template<typename Derived>
|
||||||
EIGEN_STRONG_INLINE const typename ei_traits<Derived>::Scalar MatrixBase<Derived>
|
EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::CoeffReturnType MatrixBase<Derived>
|
||||||
::operator()(int index) const
|
::operator()(int index) const
|
||||||
{
|
{
|
||||||
ei_assert(index >= 0 && index < size());
|
ei_assert(index >= 0 && index < size());
|
||||||
@ -205,22 +205,22 @@ EIGEN_STRONG_INLINE typename ei_traits<Derived>::Scalar& MatrixBase<Derived>
|
|||||||
|
|
||||||
/** equivalent to operator[](0). */
|
/** equivalent to operator[](0). */
|
||||||
template<typename Derived>
|
template<typename Derived>
|
||||||
EIGEN_STRONG_INLINE const typename ei_traits<Derived>::Scalar MatrixBase<Derived>
|
EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::CoeffReturnType MatrixBase<Derived>
|
||||||
::x() const { return (*this)[0]; }
|
::x() const { return (*this)[0]; }
|
||||||
|
|
||||||
/** equivalent to operator[](1). */
|
/** equivalent to operator[](1). */
|
||||||
template<typename Derived>
|
template<typename Derived>
|
||||||
EIGEN_STRONG_INLINE const typename ei_traits<Derived>::Scalar MatrixBase<Derived>
|
EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::CoeffReturnType MatrixBase<Derived>
|
||||||
::y() const { return (*this)[1]; }
|
::y() const { return (*this)[1]; }
|
||||||
|
|
||||||
/** equivalent to operator[](2). */
|
/** equivalent to operator[](2). */
|
||||||
template<typename Derived>
|
template<typename Derived>
|
||||||
EIGEN_STRONG_INLINE const typename ei_traits<Derived>::Scalar MatrixBase<Derived>
|
EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::CoeffReturnType MatrixBase<Derived>
|
||||||
::z() const { return (*this)[2]; }
|
::z() const { return (*this)[2]; }
|
||||||
|
|
||||||
/** equivalent to operator[](3). */
|
/** equivalent to operator[](3). */
|
||||||
template<typename Derived>
|
template<typename Derived>
|
||||||
EIGEN_STRONG_INLINE const typename ei_traits<Derived>::Scalar MatrixBase<Derived>
|
EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::CoeffReturnType MatrixBase<Derived>
|
||||||
::w() const { return (*this)[3]; }
|
::w() const { return (*this)[3]; }
|
||||||
|
|
||||||
/** equivalent to operator[](0). */
|
/** equivalent to operator[](0). */
|
||||||
|
@ -96,7 +96,7 @@ template<typename Derived> class MapBase
|
|||||||
return const_cast<Scalar*>(m_data)[row + col * stride()];
|
return const_cast<Scalar*>(m_data)[row + col * stride()];
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const Scalar coeff(int index) const
|
inline const Scalar& coeff(int index) const
|
||||||
{
|
{
|
||||||
ei_assert(Derived::IsVectorAtCompileTime || (ei_traits<Derived>::Flags & LinearAccessBit));
|
ei_assert(Derived::IsVectorAtCompileTime || (ei_traits<Derived>::Flags & LinearAccessBit));
|
||||||
if ( ((RowsAtCompileTime == 1) == IsRowMajor) )
|
if ( ((RowsAtCompileTime == 1) == IsRowMajor) )
|
||||||
|
@ -199,6 +199,10 @@ template<typename Derived> class MatrixBase
|
|||||||
*/
|
*/
|
||||||
typedef typename ei_plain_matrix_type<Derived>::type PlainMatrixType_ColMajor;
|
typedef typename ei_plain_matrix_type<Derived>::type PlainMatrixType_ColMajor;
|
||||||
|
|
||||||
|
/** \internal the return type of coeff()
|
||||||
|
*/
|
||||||
|
typedef typename ei_meta_if<int(Flags)&DirectAccessBit, const Scalar&, Scalar>::ret CoeffReturnType;
|
||||||
|
|
||||||
/** \internal Represents a matrix with all coefficients equal to one another*/
|
/** \internal Represents a matrix with all coefficients equal to one another*/
|
||||||
typedef CwiseNullaryOp<ei_scalar_constant_op<Scalar>,Derived> ConstantReturnType;
|
typedef CwiseNullaryOp<ei_scalar_constant_op<Scalar>,Derived> ConstantReturnType;
|
||||||
/** \internal Represents a scalar multiple of a matrix */
|
/** \internal Represents a scalar multiple of a matrix */
|
||||||
@ -264,15 +268,15 @@ template<typename Derived> class MatrixBase
|
|||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
CommaInitializer<Derived> operator<< (const MatrixBase<OtherDerived>& other);
|
CommaInitializer<Derived> operator<< (const MatrixBase<OtherDerived>& other);
|
||||||
|
|
||||||
const Scalar coeff(int row, int col) const;
|
const CoeffReturnType coeff(int row, int col) const;
|
||||||
const Scalar operator()(int row, int col) const;
|
const CoeffReturnType operator()(int row, int col) const;
|
||||||
|
|
||||||
Scalar& coeffRef(int row, int col);
|
Scalar& coeffRef(int row, int col);
|
||||||
Scalar& operator()(int row, int col);
|
Scalar& operator()(int row, int col);
|
||||||
|
|
||||||
const Scalar coeff(int index) const;
|
const CoeffReturnType coeff(int index) const;
|
||||||
const Scalar operator[](int index) const;
|
const CoeffReturnType operator[](int index) const;
|
||||||
const Scalar operator()(int index) const;
|
const CoeffReturnType operator()(int index) const;
|
||||||
|
|
||||||
Scalar& coeffRef(int index);
|
Scalar& coeffRef(int index);
|
||||||
Scalar& operator[](int index);
|
Scalar& operator[](int index);
|
||||||
@ -299,10 +303,10 @@ template<typename Derived> class MatrixBase
|
|||||||
template<int StoreMode>
|
template<int StoreMode>
|
||||||
void writePacket(int index, const PacketScalar& x);
|
void writePacket(int index, const PacketScalar& x);
|
||||||
|
|
||||||
const Scalar x() const;
|
const CoeffReturnType x() const;
|
||||||
const Scalar y() const;
|
const CoeffReturnType y() const;
|
||||||
const Scalar z() const;
|
const CoeffReturnType z() const;
|
||||||
const Scalar w() const;
|
const CoeffReturnType w() const;
|
||||||
Scalar& x();
|
Scalar& x();
|
||||||
Scalar& y();
|
Scalar& y();
|
||||||
Scalar& z();
|
Scalar& z();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user