From 2f3d685e0c687ae1121428dab6bc0ec868b14fe3 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Tue, 2 Mar 2010 15:31:39 +0100 Subject: [PATCH] a matrix (or array) does not always have the LinearAccessBit! => fixes in outerStride and matrix flags --- Eigen/src/Array/Array.h | 3 --- Eigen/src/Core/DenseStorageBase.h | 9 ++++++++- Eigen/src/Core/Matrix.h | 3 --- Eigen/src/Core/util/XprHelper.h | 9 +++++++-- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Eigen/src/Array/Array.h b/Eigen/src/Array/Array.h index 91a091152..5a398d849 100644 --- a/Eigen/src/Array/Array.h +++ b/Eigen/src/Array/Array.h @@ -213,9 +213,6 @@ class Array void swap(ArrayBase EIGEN_REF_TO_TEMPORARY other) { this->_swap(other.derived()); } - inline int innerStride() const { return 1; } - inline int outerStride() const { return this->innerSize(); } - #ifdef EIGEN_ARRAY_PLUGIN #include EIGEN_ARRAY_PLUGIN #endif diff --git a/Eigen/src/Core/DenseStorageBase.h b/Eigen/src/Core/DenseStorageBase.h index c7f903c7a..a0f3de542 100644 --- a/Eigen/src/Core/DenseStorageBase.h +++ b/Eigen/src/Core/DenseStorageBase.h @@ -139,6 +139,13 @@ class DenseStorageBase : public _Base EIGEN_STRONG_INLINE Scalar *data() { return m_storage.data(); } + inline int innerStride() const { return 1; } + inline int outerStride() const + { + static const int MaxInnerSize = Base::IsRowMajor ? MaxColsAtCompileTime : MaxRowsAtCompileTime; + return (!IsVectorAtCompileTime) && MaxInnerSize!=Dynamic ? MaxInnerSize : this->innerSize(); + } + /** Resizes \c *this to a \a rows x \a cols matrix. * * This method is intended for dynamic-size matrices, although it is legal to call it on any @@ -601,7 +608,7 @@ struct ei_conservative_resize_like_impl const int new_rows = Derived::RowsAtCompileTime==1 ? 1 : other.rows(); const int new_cols = Derived::RowsAtCompileTime==1 ? other.cols() : 1; _this.derived().m_storage.conservativeResize(other.size(),new_rows,new_cols); - + if (num_new_elements > 0) _this.tail(num_new_elements) = other.tail(num_new_elements); } diff --git a/Eigen/src/Core/Matrix.h b/Eigen/src/Core/Matrix.h index e7422457c..3cd3f7814 100644 --- a/Eigen/src/Core/Matrix.h +++ b/Eigen/src/Core/Matrix.h @@ -318,9 +318,6 @@ class Matrix void swap(MatrixBase EIGEN_REF_TO_TEMPORARY other) { this->_swap(other.derived()); } - inline int innerStride() const { return 1; } - inline int outerStride() const { return this->innerSize(); } - /////////// Geometry module /////////// template diff --git a/Eigen/src/Core/util/XprHelper.h b/Eigen/src/Core/util/XprHelper.h index a09475e20..fc4c01468 100644 --- a/Eigen/src/Core/util/XprHelper.h +++ b/Eigen/src/Core/util/XprHelper.h @@ -90,14 +90,19 @@ class ei_compute_matrix_flags inner_max_size = MaxCols==1 ? MaxRows : MaxRows==1 ? MaxCols : row_major_bit ? MaxCols : MaxRows, + inner_size = Cols==1 ? Rows + : Rows==1 ? Cols + : row_major_bit ? Cols : Rows, is_big = inner_max_size == Dynamic, + is_matrix = Cols!=1 && Rows!=1, is_packet_size_multiple = MaxRows==Dynamic || MaxCols==Dynamic || ((MaxCols*MaxRows) % ei_packet_traits::size) == 0, aligned_bit = (((Options&DontAlign)==0) && (is_big || is_packet_size_multiple)) ? AlignedBit : 0, - packet_access_bit = ei_packet_traits::size > 1 && aligned_bit ? PacketAccessBit : 0 + packet_access_bit = ei_packet_traits::size > 1 && aligned_bit ? PacketAccessBit : 0, + linear_access_bit = (inner_max_size!=Dynamic && inner_size!=inner_max_size && is_matrix) ? 0 : LinearAccessBit }; public: - enum { ret = LinearAccessBit | DirectAccessBit | NestByRefBit | packet_access_bit | row_major_bit | aligned_bit }; + enum { ret = DirectAccessBit | NestByRefBit | packet_access_bit | row_major_bit | aligned_bit | linear_access_bit }; }; template struct ei_size_at_compile_time