diff --git a/Eigen/src/Array/CwiseOperators.h b/Eigen/src/Array/CwiseOperators.h index 185fa7b1a..0dd7bb01c 100644 --- a/Eigen/src/Array/CwiseOperators.h +++ b/Eigen/src/Array/CwiseOperators.h @@ -31,7 +31,7 @@ * * \returns an expression of the coefficient-wise square root of *this. */ template -inline const typename Cwise::template UnOp::ReturnType +inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_sqrt_op) Cwise::sqrt() const { return _expression(); @@ -41,7 +41,7 @@ Cwise::sqrt() const * * \returns an expression of the coefficient-wise exponential of *this. */ template -inline const typename Cwise::template UnOp::ReturnType +inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_exp_op) Cwise::exp() const { return _expression(); @@ -51,7 +51,7 @@ Cwise::exp() const * * \returns an expression of the coefficient-wise logarithm of *this. */ template -inline const typename Cwise::template UnOp::ReturnType +inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_log_op) Cwise::log() const { return _expression(); @@ -61,7 +61,7 @@ Cwise::log() const * * \returns an expression of the coefficient-wise cosine of *this. */ template -inline const typename Cwise::template UnOp::ReturnType +inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_cos_op) Cwise::cos() const { return _expression(); @@ -72,7 +72,7 @@ Cwise::cos() const * * \returns an expression of the coefficient-wise sine of *this. */ template -inline const typename Cwise::template UnOp::ReturnType +inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_sin_op) Cwise::sin() const { return _expression(); @@ -83,10 +83,10 @@ Cwise::sin() const * * \returns an expression of the coefficient-wise power of *this to the given exponent. */ template -inline const typename Cwise::template UnOp::ReturnType +inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_pow_op) Cwise::pow(const Scalar& exponent) const { - return typename UnOp::ReturnType(_expression(), ei_scalar_pow_op(exponent)); + return EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_pow_op)(_expression(), ei_scalar_pow_op(exponent)); } @@ -94,7 +94,7 @@ Cwise::pow(const Scalar& exponent) const * * \returns an expression of the coefficient-wise inverse of *this. */ template -inline const typename Cwise::template UnOp::ReturnType +inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_inverse_op) Cwise::inverse() const { return _expression(); @@ -104,7 +104,7 @@ Cwise::inverse() const * * \returns an expression of the coefficient-wise square of *this. */ template -inline const typename Cwise::template UnOp::ReturnType +inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_square_op) Cwise::square() const { return _expression(); @@ -114,7 +114,7 @@ Cwise::square() const * * \returns an expression of the coefficient-wise cube of *this. */ template -inline const typename Cwise::template UnOp::ReturnType +inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_cube_op) Cwise::cube() const { return _expression(); @@ -133,10 +133,10 @@ Cwise::cube() const */ template template -inline const typename Cwise::template BinOp::ReturnType +inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less) Cwise::operator<(const MatrixBase &other) const { - return typename BinOp::ReturnType(_expression(), other.derived()); + return EIGEN_CWISE_BINOP_RETURN_TYPE(std::less)(_expression(), other.derived()); } /** \array_module @@ -147,10 +147,10 @@ Cwise::operator<(const MatrixBase &other) const */ template template -inline const typename Cwise::template BinOp::ReturnType +inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less_equal) Cwise::operator<=(const MatrixBase &other) const { - return typename BinOp::ReturnType(_expression(), other.derived()); + return EIGEN_CWISE_BINOP_RETURN_TYPE(std::less_equal)(_expression(), other.derived()); } /** \array_module @@ -163,10 +163,10 @@ Cwise::operator<=(const MatrixBase &other) const */ template template -inline const typename Cwise::template BinOp::ReturnType +inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater) Cwise::operator>(const MatrixBase &other) const { - return typename BinOp::ReturnType(_expression(), other.derived()); + return EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater)(_expression(), other.derived()); } /** \array_module @@ -177,10 +177,10 @@ Cwise::operator>(const MatrixBase &other) const */ template template -inline const typename Cwise::template BinOp::ReturnType +inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater_equal) Cwise::operator>=(const MatrixBase &other) const { - return typename BinOp::ReturnType(_expression(), other.derived()); + return EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater_equal)(_expression(), other.derived()); } /** \array_module @@ -191,10 +191,10 @@ Cwise::operator>=(const MatrixBase &other) const */ template template -inline const typename Cwise::template BinOp::ReturnType +inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::equal_to) Cwise::operator==(const MatrixBase &other) const { - return typename BinOp::ReturnType(_expression(), other.derived()); + return EIGEN_CWISE_BINOP_RETURN_TYPE(std::equal_to)(_expression(), other.derived()); } /** \array_module @@ -205,10 +205,10 @@ Cwise::operator==(const MatrixBase &other) const */ template template -inline const typename Cwise::template BinOp::ReturnType +inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::not_equal_to) Cwise::operator!=(const MatrixBase &other) const { - return typename BinOp::ReturnType(_expression(), other.derived()); + return EIGEN_CWISE_BINOP_RETURN_TYPE(std::not_equal_to)(_expression(), other.derived()); } diff --git a/Eigen/src/Array/PartialRedux.h b/Eigen/src/Array/PartialRedux.h index f7e2f628c..48daad770 100644 --- a/Eigen/src/Array/PartialRedux.h +++ b/Eigen/src/Array/PartialRedux.h @@ -61,9 +61,11 @@ struct ei_traits > Flags = ((int(RowsAtCompileTime) == Dynamic || int(ColsAtCompileTime) == Dynamic) ? (unsigned int)_MatrixTypeNested::Flags : (unsigned int)_MatrixTypeNested::Flags & ~LargeBit) & HereditaryBits, - TraversalSize = Direction==Vertical ? RowsAtCompileTime : ColsAtCompileTime, - CoeffReadCost = TraversalSize * _MatrixTypeNested::CoeffReadCost - + MemberOp::template Cost::value + TraversalSize = Direction==Vertical ? RowsAtCompileTime : ColsAtCompileTime + }; + typedef typename MemberOp::template Cost CostOpType; + enum { + CoeffReadCost = TraversalSize * _MatrixTypeNested::CoeffReadCost + CostOpType::value }; }; diff --git a/Eigen/src/Cholesky/Cholesky.h b/Eigen/src/Cholesky/Cholesky.h index 02dbed399..2907f5fa7 100644 --- a/Eigen/src/Cholesky/Cholesky.h +++ b/Eigen/src/Cholesky/Cholesky.h @@ -147,7 +147,7 @@ typename Derived::Eval Cholesky::solve(const MatrixBase &b) * \returns the Cholesky decomposition of \c *this */ template -inline const Cholesky::type> +inline const Cholesky::EvalType> MatrixBase::cholesky() const { return Cholesky::type>(derived()); diff --git a/Eigen/src/Cholesky/CholeskyWithoutSquareRoot.h b/Eigen/src/Cholesky/CholeskyWithoutSquareRoot.h index ac26c88b1..1eb9904fc 100644 --- a/Eigen/src/Cholesky/CholeskyWithoutSquareRoot.h +++ b/Eigen/src/Cholesky/CholeskyWithoutSquareRoot.h @@ -159,7 +159,7 @@ typename Derived::Eval CholeskyWithoutSquareRoot::solve(const Matrix * \returns the Cholesky decomposition without square root of \c *this */ template -inline const CholeskyWithoutSquareRoot::type> +inline const CholeskyWithoutSquareRoot::EvalType> MatrixBase::choleskyNoSqrt() const { return derived(); diff --git a/Eigen/src/Core/Assign.h b/Eigen/src/Core/Assign.h index ba53e299d..fdc6577fb 100644 --- a/Eigen/src/Core/Assign.h +++ b/Eigen/src/Core/Assign.h @@ -47,20 +47,20 @@ private: enum { MightVectorize = (int(Derived::Flags) & int(OtherDerived::Flags) & ActualPacketAccessBit) - && ((int(Derived::Flags)&RowMajorBit)==(int(OtherDerived::Flags)&RowMajorBit)), - MayInnerVectorize = MightVectorize && InnerSize!=Dynamic && int(InnerSize)%int(PacketSize)==0, + && ((int(Derived::Flags)&RowMajorBit)==(int(OtherDerived::Flags)&RowMajorBit)), + MayInnerVectorize = MightVectorize && int(InnerSize)!=Dynamic && int(InnerSize)%int(PacketSize)==0, MayLinearVectorize = MightVectorize && (int(Derived::Flags) & int(OtherDerived::Flags) & LinearAccessBit), - MaySliceVectorize = MightVectorize && InnerMaxSize==Dynamic /* slice vectorization can be slow, so we only + MaySliceVectorize = MightVectorize && int(InnerMaxSize)==Dynamic /* slice vectorization can be slow, so we only want it if the slices are big, which is indicated by InnerMaxSize rather than InnerSize, think of the case of a dynamic block in a fixed-size matrix */ }; public: enum { - Vectorization = MayInnerVectorize ? InnerVectorization - : MayLinearVectorize ? LinearVectorization - : MaySliceVectorize ? SliceVectorization - : NoVectorization + Vectorization = int(MayInnerVectorize) ? int(InnerVectorization) + : int(MayLinearVectorize) ? int(LinearVectorization) + : int(MaySliceVectorize) ? int(SliceVectorization) + : int(NoVectorization) }; private: @@ -74,13 +74,13 @@ public: enum { Unrolling = (int(Vectorization) == int(InnerVectorization) || int(Vectorization) == int(NoVectorization)) ? ( - MayUnrollCompletely ? CompleteUnrolling - : MayUnrollInner ? InnerUnrolling - : NoUnrolling + int(MayUnrollCompletely) ? int(CompleteUnrolling) + : int(MayUnrollInner) ? int(InnerUnrolling) + : int(NoUnrolling) ) : int(Vectorization) == int(LinearVectorization) - ? ( MayUnrollCompletely ? CompleteUnrolling : NoUnrolling ) - : NoUnrolling + ? ( int(MayUnrollCompletely) ? int(CompleteUnrolling) : int(NoUnrolling) ) + : int(NoUnrolling) }; }; diff --git a/Eigen/src/Core/Block.h b/Eigen/src/Core/Block.h index 9e15261b3..62617172e 100644 --- a/Eigen/src/Core/Block.h +++ b/Eigen/src/Core/Block.h @@ -336,7 +336,6 @@ template class Block m_blockCols; }; - /** \returns a dynamic-size expression of a block in *this. * * \param startRow the first row in the block @@ -356,18 +355,18 @@ template class Block -inline Block MatrixBase +inline typename BlockReturnType::Type MatrixBase ::block(int startRow, int startCol, int blockRows, int blockCols) { - return Block(derived(), startRow, startCol, blockRows, blockCols); + return typename BlockReturnType::Type(derived(), startRow, startCol, blockRows, blockCols); } /** This is the const version of block(int,int,int,int). */ template -inline const Block MatrixBase +inline const typename BlockReturnType::Type MatrixBase ::block(int startRow, int startCol, int blockRows, int blockCols) const { - return Block(derived(), startRow, startCol, blockRows, blockCols); + return typename BlockReturnType::Type(derived(), startRow, startCol, blockRows, blockCols); } /** \returns a dynamic-size expression of a block in *this. @@ -389,11 +388,11 @@ inline const Block MatrixBase * \sa class Block, block(int) */ template -inline Block MatrixBase +inline typename BlockReturnType::SubVectorType MatrixBase ::block(int start, int size) { EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived); - return Block(derived(), RowsAtCompileTime == 1 ? 0 : start, + return typename BlockReturnType::SubVectorType(derived(), RowsAtCompileTime == 1 ? 0 : start, ColsAtCompileTime == 1 ? 0 : start, RowsAtCompileTime == 1 ? 1 : size, ColsAtCompileTime == 1 ? 1 : size); @@ -401,11 +400,11 @@ inline Block MatrixBase /** This is the const version of block(int,int).*/ template -inline const Block MatrixBase - ::block(int start, int size) const +inline const typename BlockReturnType::SubVectorType +MatrixBase::block(int start, int size) const { EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived); - return Block(derived(), RowsAtCompileTime == 1 ? 0 : start, + return typename BlockReturnType::SubVectorType(derived(), RowsAtCompileTime == 1 ? 0 : start, ColsAtCompileTime == 1 ? 0 : start, RowsAtCompileTime == 1 ? 1 : size, ColsAtCompileTime == 1 ? 1 : size); @@ -429,7 +428,7 @@ inline const Block MatrixBase * \sa class Block, block(int,int) */ template -inline typename MatrixBase::template SubVectorReturnType::Type +inline typename BlockReturnType::SubVectorType MatrixBase::start(int size) { EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived); @@ -443,7 +442,7 @@ MatrixBase::start(int size) /** This is the const version of start(int).*/ template -inline const typename MatrixBase::template SubVectorReturnType::Type +inline const typename BlockReturnType::SubVectorType MatrixBase::start(int size) const { EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived); @@ -473,7 +472,7 @@ MatrixBase::start(int size) const * \sa class Block, block(int,int) */ template -inline typename MatrixBase::template SubVectorReturnType::Type +inline typename BlockReturnType::SubVectorType MatrixBase::end(int size) { EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived); @@ -489,7 +488,7 @@ MatrixBase::end(int size) /** This is the const version of end(int).*/ template -inline const typename MatrixBase::template SubVectorReturnType::Type +inline const typename BlockReturnType::SubVectorType MatrixBase::end(int size) const { EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived); @@ -518,7 +517,7 @@ MatrixBase::end(int size) const */ template template -inline typename MatrixBase::template SubVectorReturnType::Type +inline typename BlockReturnType::SubVectorType MatrixBase::start() { EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived); @@ -529,7 +528,7 @@ MatrixBase::start() /** This is the const version of start().*/ template template -inline const typename MatrixBase::template SubVectorReturnType::Type +inline const typename BlockReturnType::SubVectorType MatrixBase::start() const { EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived); @@ -550,7 +549,7 @@ MatrixBase::start() const */ template template -inline typename MatrixBase::template SubVectorReturnType::Type +inline typename BlockReturnType::SubVectorType MatrixBase::end() { EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived); @@ -564,7 +563,7 @@ MatrixBase::end() /** This is the const version of end.*/ template template -inline const typename MatrixBase::template SubVectorReturnType::Type +inline const typename BlockReturnType::SubVectorType MatrixBase::end() const { EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived); @@ -594,7 +593,7 @@ MatrixBase::end() const * \sa class Block, block(int,int,int,int) */ template -inline Block MatrixBase +inline typename BlockReturnType::Type MatrixBase ::corner(CornerType type, int cRows, int cCols) { switch(type) @@ -602,33 +601,33 @@ inline Block MatrixBase default: ei_assert(false && "Bad corner type."); case TopLeft: - return Block(derived(), 0, 0, cRows, cCols); + return typename BlockReturnType::Type(derived(), 0, 0, cRows, cCols); case TopRight: - return Block(derived(), 0, cols() - cCols, cRows, cCols); + return typename BlockReturnType::Type(derived(), 0, cols() - cCols, cRows, cCols); case BottomLeft: - return Block(derived(), rows() - cRows, 0, cRows, cCols); + return typename BlockReturnType::Type(derived(), rows() - cRows, 0, cRows, cCols); case BottomRight: - return Block(derived(), rows() - cRows, cols() - cCols, cRows, cCols); + return typename BlockReturnType::Type(derived(), rows() - cRows, cols() - cCols, cRows, cCols); } } /** This is the const version of corner(CornerType, int, int).*/ template -inline const Block MatrixBase - ::corner(CornerType type, int cRows, int cCols) const +inline const typename BlockReturnType::Type +MatrixBase::corner(CornerType type, int cRows, int cCols) const { switch(type) { default: ei_assert(false && "Bad corner type."); case TopLeft: - return Block(derived(), 0, 0, cRows, cCols); + return typename BlockReturnType::Type(derived(), 0, 0, cRows, cCols); case TopRight: - return Block(derived(), 0, cols() - cCols, cRows, cCols); + return typename BlockReturnType::Type(derived(), 0, cols() - cCols, cRows, cCols); case BottomLeft: - return Block(derived(), rows() - cRows, 0, cRows, cCols); + return typename BlockReturnType::Type(derived(), rows() - cRows, 0, cRows, cCols); case BottomRight: - return Block(derived(), rows() - cRows, cols() - cCols, cRows, cCols); + return typename BlockReturnType::Type(derived(), rows() - cRows, cols() - cCols, cRows, cCols); } } @@ -646,8 +645,8 @@ inline const Block MatrixBase */ template template -inline Block MatrixBase - ::corner(CornerType type) +inline typename BlockReturnType::Type +MatrixBase::corner(CornerType type) { switch(type) { @@ -667,8 +666,8 @@ inline Block MatrixBase /** This is the const version of corner(CornerType).*/ template template -inline const Block MatrixBase - ::corner(CornerType type) const +inline const typename BlockReturnType::Type +MatrixBase::corner(CornerType type) const { switch(type) { @@ -705,8 +704,8 @@ inline const Block MatrixBase */ template template -inline Block MatrixBase - ::block(int startRow, int startCol) +inline typename BlockReturnType::Type +MatrixBase::block(int startRow, int startCol) { return Block(derived(), startRow, startCol); } @@ -714,8 +713,8 @@ inline Block MatrixBase /** This is the const version of block<>(int, int). */ template template -inline const Block MatrixBase - ::block(int startRow, int startCol) const +inline const typename BlockReturnType::Type +MatrixBase::block(int startRow, int startCol) const { return Block(derived(), startRow, startCol); } @@ -729,18 +728,18 @@ inline const Block MatrixBase * * \sa row(), class Block */ template -inline Block::RowsAtCompileTime, 1> +inline typename MatrixBase::ColXpr MatrixBase::col(int i) { - return Block::RowsAtCompileTime, 1>(derived(), i); + return ColXpr(derived(), i); } /** This is the const version of col(). */ template -inline const Block::RowsAtCompileTime, 1> +inline const typename MatrixBase::ColXpr MatrixBase::col(int i) const { - return Block::RowsAtCompileTime, 1>(derived(), i); + return ColXpr(derived(), i); } /** \returns an expression of the \a i-th row of *this. Note that the numbering starts at 0. @@ -752,18 +751,18 @@ MatrixBase::col(int i) const * * \sa col(), class Block */ template -inline Block::ColsAtCompileTime> +inline typename MatrixBase::RowXpr MatrixBase::row(int i) { - return Block::ColsAtCompileTime>(derived(), i); + return RowXpr(derived(), i); } /** This is the const version of row(). */ template -inline const Block::ColsAtCompileTime> +inline const typename MatrixBase::RowXpr MatrixBase::row(int i) const { - return Block::ColsAtCompileTime>(derived(), i); + return RowXpr(derived(), i); } #endif // EIGEN_BLOCK_H diff --git a/Eigen/src/Core/Cwise.h b/Eigen/src/Core/Cwise.h index bd16b0230..adfcfb2e8 100644 --- a/Eigen/src/Core/Cwise.h +++ b/Eigen/src/Core/Cwise.h @@ -35,6 +35,16 @@ */ template::size)>1?true:false) > struct ei_scalar_add_op; +/** \internal + * convenient macro to defined the return type of a cwise binary operation */ +#define EIGEN_CWISE_BINOP_RETURN_TYPE(OP) \ + CwiseBinaryOp::Scalar>, ExpressionType, OtherDerived> + +/** \internal + * convenient macro to defined the return type of a cwise unary operation */ +#define EIGEN_CWISE_UNOP_RETURN_TYPE(OP) \ + CwiseUnaryOp::Scalar>, ExpressionType> + /** \class Cwise * * \brief Pseudo expression providing additional coefficient-wise operations @@ -56,56 +66,40 @@ template class Cwise typedef typename ei_traits::Scalar Scalar; typedef typename ei_meta_if::ret, ExpressionType, const ExpressionType&>::ret ExpressionTypeNested; -// typedef NestByValue ConstantReturnType; typedef CwiseUnaryOp, ExpressionType> ScalarAddReturnType; - template class Functor, typename OtherDerived> struct BinOp - { - typedef CwiseBinaryOp::Scalar>, - ExpressionType, - OtherDerived - > ReturnType; - }; - - template class Functor> struct UnOp - { - typedef CwiseUnaryOp::Scalar>, - ExpressionType - > ReturnType; - }; - inline Cwise(const ExpressionType& matrix) : m_matrix(matrix) {} /** \internal */ inline const ExpressionType& _expression() const { return m_matrix; } template - const typename BinOp::ReturnType + const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_product_op) operator*(const MatrixBase &other) const; template - const typename BinOp::ReturnType + const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_quotient_op) operator/(const MatrixBase &other) const; template - const typename BinOp::ReturnType + const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_min_op) min(const MatrixBase &other) const; template - const typename BinOp::ReturnType + const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_max_op) max(const MatrixBase &other) const; - const typename UnOp::ReturnType abs() const; - const typename UnOp::ReturnType abs2() const; - const typename UnOp::ReturnType square() const; - const typename UnOp::ReturnType cube() const; - const typename UnOp::ReturnType inverse() const; - const typename UnOp::ReturnType sqrt() const; - const typename UnOp::ReturnType exp() const; - const typename UnOp::ReturnType log() const; - const typename UnOp::ReturnType cos() const; - const typename UnOp::ReturnType sin() const; - const typename UnOp::ReturnType pow(const Scalar& exponent) const; + const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_abs_op) abs() const; + const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_abs2_op) abs2() const; + const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_square_op) square() const; + const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_cube_op) cube() const; + const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_inverse_op) inverse() const; + const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_sqrt_op) sqrt() const; + const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_exp_op) exp() const; + const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_log_op) log() const; + const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_cos_op) cos() const; + const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_sin_op) sin() const; + const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_pow_op) pow(const Scalar& exponent) const; const ScalarAddReturnType @@ -123,22 +117,22 @@ template class Cwise ExpressionType& operator-=(const Scalar& scalar); - template const typename BinOp::ReturnType + template const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less) operator<(const MatrixBase& other) const; - template const typename BinOp::ReturnType + template const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less_equal) operator<=(const MatrixBase& other) const; - template const typename BinOp::ReturnType + template const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater) operator>(const MatrixBase& other) const; - template const typename BinOp::ReturnType + template const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater_equal) operator>=(const MatrixBase& other) const; - template const typename BinOp::ReturnType + template const EIGEN_CWISE_BINOP_RETURN_TYPE(std::equal_to) operator==(const MatrixBase& other) const; - template const typename BinOp::ReturnType + template const EIGEN_CWISE_BINOP_RETURN_TYPE(std::not_equal_to) operator!=(const MatrixBase& other) const; diff --git a/Eigen/src/Core/CwiseBinaryOp.h b/Eigen/src/Core/CwiseBinaryOp.h index ac5440c22..51c1f9e43 100644 --- a/Eigen/src/Core/CwiseBinaryOp.h +++ b/Eigen/src/Core/CwiseBinaryOp.h @@ -186,10 +186,10 @@ MatrixBase::operator+=(const MatrixBase& other) */ template template -inline const typename Cwise::template BinOp::ReturnType +inline const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_product_op) Cwise::operator*(const MatrixBase &other) const { - return typename BinOp::ReturnType(_expression(), other.derived()); + return EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_product_op)(_expression(), other.derived()); } /** \returns an expression of the coefficient-wise quotient of *this and \a other @@ -198,10 +198,10 @@ Cwise::operator*(const MatrixBase &other) const */ template template -inline const typename Cwise::template BinOp::ReturnType +inline const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_quotient_op) Cwise::operator/(const MatrixBase &other) const { - return typename BinOp::ReturnType(_expression(), other.derived()); + return EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_quotient_op)(_expression(), other.derived()); } /** \returns an expression of the coefficient-wise min of *this and \a other @@ -210,10 +210,10 @@ Cwise::operator/(const MatrixBase &other) const */ template template -inline const typename Cwise::template BinOp::ReturnType +inline const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_min_op) Cwise::min(const MatrixBase &other) const { - return typename BinOp::ReturnType(_expression(), other.derived()); + return EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_min_op)(_expression(), other.derived()); } /** \returns an expression of the coefficient-wise max of *this and \a other @@ -222,10 +222,10 @@ Cwise::min(const MatrixBase &other) const */ template template -inline const typename Cwise::template BinOp::ReturnType +inline const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_max_op) Cwise::max(const MatrixBase &other) const { - return typename BinOp::ReturnType(_expression(), other.derived()); + return EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_max_op)(_expression(), other.derived()); } /** \returns an expression of a custom coefficient-wise operator \a func of *this and \a other diff --git a/Eigen/src/Core/CwiseUnaryOp.h b/Eigen/src/Core/CwiseUnaryOp.h index b5a9e4d91..bb354958e 100644 --- a/Eigen/src/Core/CwiseUnaryOp.h +++ b/Eigen/src/Core/CwiseUnaryOp.h @@ -137,7 +137,7 @@ MatrixBase::operator-() const /** \returns an expression of the coefficient-wise absolute value of \c *this */ template -inline const typename Cwise::template UnOp::ReturnType +inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_abs_op) Cwise::abs() const { return _expression(); @@ -146,7 +146,7 @@ Cwise::abs() const /** \returns an expression of the coefficient-wise squared absolute value of \c *this */ template -inline const typename Cwise::template UnOp::ReturnType +inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_abs2_op) Cwise::abs2() const { return _expression(); diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h index 1e9d0d958..f15e560cb 100644 --- a/Eigen/src/Core/MatrixBase.h +++ b/Eigen/src/Core/MatrixBase.h @@ -175,34 +175,33 @@ template class MatrixBase * i.e., the number of rows for a columns major matrix, and the number of cols otherwise */ int innerSize() const { return (int(Flags)&RowMajorBit) ? this->cols() : this->rows(); } - /** Represents a constant matrix */ + /** \internal the type to which the expression gets evaluated (needed by MSVC) */ + typedef typename ei_eval::type EvalType; + /** \internal Represents a constant matrix */ typedef CwiseNullaryOp,Derived> ConstantReturnType; - /** Represents a vector block of a matrix */ - template struct SubVectorReturnType - { - typedef Block::RowsAtCompileTime == 1 ? 1 : Size), - (ei_traits::ColsAtCompileTime == 1 ? 1 : Size)> Type; - }; - /** Represents a scalar multiple of a matrix */ + /** \internal Represents a scalar multiple of a matrix */ typedef CwiseUnaryOp, Derived> ScalarMultipleReturnType; - /** Represents a quotient of a matrix by a scalar*/ + /** \internal Represents a quotient of a matrix by a scalar*/ typedef CwiseUnaryOp, Derived> ScalarQuotient1ReturnType; - - /** the return type of MatrixBase::conjugate() */ + /** \internal the return type of MatrixBase::conjugate() */ typedef typename ei_meta_if::IsComplex, CwiseUnaryOp, Derived>, Derived& >::ret ConjugateReturnType; - /** the return type of MatrixBase::real() */ + /** \internal the return type of MatrixBase::real() */ typedef CwiseUnaryOp, Derived> RealReturnType; - /** the return type of MatrixBase::adjoint() */ + /** \internal the return type of MatrixBase::adjoint() */ typedef Transpose::type> > AdjointReturnType; - /** the return type of MatrixBase::eigenvalues() */ + /** \internal the return type of MatrixBase::eigenvalues() */ typedef Matrix::Scalar>::Real, ei_traits::ColsAtCompileTime, 1> EigenvaluesReturnType; - /** the return type of identity */ + /** \internal expression tyepe of a column */ + typedef Block::RowsAtCompileTime, 1> ColXpr; + /** \internal expression tyepe of a column */ + typedef Block::ColsAtCompileTime> RowXpr; + /** \internal the return type of identity */ typedef CwiseNullaryOp,Derived> IdentityReturnType; - /** the return type of unit vectors */ + /** \internal the return type of unit vectors */ typedef Block, SquareMatrixType>, ei_traits::RowsAtCompileTime, ei_traits::ColsAtCompileTime> BasisReturnType; @@ -330,48 +329,46 @@ template class MatrixBase const AdjointReturnType adjoint() const; - Block::ColsAtCompileTime> row(int i); - const Block::ColsAtCompileTime> row(int i) const; + RowXpr row(int i); + const RowXpr row(int i) const; - Block::RowsAtCompileTime, 1> col(int i); - const Block::RowsAtCompileTime, 1> col(int i) const; + ColXpr col(int i); + const ColXpr col(int i) const; Minor minor(int row, int col); const Minor minor(int row, int col) const; - Block block(int startRow, int startCol, int blockRows, int blockCols); - const Block + typename BlockReturnType::Type block(int startRow, int startCol, int blockRows, int blockCols); + const typename BlockReturnType::Type block(int startRow, int startCol, int blockRows, int blockCols) const; - Block block(int start, int size); - const Block block(int start, int size) const; + typename BlockReturnType::SubVectorType block(int start, int size); + const typename BlockReturnType::SubVectorType block(int start, int size) const; - typename SubVectorReturnType::Type start(int size); - const typename SubVectorReturnType::Type start(int size) const; + typename BlockReturnType::SubVectorType start(int size); + const typename BlockReturnType::SubVectorType start(int size) const; - typename SubVectorReturnType::Type end(int size); - const typename SubVectorReturnType::Type end(int size) const; + typename BlockReturnType::SubVectorType end(int size); + const typename BlockReturnType::SubVectorType end(int size) const; - Block corner(CornerType type, int cRows, int cCols); - const Block corner(CornerType type, int cRows, int cCols) const; + typename BlockReturnType::Type corner(CornerType type, int cRows, int cCols); + const typename BlockReturnType::Type corner(CornerType type, int cRows, int cCols) const; template - Block block(int startRow, int startCol); + typename BlockReturnType::Type block(int startRow, int startCol); template - const Block block(int startRow, int startCol) const; + const typename BlockReturnType::Type block(int startRow, int startCol) const; - template Block corner(CornerType type); - template const Block corner(CornerType type) const; + template + typename BlockReturnType::Type corner(CornerType type); + template + const typename BlockReturnType::Type corner(CornerType type) const; - template - typename SubVectorReturnType::Type start(void); - template - const typename SubVectorReturnType::Type start() const; + template typename BlockReturnType::SubVectorType start(void); + template const typename BlockReturnType::SubVectorType start() const; - template - typename SubVectorReturnType::Type end(); - template - const typename SubVectorReturnType::Type end() const; + template typename BlockReturnType::SubVectorType end(); + template const typename BlockReturnType::SubVectorType end() const; DiagonalCoeffs diagonal(); const DiagonalCoeffs diagonal() const; @@ -529,18 +526,18 @@ template class MatrixBase /////////// LU module /////////// - const typename ei_eval::type inverse() const; - void computeInverse(typename ei_eval::type *result) const; + const EvalType inverse() const; + void computeInverse(EvalType *result) const; Scalar determinant() const; /////////// Cholesky module /////////// - const Cholesky::type> cholesky() const; - const CholeskyWithoutSquareRoot::type> choleskyNoSqrt() const; + const Cholesky cholesky() const; + const CholeskyWithoutSquareRoot choleskyNoSqrt() const; /////////// QR module /////////// - const QR::type> qr() const; + const QR qr() const; EigenvaluesReturnType eigenvalues() const; RealScalar matrixNorm() const; @@ -548,9 +545,14 @@ template class MatrixBase /////////// Geometry module /////////// template - typename ei_eval::type - cross(const MatrixBase& other) const; - typename ei_eval::type someOrthogonal(void) const; + EvalType cross(const MatrixBase& other) const; + EvalType someOrthogonal(void) const; + + /** + */ + #ifdef EIGEN_MATRIXBASE_PLUGIN + #include EIGEN_MATRIXBASE_PLUGIN + #endif }; #endif // EIGEN_MATRIXBASE_H diff --git a/Eigen/src/Core/util/Meta.h b/Eigen/src/Core/util/Meta.h index e7bfc195d..2fb401c6c 100644 --- a/Eigen/src/Core/util/Meta.h +++ b/Eigen/src/Core/util/Meta.h @@ -240,4 +240,13 @@ template struct ei_are_flags_consistent }; }; +/** \internal Gives the type of a sub-matrix or sub-vector of a matrix of type \a ExpressionType and size \a Size + * TODO: could be a good idea to define a big ReturnType struct ?? + */ +template struct BlockReturnType { + typedef Block::RowsAtCompileTime == 1 ? 1 : RowsOrSize), + (ei_traits::ColsAtCompileTime == 1 ? 1 : RowsOrSize)> SubVectorType; + typedef Block Type; +}; + #endif // EIGEN_META_H diff --git a/Eigen/src/Geometry/OrthoMethods.h b/Eigen/src/Geometry/OrthoMethods.h index ea71c12d2..b6206f7b2 100644 --- a/Eigen/src/Geometry/OrthoMethods.h +++ b/Eigen/src/Geometry/OrthoMethods.h @@ -30,7 +30,7 @@ * \returns the cross product of \c *this and \a other */ template template -inline typename ei_eval::type +inline typename MatrixBase::EvalType MatrixBase::cross(const MatrixBase& other) const { EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Derived,3); @@ -100,7 +100,7 @@ struct ei_perpendicular_selector * \sa cross() */ template -typename ei_eval::type +typename MatrixBase::EvalType MatrixBase::someOrthogonal() const { EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived); diff --git a/Eigen/src/Geometry/Quaternion.h b/Eigen/src/Geometry/Quaternion.h index 55d85ef57..e17e9ff4a 100644 --- a/Eigen/src/Geometry/Quaternion.h +++ b/Eigen/src/Geometry/Quaternion.h @@ -356,10 +356,10 @@ Quaternion Quaternion::slerp(Scalar t, const Quaternion& other) // 2 - Quaternion slerp(Scalar t, const Quaternion& other) const // which returns the s-lerp between this and other // ?? - if (*this == other) + if (m_coeffs == other.m_coeffs) return *this; - Scalar d = this->dot(other); + Scalar d = m_coeffs.dot(other.m_coeffs); // theta is the angle between the 2 quaternions Scalar theta = std::acos(ei_abs(d)); @@ -370,7 +370,7 @@ Quaternion Quaternion::slerp(Scalar t, const Quaternion& other) if (d<0) scale1 = -scale1; - return scale0 * (*this) + scale1 * other; + return Quaternion(scale0 * m_coeffs + scale1 * other.m_coeffs); } // set from a rotation matrix diff --git a/Eigen/src/Geometry/Transform.h b/Eigen/src/Geometry/Transform.h index 3da958aa7..846ec2c8d 100644 --- a/Eigen/src/Geometry/Transform.h +++ b/Eigen/src/Geometry/Transform.h @@ -120,9 +120,18 @@ public: /** \returns a writable expression of the translation vector of the transformation */ inline TranslationPart translation() { return m_matrix.template block(0,Dim); } + /** \returns an expression of the product between the transform \c *this and a matrix expression \a other + * + * The right hand side \a other might be either: + * \li a vector of size Dim, + * \li an homogeneous vector of size Dim+1, + * \li a transformation matrix of size Dim+1 x Dim+1. + */ + // note: this function is defined here because some compilers cannot find the respective declaration template const typename ei_transform_product_impl::ResultType - operator * (const MatrixBase &other) const; + operator * (const MatrixBase &other) const + { return ei_transform_product_impl::run(*this,other.derived()); } /** Contatenates two transformations */ const typename ProductReturnType::Type @@ -216,21 +225,6 @@ QMatrix Transform::toQMatrix(void) const } #endif -/** \returns an expression of the product between the transform \c *this and a matrix expression \a other - * - * The right hand side \a other might be either: - * \li a vector of size Dim, - * \li an homogeneous vector of size Dim+1, - * \li a transformation matrix of size Dim+1 x Dim+1. - */ -template -template -const typename ei_transform_product_impl::ResultType -Transform::operator*(const MatrixBase &other) const -{ - return ei_transform_product_impl::run(*this,other.derived()); -} - /** Applies on the right the non uniform scale transformation represented * by the vector \a other to \c *this and returns a reference to \c *this. * \sa prescale() diff --git a/Eigen/src/LU/Inverse.h b/Eigen/src/LU/Inverse.h index cfe90161a..68cac5985 100644 --- a/Eigen/src/LU/Inverse.h +++ b/Eigen/src/LU/Inverse.h @@ -301,7 +301,7 @@ struct ei_compute_inverse * \sa inverse() */ template -inline void MatrixBase::computeInverse(typename ei_eval::type *result) const +inline void MatrixBase::computeInverse(typename MatrixBase::EvalType *result) const { typedef typename ei_eval::type MatrixType; ei_assert(rows() == cols()); @@ -324,10 +324,9 @@ inline void MatrixBase::computeInverse(typename ei_eval::type * \sa computeInverse() */ template -inline const typename ei_eval::type MatrixBase::inverse() const +inline const typename MatrixBase::EvalType MatrixBase::inverse() const { - typedef typename ei_eval::type MatrixType; - MatrixType result(rows(), cols()); + EvalType result(rows(), cols()); computeInverse(&result); return result; } diff --git a/Eigen/src/QR/QR.h b/Eigen/src/QR/QR.h index 6e2f9c546..8ca787c2a 100644 --- a/Eigen/src/QR/QR.h +++ b/Eigen/src/QR/QR.h @@ -168,7 +168,7 @@ MatrixType QR::matrixQ(void) const * \sa class QR */ template -const QR::type> +const QR::EvalType> MatrixBase::qr() const { return QR::type>(derived()); diff --git a/Eigen/src/QR/SelfAdjointEigenSolver.h b/Eigen/src/QR/SelfAdjointEigenSolver.h index 28eb59cbb..2d833bf13 100644 --- a/Eigen/src/QR/SelfAdjointEigenSolver.h +++ b/Eigen/src/QR/SelfAdjointEigenSolver.h @@ -41,6 +41,7 @@ template class SelfAdjointEigenSolver { public: + enum {Size = _MatrixType::RowsAtCompileTime }; typedef _MatrixType MatrixType; typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits::Real RealScalar; @@ -49,6 +50,18 @@ template class SelfAdjointEigenSolver typedef Matrix RealVectorTypeX; typedef Tridiagonalization TridiagonalizationType; + SelfAdjointEigenSolver() + : m_eivec(Size, Size), + m_eivalues(Size) + { + ei_assert(Size!=Dynamic); + } + + SelfAdjointEigenSolver(int size) + : m_eivec(size, size), + m_eivalues(size) + {} + /** Constructors computing the eigenvalues of the selfadjoint matrix \a matrix, * as well as the eigenvectors if \a computeEigenvectors is true. *