diff options
-rw-r--r-- | Eigen/src/Core/util/Constants.h | 2 | ||||
-rw-r--r-- | Eigen/src/plugins/ReshapedMethods.h | 9 | ||||
-rw-r--r-- | test/reshape.cpp | 7 |
3 files changed, 18 insertions, 0 deletions
diff --git a/Eigen/src/Core/util/Constants.h b/Eigen/src/Core/util/Constants.h index 5d37e5d04..612dbf5e8 100644 --- a/Eigen/src/Core/util/Constants.h +++ b/Eigen/src/Core/util/Constants.h @@ -339,6 +339,8 @@ enum SideType { OnTheRight = 2 }; + + /* the following used to be written as: * * struct NoChange_t {}; diff --git a/Eigen/src/plugins/ReshapedMethods.h b/Eigen/src/plugins/ReshapedMethods.h index 7a11a4bcc..3a1b20301 100644 --- a/Eigen/src/plugins/ReshapedMethods.h +++ b/Eigen/src/plugins/ReshapedMethods.h @@ -70,4 +70,13 @@ reshaped(NRowsType nRows, NColsType nCols, OrderType) const derived(), internal::get_runtime_value(nRows), internal::get_runtime_value(nCols)); } +// Views as linear vectors + +EIGEN_DEVICE_FUNC +inline const Reshaped<const Derived,SizeAtCompileTime,1> +operator()(const Eigen::internal::all_t&) +{ + return Reshaped<const Derived,SizeAtCompileTime,1>(derived(),size(),1); +} + #endif // EIGEN_PARSED_BY_DOXYGEN diff --git a/test/reshape.cpp b/test/reshape.cpp index 516dce0ba..40d98ca1f 100644 --- a/test/reshape.cpp +++ b/test/reshape.cpp @@ -73,6 +73,13 @@ void reshape4x4(MatType m) MatrixXi m28r1 = m.reshaped(2,8,RowOrder); MatrixXi m28r2 = m.transpose().reshaped(8,2,ColOrder).transpose(); VERIFY_IS_EQUAL( m28r1, m28r2); + + using placeholders::all; + VERIFY_IS_EQUAL(m.reshaped(16,1), m(all)); + VERIFY_IS_EQUAL(m.reshaped(1,16), m(all).transpose()); + VERIFY_IS_EQUAL(m(all).reshaped(2,8), m.reshaped(2,8)); + VERIFY_IS_EQUAL(m(all).reshaped(4,4), m.reshaped(4,4)); + VERIFY_IS_EQUAL(m(all).reshaped(8,2), m.reshaped(8,2)); } void test_reshape() |