aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2012-02-07 17:12:15 +0100
committerGravatar Gael Guennebaud <g.gael@free.fr>2012-02-07 17:12:15 +0100
commit38364026311d3e0dee50c4cdbc7f8205398cbaf0 (patch)
tree51a68e9b4b57d5268509c50515e2587107932dac /Eigen
parentff67676c0bdfb8192b62d88480dcf94b87bb7264 (diff)
Improve performance of some Transform<> operations by better preserving the alignment status.
There probably many other places in Transform.h where such optimizations could be done.
Diffstat (limited to 'Eigen')
-rw-r--r--Eigen/src/Geometry/Transform.h26
1 files changed, 12 insertions, 14 deletions
diff --git a/Eigen/src/Geometry/Transform.h b/Eigen/src/Geometry/Transform.h
index 46cf6e579..a9e4e3c6d 100644
--- a/Eigen/src/Geometry/Transform.h
+++ b/Eigen/src/Geometry/Transform.h
@@ -207,9 +207,9 @@ public:
/** type of the matrix used to represent the linear part of the transformation */
typedef Matrix<Scalar,Dim,Dim,Options> LinearMatrixType;
/** type of read/write reference to the linear part of the transformation */
- typedef Block<MatrixType,Dim,Dim> LinearPart;
+ typedef Block<MatrixType,Dim,Dim,int(Mode)==(AffineCompact)> LinearPart;
/** type of read reference to the linear part of the transformation */
- typedef const Block<ConstMatrixType,Dim,Dim> ConstLinearPart;
+ typedef const Block<ConstMatrixType,Dim,Dim,int(Mode)==(AffineCompact)> ConstLinearPart;
/** type of read/write reference to the affine part of the transformation */
typedef typename internal::conditional<int(Mode)==int(AffineCompact),
MatrixType&,
@@ -221,9 +221,9 @@ public:
/** type of a vector */
typedef Matrix<Scalar,Dim,1> VectorType;
/** type of a read/write reference to the translation part of the rotation */
- typedef Block<MatrixType,Dim,1> TranslationPart;
+ typedef Block<MatrixType,Dim,1,int(Mode)==(AffineCompact)> TranslationPart;
/** type of a read reference to the translation part of the rotation */
- typedef const Block<ConstMatrixType,Dim,1> ConstTranslationPart;
+ typedef const Block<ConstMatrixType,Dim,1,int(Mode)==(AffineCompact)> ConstTranslationPart;
/** corresponding translation type */
typedef Translation<Scalar,Dim> TranslationType;
@@ -382,9 +382,9 @@ public:
inline MatrixType& matrix() { return m_matrix; }
/** \returns a read-only expression of the linear part of the transformation */
- inline ConstLinearPart linear() const { return m_matrix.template block<Dim,Dim>(0,0); }
+ inline ConstLinearPart linear() const { return ConstLinearPart(m_matrix,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); }
+ inline LinearPart linear() { return LinearPart(m_matrix,0,0); }
/** \returns a read-only expression of the Dim x HDim affine part of the transformation */
inline ConstAffinePart affine() const { return take_affine_part::run(m_matrix); }
@@ -392,9 +392,9 @@ public:
inline AffinePart affine() { return take_affine_part::run(m_matrix); }
/** \returns a read-only expression of the translation vector of the transformation */
- inline ConstTranslationPart translation() const { return m_matrix.template block<Dim,1>(0,Dim); }
+ inline ConstTranslationPart translation() const { return ConstTranslationPart(m_matrix,0,Dim); }
/** \returns a writable expression of the translation vector of the transformation */
- inline TranslationPart translation() { return m_matrix.template block<Dim,1>(0,Dim); }
+ inline TranslationPart translation() { return TranslationPart(m_matrix,0,Dim); }
/** \returns an expression of the product between the transform \c *this and a matrix expression \a other
*
@@ -1247,7 +1247,7 @@ struct transform_right_product_impl< TransformType, MatrixType, 1 >
{
EIGEN_STATIC_ASSERT(OtherRows==HDim, YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES);
- typedef Block<ResultType, Dim, OtherCols> TopLeftLhs;
+ typedef Block<ResultType, Dim, OtherCols, int(MatrixType::RowsAtCompileTime)==Dim> TopLeftLhs;
ResultType res(other.rows(),other.cols());
TopLeftLhs(res, 0, 0, Dim, other.cols()).noalias() = T.affine() * other;
@@ -1273,11 +1273,9 @@ struct transform_right_product_impl< TransformType, MatrixType, 2 >
{
EIGEN_STATIC_ASSERT(OtherRows==Dim, YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES);
- typedef Block<ResultType, Dim, OtherCols> TopLeftLhs;
-
- ResultType res(other.rows(),other.cols());
- TopLeftLhs(res, 0, 0, Dim, other.cols()).noalias() = T.linear() * other;
- TopLeftLhs(res, 0, 0, Dim, other.cols()).colwise() += T.translation();
+ typedef Block<ResultType, Dim, OtherCols, true> TopLeftLhs;
+ ResultType res(Replicate<typename TransformType::ConstTranslationPart, 1, OtherCols>(T.translation(),1,other.cols()));
+ TopLeftLhs(res, 0, 0, Dim, other.cols()).noalias() += T.linear() * other;
return res;
}