diff --git a/Eigen/src/Core/util/XprHelper.h b/Eigen/src/Core/util/XprHelper.h index 61ffe702f..7232fa0f8 100644 --- a/Eigen/src/Core/util/XprHelper.h +++ b/Eigen/src/Core/util/XprHelper.h @@ -421,30 +421,53 @@ template struct ei_promote_storage_type typedef A ret; }; -/** \internal gives the plain matrix type to store a row/column/diagonal of a matrix type. +/** \internal gives the plain matrix or array type to store a row/column/diagonal of a matrix type. * \param Scalar optional parameter allowing to pass a different scalar type than the one of the MatrixType. */ -template +template struct ei_plain_row_type { - typedef Matrix type; + typedef Matrix MatrixRowType; + typedef Array ArrayRowType; + + typedef typename ei_meta_if< + ei_is_same_type< typename ei_traits::XprKind, MatrixXpr >::ret, + MatrixRowType, + ArrayRowType + >::ret type; }; -template +template struct ei_plain_col_type { - typedef Matrix type; + typedef Matrix MatrixColType; + typedef Array ArrayColType; + + typedef typename ei_meta_if< + ei_is_same_type< typename ei_traits::XprKind, MatrixXpr >::ret, + MatrixColType, + ArrayColType + >::ret type; }; -template +template struct ei_plain_diag_type { - enum { diag_size = EIGEN_SIZE_MIN_PREFER_DYNAMIC(MatrixType::RowsAtCompileTime, MatrixType::ColsAtCompileTime), - max_diag_size = EIGEN_SIZE_MIN_PREFER_FIXED(MatrixType::MaxRowsAtCompileTime, MatrixType::MaxColsAtCompileTime) + enum { diag_size = EIGEN_SIZE_MIN_PREFER_DYNAMIC(ExpressionType::RowsAtCompileTime, ExpressionType::ColsAtCompileTime), + max_diag_size = EIGEN_SIZE_MIN_PREFER_FIXED(ExpressionType::MaxRowsAtCompileTime, ExpressionType::MaxColsAtCompileTime) }; - typedef Matrix type; + typedef Matrix MatrixDiagType; + typedef Array ArrayDiagType; + + typedef typename ei_meta_if< + ei_is_same_type< typename ei_traits::XprKind, MatrixXpr >::ret, + MatrixDiagType, + ArrayDiagType + >::ret type; }; #endif // EIGEN_XPRHELPER_H