* remove ei_block_direct_access_status

* remove HasDirectAccess / NoDirectAccess constants
This commit is contained in:
Benoit Jacob 2010-04-23 11:36:22 -04:00
parent 58e7297859
commit a16ba80bfa
9 changed files with 25 additions and 33 deletions

View File

@ -38,7 +38,7 @@ class Array
{ {
public: public:
typedef DenseStorageBase<Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> > Base; typedef DenseStorageBase<Array> Base;
EIGEN_DENSE_PUBLIC_INTERFACE(Array) EIGEN_DENSE_PUBLIC_INTERFACE(Array)
enum { Options = _Options }; enum { Options = _Options };

View File

@ -57,8 +57,8 @@
* *
* \sa DenseBase::block(int,int,int,int), DenseBase::block(int,int), class VectorBlock * \sa DenseBase::block(int,int,int,int), DenseBase::block(int,int), class VectorBlock
*/ */
template<typename XprType, int BlockRows, int BlockCols, int _DirectAccessStatus> template<typename XprType, int BlockRows, int BlockCols, bool HasDirectAccess>
struct ei_traits<Block<XprType, BlockRows, BlockCols, _DirectAccessStatus> > : ei_traits<XprType> struct ei_traits<Block<XprType, BlockRows, BlockCols, HasDirectAccess> > : ei_traits<XprType>
{ {
typedef typename ei_traits<XprType>::Scalar Scalar; typedef typename ei_traits<XprType>::Scalar Scalar;
typedef typename ei_traits<XprType>::StorageKind StorageKind; typedef typename ei_traits<XprType>::StorageKind StorageKind;
@ -99,12 +99,12 @@ struct ei_traits<Block<XprType, BlockRows, BlockCols, _DirectAccessStatus> > : e
}; };
}; };
template<typename XprType, int BlockRows, int BlockCols, int _DirectAccessStatus> class Block template<typename XprType, int BlockRows, int BlockCols, bool HasDirectAccess> class Block
: public ei_dense_xpr_base<Block<XprType, BlockRows, BlockCols, _DirectAccessStatus> >::type : public ei_dense_xpr_base<Block<XprType, BlockRows, BlockCols, HasDirectAccess> >::type
{ {
public: public:
typedef typename XprType::template MakeBase< Block<XprType, BlockRows, BlockCols, _DirectAccessStatus> >::Type Base; typedef typename XprType::template MakeBase<Block>::Type Base;
EIGEN_DENSE_PUBLIC_INTERFACE(Block) EIGEN_DENSE_PUBLIC_INTERFACE(Block)
class InnerIterator; class InnerIterator;
@ -230,8 +230,8 @@ template<typename XprType, int BlockRows, int BlockCols, int _DirectAccessStatus
/** \internal */ /** \internal */
template<typename XprType, int BlockRows, int BlockCols> template<typename XprType, int BlockRows, int BlockCols>
class Block<XprType,BlockRows,BlockCols,HasDirectAccess> class Block<XprType,BlockRows,BlockCols,true>
: public MapBase<Block<XprType, BlockRows, BlockCols,HasDirectAccess> > : public MapBase<Block<XprType, BlockRows, BlockCols,true> >
{ {
public: public:

View File

@ -1,7 +1,7 @@
// This file is part of Eigen, a lightweight C++ template library // This file is part of Eigen, a lightweight C++ template library
// for linear algebra. // for linear algebra.
// //
// Copyright (C) 2006-2009 Benoit Jacob <jacob.benoit.1@gmail.com> // Copyright (C) 2007-2010 Benoit Jacob <jacob.benoit.1@gmail.com>
// Copyright (C) 2008-2010 Gael Guennebaud <g.gael@free.fr> // Copyright (C) 2008-2010 Gael Guennebaud <g.gael@free.fr>
// //
// Eigen is free software; you can redistribute it and/or // Eigen is free software; you can redistribute it and/or
@ -26,12 +26,7 @@
#ifndef EIGEN_DENSEBASE_H #ifndef EIGEN_DENSEBASE_H
#define EIGEN_DENSEBASE_H #define EIGEN_DENSEBASE_H
template<typename Derived> struct ei_has_direct_access template<typename Derived, bool HasDirectAccess = ei_has_direct_access<Derived>::ret>
{
enum { ret = (ei_traits<Derived>::Flags & DirectAccessBit) ? 1 : 0 };
};
template<typename Derived, bool _HasDirectAccess = ei_has_direct_access<Derived>::ret>
struct ei_inner_stride_at_compile_time struct ei_inner_stride_at_compile_time
{ {
enum { ret = ei_traits<Derived>::InnerStrideAtCompileTime }; enum { ret = ei_traits<Derived>::InnerStrideAtCompileTime };
@ -43,7 +38,7 @@ struct ei_inner_stride_at_compile_time<Derived, false>
enum { ret = 0 }; enum { ret = 0 };
}; };
template<typename Derived, bool _HasDirectAccess = ei_has_direct_access<Derived>::ret> template<typename Derived, bool HasDirectAccess = ei_has_direct_access<Derived>::ret>
struct ei_outer_stride_at_compile_time struct ei_outer_stride_at_compile_time
{ {
enum { ret = ei_traits<Derived>::OuterStrideAtCompileTime }; enum { ret = ei_traits<Derived>::OuterStrideAtCompileTime };

View File

@ -136,7 +136,7 @@ class Matrix
/** \brief Base class typedef. /** \brief Base class typedef.
* \sa DenseStorageBase * \sa DenseStorageBase
*/ */
typedef DenseStorageBase<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> > Base; typedef DenseStorageBase<Matrix> Base;
enum { Options = _Options }; enum { Options = _Options };

View File

@ -285,7 +285,7 @@ class GeneralProduct<Lhs, Rhs, GemvProduct>
{ {
ei_assert(m_lhs.rows() == dst.rows() && m_rhs.cols() == dst.cols()); ei_assert(m_lhs.rows() == dst.rows() && m_rhs.cols() == dst.cols());
ei_gemv_selector<Side,(int(MatrixType::Flags)&RowMajorBit) ? RowMajor : ColMajor, ei_gemv_selector<Side,(int(MatrixType::Flags)&RowMajorBit) ? RowMajor : ColMajor,
bool(ei_blas_traits<MatrixType>::ActualAccess)>::run(*this, dst, alpha); bool(ei_blas_traits<MatrixType>::HasUsableDirectAccess)>::run(*this, dst, alpha);
} }
}; };

View File

@ -87,7 +87,7 @@ template<typename MatrixType> class Transpose
const typename MatrixType::Nested m_matrix; const typename MatrixType::Nested m_matrix;
}; };
template<typename MatrixType, bool _HasDirectAccess = ei_has_direct_access<MatrixType>::ret> template<typename MatrixType, bool HasDirectAccess = ei_has_direct_access<MatrixType>::ret>
struct ei_TransposeImpl_base struct ei_TransposeImpl_base
{ {
typedef typename ei_dense_xpr_base<Transpose<MatrixType> >::type type; typedef typename ei_dense_xpr_base<Transpose<MatrixType> >::type type;

View File

@ -158,14 +158,14 @@ template<typename XprType> struct ei_blas_traits
IsComplex = NumTraits<Scalar>::IsComplex, IsComplex = NumTraits<Scalar>::IsComplex,
IsTransposed = false, IsTransposed = false,
NeedToConjugate = false, NeedToConjugate = false,
ActualAccess = ( (int(XprType::Flags)&DirectAccessBit) HasUsableDirectAccess = ( (int(XprType::Flags)&DirectAccessBit)
&& ( /* Uncomment this when the low-level matrix-vector product functions support strided vectors && ( /* Uncomment this when the low-level matrix-vector product functions support strided vectors
bool(XprType::IsVectorAtCompileTime) bool(XprType::IsVectorAtCompileTime)
|| */ || */
int(ei_inner_stride_at_compile_time<XprType>::ret) == 1) int(ei_inner_stride_at_compile_time<XprType>::ret) == 1)
) ? HasDirectAccess : NoDirectAccess ) ? 1 : 0
}; };
typedef typename ei_meta_if<int(ActualAccess)==HasDirectAccess, typedef typename ei_meta_if<bool(HasUsableDirectAccess),
ExtractType, ExtractType,
typename _ExtractType::PlainObject typename _ExtractType::PlainObject
>::ret DirectLinearAccessType; >::ret DirectLinearAccessType;
@ -226,7 +226,7 @@ struct ei_blas_traits<Transpose<NestedXpr> >
typedef Transpose<NestedXpr> XprType; typedef Transpose<NestedXpr> XprType;
typedef Transpose<typename Base::_ExtractType> ExtractType; typedef Transpose<typename Base::_ExtractType> ExtractType;
typedef Transpose<typename Base::_ExtractType> _ExtractType; typedef Transpose<typename Base::_ExtractType> _ExtractType;
typedef typename ei_meta_if<int(Base::ActualAccess)==HasDirectAccess, typedef typename ei_meta_if<bool(Base::HasUsableDirectAccess),
ExtractType, ExtractType,
typename ExtractType::PlainObject typename ExtractType::PlainObject
>::ret DirectLinearAccessType; >::ret DirectLinearAccessType;
@ -237,7 +237,7 @@ struct ei_blas_traits<Transpose<NestedXpr> >
static inline Scalar extractScalarFactor(const XprType& x) { return Base::extractScalarFactor(x.nestedExpression()); } static inline Scalar extractScalarFactor(const XprType& x) { return Base::extractScalarFactor(x.nestedExpression()); }
}; };
template<typename T, int Access=ei_blas_traits<T>::ActualAccess> template<typename T, bool HasUsableDirectAccess=ei_blas_traits<T>::HasUsableDirectAccess>
struct ei_extract_data_selector { struct ei_extract_data_selector {
static const typename T::Scalar* run(const T& m) static const typename T::Scalar* run(const T& m)
{ {
@ -246,7 +246,7 @@ struct ei_extract_data_selector {
}; };
template<typename T> template<typename T>
struct ei_extract_data_selector<T,NoDirectAccess> { struct ei_extract_data_selector<T,false> {
static typename T::Scalar* run(const T&) { return 0; } static typename T::Scalar* run(const T&) { return 0; }
}; };

View File

@ -241,9 +241,7 @@ namespace {
enum { enum {
IsDense = 0, IsDense = 0,
IsSparse, IsSparse
NoDirectAccess = 0,
HasDirectAccess = DirectAccessBit
}; };
enum TransformTraits { enum TransformTraits {

View File

@ -49,17 +49,16 @@ template<typename ExpressionType> class NestByValue;
template<typename ExpressionType> class ForceAlignedAccess; template<typename ExpressionType> class ForceAlignedAccess;
template<typename ExpressionType> class SwapWrapper; template<typename ExpressionType> class SwapWrapper;
// MSVC has a big bug: when the expression ei_traits<MatrixType>::Flags&DirectAccessBit ? HasDirectAccess : NoDirectAccess // MSVC has a big bug: when the expression ei_traits<MatrixType>::Flags&DirectAccessBit ? 1 : 0
// is used as default template parameter value here, it gets mis-evaluated as just ei_traits<MatrixType>::Flags // is used as default template parameter value here, it gets mis-evaluated as just ei_traits<MatrixType>::Flags
// Moreover, adding brackets tends to give compilation errors with MSVC. // Moreover, adding brackets tends to give compilation errors with MSVC.
// Solution: defer that to a helper struct. // Solution: defer that to a helper struct.
template<typename XprType> template<typename Derived> struct ei_has_direct_access
struct ei_block_direct_access_status
{ {
enum { ret = ei_traits<XprType>::Flags&DirectAccessBit ? HasDirectAccess : NoDirectAccess }; enum { ret = (ei_traits<Derived>::Flags & DirectAccessBit) ? 1 : 0 };
}; };
template<typename XprType, int BlockRows=Dynamic, int BlockCols=Dynamic, template<typename XprType, int BlockRows=Dynamic, int BlockCols=Dynamic,
int _DirectAccessStatus = ei_block_direct_access_status<XprType>::ret> class Block; bool HasDirectAccess = ei_has_direct_access<XprType>::ret> class Block;
template<typename MatrixType, int Size=Dynamic> class VectorBlock; template<typename MatrixType, int Size=Dynamic> class VectorBlock;
template<typename MatrixType> class Transpose; template<typename MatrixType> class Transpose;