mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
fix Matrix::stride for vectors, add a unit test for Block::stride
and make use of it where it was relevant
This commit is contained in:
@@ -142,12 +142,21 @@ class Matrix
|
||||
EIGEN_STRONG_INLINE int rows() const { return m_storage.rows(); }
|
||||
EIGEN_STRONG_INLINE int cols() const { return m_storage.cols(); }
|
||||
|
||||
EIGEN_STRONG_INLINE int stride(void) const
|
||||
/** Returns the leading dimension (for matrices) or the increment (for vectors) to be used with data().
|
||||
*
|
||||
* More precisely:
|
||||
* - for a column major matrix it returns the number of elements between two successive columns
|
||||
* - for a row major matrix it returns the number of elements between two successive rows
|
||||
* - for a vector it returns the number of elements between two successive coefficients
|
||||
* This function has to be used together with the MapBase::data() function.
|
||||
*
|
||||
* \sa Matrix::data() */
|
||||
EIGEN_STRONG_INLINE int stride() const
|
||||
{
|
||||
if(Flags & RowMajorBit)
|
||||
return m_storage.cols();
|
||||
if(IsVectorAtCompileTime)
|
||||
return 1;
|
||||
else
|
||||
return m_storage.rows();
|
||||
return (Flags & RowMajorBit) ? m_storage.cols() : m_storage.rows();
|
||||
}
|
||||
|
||||
EIGEN_STRONG_INLINE const Scalar& coeff(int row, int col) const
|
||||
|
||||
@@ -185,14 +185,14 @@ struct SelfadjointProductMatrix<Lhs,LhsMode,false,Rhs,0,true>
|
||||
Scalar actualAlpha = alpha * LhsBlasTraits::extractScalarFactor(m_lhs)
|
||||
* RhsBlasTraits::extractScalarFactor(m_rhs);
|
||||
|
||||
ei_assert((&dst.coeff(1))-(&dst.coeff(0))==1 && "not implemented yet");
|
||||
ei_assert(dst.stride()==1 && "not implemented yet");
|
||||
ei_product_selfadjoint_vector<Scalar, ei_traits<_ActualLhsType>::Flags&RowMajorBit, int(LhsUpLo), bool(LhsBlasTraits::NeedToConjugate), bool(RhsBlasTraits::NeedToConjugate)>
|
||||
(
|
||||
lhs.rows(), // size
|
||||
&lhs.coeff(0,0), lhs.stride(), // lhs info
|
||||
&rhs.coeff(0), (&rhs.coeff(1))-(&rhs.coeff(0)), // rhs info
|
||||
&dst.coeffRef(0), // result info
|
||||
actualAlpha // scale factor
|
||||
lhs.rows(), // size
|
||||
&lhs.coeff(0,0), lhs.stride(), // lhs info
|
||||
&rhs.coeff(0), rhs.stride(), // rhs info
|
||||
&dst.coeffRef(0), // result info
|
||||
actualAlpha // scale factor
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user