* remove class DenseDirectAccessBase

* remove member XprBase typedefs, use ei_dense_xpr_base
* remove member _HasDirectAccess typedefs, use ei_has_direct_access
This commit is contained in:
Benoit Jacob 2010-04-23 10:27:15 -04:00
parent 1dd27ce280
commit 58e7297859
10 changed files with 105 additions and 160 deletions

View File

@ -233,7 +233,6 @@ using std::size_t;
#include "src/Core/Functors.h"
#include "src/Core/DenseBase.h"
#include "src/Core/DenseDirectAccessBase.h"
#include "src/Core/MatrixBase.h"
#include "src/Core/EigenBase.h"
#include "src/Core/Coeffs.h"

View File

@ -73,7 +73,6 @@ template<typename Derived> class ArrayBase
using Base::IsVectorAtCompileTime;
using Base::Flags;
using Base::CoeffReadCost;
using Base::_HasDirectAccess;
using Base::derived;
using Base::const_cast_derived;

View File

@ -26,6 +26,53 @@
#ifndef EIGEN_DENSEBASE_H
#define EIGEN_DENSEBASE_H
template<typename Derived> struct ei_has_direct_access
{
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
{
enum { ret = ei_traits<Derived>::InnerStrideAtCompileTime };
};
template<typename Derived>
struct ei_inner_stride_at_compile_time<Derived, false>
{
enum { ret = 0 };
};
template<typename Derived, bool _HasDirectAccess = ei_has_direct_access<Derived>::ret>
struct ei_outer_stride_at_compile_time
{
enum { ret = ei_traits<Derived>::OuterStrideAtCompileTime };
};
template<typename Derived>
struct ei_outer_stride_at_compile_time<Derived, false>
{
enum { ret = 0 };
};
template<typename Derived, typename XprKind = typename ei_traits<Derived>::XprKind>
struct ei_dense_xpr_base
{
/* ei_dense_xpr_base should only ever be used on dense expressions, thus falling either into the MatrixXpr or into the ArrayXpr cases */
};
template<typename Derived>
struct ei_dense_xpr_base<Derived, MatrixXpr>
{
typedef MatrixBase<Derived> type;
};
template<typename Derived>
struct ei_dense_xpr_base<Derived, ArrayXpr>
{
typedef ArrayBase<Derived> type;
};
/** \class DenseBase
*
* \brief Base class for all dense matrices, vectors, and arrays
@ -134,9 +181,8 @@ template<typename Derived> class DenseBase
* this expression.
*/
#ifndef EIGEN_PARSED_BY_DOXYGEN
_HasDirectAccess = (int(Flags)&DirectAccessBit) ? 1 : 0 // workaround sunCC
#endif
InnerStrideAtCompileTime = ei_inner_stride_at_compile_time<Derived>::ret,
OuterStrideAtCompileTime = ei_outer_stride_at_compile_time<Derived>::ret
};
#ifndef EIGEN_PARSED_BY_DOXYGEN
@ -208,7 +254,7 @@ template<typename Derived> class DenseBase
#ifndef EIGEN_PARSED_BY_DOXYGEN
/** \internal the return type of coeff()
*/
typedef typename ei_meta_if<_HasDirectAccess, const Scalar&, Scalar>::ret CoeffReturnType;
typedef typename ei_meta_if<ei_has_direct_access<Derived>::ret, const Scalar&, Scalar>::ret CoeffReturnType;
/** \internal Represents a matrix with all coefficients equal to one another*/
typedef CwiseNullaryOp<ei_scalar_constant_op<Scalar>,Derived> ConstantReturnType;
@ -270,6 +316,48 @@ template<typename Derived> class DenseBase
Derived& lazyAssign(const DenseBase<OtherDerived>& other);
#endif // not EIGEN_PARSED_BY_DOXYGEN
/** \returns the pointer increment between two consecutive elements within a slice in the inner direction.
*
* \sa outerStride(), rowStride(), colStride()
*/
inline int innerStride() const
{
return derived().innerStride();
}
/** \returns the pointer increment between two consecutive inner slices (for example, between two consecutive columns
* in a column-major matrix).
*
* \sa innerStride(), rowStride(), colStride()
*/
inline int outerStride() const
{
return derived().outerStride();
}
inline int stride() const
{
return IsVectorAtCompileTime ? innerStride() : outerStride();
}
/** \returns the pointer increment between two consecutive rows.
*
* \sa innerStride(), outerStride(), colStride()
*/
inline int rowStride() const
{
return IsRowMajor ? outerStride() : innerStride();
}
/** \returns the pointer increment between two consecutive columns.
*
* \sa innerStride(), outerStride(), rowStride()
*/
inline int colStride() const
{
return IsRowMajor ? innerStride() : outerStride();
}
CommaInitializer<Derived> operator<< (const Scalar& s);
template<unsigned int Added,unsigned int Removed>

View File

@ -1,138 +0,0 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
// Copyright (C) 2010 Benoit Jacob <jacob.benoit.1@gmail.com>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of
// the License, or (at your option) any later version.
//
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_DENSEDIRECTACCESSBASE_H
#define EIGEN_DENSEDIRECTACCESSBASE_H
template<typename Derived> struct ei_has_direct_access
{
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
{
enum { ret = ei_traits<Derived>::InnerStrideAtCompileTime };
};
template<typename Derived>
struct ei_inner_stride_at_compile_time<Derived, false>
{
enum { ret = 0 };
};
template<typename Derived, bool _HasDirectAccess = ei_has_direct_access<Derived>::ret>
struct ei_outer_stride_at_compile_time
{
enum { ret = ei_traits<Derived>::OuterStrideAtCompileTime };
};
template<typename Derived>
struct ei_outer_stride_at_compile_time<Derived, false>
{
enum { ret = 0 };
};
template<typename Derived, typename XprKind = typename ei_traits<Derived>::XprKind>
struct ei_dense_xpr_base
{
/* ei_dense_xpr_base should only ever be used on dense expressions, thus falling either into the MatrixXpr or into the ArrayXpr cases */
};
template<typename Derived>
struct ei_dense_xpr_base<Derived, MatrixXpr>
{
typedef MatrixBase<Derived> type;
};
template<typename Derived>
struct ei_dense_xpr_base<Derived, ArrayXpr>
{
typedef ArrayBase<Derived> type;
};
template<typename Derived> class DenseDirectAccessBase
: public ei_dense_xpr_base<Derived>::type
{
public:
typedef typename ei_dense_xpr_base<Derived>::type Base;
using Base::IsVectorAtCompileTime;
using Base::IsRowMajor;
using Base::derived;
using Base::operator=;
typedef typename Base::CoeffReturnType CoeffReturnType;
enum {
InnerStrideAtCompileTime = ei_traits<Derived>::InnerStrideAtCompileTime,
OuterStrideAtCompileTime = ei_traits<Derived>::OuterStrideAtCompileTime
};
/** \returns the pointer increment between two consecutive elements within a slice in the inner direction.
*
* \sa outerStride(), rowStride(), colStride()
*/
inline int innerStride() const
{
return derived().innerStride();
}
/** \returns the pointer increment between two consecutive inner slices (for example, between two consecutive columns
* in a column-major matrix).
*
* \sa innerStride(), rowStride(), colStride()
*/
inline int outerStride() const
{
return derived().outerStride();
}
inline int stride() const
{
return IsVectorAtCompileTime ? innerStride() : outerStride();
}
/** \returns the pointer increment between two consecutive rows.
*
* \sa innerStride(), outerStride(), colStride()
*/
inline int rowStride() const
{
return IsRowMajor ? outerStride() : innerStride();
}
/** \returns the pointer increment between two consecutive columns.
*
* \sa innerStride(), outerStride(), rowStride()
*/
inline int colStride() const
{
return IsRowMajor ? innerStride() : outerStride();
}
};
#endif // EIGEN_DENSEDIRECTACCESSBASE_H

View File

@ -39,11 +39,11 @@ template<typename MatrixTypeA, typename MatrixTypeB, bool SwapPointers> struct e
* \brief Dense storage base class for matrices and arrays.
**/
template<typename Derived>
class DenseStorageBase : public DenseDirectAccessBase<Derived>
class DenseStorageBase : public ei_dense_xpr_base<Derived>::type
{
public:
enum { Options = ei_traits<Derived>::Options };
typedef typename ei_traits<Derived>::XprBase Base;
typedef typename ei_dense_xpr_base<Derived>::type Base;
typedef typename Base::PlainObject PlainObject;
typedef typename Base::Scalar Scalar;
typedef typename Base::PacketScalar PacketScalar;

View File

@ -33,11 +33,11 @@
* \sa class Map, class Block
*/
template<typename Derived> class MapBase
: public DenseDirectAccessBase<Derived>
: public ei_dense_xpr_base<Derived>::type
{
public:
typedef DenseDirectAccessBase<Derived> Base;
typedef typename ei_dense_xpr_base<Derived>::type Base;
enum {
RowsAtCompileTime = ei_traits<Derived>::RowsAtCompileTime,
ColsAtCompileTime = ei_traits<Derived>::ColsAtCompileTime,
@ -58,7 +58,6 @@ template<typename Derived> class MapBase
using Base::IsRowMajor;
using Base::CoeffReadCost;
using Base::_HasDirectAccess;
// using Base::derived;
using Base::const_cast_derived;

View File

@ -114,7 +114,6 @@ struct ei_traits<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> >
typedef _Scalar Scalar;
typedef Dense StorageKind;
typedef MatrixXpr XprKind;
typedef MatrixBase<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> > XprBase;
enum {
RowsAtCompileTime = _Rows,
ColsAtCompileTime = _Cols,

View File

@ -75,7 +75,6 @@ template<typename Derived> class MatrixBase
using Base::IsVectorAtCompileTime;
using Base::Flags;
using Base::CoeffReadCost;
using Base::_HasDirectAccess;
using Base::derived;
using Base::const_cast_derived;

View File

@ -90,7 +90,7 @@ template<typename MatrixType> class Transpose
template<typename MatrixType, bool _HasDirectAccess = ei_has_direct_access<MatrixType>::ret>
struct ei_TransposeImpl_base
{
typedef DenseDirectAccessBase<Transpose<MatrixType> > type;
typedef typename ei_dense_xpr_base<Transpose<MatrixType> >::type type;
};
template<typename MatrixType>

View File

@ -222,7 +222,7 @@ class FFT
template<typename InputDerived, typename ComplexDerived>
inline
void fwd( DenseDirectAccessBase<ComplexDerived> & dst, const DenseDirectAccessBase<InputDerived> & src,int nfft=-1)
void fwd( MatrixBase<ComplexDerived> & dst, const MatrixBase<InputDerived> & src,int nfft=-1)
{
typedef typename ComplexDerived::Scalar dst_type;
typedef typename InputDerived::Scalar src_type;
@ -258,18 +258,18 @@ class FFT
template<typename InputDerived>
inline
fft_fwd_proxy< DenseDirectAccessBase<InputDerived>, FFT<T_Scalar,T_Impl> >
fwd( const DenseDirectAccessBase<InputDerived> & src,int nfft=-1)
fft_fwd_proxy< MatrixBase<InputDerived>, FFT<T_Scalar,T_Impl> >
fwd( const MatrixBase<InputDerived> & src,int nfft=-1)
{
return fft_fwd_proxy< DenseDirectAccessBase<InputDerived> ,FFT<T_Scalar,T_Impl> >( src, *this,nfft );
return fft_fwd_proxy< MatrixBase<InputDerived> ,FFT<T_Scalar,T_Impl> >( src, *this,nfft );
}
template<typename InputDerived>
inline
fft_inv_proxy< DenseDirectAccessBase<InputDerived>, FFT<T_Scalar,T_Impl> >
inv( const DenseDirectAccessBase<InputDerived> & src,int nfft=-1)
fft_inv_proxy< MatrixBase<InputDerived>, FFT<T_Scalar,T_Impl> >
inv( const MatrixBase<InputDerived> & src,int nfft=-1)
{
return fft_inv_proxy< DenseDirectAccessBase<InputDerived> ,FFT<T_Scalar,T_Impl> >( src, *this,nfft );
return fft_inv_proxy< MatrixBase<InputDerived> ,FFT<T_Scalar,T_Impl> >( src, *this,nfft );
}
inline
@ -290,7 +290,7 @@ class FFT
template<typename OutputDerived, typename ComplexDerived>
inline
void inv( DenseDirectAccessBase<OutputDerived> & dst, const DenseDirectAccessBase<ComplexDerived> & src, int nfft=-1)
void inv( MatrixBase<OutputDerived> & dst, const MatrixBase<ComplexDerived> & src, int nfft=-1)
{
typedef typename ComplexDerived::Scalar src_type;
typedef typename OutputDerived::Scalar dst_type;