aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2009-08-31 17:39:56 +0200
committerGravatar Gael Guennebaud <g.gael@free.fr>2009-08-31 17:39:56 +0200
commita16599751f42242a3cbb80a00cddc983a6bb2675 (patch)
tree9418fb25c93eb21febd27cb1c690d49168323276 /Eigen
parentab6eb6a1a49124b41b2764be98ac5b07a74a2a41 (diff)
fix Matrix::stride for vectors, add a unit test for Block::stride
and make use of it where it was relevant
Diffstat (limited to 'Eigen')
-rw-r--r--Eigen/src/Core/Matrix.h17
-rw-r--r--Eigen/src/Core/products/SelfadjointMatrixVector.h12
2 files changed, 19 insertions, 10 deletions
diff --git a/Eigen/src/Core/Matrix.h b/Eigen/src/Core/Matrix.h
index f58424ba2..d0603871a 100644
--- a/Eigen/src/Core/Matrix.h
+++ b/Eigen/src/Core/Matrix.h
@@ -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
diff --git a/Eigen/src/Core/products/SelfadjointMatrixVector.h b/Eigen/src/Core/products/SelfadjointMatrixVector.h
index c2c33d5b8..d5927307d 100644
--- a/Eigen/src/Core/products/SelfadjointMatrixVector.h
+++ b/Eigen/src/Core/products/SelfadjointMatrixVector.h
@@ -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
);
}
};