diff --git a/Eigen/src/Array/ArrayBase.h b/Eigen/src/Array/ArrayBase.h index 644c3bc1f..d59f1e755 100644 --- a/Eigen/src/Array/ArrayBase.h +++ b/Eigen/src/Array/ArrayBase.h @@ -179,27 +179,6 @@ template class ArrayBase // const VectorwiseOp colwise() const; // VectorwiseOp colwise(); -// template -// const Select -// select(const ArrayBase& thenMatrix, -// const ArrayBase& elseMatrix) const; - -// template -// inline const Select > -// select(const ArrayBase& thenMatrix, typename ThenDerived::Scalar elseScalar) const; - -// template -// inline const Select, ElseDerived > -// select(typename ElseDerived::Scalar thenScalar, const ArrayBase& elseMatrix) const; - -// template -// const Replicate replicate() const; -// const Replicate replicate(int rowFacor,int colFactor) const; - -// Eigen::Reverse reverse(); -// const Eigen::Reverse reverse() const; -// void reverseInPlace(); - #ifdef EIGEN_ARRAYBASE_PLUGIN #include EIGEN_ARRAYBASE_PLUGIN #endif diff --git a/Eigen/src/Array/Replicate.h b/Eigen/src/Array/Replicate.h index 079d59d59..b17c13aa6 100644 --- a/Eigen/src/Array/Replicate.h +++ b/Eigen/src/Array/Replicate.h @@ -33,10 +33,10 @@ * \param MatrixType the type of the object we are replicating * * This class represents an expression of the multiple replication of a matrix or vector. - * It is the return type of MatrixBase::replicate() and most of the time + * It is the return type of DenseBase::replicate() and most of the time * this is the only way it is used. * - * \sa MatrixBase::replicate() + * \sa DenseBase::replicate() */ template struct ei_traits > @@ -60,11 +60,12 @@ struct ei_traits > }; template class Replicate - : public MatrixBase > + : public MatrixType::template MakeBase< Replicate >::Type { public: - EIGEN_GENERIC_PUBLIC_INTERFACE(Replicate) + typedef typename MatrixType::template MakeBase< Replicate >::Type Base; + _EIGEN_GENERIC_PUBLIC_INTERFACE(Replicate) template inline explicit Replicate(const OriginalMatrixType& matrix) @@ -106,12 +107,12 @@ template class Replicate * Example: \include MatrixBase_replicate.cpp * Output: \verbinclude MatrixBase_replicate.out * - * \sa VectorwiseOp::replicate(), MatrixBase::replicate(int,int), class Replicate + * \sa VectorwiseOp::replicate(), DenseBase::replicate(int,int), class Replicate */ template template inline const Replicate -MatrixBase::replicate() const +DenseBase::replicate() const { return Replicate(derived()); } @@ -122,11 +123,11 @@ MatrixBase::replicate() const * Example: \include MatrixBase_replicate_int_int.cpp * Output: \verbinclude MatrixBase_replicate_int_int.out * - * \sa VectorwiseOp::replicate(), MatrixBase::replicate(), class Replicate + * \sa VectorwiseOp::replicate(), DenseBase::replicate(), class Replicate */ template inline const Replicate -MatrixBase::replicate(int rowFactor,int colFactor) const +DenseBase::replicate(int rowFactor,int colFactor) const { return Replicate(derived(),rowFactor,colFactor); } @@ -137,7 +138,7 @@ MatrixBase::replicate(int rowFactor,int colFactor) const * Example: \include DirectionWise_replicate_int.cpp * Output: \verbinclude DirectionWise_replicate_int.out * - * \sa VectorwiseOp::replicate(), MatrixBase::replicate(), class Replicate + * \sa VectorwiseOp::replicate(), DenseBase::replicate(), class Replicate */ template const Replicate diff --git a/Eigen/src/Array/Reverse.h b/Eigen/src/Array/Reverse.h index d19c68ef9..44380eb48 100644 --- a/Eigen/src/Array/Reverse.h +++ b/Eigen/src/Array/Reverse.h @@ -76,11 +76,12 @@ template struct ei_reverse_packet_cond class Reverse - : public MatrixBase > + : public MatrixType::template MakeBase< Reverse >::Type { public: - EIGEN_GENERIC_PUBLIC_INTERFACE(Reverse) + typedef typename MatrixType::template MakeBase< Reverse >::Type Base; + _EIGEN_GENERIC_PUBLIC_INTERFACE(Reverse) protected: enum { @@ -168,7 +169,7 @@ template class Reverse */ template inline Reverse -MatrixBase::reverse() +DenseBase::reverse() { return derived(); } @@ -176,7 +177,7 @@ MatrixBase::reverse() /** This is the const version of reverse(). */ template inline const Reverse -MatrixBase::reverse() const +DenseBase::reverse() const { return derived(); } @@ -194,7 +195,7 @@ MatrixBase::reverse() const * * \sa reverse() */ template -inline void MatrixBase::reverseInPlace() +inline void DenseBase::reverseInPlace() { derived() = derived().reverse().eval(); } diff --git a/Eigen/src/Array/Select.h b/Eigen/src/Array/Select.h index fa4e16dac..e0f309f80 100644 --- a/Eigen/src/Array/Select.h +++ b/Eigen/src/Array/Select.h @@ -36,9 +36,9 @@ * \param ElseMatrixType the type of the \em else expression * * This class represents an expression of a coefficient wise version of the C++ ternary operator ?:. - * It is the return type of MatrixBase::select() and most of the time this is the only way it is used. + * It is the return type of DenseBase::select() and most of the time this is the only way it is used. * - * \sa MatrixBase::select(const MatrixBase&, const MatrixBase&) const + * \sa DenseBase::select(const DenseBase&, const DenseBase&) const */ template @@ -63,11 +63,12 @@ struct ei_traits > template class Select : ei_no_assignment_operator, - public MatrixBase > + public ConditionMatrixType::template MakeBase< Select >::Type { public: - EIGEN_GENERIC_PUBLIC_INTERFACE(Select) + typedef typename ConditionMatrixType::template MakeBase< Select >::Type Base; + _EIGEN_GENERIC_PUBLIC_INTERFACE(Select) Select(const ConditionMatrixType& conditionMatrix, const ThenMatrixType& thenMatrix, @@ -117,23 +118,23 @@ class Select : ei_no_assignment_operator, template template inline const Select -MatrixBase::select(const MatrixBase& thenMatrix, - const MatrixBase& elseMatrix) const +DenseBase::select(const DenseBase& thenMatrix, + const DenseBase& elseMatrix) const { return Select(derived(), thenMatrix.derived(), elseMatrix.derived()); } /** \array_module * - * Version of MatrixBase::select(const MatrixBase&, const MatrixBase&) with + * Version of DenseBase::select(const DenseBase&, const DenseBase&) with * the \em else expression being a scalar value. * - * \sa MatrixBase::select(const MatrixBase&, const MatrixBase&) const, class Select + * \sa DenseBase::select(const DenseBase&, const DenseBase&) const, class Select */ template template inline const Select > -MatrixBase::select(const MatrixBase& thenMatrix, +DenseBase::select(const DenseBase& thenMatrix, typename ThenDerived::Scalar elseScalar) const { return Select >( @@ -142,16 +143,16 @@ MatrixBase::select(const MatrixBase& thenMatrix, /** \array_module * - * Version of MatrixBase::select(const MatrixBase&, const MatrixBase&) with + * Version of DenseBase::select(const DenseBase&, const DenseBase&) with * the \em then expression being a scalar value. * - * \sa MatrixBase::select(const MatrixBase&, const MatrixBase&) const, class Select + * \sa DenseBase::select(const DenseBase&, const DenseBase&) const, class Select */ template template inline const Select, ElseDerived > -MatrixBase::select(typename ElseDerived::Scalar thenScalar, - const MatrixBase& elseMatrix) const +DenseBase::select(typename ElseDerived::Scalar thenScalar, + const DenseBase& elseMatrix) const { return Select,ElseDerived>( derived(), ElseDerived::Constant(rows(),cols(),thenScalar), elseMatrix.derived()); diff --git a/Eigen/src/Array/VectorwiseOp.h b/Eigen/src/Array/VectorwiseOp.h index 241105635..a409d4dc6 100644 --- a/Eigen/src/Array/VectorwiseOp.h +++ b/Eigen/src/Array/VectorwiseOp.h @@ -74,11 +74,12 @@ struct ei_traits > template< typename MatrixType, typename MemberOp, int Direction> class PartialReduxExpr : ei_no_assignment_operator, - public MatrixBase > + public MatrixType::template MakeBase< PartialReduxExpr >::Type { public: - EIGEN_GENERIC_PUBLIC_INTERFACE(PartialReduxExpr) + typedef typename MatrixType::template MakeBase< PartialReduxExpr >::Type Base; + _EIGEN_GENERIC_PUBLIC_INTERFACE(PartialReduxExpr) typedef typename ei_traits::MatrixTypeNested MatrixTypeNested; typedef typename ei_traits::_MatrixTypeNested _MatrixTypeNested; diff --git a/Eigen/src/Core/DenseBase.h b/Eigen/src/Core/DenseBase.h index d4808cf06..58312e120 100644 --- a/Eigen/src/Core/DenseBase.h +++ b/Eigen/src/Core/DenseBase.h @@ -37,6 +37,7 @@ */ template class DenseBase #ifndef EIGEN_PARSED_BY_DOXYGEN +// : public AnyMatrixBase : public ei_special_scalar_op_base::Scalar, typename NumTraits::Scalar>::Real> #endif // not EIGEN_PARSED_BY_DOXYGEN diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h index 9cb13cf9b..4c03bfe24 100644 --- a/Eigen/src/Core/MatrixBase.h +++ b/Eigen/src/Core/MatrixBase.h @@ -61,8 +61,7 @@ template class MatrixBase /** Construct the base class type for the derived class OtherDerived */ template struct MakeBase { typedef MatrixBase Type; }; - using ei_special_scalar_op_base::Scalar, - typename NumTraits::Scalar>::Real>::operator*; +// using DenseBase::operator*; class InnerIterator; @@ -442,29 +441,8 @@ template class MatrixBase const VectorwiseOp colwise() const; VectorwiseOp colwise(); - template - const Select - select(const MatrixBase& thenMatrix, - const MatrixBase& elseMatrix) const; - - template - inline const Select > - select(const MatrixBase& thenMatrix, typename ThenDerived::Scalar elseScalar) const; - - template - inline const Select, ElseDerived > - select(typename ElseDerived::Scalar thenScalar, const MatrixBase& elseMatrix) const; - template RealScalar lpNorm() const; - template - const Replicate replicate() const; - const Replicate replicate(int rowFacor,int colFactor) const; - - Eigen::Reverse reverse(); - const Eigen::Reverse reverse() const; - void reverseInPlace(); - ArrayWrapper array() { return derived(); } const ArrayWrapper array() const { return derived(); } diff --git a/Eigen/src/Core/util/XprHelper.h b/Eigen/src/Core/util/XprHelper.h index 5e37194f3..6b9dbc781 100644 --- a/Eigen/src/Core/util/XprHelper.h +++ b/Eigen/src/Core/util/XprHelper.h @@ -237,7 +237,7 @@ struct ei_special_scalar_op_base : public AnyM inline friend const CwiseUnaryOp, Derived> operator*(const OtherScalar& scalar, const Derived& matrix) - { return matrix*scalar; } + { return static_cast(matrix).operator*(scalar); } }; /** \internal Gives the type of a sub-matrix or sub-vector of a matrix of type \a ExpressionType and size \a Size diff --git a/Eigen/src/Geometry/Transform.h b/Eigen/src/Geometry/Transform.h index 4ee036140..cf961b98b 100644 --- a/Eigen/src/Geometry/Transform.h +++ b/Eigen/src/Geometry/Transform.h @@ -612,7 +612,7 @@ Transform& Transform::scale(const MatrixBase &other) { EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,int(Dim)) - linearExt() = (linearExt() * other.asDiagonal()).lazy(); + linearExt().noalias() = (linearExt() * other.asDiagonal()); return *this; } @@ -637,7 +637,7 @@ Transform& Transform::prescale(const MatrixBase &other) { EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,int(Dim)) - m_matrix.template block(0,0) = (other.asDiagonal() * m_matrix.template block(0,0)).lazy(); + m_matrix.template block(0,0).noalias() = (other.asDiagonal() * m_matrix.template block(0,0)); return *this; } @@ -1118,7 +1118,7 @@ struct ei_transform_right_product_impl { TransformType res; res.matrix().col(Dim) = tr.matrix().col(Dim); - res.linearExt() = (tr.linearExt() * other).lazy(); + res.linearExt().noalias() = (tr.linearExt() * other); if(Mode==Affine) res.matrix().row(Dim).template start() = tr.matrix().row(Dim).template start(); return res; @@ -1136,7 +1136,7 @@ struct ei_transform_right_product_impl { TransformType res; const int Rows = Mode==Projective ? HDim : Dim; - res.matrix().template block(0,0) = (tr.linearExt() * other).lazy(); + res.matrix().template block(0,0).noalias() = (tr.linearExt() * other); res.translationExt() += tr.translationExt(); if(Mode!=Affine) res.makeAffine(); @@ -1152,7 +1152,7 @@ struct ei_transform_right_product_impl typedef typename TransformType::MatrixType MatrixType; typedef Transform ResultType; static ResultType run(const TransformType& tr, const Other& other) - { return ResultType((tr.matrix() * other).lazy()); } + { return ResultType(tr.matrix() * other); } }; // AffineCompact * generic matrix => Projective @@ -1164,7 +1164,7 @@ struct ei_transform_right_product_impl static ResultType run(const TransformType& tr, const Other& other) { ResultType res; - res.affine() = (tr.matrix() * other).lazy(); + res.affine().noalias() = tr.matrix() * other; res.makeAffine(); return res; } @@ -1179,7 +1179,7 @@ struct ei_transform_left_product_impl typedef typename TransformType::MatrixType MatrixType; typedef Transform ResultType; static ResultType run(const Other& other,const TransformType& tr) - { return ResultType((other * tr.matrix()).lazy()); } + { return ResultType(other * tr.matrix()); } }; // generic HDim x HDim matrix * AffineCompact => Projective @@ -1192,7 +1192,7 @@ struct ei_transform_left_product_impl static ResultType run(const Other& other,const TransformType& tr) { ResultType res; - res.matrix() = (other.template block(0,0) * tr.matrix()).lazy(); + res.matrix().noalias() = other.template block(0,0) * tr.matrix(); res.matrix().col(Dim) += other.col(Dim); return res; } @@ -1208,7 +1208,7 @@ struct ei_transform_left_product_impl static ResultType run(const Other& other,const TransformType& tr) { ResultType res; - res.affine() = (other * tr.matrix()).lazy(); + res.affine().noalias() = other * tr.matrix(); res.matrix().row(Dim) = tr.matrix().row(Dim); return res; } @@ -1224,7 +1224,7 @@ struct ei_transform_left_product_impl static ResultType run(const Other& other,const TransformType& tr) { ResultType res; - res.matrix() = (other.template block(0,0) * tr.matrix()).lazy(); + res.matrix().noalias() = other.template block(0,0) * tr.matrix(); res.translation() += other.col(Dim); return res; } @@ -1242,8 +1242,8 @@ struct ei_transform_left_product_impl TransformType res; if(Mode!=AffineCompact) res.matrix().row(Dim) = tr.matrix().row(Dim); - res.matrix().template corner(TopLeft) - = (other * tr.matrix().template corner(TopLeft)).lazy(); + res.matrix().template corner(TopLeft).noalias() + = other * tr.matrix().template corner(TopLeft); return res; } }; @@ -1259,7 +1259,7 @@ struct ei_transform_transform_product_impl,Transform< typedef TransformType ResultType; static ResultType run(const TransformType& lhs, const TransformType& rhs) { - return ResultType((lhs.matrix() * rhs.matrix()).lazy()); + return ResultType(lhs.matrix() * rhs.matrix()); } }; @@ -1297,7 +1297,7 @@ struct ei_transform_transform_product_impl, typedef Transform ResultType; static ResultType run(const Lhs& lhs, const Rhs& rhs) { - return ResultType((lhs.matrix() * rhs.matrix()).lazy()); + return ResultType(lhs.matrix() * rhs.matrix()); } }; diff --git a/Eigen/src/plugins/MatrixCwiseBinaryOps.h b/Eigen/src/plugins/MatrixCwiseBinaryOps.h index 74b7a5610..2b9621977 100644 --- a/Eigen/src/plugins/MatrixCwiseBinaryOps.h +++ b/Eigen/src/plugins/MatrixCwiseBinaryOps.h @@ -32,13 +32,28 @@ * * \sa class CwiseBinaryOp, cwiseAbs2 */ + +#define EIGEN_CWISE_PRODUCT_RETURN_TYPE \ + CwiseBinaryOp< \ + ei_scalar_product_op< \ + typename ei_scalar_product_traits< \ + typename ei_traits::Scalar, \ + typename ei_traits::Scalar \ + >::ReturnType \ + >, \ + Derived, \ + OtherDerived \ + > + template -EIGEN_STRONG_INLINE const CwiseBinaryOp, Derived, OtherDerived> +EIGEN_STRONG_INLINE const EIGEN_CWISE_PRODUCT_RETURN_TYPE cwiseProduct(const EIGEN_CURRENT_STORAGE_BASE_CLASS &other) const { - return CwiseBinaryOp, Derived, OtherDerived>(derived(), other.derived()); + return EIGEN_CWISE_PRODUCT_RETURN_TYPE(derived(), other.derived()); } +#undef EIGEN_CWISE_PRODUCT_RETURN_TYPE + /** \returns an expression of the coefficient-wise == operator of *this and \a other * * \warning this performs an exact comparison, which is generally a bad idea with floating-point types. diff --git a/test/geo_transformations.cpp b/test/geo_transformations.cpp index 2477ea925..bcef908d8 100644 --- a/test/geo_transformations.cpp +++ b/test/geo_transformations.cpp @@ -128,7 +128,7 @@ template void transformations(void) t0.pretranslate(v0); t0.scale(v1); t1.linear() = q1.conjugate().toRotationMatrix(); - t1.prescale(v1.cwise().inverse()); + t1.prescale(v1.cwiseInverse()); t1.translate(-v0); VERIFY((t0 * t1).matrix().isIdentity(test_precision())); @@ -183,7 +183,7 @@ template void transformations(void) Transform3 t6(sv3); t4 = sv3; VERIFY_IS_APPROX(t6.matrix(), t4.matrix()); - t4.scale(v3.cwise().inverse()); + t4.scale(v3.cwiseInverse()); VERIFY_IS_APPROX(t4.matrix(), MatrixType::Identity()); t4 *= sv3; VERIFY_IS_APPROX(t6.matrix(), t4.matrix()); @@ -213,7 +213,7 @@ template void transformations(void) t21.setIdentity(); t21.linear() = Rotation2D(-a).toRotationMatrix(); VERIFY( (t20.fromPositionOrientationScale(v20,a,v21) - * (t21.prescale(v21.cwise().inverse()).translate(-v20))).matrix().isIdentity(test_precision()) ); + * (t21.prescale(v21.cwiseInverse()).translate(-v20))).matrix().isIdentity(test_precision()) ); // Transform - new API // 3D diff --git a/test/linearstructure.cpp b/test/linearstructure.cpp index f2ffc33bd..3e570f2a0 100644 --- a/test/linearstructure.cpp +++ b/test/linearstructure.cpp @@ -79,7 +79,7 @@ template void linearStructure(const MatrixType& m) // use .block to disable vectorization and compare to the vectorized version VERIFY_IS_APPROX(m1+m1.block(0,0,rows,cols), m1+m1); - VERIFY_IS_APPROX(m1.cwise() * m1.block(0,0,rows,cols), m1.cwise() * m1); + VERIFY_IS_APPROX(m1.cwiseProduct(m1.block(0,0,rows,cols)), m1.cwiseProduct(m1)); VERIFY_IS_APPROX(m1 - m1.block(0,0,rows,cols), m1 - m1); VERIFY_IS_APPROX(m1.block(0,0,rows,cols) * s1, m1 * s1); }