From 1be6449f2e1bd51393a55b06b967f43dc9be6ec6 Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Thu, 9 Dec 2010 02:38:07 -0500 Subject: fix bug #127. our product selection logic was flawed in that it used the Max-sized to determine whether the size is 1. + test. --- Eigen/src/Core/Product.h | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'Eigen/src') diff --git a/Eigen/src/Core/Product.h b/Eigen/src/Core/Product.h index c8b5b6b52..35ed1cbd7 100644 --- a/Eigen/src/Core/Product.h +++ b/Eigen/src/Core/Product.h @@ -57,23 +57,39 @@ namespace internal { template struct product_type_selector; +template struct product_size_category +{ + enum { is_large = MaxSize == Dynamic || + Size >= EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD, + value = is_large ? Large + : Size == 1 ? 1 + : Small + }; +}; + template struct product_type { typedef typename remove_all::type _Lhs; typedef typename remove_all::type _Rhs; enum { - Rows = _Lhs::MaxRowsAtCompileTime, - Cols = _Rhs::MaxColsAtCompileTime, - Depth = EIGEN_SIZE_MIN_PREFER_FIXED(_Lhs::MaxColsAtCompileTime,_Rhs::MaxRowsAtCompileTime) + MaxRows = _Lhs::MaxRowsAtCompileTime, + Rows = _Lhs::RowsAtCompileTime, + MaxCols = _Rhs::MaxColsAtCompileTime, + Cols = _Rhs::ColsAtCompileTime, + MaxDepth = EIGEN_SIZE_MIN_PREFER_FIXED(_Lhs::MaxColsAtCompileTime, + _Rhs::MaxRowsAtCompileTime), + Depth = EIGEN_SIZE_MIN_PREFER_FIXED(_Lhs::ColsAtCompileTime, + _Rhs::RowsAtCompileTime), + LargeThreshold = EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD }; // the splitting into different lines of code here, introducing the _select enums and the typedef below, // is to work around an internal compiler error with gcc 4.1 and 4.2. private: enum { - rows_select = Rows == Dynamic || Rows >=EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD ? Large : (Rows==1 ? 1 : Small), - cols_select = Cols == Dynamic || Cols >=EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD ? Large : (Cols==1 ? 1 : Small), - depth_select = Depth == Dynamic || Depth>=EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD ? Large : (Depth==1 ? 1 : Small) + rows_select = product_size_category::value, + cols_select = product_size_category::value, + depth_select = product_size_category::value }; typedef product_type_selector selector; -- cgit v1.2.3