fix compilation with old, and future gcc

This commit is contained in:
Gael Guennebaud 2009-03-10 11:55:50 +00:00
parent 3e4307d8a8
commit 14691d6836
4 changed files with 98 additions and 104 deletions

View File

@ -176,7 +176,7 @@ template<typename Derived> class MapBase
{
return Base::operator=(other);
}
using Base::operator*=;
template<typename OtherDerived>

View File

@ -585,11 +585,11 @@ template<typename Derived> class MatrixBase
select(typename ElseDerived::Scalar thenScalar, const MatrixBase<ElseDerived>& elseMatrix) const;
template<int p> RealScalar lpNorm() const;
template<int RowFactor, int ColFactor>
const Replicate<Derived,RowFactor,ColFactor> replicate() const;
const Replicate<Derived,Dynamic,Dynamic> replicate(int rowFacor,int colFactor) const;
Eigen::Reverse<Derived, BothDirections> reverse();
const Eigen::Reverse<Derived, BothDirections> reverse() const;
void reverseInPlace();
@ -630,11 +630,12 @@ template<typename Derived> class MatrixBase
typedef Block<Derived,
ei_traits<Derived>::ColsAtCompileTime==1 ? SizeMinusOne : 1,
ei_traits<Derived>::ColsAtCompileTime==1 ? 1 : SizeMinusOne> StartMinusOne;
typedef CwiseUnaryOp<ei_scalar_quotient1_op<typename ei_traits<Derived>::Scalar>,
typedef CwiseUnaryOp<ei_scalar_quotient1_op<typename ei_traits<Derived>::Scalar>,
NestByValue<StartMinusOne> > HNormalizedReturnType;
const HNormalizedReturnType hnormalized() const;
const Homogeneous<Derived,MatrixBase<Derived>::ColsAtCompileTime==1?Vertical:Horizontal> homogeneous() const;
typedef Homogeneous<Derived,MatrixBase<Derived>::ColsAtCompileTime==1?Vertical:Horizontal> HomogeneousReturnType;
const HomogeneousReturnType homogeneous() const;
/////////// Sparse module ///////////

View File

@ -26,7 +26,7 @@
#define EIGEN_HOMOGENEOUS_H
/** \geometry_module \ingroup Geometry_Module
* \nonstableyet
* \nonstableyet
* \class Homogeneous
*
* \brief Expression of one (or a set of) homogeneous vector(s)
@ -83,7 +83,7 @@ template<typename MatrixType,int Direction> class Homogeneous
return 1;
return m_matrix.coeff(row, col);
}
template<typename Rhs>
inline const ei_homogeneous_right_product_impl<Homogeneous,Rhs>
operator* (const MatrixBase<Rhs>& rhs) const
@ -91,16 +91,16 @@ template<typename MatrixType,int Direction> class Homogeneous
ei_assert(Direction==Horizontal);
return ei_homogeneous_right_product_impl<Homogeneous,Rhs>(m_matrix,rhs.derived());
}
template<typename Lhs> friend
template<typename Lhs> friend
inline const ei_homogeneous_left_product_impl<Homogeneous,Lhs>
operator* (const MatrixBase<Lhs>& lhs, const Homogeneous& rhs)
{
ei_assert(Direction==Vertical);
return ei_homogeneous_left_product_impl<Homogeneous,Lhs>(lhs.derived(),rhs.m_matrix);
}
template<typename Scalar, int Dim, int Mode> friend
template<typename Scalar, int Dim, int Mode> friend
inline const ei_homogeneous_left_product_impl<Homogeneous,
typename Transform<Scalar,Dim,Mode>::AffinePart>
operator* (const Transform<Scalar,Dim,Mode>& tr, const Homogeneous& rhs)
@ -109,8 +109,8 @@ template<typename MatrixType,int Direction> class Homogeneous
return ei_homogeneous_left_product_impl<Homogeneous,typename Transform<Scalar,Dim,Mode>::AffinePart>
(tr.affine(),rhs.m_matrix);
}
template<typename Scalar, int Dim> friend
template<typename Scalar, int Dim> friend
inline const ei_homogeneous_left_product_impl<Homogeneous,
typename Transform<Scalar,Dim,Projective>::MatrixType>
operator* (const Transform<Scalar,Dim,Projective>& tr, const Homogeneous& rhs)
@ -125,9 +125,9 @@ template<typename MatrixType,int Direction> class Homogeneous
};
/** \geometry_module
* \nonstableyet
* \nonstableyet
* \return an expression of the equivalent homogeneous vector
*
*
* \vectoronly
*
* Example: \include MatrixBase_homogeneous.cpp
@ -136,7 +136,7 @@ template<typename MatrixType,int Direction> class Homogeneous
* \sa class Homogeneous
*/
template<typename Derived>
inline const Homogeneous<Derived,MatrixBase<Derived>::ColsAtCompileTime==1?Vertical:Horizontal>
inline const typename MatrixBase<Derived>::HomogeneousReturnType
MatrixBase<Derived>::homogeneous() const
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived);
@ -144,7 +144,7 @@ MatrixBase<Derived>::homogeneous() const
}
/** \geometry_module
* \nonstableyet
* \nonstableyet
* \returns a matrix expression of homogeneous column (or row) vectors
*
* Example: \include PartialRedux_homogeneous.cpp
@ -159,7 +159,7 @@ PartialRedux<ExpressionType,Direction>::homogeneous() const
}
/** \geometry_module
* \nonstableyet
* \nonstableyet
* \returns an expression of the homogeneous normalized vector of \c *this
*
* Example: \include MatrixBase_hnormalized.cpp
@ -177,7 +177,7 @@ MatrixBase<Derived>::hnormalized() const
}
/** \geometry_module
* \nonstableyet
* \nonstableyet
* \returns an expression of the homogeneous normalized vector of \c *this
*
* Example: \include DirectionWise_hnormalized.cpp
@ -214,7 +214,7 @@ struct ei_homogeneous_left_product_impl<Homogeneous<MatrixType,Vertical>,Lhs>
ei_homogeneous_left_product_impl(const Lhs& lhs, const MatrixType& rhs)
: m_lhs(lhs), m_rhs(rhs)
{}
template<typename Dest> void evalTo(Dest& dst) const
{
// FIXME investigate how to allow lazy evaluation of this product when possible
@ -225,7 +225,7 @@ struct ei_homogeneous_left_product_impl<Homogeneous<MatrixType,Vertical>,Lhs>
dst += m_lhs.col(m_lhs.cols()-1).rowwise()
.template replicate<MatrixType::ColsAtCompileTime>(m_rhs.cols());
}
const typename Lhs::Nested m_lhs;
const typename MatrixType::Nested m_rhs;
};
@ -240,7 +240,7 @@ struct ei_homogeneous_right_product_impl<Homogeneous<MatrixType,Horizontal>,Rhs>
ei_homogeneous_right_product_impl(const MatrixType& lhs, const Rhs& rhs)
: m_lhs(lhs), m_rhs(rhs)
{}
template<typename Dest> void evalTo(Dest& dst) const
{
// FIXME investigate how to allow lazy evaluation of this product when possible
@ -251,10 +251,10 @@ struct ei_homogeneous_right_product_impl<Homogeneous<MatrixType,Horizontal>,Rhs>
dst += m_rhs.row(m_rhs.rows()-1).colwise()
.template replicate<MatrixType::RowsAtCompileTime>(m_lhs.rows());
}
const typename MatrixType::Nested m_lhs;
const typename Rhs::Nested m_rhs;
};
#endif // EIGEN_HOMOGENEOUS_H

View File

@ -49,6 +49,14 @@ struct ei_transform_left_product_impl;
template<typename Lhs,typename Rhs> struct ei_transform_transform_product_impl;
template< typename Other,
int Mode,
int Dim,
int HDim,
int OtherRows=Other::RowsAtCompileTime,
int OtherCols=Other::ColsAtCompileTime>
struct ei_transform_construct_from_matrix;
/** \geometry_module \ingroup Geometry_Module
*
* \class Transform
@ -69,19 +77,19 @@ template<typename Lhs,typename Rhs> struct ei_transform_transform_product_impl;
* is available through the matrix() method. To understand the behavior of
* this class you have to think a Transform object as its internal
* matrix representation. The chosen convention is right multiply:
*
*
* \code v' = T * v \endcode
*
*
* Thefore, an affine transformation matrix M is shaped like this:
*
*
* \f$ \left( \begin{array}{cc}
* linear & translation\\
* 0 ... 0 & 1
* \end{array} \right) \f$
*
*
* Note that for a provective transformation the last row can be anything,
* and then the interpretation of different parts might be sighlty different.
*
*
* However, unlike a plain matrix, the Transform class provides many features
* simplifying both its assembly and usage. In particular, it can be composed
* with any other transformations (Transform,Trnaslation,RotationBase,Matrix)
@ -138,7 +146,7 @@ template<typename Lhs,typename Rhs> struct ei_transform_transform_product_impl;
* transformation of non homogeneous vectors by an affine transformation. In
* that case the last matrix row can be ignored, and the product returns non
* homogeneous vectors.
*
*
* Since, for instance, a Dim x Dim matrix is interpreted as a linear transformation,
* it is not possible to directly transform Dim vectors stored in a Dim x Dim matrix.
* The solution is either to use a Dim x Dynamic matrix or explicitely request a
@ -147,7 +155,7 @@ template<typename Lhs,typename Rhs> struct ei_transform_transform_product_impl;
* m' = T * m.colwise().homogeneous();
* \endcode
* Note that there is zero overhead.
*
*
* Conversion methods from/to Qt's QMatrix and QTransform are available if the
* preprocessor token EIGEN_QT_SUPPORT is defined.
*
@ -193,7 +201,7 @@ public:
inline Transform() { }
inline Transform(const Transform& other)
{
{
m_matrix = other.m_matrix;
}
@ -205,95 +213,37 @@ public:
inline Transform& operator=(const Transform& other)
{ m_matrix = other.m_matrix; return *this; }
template<typename OtherDerived, bool IsCompact, int _Rows, int _Cols>
struct construct_from_matrix;
template<typename OtherDerived> struct construct_from_matrix<OtherDerived, false, Dim, Dim>
{
static inline void run(Transform *transform, const MatrixBase<OtherDerived>& other)
{
transform->linear() = other;
transform->translation().setZero();
transform->makeAffine();
}
};
template<typename OtherDerived> struct construct_from_matrix<OtherDerived, true, Dim, Dim>
{
static inline void run(Transform *transform, const MatrixBase<OtherDerived>& other)
{
transform->linear() = other;
transform->translation().setZero();
}
};
template<typename OtherDerived> struct construct_from_matrix<OtherDerived, false, Dim, HDim>
{
static inline void run(Transform *transform, const MatrixBase<OtherDerived>& other)
{
transform->affine() = other;
transform->makeAffine();
}
};
template<typename OtherDerived> struct construct_from_matrix<OtherDerived, true, Dim, HDim>
{
static inline void run(Transform *transform, const MatrixBase<OtherDerived>& other)
{ transform->affine() = other; }
};
template<typename OtherDerived> struct construct_from_matrix<OtherDerived, false, HDim, HDim>
{
static inline void run(Transform *transform, const MatrixBase<OtherDerived>& other)
{ transform->matrix() = other; }
};
template<typename OtherDerived> struct construct_from_matrix<OtherDerived, true, HDim, HDim>
{
static inline void run(Transform *transform, const MatrixBase<OtherDerived>& other)
{ transform->matrix() = other.template block<Dim,HDim>(0,0); }
};
typedef ei_transform_take_affine_part<Transform> take_affine_part;
/** Constructs and initializes a transformation from a Dim^2 or a (Dim+1)^2 matrix. */
template<typename OtherDerived>
inline explicit Transform(const MatrixBase<OtherDerived>& other)
{
construct_from_matrix<OtherDerived,
int(Mode)==int(AffineCompact),
int(OtherDerived::RowsAtCompileTime),
int(OtherDerived::ColsAtCompileTime)>::run(this, other);
ei_transform_construct_from_matrix<OtherDerived,Mode,Dim,HDim>::run(this, other.derived());
}
/** Set \c *this from a Dim^2 or (Dim+1)^2 matrix. */
template<typename OtherDerived>
inline Transform& operator=(const MatrixBase<OtherDerived>& other)
{
construct_from_matrix<OtherDerived,
int(Mode)==int(AffineCompact),
int(OtherDerived::RowsAtCompileTime),
int(OtherDerived::ColsAtCompileTime)>::run(this, other);
ei_transform_construct_from_matrix<OtherDerived,Mode,Dim,HDim>::run(this, other.derived());
return *this;
}
template<int OtherMode>
inline Transform(const Transform<Scalar,Dim,OtherMode>& other)
{
ei_assert(OtherMode!=Projective && "You cannot directly assign a projective transform to an affine one.");
typedef typename Transform<Scalar,Dim,OtherMode>::MatrixType OtherMatrixType;
construct_from_matrix<OtherMatrixType,
int(Mode)==int(AffineCompact),
int(OtherMatrixType::RowsAtCompileTime),
int(OtherMatrixType::ColsAtCompileTime)>::run(this, other.matrix());
ei_transform_construct_from_matrix<OtherMatrixType,Mode,Dim,HDim>::run(this, other.matrix());
}
template<typename OtherDerived,typename OtherEvalType>
Transform(const ReturnByValue<OtherDerived,OtherEvalType>& other)
{
other.evalTo(*this);
}
template<typename OtherDerived,typename OtherEvalType>
Transform& operator=(const ReturnByValue<OtherDerived,OtherEvalType>& other)
{
@ -326,7 +276,7 @@ public:
inline const LinearPart linear() const { return m_matrix.template block<Dim,Dim>(0,0); }
/** \returns a writable expression of the linear part of the transformation */
inline LinearPart linear() { return m_matrix.template block<Dim,Dim>(0,0); }
/** \returns a read-only expression of the Dim x HDim affine part of the transformation */
inline const AffinePart affine() const { return take_affine_part::run(m_matrix); }
/** \returns a writable expression of the Dim x HDim affine part of the transformation */
@ -365,7 +315,7 @@ public:
inline const typename ei_transform_left_product_impl<OtherDerived,Mode,_Dim,_Dim+1>::ResultType
operator * (const MatrixBase<OtherDerived> &a, const Transform &b)
{ return ei_transform_left_product_impl<OtherDerived,Mode,Dim,HDim>::run(a.derived(),b); }
template<typename OtherDerived>
inline Transform& operator*=(const MatrixBase<OtherDerived>& other) { return *this = *this * other; }
@ -374,7 +324,7 @@ public:
{
return ei_transform_transform_product_impl<Transform,Transform>::run(*this,other);
}
/** Contatenates two different transformations */
template<int OtherMode>
inline const typename ei_transform_transform_product_impl<
@ -474,7 +424,7 @@ public:
matrix().coeffRef(Dim,Dim) = 1;
}
}
/** \internal
* \returns the Dim x Dim linear part if the transformation is affine,
* and the HDim x Dim part for projective transformations.
@ -487,7 +437,7 @@ public:
*/
inline const Block<MatrixType,int(Mode)==int(Projective)?HDim:Dim,Dim> linearExt() const
{ return m_matrix.template block<int(Mode)==int(Projective)?HDim:Dim,Dim>(0,0); }
/** \internal
* \returns the translation part if the transformation is affine,
* and the last column for projective transformations.
@ -500,7 +450,7 @@ public:
*/
inline const Block<MatrixType,int(Mode)==int(Projective)?HDim:Dim,1> translationExt() const
{ return m_matrix.template block<int(Mode)==int(Projective)?HDim:Dim,1>(0,Dim); }
};
/** \ingroup Geometry_Module */
@ -889,7 +839,7 @@ template<typename Scalar, int Dim, int Mode>
template<typename ScalingMatrixType, typename RotationMatrixType>
void Transform<Scalar,Dim,Mode>::computeScalingRotation(ScalingMatrixType *scaling, RotationMatrixType *rotation) const
{
linear().svd().computeScalingRotation(scaling, rotation);
linear().svd().computeScalingRotation(scaling, rotation);
}
/** Convenient method to set \c *this from a position, orientation and scale
@ -958,6 +908,10 @@ Transform<Scalar,Dim,Mode>::inverse(TransformTraits hint) const
}
}
/*****************************************************
*** Specializations of take affine part ***
*****************************************************/
template<typename TransformType> struct ei_transform_take_affine_part {
typedef typename TransformType::MatrixType MatrixType;
typedef typename TransformType::AffinePart AffinePart;
@ -974,6 +928,45 @@ struct ei_transform_take_affine_part<Transform<Scalar,Dim,AffineCompact> > {
static inline const MatrixType& run(const MatrixType& m) { return m; }
};
/*****************************************************
*** Specializations of construct from matix ***
*****************************************************/
template<typename Other, int Mode, int Dim, int HDim>
struct ei_transform_construct_from_matrix<Other, Mode,Dim,HDim, Dim,Dim>
{
static inline void run(Transform<typename ei_traits<Other>::Scalar,Dim,Mode> *transform, const Other& other)
{
transform->linear() = other;
transform->translation().setZero();
transform->makeAffine();
}
};
template<typename Other, int Mode, int Dim, int HDim>
struct ei_transform_construct_from_matrix<Other, Mode,Dim,HDim, Dim,HDim>
{
static inline void run(Transform<typename ei_traits<Other>::Scalar,Dim,Mode> *transform, const Other& other)
{
transform->affine() = other;
transform->makeAffine();
}
};
template<typename Other, int Mode, int Dim, int HDim>
struct ei_transform_construct_from_matrix<Other, Mode,Dim,HDim, HDim,HDim>
{
static inline void run(Transform<typename ei_traits<Other>::Scalar,Dim,Mode> *transform, const Other& other)
{ transform->matrix() = other; }
};
template<typename Other, int Dim, int HDim>
struct ei_transform_construct_from_matrix<Other, AffineCompact,Dim,HDim, HDim,HDim>
{
static inline void run(Transform<typename ei_traits<Other>::Scalar,Dim,AffineCompact> *transform, const Other& other)
{ transform->matrix() = other.template block<Dim,HDim>(0,0); }
};
/*****************************************************
*** Specializations of operator* with a MatrixBase ***
*****************************************************/