From af4d8c5cecf1a1595dc601f2220ff3a8fd8d2957 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Thu, 17 Dec 2009 19:28:54 +0100 Subject: a couple of fixes, now Array passes the linearstructure test --- Eigen/src/Core/util/XprHelper.h | 77 ++++++++++++++++++++++++++++++++--------- 1 file changed, 61 insertions(+), 16 deletions(-) (limited to 'Eigen/src/Core/util/XprHelper.h') diff --git a/Eigen/src/Core/util/XprHelper.h b/Eigen/src/Core/util/XprHelper.h index 6b9dbc781..6d6540acc 100644 --- a/Eigen/src/Core/util/XprHelper.h +++ b/Eigen/src/Core/util/XprHelper.h @@ -104,13 +104,35 @@ template struct ei_size_at_compile_time enum { ret = (_Rows==Dynamic || _Cols==Dynamic) ? Dynamic : _Rows * _Cols }; }; -/* ei_eval : the return type of eval(). For matrices, this is just a const reference - * in order to avoid a useless copy +/* ei_plain_matrix_type : the difference from ei_eval is that ei_plain_matrix_type is always a plain matrix type, + * whereas ei_eval is a const reference in the case of a matrix */ -template::StorageType> class ei_eval; +// template class MatrixBase; +// template class ArrayBase; +// template struct ei_is_matrix_or_array +// { +// struct is_matrix {int a[1];}; +// struct is_array {int a[2];}; +// struct is_none {int a[3];}; +// +// template +// static is_matrix testBaseClass(const MatrixBase*); +// template +// static is_array testBaseClass(const ArrayBase*); +// // static is_none testBaseClass(...); +// +// enum {BaseClassType = sizeof(testBaseClass(static_cast(0)))}; +// }; -template struct ei_eval +template::StorageType> class ei_plain_matrix_type; +template struct ei_plain_matrix_type_dense; +template struct ei_plain_matrix_type +{ + typedef typename ei_plain_matrix_type_dense::DenseStorageType>::type type; +}; + +template struct ei_plain_matrix_type_dense { typedef Matrix::Scalar, ei_traits::RowsAtCompileTime, @@ -121,6 +143,36 @@ template struct ei_eval > type; }; +template struct ei_plain_matrix_type_dense +{ + typedef Array::Scalar, + ei_traits::RowsAtCompileTime, + ei_traits::ColsAtCompileTime, + AutoAlign | (ei_traits::Flags&RowMajorBit ? RowMajor : ColMajor), + ei_traits::MaxRowsAtCompileTime, + ei_traits::MaxColsAtCompileTime + > type; +}; + +/* ei_eval : the return type of eval(). For matrices, this is just a const reference + * in order to avoid a useless copy + */ + +template::StorageType> class ei_eval; + +template struct ei_eval +{ + typedef typename ei_plain_matrix_type::type type; +// typedef typename T::PlainMatrixType type; +// typedef T::Matrix::Scalar, +// ei_traits::RowsAtCompileTime, +// ei_traits::ColsAtCompileTime, +// AutoAlign | (ei_traits::Flags&RowMajorBit ? RowMajor : ColMajor), +// ei_traits::MaxRowsAtCompileTime, +// ei_traits::MaxColsAtCompileTime +// > type; +}; + // for matrices, no need to evaluate, just use a const reference to avoid a useless copy template struct ei_eval, Dense> @@ -128,21 +180,14 @@ struct ei_eval, typedef const Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols>& type; }; -/* ei_plain_matrix_type : the difference from ei_eval is that ei_plain_matrix_type is always a plain matrix type, - * whereas ei_eval is a const reference in the case of a matrix - */ -template struct ei_plain_matrix_type +template +struct ei_eval, Dense> { -// typedef typename T::PlainMatrixType type; - typedef Matrix::Scalar, - ei_traits::RowsAtCompileTime, - ei_traits::ColsAtCompileTime, - AutoAlign | (ei_traits::Flags&RowMajorBit ? RowMajor : ColMajor), - ei_traits::MaxRowsAtCompileTime, - ei_traits::MaxColsAtCompileTime - > type; + typedef const Array<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols>& type; }; + + /* ei_plain_matrix_type_column_major : same as ei_plain_matrix_type but guaranteed to be column-major */ template struct ei_plain_matrix_type_column_major -- cgit v1.2.3