a couple of fixes, now Array passes the linearstructure test

This commit is contained in:
Gael Guennebaud
2009-12-17 19:28:54 +01:00
parent 4b70b47998
commit af4d8c5cec
14 changed files with 146 additions and 44 deletions

View File

@@ -271,6 +271,9 @@ const int EiArch_Generic = 0x0;
const int EiArch_SSE = 0x1;
const int EiArch_AltiVec = 0x2;
enum DenseStorageMatrix {};
enum DenseStorageArray {};
#if defined EIGEN_VECTORIZE_SSE
const int EiArch = EiArch_SSE;
#elif defined EIGEN_VECTORIZE_ALTIVEC

View File

@@ -104,13 +104,35 @@ template<int _Rows, int _Cols> 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<typename T, typename StorageType = typename ei_traits<T>::StorageType> class ei_eval;
// template<typename Derived> class MatrixBase;
// template<typename Derived> class ArrayBase;
// template<typename Object> 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<typename T>
// static is_matrix testBaseClass(const MatrixBase<T>*);
// template<typename T>
// static is_array testBaseClass(const ArrayBase<T>*);
// // static is_none testBaseClass(...);
//
// enum {BaseClassType = sizeof(testBaseClass(static_cast<const Object*>(0)))};
// };
template<typename T> struct ei_eval<T,Dense>
template<typename T, typename StorageType = typename ei_traits<T>::StorageType> class ei_plain_matrix_type;
template<typename T, typename BaseClassType> struct ei_plain_matrix_type_dense;
template<typename T> struct ei_plain_matrix_type<T,Dense>
{
typedef typename ei_plain_matrix_type_dense<T,typename ei_traits<T>::DenseStorageType>::type type;
};
template<typename T> struct ei_plain_matrix_type_dense<T,DenseStorageMatrix>
{
typedef Matrix<typename ei_traits<T>::Scalar,
ei_traits<T>::RowsAtCompileTime,
@@ -121,6 +143,36 @@ template<typename T> struct ei_eval<T,Dense>
> type;
};
template<typename T> struct ei_plain_matrix_type_dense<T,DenseStorageArray>
{
typedef Array<typename ei_traits<T>::Scalar,
ei_traits<T>::RowsAtCompileTime,
ei_traits<T>::ColsAtCompileTime,
AutoAlign | (ei_traits<T>::Flags&RowMajorBit ? RowMajor : ColMajor),
ei_traits<T>::MaxRowsAtCompileTime,
ei_traits<T>::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<typename T, typename StorageType = typename ei_traits<T>::StorageType> class ei_eval;
template<typename T> struct ei_eval<T,Dense>
{
typedef typename ei_plain_matrix_type<T>::type type;
// typedef typename T::PlainMatrixType type;
// typedef T::Matrix<typename ei_traits<T>::Scalar,
// ei_traits<T>::RowsAtCompileTime,
// ei_traits<T>::ColsAtCompileTime,
// AutoAlign | (ei_traits<T>::Flags&RowMajorBit ? RowMajor : ColMajor),
// ei_traits<T>::MaxRowsAtCompileTime,
// ei_traits<T>::MaxColsAtCompileTime
// > type;
};
// for matrices, no need to evaluate, just use a const reference to avoid a useless copy
template<typename _Scalar, int _Rows, int _Cols, int _StorageOrder, int _MaxRows, int _MaxCols>
struct ei_eval<Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols>, Dense>
@@ -128,21 +180,14 @@ struct ei_eval<Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols>,
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<typename T> struct ei_plain_matrix_type
template<typename _Scalar, int _Rows, int _Cols, int _StorageOrder, int _MaxRows, int _MaxCols>
struct ei_eval<Array<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols>, Dense>
{
// typedef typename T::PlainMatrixType type;
typedef Matrix<typename ei_traits<T>::Scalar,
ei_traits<T>::RowsAtCompileTime,
ei_traits<T>::ColsAtCompileTime,
AutoAlign | (ei_traits<T>::Flags&RowMajorBit ? RowMajor : ColMajor),
ei_traits<T>::MaxRowsAtCompileTime,
ei_traits<T>::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<typename T> struct ei_plain_matrix_type_column_major