mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-11 19:29:02 +08:00
Experiment the ET refactoring on Transpose for Dense and Sparse storages.
All tests work fine.
This commit is contained in:
parent
a89b22f352
commit
2a3a6fe45e
@ -42,6 +42,7 @@ template<typename MatrixType,int RowFactor,int ColFactor>
|
|||||||
struct ei_traits<Replicate<MatrixType,RowFactor,ColFactor> >
|
struct ei_traits<Replicate<MatrixType,RowFactor,ColFactor> >
|
||||||
{
|
{
|
||||||
typedef typename MatrixType::Scalar Scalar;
|
typedef typename MatrixType::Scalar Scalar;
|
||||||
|
typedef typename ei_traits<MatrixType>::StorageType StorageType;
|
||||||
typedef typename ei_nested<MatrixType>::type MatrixTypeNested;
|
typedef typename ei_nested<MatrixType>::type MatrixTypeNested;
|
||||||
typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested;
|
typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested;
|
||||||
enum {
|
enum {
|
||||||
|
@ -45,6 +45,7 @@ template<typename MatrixType, int Direction>
|
|||||||
struct ei_traits<Reverse<MatrixType, Direction> >
|
struct ei_traits<Reverse<MatrixType, Direction> >
|
||||||
{
|
{
|
||||||
typedef typename MatrixType::Scalar Scalar;
|
typedef typename MatrixType::Scalar Scalar;
|
||||||
|
typedef typename ei_traits<MatrixType>::StorageType StorageType;
|
||||||
typedef typename ei_nested<MatrixType>::type MatrixTypeNested;
|
typedef typename ei_nested<MatrixType>::type MatrixTypeNested;
|
||||||
typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested;
|
typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested;
|
||||||
enum {
|
enum {
|
||||||
|
@ -50,6 +50,7 @@ template<typename MatrixType, typename MemberOp, int Direction>
|
|||||||
struct ei_traits<PartialReduxExpr<MatrixType, MemberOp, Direction> >
|
struct ei_traits<PartialReduxExpr<MatrixType, MemberOp, Direction> >
|
||||||
{
|
{
|
||||||
typedef typename MemberOp::result_type Scalar;
|
typedef typename MemberOp::result_type Scalar;
|
||||||
|
typedef typename ei_traits<MatrixType>::StorageType StorageType;
|
||||||
typedef typename MatrixType::Scalar InputScalar;
|
typedef typename MatrixType::Scalar InputScalar;
|
||||||
typedef typename ei_nested<MatrixType>::type MatrixTypeNested;
|
typedef typename ei_nested<MatrixType>::type MatrixTypeNested;
|
||||||
typedef typename ei_cleantype<MatrixTypeNested>::type _MatrixTypeNested;
|
typedef typename ei_cleantype<MatrixTypeNested>::type _MatrixTypeNested;
|
||||||
|
@ -67,6 +67,7 @@ struct ei_traits<Block<MatrixType, BlockRows, BlockCols, _PacketAccess, _DirectA
|
|||||||
typedef typename ei_traits<MatrixType>::Scalar Scalar;
|
typedef typename ei_traits<MatrixType>::Scalar Scalar;
|
||||||
typedef typename ei_nested<MatrixType>::type MatrixTypeNested;
|
typedef typename ei_nested<MatrixType>::type MatrixTypeNested;
|
||||||
typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested;
|
typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested;
|
||||||
|
typedef typename ei_traits<MatrixType>::StorageType StorageType;
|
||||||
enum{
|
enum{
|
||||||
RowsAtCompileTime = BlockRows,
|
RowsAtCompileTime = BlockRows,
|
||||||
ColsAtCompileTime = BlockCols,
|
ColsAtCompileTime = BlockCols,
|
||||||
|
@ -54,6 +54,8 @@ struct ei_traits<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >
|
|||||||
typename Rhs::Scalar
|
typename Rhs::Scalar
|
||||||
)
|
)
|
||||||
>::type Scalar;
|
>::type Scalar;
|
||||||
|
typedef typename ei_promote_storage_type<typename ei_traits<Lhs>::StorageType,
|
||||||
|
typename ei_traits<Rhs>::StorageType>::ret StorageType;
|
||||||
typedef typename Lhs::Nested LhsNested;
|
typedef typename Lhs::Nested LhsNested;
|
||||||
typedef typename Rhs::Nested RhsNested;
|
typedef typename Rhs::Nested RhsNested;
|
||||||
typedef typename ei_unref<LhsNested>::type _LhsNested;
|
typedef typename ei_unref<LhsNested>::type _LhsNested;
|
||||||
|
@ -46,6 +46,7 @@ template<typename MatrixType, int Index>
|
|||||||
struct ei_traits<Diagonal<MatrixType,Index> >
|
struct ei_traits<Diagonal<MatrixType,Index> >
|
||||||
{
|
{
|
||||||
typedef typename MatrixType::Scalar Scalar;
|
typedef typename MatrixType::Scalar Scalar;
|
||||||
|
typedef typename ei_traits<MatrixType>::StorageType StorageType;
|
||||||
typedef typename ei_nested<MatrixType>::type MatrixTypeNested;
|
typedef typename ei_nested<MatrixType>::type MatrixTypeNested;
|
||||||
typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested;
|
typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested;
|
||||||
enum {
|
enum {
|
||||||
|
@ -30,6 +30,7 @@ template<typename MatrixType, typename DiagonalType, int ProductOrder>
|
|||||||
struct ei_traits<DiagonalProduct<MatrixType, DiagonalType, ProductOrder> >
|
struct ei_traits<DiagonalProduct<MatrixType, DiagonalType, ProductOrder> >
|
||||||
{
|
{
|
||||||
typedef typename ei_scalar_product_traits<typename MatrixType::Scalar, typename DiagonalType::Scalar>::ReturnType Scalar;
|
typedef typename ei_scalar_product_traits<typename MatrixType::Scalar, typename DiagonalType::Scalar>::ReturnType Scalar;
|
||||||
|
typedef typename ei_traits<MatrixType>::StorageType StorageType;
|
||||||
enum {
|
enum {
|
||||||
RowsAtCompileTime = MatrixType::RowsAtCompileTime,
|
RowsAtCompileTime = MatrixType::RowsAtCompileTime,
|
||||||
ColsAtCompileTime = MatrixType::ColsAtCompileTime,
|
ColsAtCompileTime = MatrixType::ColsAtCompileTime,
|
||||||
|
@ -118,6 +118,7 @@ template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int
|
|||||||
struct ei_traits<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> >
|
struct ei_traits<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> >
|
||||||
{
|
{
|
||||||
typedef _Scalar Scalar;
|
typedef _Scalar Scalar;
|
||||||
|
typedef Dense StorageType;
|
||||||
enum {
|
enum {
|
||||||
RowsAtCompileTime = _Rows,
|
RowsAtCompileTime = _Rows,
|
||||||
ColsAtCompileTime = _Cols,
|
ColsAtCompileTime = _Cols,
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
/** \class MatrixBase
|
/** \class MatrixBase
|
||||||
*
|
*
|
||||||
* \brief Base class for all matrices, vectors, and expressions
|
* \brief Base class for all dense matrices, vectors, and expressions
|
||||||
*
|
*
|
||||||
* This class is the base that is inherited by all matrix, vector, and expression
|
* This class is the base that is inherited by all matrix, vector, and expression
|
||||||
* types. Most of the Eigen API is contained in this class. Other important classes for
|
* types. Most of the Eigen API is contained in this class. Other important classes for
|
||||||
@ -51,6 +51,9 @@
|
|||||||
}
|
}
|
||||||
* \endcode
|
* \endcode
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
struct Dense {};
|
||||||
|
|
||||||
template<typename Derived> class MatrixBase
|
template<typename Derived> class MatrixBase
|
||||||
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
||||||
: public ei_special_scalar_op_base<Derived,typename ei_traits<Derived>::Scalar,
|
: public ei_special_scalar_op_base<Derived,typename ei_traits<Derived>::Scalar,
|
||||||
|
@ -42,6 +42,7 @@ template<typename MatrixType>
|
|||||||
struct ei_traits<Minor<MatrixType> >
|
struct ei_traits<Minor<MatrixType> >
|
||||||
{
|
{
|
||||||
typedef typename MatrixType::Scalar Scalar;
|
typedef typename MatrixType::Scalar Scalar;
|
||||||
|
typedef typename ei_traits<MatrixType>::StorageType StorageType;
|
||||||
typedef typename ei_nested<MatrixType>::type MatrixTypeNested;
|
typedef typename ei_nested<MatrixType>::type MatrixTypeNested;
|
||||||
typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested;
|
typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested;
|
||||||
enum {
|
enum {
|
||||||
|
@ -34,6 +34,8 @@ struct ei_traits<ProductBase<Derived,_Lhs,_Rhs> >
|
|||||||
typedef typename ei_cleantype<_Lhs>::type Lhs;
|
typedef typename ei_cleantype<_Lhs>::type Lhs;
|
||||||
typedef typename ei_cleantype<_Rhs>::type Rhs;
|
typedef typename ei_cleantype<_Rhs>::type Rhs;
|
||||||
typedef typename ei_scalar_product_traits<typename Lhs::Scalar, typename Rhs::Scalar>::ReturnType Scalar;
|
typedef typename ei_scalar_product_traits<typename Lhs::Scalar, typename Rhs::Scalar>::ReturnType Scalar;
|
||||||
|
typedef typename ei_promote_storage_type<typename ei_traits<Lhs>::StorageType,
|
||||||
|
typename ei_traits<Rhs>::StorageType>::ret StorageType;
|
||||||
enum {
|
enum {
|
||||||
RowsAtCompileTime = ei_traits<Lhs>::RowsAtCompileTime,
|
RowsAtCompileTime = ei_traits<Lhs>::RowsAtCompileTime,
|
||||||
ColsAtCompileTime = ei_traits<Rhs>::ColsAtCompileTime,
|
ColsAtCompileTime = ei_traits<Rhs>::ColsAtCompileTime,
|
||||||
|
@ -43,6 +43,7 @@ struct ei_traits<Transpose<MatrixType> >
|
|||||||
typedef typename MatrixType::Scalar Scalar;
|
typedef typename MatrixType::Scalar Scalar;
|
||||||
typedef typename ei_nested<MatrixType>::type MatrixTypeNested;
|
typedef typename ei_nested<MatrixType>::type MatrixTypeNested;
|
||||||
typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested;
|
typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested;
|
||||||
|
typedef typename ei_traits<MatrixType>::StorageType StorageType;
|
||||||
enum {
|
enum {
|
||||||
RowsAtCompileTime = MatrixType::ColsAtCompileTime,
|
RowsAtCompileTime = MatrixType::ColsAtCompileTime,
|
||||||
ColsAtCompileTime = MatrixType::RowsAtCompileTime,
|
ColsAtCompileTime = MatrixType::RowsAtCompileTime,
|
||||||
@ -56,12 +57,15 @@ struct ei_traits<Transpose<MatrixType> >
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename MatrixType, typename StorageType> class TransposeImpl;
|
||||||
|
|
||||||
template<typename MatrixType> class Transpose
|
template<typename MatrixType> class Transpose
|
||||||
: public MatrixBase<Transpose<MatrixType> >
|
: public TransposeImpl<MatrixType,typename ei_traits<MatrixType>::StorageType>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
EIGEN_GENERIC_PUBLIC_INTERFACE(Transpose)
|
typedef typename TransposeImpl<MatrixType,typename ei_traits<MatrixType>::StorageType>::Base Base;
|
||||||
|
EIGEN_GENERIC_PUBLIC_INTERFACE_NEW(Transpose)
|
||||||
|
|
||||||
inline Transpose(const MatrixType& matrix) : m_matrix(matrix) {}
|
inline Transpose(const MatrixType& matrix) : m_matrix(matrix) {}
|
||||||
|
|
||||||
@ -69,62 +73,86 @@ template<typename MatrixType> class Transpose
|
|||||||
|
|
||||||
inline int rows() const { return m_matrix.cols(); }
|
inline int rows() const { return m_matrix.cols(); }
|
||||||
inline int cols() const { return m_matrix.rows(); }
|
inline int cols() const { return m_matrix.rows(); }
|
||||||
inline int stride() const { return m_matrix.stride(); }
|
|
||||||
inline Scalar* data() { return m_matrix.data(); }
|
|
||||||
inline const Scalar* data() const { return m_matrix.data(); }
|
|
||||||
|
|
||||||
inline Scalar& coeffRef(int row, int col)
|
|
||||||
{
|
|
||||||
return m_matrix.const_cast_derived().coeffRef(col, row);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Scalar& coeffRef(int index)
|
|
||||||
{
|
|
||||||
return m_matrix.const_cast_derived().coeffRef(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline const CoeffReturnType coeff(int row, int col) const
|
|
||||||
{
|
|
||||||
return m_matrix.coeff(col, row);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline const CoeffReturnType coeff(int index) const
|
|
||||||
{
|
|
||||||
return m_matrix.coeff(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<int LoadMode>
|
|
||||||
inline const PacketScalar packet(int row, int col) const
|
|
||||||
{
|
|
||||||
return m_matrix.template packet<LoadMode>(col, row);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<int LoadMode>
|
|
||||||
inline void writePacket(int row, int col, const PacketScalar& x)
|
|
||||||
{
|
|
||||||
m_matrix.const_cast_derived().template writePacket<LoadMode>(col, row, x);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<int LoadMode>
|
|
||||||
inline const PacketScalar packet(int index) const
|
|
||||||
{
|
|
||||||
return m_matrix.template packet<LoadMode>(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<int LoadMode>
|
|
||||||
inline void writePacket(int index, const PacketScalar& x)
|
|
||||||
{
|
|
||||||
m_matrix.const_cast_derived().template writePacket<LoadMode>(index, x);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** \internal used for introspection */
|
/** \internal used for introspection */
|
||||||
const typename ei_cleantype<typename MatrixType::Nested>::type&
|
const typename ei_cleantype<typename MatrixType::Nested>::type&
|
||||||
_expression() const { return m_matrix; }
|
_expression() const { return m_matrix; }
|
||||||
|
|
||||||
|
const typename ei_cleantype<typename MatrixType::Nested>::type&
|
||||||
|
nestedExpression() const { return m_matrix; }
|
||||||
|
|
||||||
|
typename ei_cleantype<typename MatrixType::Nested>::type&
|
||||||
|
nestedExpression() { return m_matrix.const_cast_derived(); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const typename MatrixType::Nested m_matrix;
|
const typename MatrixType::Nested m_matrix;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template<typename MatrixType> class TransposeImpl<MatrixType,Dense>
|
||||||
|
: public MatrixBase<Transpose<MatrixType> >
|
||||||
|
{
|
||||||
|
const typename ei_cleantype<typename MatrixType::Nested>::type& matrix() const
|
||||||
|
{ return derived().nestedExpression(); }
|
||||||
|
typename ei_cleantype<typename MatrixType::Nested>::type& matrix()
|
||||||
|
{ return derived().nestedExpression(); }
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//EIGEN_DENSE_PUBLIC_INTERFACE(TransposeImpl,MatrixBase<Transpose<MatrixType> >)
|
||||||
|
EIGEN_DENSE_PUBLIC_INTERFACE(Transpose<MatrixType>)
|
||||||
|
|
||||||
|
// EIGEN_EXPRESSION_IMPL_COMMON(MatrixBase<Transpose<MatrixType> >)
|
||||||
|
|
||||||
|
inline int stride() const { return matrix().stride(); }
|
||||||
|
inline Scalar* data() { return matrix().data(); }
|
||||||
|
inline const Scalar* data() const { return matrix().data(); }
|
||||||
|
|
||||||
|
inline Scalar& coeffRef(int row, int col)
|
||||||
|
{
|
||||||
|
return matrix().const_cast_derived().coeffRef(col, row);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Scalar& coeffRef(int index)
|
||||||
|
{
|
||||||
|
return matrix().const_cast_derived().coeffRef(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const CoeffReturnType coeff(int row, int col) const
|
||||||
|
{
|
||||||
|
return matrix().coeff(col, row);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const CoeffReturnType coeff(int index) const
|
||||||
|
{
|
||||||
|
return matrix().coeff(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<int LoadMode>
|
||||||
|
inline const PacketScalar packet(int row, int col) const
|
||||||
|
{
|
||||||
|
return matrix().template packet<LoadMode>(col, row);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<int LoadMode>
|
||||||
|
inline void writePacket(int row, int col, const PacketScalar& x)
|
||||||
|
{
|
||||||
|
matrix().const_cast_derived().template writePacket<LoadMode>(col, row, x);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<int LoadMode>
|
||||||
|
inline const PacketScalar packet(int index) const
|
||||||
|
{
|
||||||
|
return matrix().template packet<LoadMode>(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<int LoadMode>
|
||||||
|
inline void writePacket(int index, const PacketScalar& x)
|
||||||
|
{
|
||||||
|
matrix().const_cast_derived().template writePacket<LoadMode>(index, x);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/** \returns an expression of the transpose of *this.
|
/** \returns an expression of the transpose of *this.
|
||||||
*
|
*
|
||||||
* Example: \include MatrixBase_transpose.cpp
|
* Example: \include MatrixBase_transpose.cpp
|
||||||
|
@ -48,6 +48,8 @@ struct ei_traits<GeneralProduct<LhsNested,RhsNested,UnrolledProduct> >
|
|||||||
typedef typename ei_cleantype<LhsNested>::type _LhsNested;
|
typedef typename ei_cleantype<LhsNested>::type _LhsNested;
|
||||||
typedef typename ei_cleantype<RhsNested>::type _RhsNested;
|
typedef typename ei_cleantype<RhsNested>::type _RhsNested;
|
||||||
typedef typename ei_scalar_product_traits<typename _LhsNested::Scalar, typename _RhsNested::Scalar>::ReturnType Scalar;
|
typedef typename ei_scalar_product_traits<typename _LhsNested::Scalar, typename _RhsNested::Scalar>::ReturnType Scalar;
|
||||||
|
typedef typename ei_promote_storage_type<typename ei_traits<_LhsNested>::StorageType,
|
||||||
|
typename ei_traits<_RhsNested>::StorageType>::ret StorageType;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
LhsCoeffReadCost = _LhsNested::CoeffReadCost,
|
LhsCoeffReadCost = _LhsNested::CoeffReadCost,
|
||||||
|
@ -263,43 +263,79 @@ using Eigen::ei_cos;
|
|||||||
|
|
||||||
#if defined(_MSC_VER) && (!defined(__INTEL_COMPILER))
|
#if defined(_MSC_VER) && (!defined(__INTEL_COMPILER))
|
||||||
#define EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived) \
|
#define EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived) \
|
||||||
using Base::operator =;
|
using Base::operator =;
|
||||||
#else
|
#else
|
||||||
#define EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived) \
|
#define EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived) \
|
||||||
using Base::operator =; \
|
using Base::operator =; \
|
||||||
EIGEN_STRONG_INLINE Derived& operator=(const Derived& other) \
|
EIGEN_STRONG_INLINE Derived& operator=(const Derived& other) \
|
||||||
{ \
|
{ \
|
||||||
Base::operator=(other); \
|
Base::operator=(other); \
|
||||||
return *this; \
|
return *this; \
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Derived) \
|
#define EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Derived) \
|
||||||
using Base::operator +=; \
|
using Base::operator +=; \
|
||||||
using Base::operator -=; \
|
using Base::operator -=; \
|
||||||
using Base::operator *=; \
|
using Base::operator *=; \
|
||||||
using Base::operator /=; \
|
using Base::operator /=; \
|
||||||
EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived)
|
EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived)
|
||||||
|
|
||||||
#define _EIGEN_GENERIC_PUBLIC_INTERFACE(Derived, BaseClass) \
|
#define _EIGEN_GENERIC_PUBLIC_INTERFACE(Derived, BaseClass) \
|
||||||
typedef BaseClass Base; \
|
typedef BaseClass Base; \
|
||||||
typedef typename Eigen::ei_traits<Derived>::Scalar Scalar; \
|
typedef typename Eigen::ei_traits<Derived>::Scalar Scalar; \
|
||||||
typedef typename Eigen::NumTraits<Scalar>::Real RealScalar; \
|
typedef typename Eigen::NumTraits<Scalar>::Real RealScalar; \
|
||||||
typedef typename Base::PacketScalar PacketScalar; \
|
typedef typename Base::PacketScalar PacketScalar; \
|
||||||
typedef typename Base::CoeffReturnType CoeffReturnType; \
|
typedef typename Base::CoeffReturnType CoeffReturnType; \
|
||||||
typedef typename Eigen::ei_nested<Derived>::type Nested; \
|
typedef typename Eigen::ei_nested<Derived>::type Nested; \
|
||||||
enum { RowsAtCompileTime = Eigen::ei_traits<Derived>::RowsAtCompileTime, \
|
enum { RowsAtCompileTime = Eigen::ei_traits<Derived>::RowsAtCompileTime, \
|
||||||
ColsAtCompileTime = Eigen::ei_traits<Derived>::ColsAtCompileTime, \
|
ColsAtCompileTime = Eigen::ei_traits<Derived>::ColsAtCompileTime, \
|
||||||
MaxRowsAtCompileTime = Eigen::ei_traits<Derived>::MaxRowsAtCompileTime, \
|
MaxRowsAtCompileTime = Eigen::ei_traits<Derived>::MaxRowsAtCompileTime, \
|
||||||
MaxColsAtCompileTime = Eigen::ei_traits<Derived>::MaxColsAtCompileTime, \
|
MaxColsAtCompileTime = Eigen::ei_traits<Derived>::MaxColsAtCompileTime, \
|
||||||
Flags = Eigen::ei_traits<Derived>::Flags, \
|
Flags = Eigen::ei_traits<Derived>::Flags, \
|
||||||
CoeffReadCost = Eigen::ei_traits<Derived>::CoeffReadCost, \
|
CoeffReadCost = Eigen::ei_traits<Derived>::CoeffReadCost, \
|
||||||
SizeAtCompileTime = Base::SizeAtCompileTime, \
|
SizeAtCompileTime = Base::SizeAtCompileTime, \
|
||||||
MaxSizeAtCompileTime = Base::MaxSizeAtCompileTime, \
|
MaxSizeAtCompileTime = Base::MaxSizeAtCompileTime, \
|
||||||
IsVectorAtCompileTime = Base::IsVectorAtCompileTime };
|
IsVectorAtCompileTime = Base::IsVectorAtCompileTime };
|
||||||
|
|
||||||
#define EIGEN_GENERIC_PUBLIC_INTERFACE(Derived) \
|
#define EIGEN_GENERIC_PUBLIC_INTERFACE(Derived) \
|
||||||
_EIGEN_GENERIC_PUBLIC_INTERFACE(Derived, Eigen::MatrixBase<Derived>)
|
_EIGEN_GENERIC_PUBLIC_INTERFACE(Derived, Eigen::MatrixBase<Derived>)
|
||||||
|
|
||||||
|
#define EIGEN_GENERIC_PUBLIC_INTERFACE_NEW(Derived) \
|
||||||
|
typedef typename Eigen::ei_traits<Derived>::Scalar Scalar; \
|
||||||
|
typedef typename Eigen::NumTraits<Scalar>::Real RealScalar; \
|
||||||
|
typedef typename Base::CoeffReturnType CoeffReturnType; \
|
||||||
|
typedef typename Eigen::ei_nested<Derived>::type Nested; \
|
||||||
|
enum { RowsAtCompileTime = Eigen::ei_traits<Derived>::RowsAtCompileTime, \
|
||||||
|
ColsAtCompileTime = Eigen::ei_traits<Derived>::ColsAtCompileTime, \
|
||||||
|
Flags = Eigen::ei_traits<Derived>::Flags, \
|
||||||
|
CoeffReadCost = Eigen::ei_traits<Derived>::CoeffReadCost, \
|
||||||
|
SizeAtCompileTime = Base::SizeAtCompileTime, \
|
||||||
|
MaxSizeAtCompileTime = Base::MaxSizeAtCompileTime, \
|
||||||
|
IsVectorAtCompileTime = Base::IsVectorAtCompileTime };
|
||||||
|
|
||||||
|
|
||||||
|
#define _EIGEN_DENSE_PUBLIC_INTERFACE(Derived, BaseClass) \
|
||||||
|
typedef BaseClass Base; \
|
||||||
|
typedef typename Eigen::ei_traits<Derived>::Scalar Scalar; \
|
||||||
|
typedef typename Eigen::NumTraits<Scalar>::Real RealScalar; \
|
||||||
|
typedef typename Base::PacketScalar PacketScalar; \
|
||||||
|
typedef typename Base::CoeffReturnType CoeffReturnType; \
|
||||||
|
typedef typename Eigen::ei_nested<Derived>::type Nested; \
|
||||||
|
enum { RowsAtCompileTime = Eigen::ei_traits<Derived>::RowsAtCompileTime, \
|
||||||
|
ColsAtCompileTime = Eigen::ei_traits<Derived>::ColsAtCompileTime, \
|
||||||
|
MaxRowsAtCompileTime = Eigen::ei_traits<Derived>::MaxRowsAtCompileTime, \
|
||||||
|
MaxColsAtCompileTime = Eigen::ei_traits<Derived>::MaxColsAtCompileTime, \
|
||||||
|
Flags = Eigen::ei_traits<Derived>::Flags, \
|
||||||
|
CoeffReadCost = Eigen::ei_traits<Derived>::CoeffReadCost, \
|
||||||
|
SizeAtCompileTime = Base::SizeAtCompileTime, \
|
||||||
|
MaxSizeAtCompileTime = Base::MaxSizeAtCompileTime, \
|
||||||
|
IsVectorAtCompileTime = Base::IsVectorAtCompileTime }; \
|
||||||
|
using Base::derived;
|
||||||
|
|
||||||
|
#define EIGEN_DENSE_PUBLIC_INTERFACE(Derived) \
|
||||||
|
_EIGEN_DENSE_PUBLIC_INTERFACE(Derived, Eigen::MatrixBase<Derived>)
|
||||||
|
|
||||||
|
|
||||||
#define EIGEN_ENUM_MIN(a,b) (((int)a <= (int)b) ? (int)a : (int)b)
|
#define EIGEN_ENUM_MIN(a,b) (((int)a <= (int)b) ? (int)a : (int)b)
|
||||||
#define EIGEN_SIZE_MIN(a,b) (((int)a == 1 || (int)b == 1) ? 1 \
|
#define EIGEN_SIZE_MIN(a,b) (((int)a == 1 || (int)b == 1) ? 1 \
|
||||||
|
@ -268,4 +268,11 @@ template<typename XprType, typename CastType> struct ei_cast_return_type
|
|||||||
const XprType&,CastType>::ret type;
|
const XprType&,CastType>::ret type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename A, typename B> struct ei_promote_storage_type;
|
||||||
|
|
||||||
|
template <typename A> struct ei_promote_storage_type<A,A>
|
||||||
|
{
|
||||||
|
typedef A ret;
|
||||||
|
};
|
||||||
|
|
||||||
#endif // EIGEN_XPRHELPER_H
|
#endif // EIGEN_XPRHELPER_H
|
||||||
|
@ -43,6 +43,7 @@ template<typename MatrixType,int Direction>
|
|||||||
struct ei_traits<Homogeneous<MatrixType,Direction> >
|
struct ei_traits<Homogeneous<MatrixType,Direction> >
|
||||||
{
|
{
|
||||||
typedef typename MatrixType::Scalar Scalar;
|
typedef typename MatrixType::Scalar Scalar;
|
||||||
|
typedef typename ei_traits<MatrixType>::StorageType StorageType;
|
||||||
typedef typename ei_nested<MatrixType>::type MatrixTypeNested;
|
typedef typename ei_nested<MatrixType>::type MatrixTypeNested;
|
||||||
typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested;
|
typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested;
|
||||||
enum {
|
enum {
|
||||||
|
@ -46,6 +46,7 @@ template<typename _Scalar, int _Flags>
|
|||||||
struct ei_traits<DynamicSparseMatrix<_Scalar, _Flags> >
|
struct ei_traits<DynamicSparseMatrix<_Scalar, _Flags> >
|
||||||
{
|
{
|
||||||
typedef _Scalar Scalar;
|
typedef _Scalar Scalar;
|
||||||
|
typedef Sparse StorageType;
|
||||||
enum {
|
enum {
|
||||||
RowsAtCompileTime = Dynamic,
|
RowsAtCompileTime = Dynamic,
|
||||||
ColsAtCompileTime = Dynamic,
|
ColsAtCompileTime = Dynamic,
|
||||||
|
@ -45,6 +45,7 @@ template<typename _Scalar, int _Options>
|
|||||||
struct ei_traits<SparseMatrix<_Scalar, _Options> >
|
struct ei_traits<SparseMatrix<_Scalar, _Options> >
|
||||||
{
|
{
|
||||||
typedef _Scalar Scalar;
|
typedef _Scalar Scalar;
|
||||||
|
typedef Sparse StorageType;
|
||||||
enum {
|
enum {
|
||||||
RowsAtCompileTime = Dynamic,
|
RowsAtCompileTime = Dynamic,
|
||||||
ColsAtCompileTime = Dynamic,
|
ColsAtCompileTime = Dynamic,
|
||||||
|
@ -36,11 +36,15 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
struct Sparse {};
|
||||||
|
|
||||||
template<typename Derived> class SparseMatrixBase : public AnyMatrixBase<Derived>
|
template<typename Derived> class SparseMatrixBase : public AnyMatrixBase<Derived>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef typename ei_traits<Derived>::Scalar Scalar;
|
typedef typename ei_traits<Derived>::Scalar Scalar;
|
||||||
|
typedef typename ei_packet_traits<Scalar>::type PacketScalar;
|
||||||
// typedef typename Derived::InnerIterator InnerIterator;
|
// typedef typename Derived::InnerIterator InnerIterator;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@ -86,7 +90,11 @@ template<typename Derived> class SparseMatrixBase : public AnyMatrixBase<Derived
|
|||||||
* this expression.
|
* this expression.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
IsRowMajor = Flags&RowMajorBit ? 1 : 0
|
IsRowMajor = Flags&RowMajorBit ? 1 : 0,
|
||||||
|
|
||||||
|
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
||||||
|
_HasDirectAccess = (int(Flags)&DirectAccessBit) ? 1 : 0 // workaround sunCC
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/** \internal the return type of MatrixBase::conjugate() */
|
/** \internal the return type of MatrixBase::conjugate() */
|
||||||
@ -100,8 +108,8 @@ template<typename Derived> class SparseMatrixBase : public AnyMatrixBase<Derived
|
|||||||
typedef SparseCwiseUnaryOp<ei_scalar_imag_op<Scalar>, Derived> ImagReturnType;
|
typedef SparseCwiseUnaryOp<ei_scalar_imag_op<Scalar>, Derived> ImagReturnType;
|
||||||
/** \internal the return type of MatrixBase::adjoint() */
|
/** \internal the return type of MatrixBase::adjoint() */
|
||||||
typedef typename ei_meta_if<NumTraits<Scalar>::IsComplex,
|
typedef typename ei_meta_if<NumTraits<Scalar>::IsComplex,
|
||||||
SparseCwiseUnaryOp<ei_scalar_conjugate_op<Scalar>, SparseNestByValue<Eigen::SparseTranspose<Derived> > >,
|
SparseCwiseUnaryOp<ei_scalar_conjugate_op<Scalar>, SparseNestByValue<Eigen::Transpose<Derived> > >,
|
||||||
SparseTranspose<Derived>
|
Transpose<Derived>
|
||||||
>::ret AdjointReturnType;
|
>::ret AdjointReturnType;
|
||||||
|
|
||||||
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
||||||
@ -113,6 +121,10 @@ template<typename Derived> class SparseMatrixBase : public AnyMatrixBase<Derived
|
|||||||
*/
|
*/
|
||||||
typedef typename NumTraits<Scalar>::Real RealScalar;
|
typedef typename NumTraits<Scalar>::Real RealScalar;
|
||||||
|
|
||||||
|
/** \internal the return type of coeff()
|
||||||
|
*/
|
||||||
|
typedef typename ei_meta_if<_HasDirectAccess, const Scalar&, Scalar>::ret CoeffReturnType;
|
||||||
|
|
||||||
/** type of the equivalent square matrix */
|
/** type of the equivalent square matrix */
|
||||||
typedef Matrix<Scalar,EIGEN_ENUM_MAX(RowsAtCompileTime,ColsAtCompileTime),
|
typedef Matrix<Scalar,EIGEN_ENUM_MAX(RowsAtCompileTime,ColsAtCompileTime),
|
||||||
EIGEN_ENUM_MAX(RowsAtCompileTime,ColsAtCompileTime)> SquareMatrixType;
|
EIGEN_ENUM_MAX(RowsAtCompileTime,ColsAtCompileTime)> SquareMatrixType;
|
||||||
@ -353,8 +365,8 @@ template<typename Derived> class SparseMatrixBase : public AnyMatrixBase<Derived
|
|||||||
// const PlainMatrixType normalized() const;
|
// const PlainMatrixType normalized() const;
|
||||||
// void normalize();
|
// void normalize();
|
||||||
|
|
||||||
SparseTranspose<Derived> transpose() { return derived(); }
|
Transpose<Derived> transpose() { return derived(); }
|
||||||
const SparseTranspose<Derived> transpose() const { return derived(); }
|
const Transpose<Derived> transpose() const { return derived(); }
|
||||||
// void transposeInPlace();
|
// void transposeInPlace();
|
||||||
const AdjointReturnType adjoint() const { return transpose().nestByValue(); }
|
const AdjointReturnType adjoint() const { return transpose().nestByValue(); }
|
||||||
|
|
||||||
|
@ -25,64 +25,72 @@
|
|||||||
#ifndef EIGEN_SPARSETRANSPOSE_H
|
#ifndef EIGEN_SPARSETRANSPOSE_H
|
||||||
#define EIGEN_SPARSETRANSPOSE_H
|
#define EIGEN_SPARSETRANSPOSE_H
|
||||||
|
|
||||||
template<typename MatrixType>
|
// template<typename MatrixType>
|
||||||
struct ei_traits<SparseTranspose<MatrixType> > : ei_traits<Transpose<MatrixType> >
|
// struct ei_traits<SparseTranspose<MatrixType> > : ei_traits<Transpose<MatrixType> >
|
||||||
{};
|
// {};
|
||||||
|
|
||||||
template<typename MatrixType> class SparseTranspose
|
template<typename MatrixType> class TransposeImpl<MatrixType,Sparse>
|
||||||
: public SparseMatrixBase<SparseTranspose<MatrixType> >
|
: public SparseMatrixBase<Transpose<MatrixType> >
|
||||||
{
|
{
|
||||||
|
const typename ei_cleantype<typename MatrixType::Nested>::type& matrix() const
|
||||||
|
{ return derived().nestedExpression(); }
|
||||||
|
typename ei_cleantype<typename MatrixType::Nested>::type& matrix()
|
||||||
|
{ return derived().nestedExpression(); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
EIGEN_GENERIC_PUBLIC_INTERFACE(SparseTranspose)
|
|
||||||
|
// _EIGEN_SPARSE_GENERIC_PUBLIC_INTERFACE(TransposeImpl,SparseMatrixBase<Transpose<MatrixType> >)
|
||||||
|
// EIGEN_EXPRESSION_IMPL_COMMON(SparseMatrixBase<Transpose<MatrixType> >)
|
||||||
|
EIGEN_SPARSE_PUBLIC_INTERFACE(Transpose<MatrixType>)
|
||||||
|
|
||||||
class InnerIterator;
|
class InnerIterator;
|
||||||
class ReverseInnerIterator;
|
class ReverseInnerIterator;
|
||||||
|
|
||||||
inline SparseTranspose(const MatrixType& matrix) : m_matrix(matrix) {}
|
// inline SparseTranspose(const MatrixType& matrix) : m_matrix(matrix) {}
|
||||||
|
|
||||||
//EIGEN_INHERIT_ASSIGNMENT_OPERATORS(SparseTranspose)
|
//EIGEN_INHERIT_ASSIGNMENT_OPERATORS(SparseTranspose)
|
||||||
|
|
||||||
inline int rows() const { return m_matrix.cols(); }
|
// inline int rows() const { return m_matrix.cols(); }
|
||||||
inline int cols() const { return m_matrix.rows(); }
|
// inline int cols() const { return m_matrix.rows(); }
|
||||||
inline int nonZeros() const { return m_matrix.nonZeros(); }
|
inline int nonZeros() const { return matrix().nonZeros(); }
|
||||||
|
|
||||||
// FIXME should be keep them ?
|
// FIXME should be keep them ?
|
||||||
inline Scalar& coeffRef(int row, int col)
|
inline Scalar& coeffRef(int row, int col)
|
||||||
{ return m_matrix.const_cast_derived().coeffRef(col, row); }
|
{ return matrix().const_cast_derived().coeffRef(col, row); }
|
||||||
|
|
||||||
inline const Scalar coeff(int row, int col) const
|
inline const Scalar coeff(int row, int col) const
|
||||||
{ return m_matrix.coeff(col, row); }
|
{ return matrix().coeff(col, row); }
|
||||||
|
|
||||||
inline const Scalar coeff(int index) const
|
inline const Scalar coeff(int index) const
|
||||||
{ return m_matrix.coeff(index); }
|
{ return matrix().coeff(index); }
|
||||||
|
|
||||||
inline Scalar& coeffRef(int index)
|
inline Scalar& coeffRef(int index)
|
||||||
{ return m_matrix.const_cast_derived().coeffRef(index); }
|
{ return matrix().const_cast_derived().coeffRef(index); }
|
||||||
|
|
||||||
protected:
|
// protected:
|
||||||
const typename MatrixType::Nested m_matrix;
|
// const typename MatrixType::Nested m_matrix;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename MatrixType> class SparseTranspose<MatrixType>::InnerIterator : public MatrixType::InnerIterator
|
template<typename MatrixType> class TransposeImpl<MatrixType,Sparse>::InnerIterator : public MatrixType::InnerIterator
|
||||||
{
|
{
|
||||||
typedef typename MatrixType::InnerIterator Base;
|
typedef typename MatrixType::InnerIterator Base;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
EIGEN_STRONG_INLINE InnerIterator(const SparseTranspose& trans, int outer)
|
EIGEN_STRONG_INLINE InnerIterator(const TransposeImpl& trans, int outer)
|
||||||
: Base(trans.m_matrix, outer)
|
: Base(trans.matrix(), outer)
|
||||||
{}
|
{}
|
||||||
inline int row() const { return Base::col(); }
|
inline int row() const { return Base::col(); }
|
||||||
inline int col() const { return Base::row(); }
|
inline int col() const { return Base::row(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename MatrixType> class SparseTranspose<MatrixType>::ReverseInnerIterator : public MatrixType::ReverseInnerIterator
|
template<typename MatrixType> class TransposeImpl<MatrixType,Sparse>::ReverseInnerIterator : public MatrixType::ReverseInnerIterator
|
||||||
{
|
{
|
||||||
typedef typename MatrixType::ReverseInnerIterator Base;
|
typedef typename MatrixType::ReverseInnerIterator Base;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
EIGEN_STRONG_INLINE ReverseInnerIterator(const SparseTranspose& xpr, int outer)
|
EIGEN_STRONG_INLINE ReverseInnerIterator(const TransposeImpl& xpr, int outer)
|
||||||
: Base(xpr.m_matrix, outer)
|
: Base(xpr.matrix(), outer)
|
||||||
{}
|
{}
|
||||||
inline int row() const { return Base::col(); }
|
inline int row() const { return Base::col(); }
|
||||||
inline int col() const { return Base::row(); }
|
inline int col() const { return Base::row(); }
|
||||||
|
@ -69,7 +69,23 @@ enum { RowsAtCompileTime = Eigen::ei_traits<Derived>::RowsAtCompileTime, \
|
|||||||
IsVectorAtCompileTime = Base::IsVectorAtCompileTime };
|
IsVectorAtCompileTime = Base::IsVectorAtCompileTime };
|
||||||
|
|
||||||
#define EIGEN_SPARSE_GENERIC_PUBLIC_INTERFACE(Derived) \
|
#define EIGEN_SPARSE_GENERIC_PUBLIC_INTERFACE(Derived) \
|
||||||
_EIGEN_SPARSE_GENERIC_PUBLIC_INTERFACE(Derived, Eigen::SparseMatrixBase<Derived>)
|
_EIGEN_SPARSE_GENERIC_PUBLIC_INTERFACE(Derived, Eigen::SparseMatrixBase<Derived>)
|
||||||
|
|
||||||
|
#define _EIGEN_SPARSE_PUBLIC_INTERFACE(Derived, BaseClass) \
|
||||||
|
typedef BaseClass Base; \
|
||||||
|
typedef typename Eigen::ei_traits<Derived>::Scalar Scalar; \
|
||||||
|
typedef typename Eigen::NumTraits<Scalar>::Real RealScalar; \
|
||||||
|
typedef typename Eigen::ei_nested<Derived>::type Nested; \
|
||||||
|
enum { RowsAtCompileTime = Eigen::ei_traits<Derived>::RowsAtCompileTime, \
|
||||||
|
ColsAtCompileTime = Eigen::ei_traits<Derived>::ColsAtCompileTime, \
|
||||||
|
Flags = Eigen::ei_traits<Derived>::Flags, \
|
||||||
|
CoeffReadCost = Eigen::ei_traits<Derived>::CoeffReadCost, \
|
||||||
|
SizeAtCompileTime = Base::SizeAtCompileTime, \
|
||||||
|
IsVectorAtCompileTime = Base::IsVectorAtCompileTime }; \
|
||||||
|
using Base::derived;
|
||||||
|
|
||||||
|
#define EIGEN_SPARSE_PUBLIC_INTERFACE(Derived) \
|
||||||
|
_EIGEN_SPARSE_PUBLIC_INTERFACE(Derived, Eigen::SparseMatrixBase<Derived>)
|
||||||
|
|
||||||
enum SparseBackend {
|
enum SparseBackend {
|
||||||
DefaultBackend,
|
DefaultBackend,
|
||||||
@ -107,7 +123,7 @@ template<typename _Scalar, int _Flags = 0> class SparseVector;
|
|||||||
template<typename _Scalar, int _Flags = 0> class MappedSparseMatrix;
|
template<typename _Scalar, int _Flags = 0> class MappedSparseMatrix;
|
||||||
|
|
||||||
template<typename MatrixType> class SparseNestByValue;
|
template<typename MatrixType> class SparseNestByValue;
|
||||||
template<typename MatrixType> class SparseTranspose;
|
// template<typename MatrixType> class SparseTranspose;
|
||||||
template<typename MatrixType, int Size> class SparseInnerVectorSet;
|
template<typename MatrixType, int Size> class SparseInnerVectorSet;
|
||||||
template<typename Derived> class SparseCwise;
|
template<typename Derived> class SparseCwise;
|
||||||
template<typename UnaryOp, typename MatrixType> class SparseCwiseUnaryOp;
|
template<typename UnaryOp, typename MatrixType> class SparseCwiseUnaryOp;
|
||||||
|
@ -38,6 +38,7 @@ template<typename _Scalar, int _Options>
|
|||||||
struct ei_traits<SparseVector<_Scalar, _Options> >
|
struct ei_traits<SparseVector<_Scalar, _Options> >
|
||||||
{
|
{
|
||||||
typedef _Scalar Scalar;
|
typedef _Scalar Scalar;
|
||||||
|
typedef Sparse StorageType;
|
||||||
enum {
|
enum {
|
||||||
IsColVector = _Options & RowMajorBit ? 0 : 1,
|
IsColVector = _Options & RowMajorBit ? 0 : 1,
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user