mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-12 19:59:05 +08:00
Simplified to product templates to a minimum of template parameters.
Removed the ei_is_any_projective helper and added ei_transform_traits.
This commit is contained in:
parent
a64aabf73c
commit
610d79e686
@ -3,6 +3,7 @@
|
|||||||
//
|
//
|
||||||
// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
|
// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
|
||||||
// Copyright (C) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>
|
// Copyright (C) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>
|
||||||
|
// Copyright (C) 2010 Hauke Heibel <hauke.heibel@gmail.com>
|
||||||
//
|
//
|
||||||
// Eigen is free software; you can redistribute it and/or
|
// Eigen is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of the GNU Lesser General Public
|
// modify it under the terms of the GNU Lesser General Public
|
||||||
@ -26,28 +27,23 @@
|
|||||||
#ifndef EIGEN_TRANSFORM_H
|
#ifndef EIGEN_TRANSFORM_H
|
||||||
#define EIGEN_TRANSFORM_H
|
#define EIGEN_TRANSFORM_H
|
||||||
|
|
||||||
template<typename Transform, typename OtherTransform>
|
template<typename Transform>
|
||||||
struct ei_is_any_projective
|
struct ei_transform_traits
|
||||||
{
|
{
|
||||||
static const bool value =
|
enum
|
||||||
((int)Transform::Mode == Projective) ||
|
{
|
||||||
((int)OtherTransform::Mode == Projective);
|
Dim = Transform::Dim,
|
||||||
|
HDim = Transform::HDim,
|
||||||
|
Mode = Transform::Mode,
|
||||||
|
IsProjective = (Mode==Projective)
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
// Note that we have to pass Dim and HDim because it is not allowed to use a template
|
template< typename TransformType,
|
||||||
// parameter to define a template specialization. To be more precise, in the following
|
typename MatrixType,
|
||||||
// specializations, it is not allowed to use Dim+1 instead of HDim.
|
bool IsProjective = ei_transform_traits<TransformType>::IsProjective>
|
||||||
template< typename Other,
|
|
||||||
int Mode,
|
|
||||||
int Dim,
|
|
||||||
int HDim,
|
|
||||||
int OtherRows=Other::RowsAtCompileTime,
|
|
||||||
int OtherCols=Other::ColsAtCompileTime,
|
|
||||||
bool IsProjective = (Mode==(int)Projective)>
|
|
||||||
struct ei_transform_right_product_impl;
|
struct ei_transform_right_product_impl;
|
||||||
|
|
||||||
template<typename TransformType> struct ei_transform_take_affine_part;
|
|
||||||
|
|
||||||
template< typename Other,
|
template< typename Other,
|
||||||
int Mode,
|
int Mode,
|
||||||
int Dim,
|
int Dim,
|
||||||
@ -58,7 +54,9 @@ struct ei_transform_left_product_impl;
|
|||||||
|
|
||||||
template< typename Lhs,
|
template< typename Lhs,
|
||||||
typename Rhs,
|
typename Rhs,
|
||||||
bool AnyProjective = ei_is_any_projective<Lhs,Rhs>::value >
|
bool AnyProjective =
|
||||||
|
ei_transform_traits<Lhs>::IsProjective ||
|
||||||
|
ei_transform_traits<Lhs>::IsProjective>
|
||||||
struct ei_transform_transform_product_impl;
|
struct ei_transform_transform_product_impl;
|
||||||
|
|
||||||
template< typename Other,
|
template< typename Other,
|
||||||
@ -69,6 +67,8 @@ template< typename Other,
|
|||||||
int OtherCols=Other::ColsAtCompileTime>
|
int OtherCols=Other::ColsAtCompileTime>
|
||||||
struct ei_transform_construct_from_matrix;
|
struct ei_transform_construct_from_matrix;
|
||||||
|
|
||||||
|
template<typename TransformType> struct ei_transform_take_affine_part;
|
||||||
|
|
||||||
/** \geometry_module \ingroup Geometry_Module
|
/** \geometry_module \ingroup Geometry_Module
|
||||||
*
|
*
|
||||||
* \class Transform
|
* \class Transform
|
||||||
@ -354,9 +354,9 @@ public:
|
|||||||
*/
|
*/
|
||||||
// note: this function is defined here because some compilers cannot find the respective declaration
|
// note: this function is defined here because some compilers cannot find the respective declaration
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
EIGEN_STRONG_INLINE const typename ei_transform_right_product_impl<OtherDerived,Mode,_Dim,_Dim+1>::ResultType
|
EIGEN_STRONG_INLINE const typename ei_transform_right_product_impl<Transform, OtherDerived>::ResultType
|
||||||
operator * (const EigenBase<OtherDerived> &other) const
|
operator * (const EigenBase<OtherDerived> &other) const
|
||||||
{ return ei_transform_right_product_impl<OtherDerived,Mode,Dim,HDim>::run(*this,other.derived()); }
|
{ return ei_transform_right_product_impl<Transform, OtherDerived>::run(*this,other.derived()); }
|
||||||
|
|
||||||
/** \returns the product expression of a transformation matrix \a a times a transform \a b
|
/** \returns the product expression of a transformation matrix \a a times a transform \a b
|
||||||
*
|
*
|
||||||
@ -1109,30 +1109,35 @@ struct ei_transform_product_result
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
template< typename Other, int Mode, int Dim, int HDim, int OtherCols >
|
template< typename TransformType, typename MatrixType >
|
||||||
struct ei_transform_right_product_impl<Other, Mode, Dim, HDim, HDim, OtherCols, true>
|
struct ei_transform_right_product_impl< TransformType, MatrixType, true >
|
||||||
{
|
{
|
||||||
typedef typename Other::Scalar Scalar;
|
typedef typename MatrixType::PlainObject ResultType;
|
||||||
typedef typename Other::PlainObject ResultType;
|
|
||||||
|
|
||||||
EIGEN_STRONG_INLINE static ResultType run(const Transform<Scalar,Dim,Projective>& T, const Other& other)
|
EIGEN_STRONG_INLINE static ResultType run(const TransformType& T, const MatrixType& other)
|
||||||
{
|
{
|
||||||
return T.matrix() * other;
|
return T.matrix() * other;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template< typename Other, int Mode, int Dim, int HDim, int OtherRows, int OtherCols >
|
template< typename TransformType, typename MatrixType >
|
||||||
struct ei_transform_right_product_impl<Other, Mode, Dim, HDim, OtherRows, OtherCols, false>
|
struct ei_transform_right_product_impl< TransformType, MatrixType, false >
|
||||||
{
|
{
|
||||||
typedef typename Other::Scalar Scalar;
|
enum {
|
||||||
typedef typename Other::PlainObject ResultType;
|
Dim = TransformType::Dim,
|
||||||
|
HDim = TransformType::HDim,
|
||||||
|
OtherRows = MatrixType::RowsAtCompileTime,
|
||||||
|
OtherCols = MatrixType::ColsAtCompileTime
|
||||||
|
};
|
||||||
|
|
||||||
EIGEN_STRONG_INLINE static ResultType run(const Transform<Scalar,Dim,Mode>& T, const Other& other)
|
typedef typename MatrixType::PlainObject ResultType;
|
||||||
|
|
||||||
|
EIGEN_STRONG_INLINE static ResultType run(const TransformType& T, const MatrixType& other)
|
||||||
{
|
{
|
||||||
EIGEN_STATIC_ASSERT(OtherRows==Dim || OtherRows==HDim, YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES);
|
EIGEN_STATIC_ASSERT(OtherRows==Dim || OtherRows==HDim, YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES);
|
||||||
|
|
||||||
typedef Block<ResultType, Dim, OtherCols> TopLeftLhs;
|
typedef Block<ResultType, Dim, OtherCols> TopLeftLhs;
|
||||||
typedef Block<Other, Dim, OtherCols> TopLeftRhs;
|
typedef Block<MatrixType, Dim, OtherCols> TopLeftRhs;
|
||||||
|
|
||||||
ResultType res(other.rows(),other.cols());
|
ResultType res(other.rows(),other.cols());
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user