From e3d890bc5a89798eff50ff6650292b4fa934f72e Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Wed, 18 Nov 2009 18:15:19 +0100 Subject: [PATCH] Another big refactoring change: * add a new Eigen2Support module including Cwise, Flagged, and some other deprecated stuff * add a few cwiseXxx functions * adapt a few modules to use cwiseXxx instead of the .cwise() prefix --- Eigen/Array | 1 - Eigen/Cholesky | 1 - Eigen/Core | 6 +- Eigen/Eigen2Support | 57 ++++ Eigen/src/Array/Norms.h | 8 +- Eigen/src/Cholesky/LDLT.h | 10 +- Eigen/src/Core/CwiseBinaryOp.h | 139 ---------- Eigen/src/Core/CwiseBinaryOps.h | 139 ++++++++++ Eigen/src/Core/CwiseUnaryOp.h | 56 ---- Eigen/src/Core/CwiseUnaryOps.h | 60 ++++- Eigen/src/Core/DiagonalMatrix.h | 6 + Eigen/src/Core/Dot.h | 2 +- Eigen/src/Core/Fuzzy.h | 6 +- Eigen/src/Core/MatrixBase.h | 65 +++-- Eigen/src/Core/Product.h | 6 +- Eigen/src/Core/SolveTriangular.h | 6 +- Eigen/src/Core/StableNorm.h | 4 +- Eigen/src/Core/util/ForwardDeclarations.h | 5 +- Eigen/src/{Core => Eigen2Support}/Cwise.h | 53 +++- .../{Array => Eigen2Support}/CwiseOperators.h | 251 ++++++++++++++---- Eigen/src/{Core => Eigen2Support}/Flagged.h | 0 Eigen/src/Eigen2Support/Lazy.h | 0 Eigen/src/Eigen2Support/TriangularSolver.h | 0 Eigen/src/Eigenvalues/ComplexEigenSolver.h | 2 +- Eigen/src/Eigenvalues/ComplexSchur.h | 2 +- Eigen/src/Eigenvalues/EigenSolver.h | 6 +- .../src/Eigenvalues/SelfAdjointEigenSolver.h | 6 +- Eigen/src/Geometry/AlignedBox.h | 16 +- Eigen/src/Geometry/AngleAxis.h | 2 +- Eigen/src/Geometry/Homogeneous.h | 4 +- Eigen/src/Geometry/OrthoMethods.h | 2 +- Eigen/src/LU/FullPivLU.h | 32 +-- Eigen/src/LU/Inverse.h | 6 +- Eigen/src/LU/PartialPivLU.h | 6 +- Eigen/src/Sparse/SparseCwiseBinaryOp.h | 32 +-- Eigen/src/Sparse/SparseMatrixBase.h | 13 +- test/array.cpp | 1 + test/cwiseop.cpp | 13 +- test/eigensolver_complex.cpp | 2 +- test/eigensolver_selfadjoint.cpp | 4 +- test/geo_alignedbox.cpp | 1 + test/geo_eulerangles.cpp | 1 + test/geo_homogeneous.cpp | 1 + test/geo_hyperplane.cpp | 1 + test/geo_orthomethods.cpp | 1 + test/geo_parametrizedline.cpp | 1 + test/geo_quaternion.cpp | 1 + test/geo_transformations.cpp | 5 +- 48 files changed, 634 insertions(+), 408 deletions(-) create mode 100644 Eigen/Eigen2Support create mode 100644 Eigen/src/Core/CwiseBinaryOps.h rename Eigen/src/{Core => Eigen2Support}/Cwise.h (81%) rename Eigen/src/{Array => Eigen2Support}/CwiseOperators.h (61%) rename Eigen/src/{Core => Eigen2Support}/Flagged.h (100%) create mode 100644 Eigen/src/Eigen2Support/Lazy.h create mode 100644 Eigen/src/Eigen2Support/TriangularSolver.h diff --git a/Eigen/Array b/Eigen/Array index 2b5af088a..dbb4a7ca6 100644 --- a/Eigen/Array +++ b/Eigen/Array @@ -28,7 +28,6 @@ namespace Eigen { * \endcode */ -#include "src/Array/CwiseOperators.h" #include "src/Array/Functors.h" #include "src/Array/BooleanRedux.h" #include "src/Array/Select.h" diff --git a/Eigen/Cholesky b/Eigen/Cholesky index 634dc156f..d4e80e46b 100644 --- a/Eigen/Cholesky +++ b/Eigen/Cholesky @@ -31,7 +31,6 @@ namespace Eigen { */ #include "src/misc/Solve.h" -#include "src/Array/CwiseOperators.h" #include "src/Array/Functors.h" #include "src/Cholesky/LLT.h" #include "src/Cholesky/LDLT.h" diff --git a/Eigen/Core b/Eigen/Core index cc3dd1f9f..778b1c921 100644 --- a/Eigen/Core +++ b/Eigen/Core @@ -23,6 +23,10 @@ // License and a copy of the GNU General Public License along with // Eigen. If not, see . +#ifdef EIGEN2_SUPPORT +#include "Eigen2Support" +#endif + #ifndef EIGEN_CORE_H #define EIGEN_CORE_H @@ -161,10 +165,8 @@ struct Dense {}; #include "src/Core/MatrixStorage.h" #include "src/Core/NestByValue.h" #include "src/Core/ReturnByValue.h" -#include "src/Core/Flagged.h" #include "src/Core/NoAlias.h" #include "src/Core/Matrix.h" -#include "src/Core/Cwise.h" #include "src/Core/CwiseBinaryOp.h" #include "src/Core/CwiseUnaryOp.h" #include "src/Core/CwiseNullaryOp.h" diff --git a/Eigen/Eigen2Support b/Eigen/Eigen2Support new file mode 100644 index 000000000..b95b51dec --- /dev/null +++ b/Eigen/Eigen2Support @@ -0,0 +1,57 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2009 Gael Guennebaud +// +// Eigen is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 3 of the License, or (at your option) any later version. +// +// Alternatively, you can redistribute it and/or +// modify it under the terms of the GNU General Public License as +// published by the Free Software Foundation; either version 2 of +// the License, or (at your option) any later version. +// +// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License and a copy of the GNU General Public License along with +// Eigen. If not, see . + +#ifndef EIGEN2SUPPORT_H +#define EIGEN2SUPPORT_H + +#include "src/Core/util/DisableMSVCWarnings.h" + +#ifndef EIGEN2_SUPPORT +#define EIGEN2_SUPPORT +#endif + +#include "Core" +#include "Array" + +namespace Eigen { + +/** \defgroup Eigen2Support_Module Eigen2 support module + * This module provides a couple of deprecated functions improving the compatibility with Eigen2. + * + * \code + * #include + * \endcode + */ + +#include "src/Eigen2Support/Flagged.h" +#include "src/Eigen2Support/Lazy.h" +#include "src/Eigen2Support/Cwise.h" +#include "src/Eigen2Support/CwiseOperators.h" +#include "src/Eigen2Support/TriangularSolver.h" + +} // namespace Eigen + +#include "src/Core/util/EnableMSVCWarnings.h" + +#endif // EIGEN2SUPPORT_H diff --git a/Eigen/src/Array/Norms.h b/Eigen/src/Array/Norms.h index ef3f2f20d..07741cdc9 100644 --- a/Eigen/src/Array/Norms.h +++ b/Eigen/src/Array/Norms.h @@ -31,7 +31,7 @@ struct ei_lpNorm_selector typedef typename NumTraits::Scalar>::Real RealScalar; inline static RealScalar run(const MatrixBase& m) { - return ei_pow(m.cwise().abs().cwise().pow(p).sum(), RealScalar(1)/p); + return ei_pow(m.cwiseAbs().array().pow(p).sum(), RealScalar(1)/p); } }; @@ -40,7 +40,7 @@ struct ei_lpNorm_selector { inline static typename NumTraits::Scalar>::Real run(const MatrixBase& m) { - return m.cwise().abs().sum(); + return m.cwiseAbs().sum(); } }; @@ -58,12 +58,12 @@ struct ei_lpNorm_selector { inline static typename NumTraits::Scalar>::Real run(const MatrixBase& m) { - return m.cwise().abs().maxCoeff(); + return m.cwiseAbs().maxCoeff(); } }; /** \array_module - * + * * \returns the \f$ \ell^p \f$ norm of *this, that is, returns the p-th root of the sum of the p-th powers of the absolute values * of the coefficients of *this. If \a p is the special value \a Eigen::Infinity, this function returns the \f$ \ell^p\infty \f$ * norm, that is the maximum of the absolute values of the coefficients of *this. diff --git a/Eigen/src/Cholesky/LDLT.h b/Eigen/src/Cholesky/LDLT.h index d0f292634..c13be9ac2 100644 --- a/Eigen/src/Cholesky/LDLT.h +++ b/Eigen/src/Cholesky/LDLT.h @@ -81,7 +81,7 @@ template class LDLT /** \returns the lower triangular matrix L */ inline TriangularView matrixL(void) const - { + { ei_assert(m_isInitialized && "LDLT is not initialized."); return m_matrix; } @@ -132,7 +132,7 @@ template class LDLT && "LDLT::solve(): invalid number of rows of the right hand side matrix b"); return ei_solve_retval(*this, b.derived()); } - + template bool solveInPlace(MatrixBase &bAndX) const; @@ -150,7 +150,7 @@ template class LDLT inline int rows() const { return m_matrix.rows(); } inline int cols() const { return m_matrix.cols(); } - + protected: /** \internal * Used to compute and store the Cholesky decomposition A = L D L^* = U^* D U. @@ -194,7 +194,7 @@ LDLT& LDLT::compute(const MatrixType& a) { // Find largest diagonal element int index_of_biggest_in_corner; - biggest_in_corner = m_matrix.diagonal().end(size-j).cwise().abs() + biggest_in_corner = m_matrix.diagonal().end(size-j).cwiseAbs() .maxCoeff(&index_of_biggest_in_corner); index_of_biggest_in_corner += j; @@ -304,7 +304,7 @@ bool LDLT::solveInPlace(MatrixBase &bAndX) const m_matrix.template triangularView().solveInPlace(bAndX); // w = D^-1 y - bAndX = (m_matrix.diagonal().cwise().inverse().asDiagonal() * bAndX).lazy(); + bAndX = m_matrix.diagonal().asDiagonal().inverse() * bAndX; // u = L^-T w m_matrix.adjoint().template triangularView().solveInPlace(bAndX); diff --git a/Eigen/src/Core/CwiseBinaryOp.h b/Eigen/src/Core/CwiseBinaryOp.h index bba66f2f3..462e0f92d 100644 --- a/Eigen/src/Core/CwiseBinaryOp.h +++ b/Eigen/src/Core/CwiseBinaryOp.h @@ -169,22 +169,6 @@ class CwiseBinaryOpImpl } }; -/**\returns an expression of the difference of \c *this and \a other - * - * \note If you want to substract a given scalar from all coefficients, see Cwise::operator-(). - * - * \sa class CwiseBinaryOp, MatrixBase::operator-=(), Cwise::operator-() - */ -template -template -EIGEN_STRONG_INLINE const CwiseBinaryOp::Scalar>, - Derived, OtherDerived> -MatrixBase::operator-(const MatrixBase &other) const -{ - return CwiseBinaryOp, - Derived, OtherDerived>(derived(), other.derived()); -} - /** replaces \c *this by \c *this - \a other. * * \returns a reference to \c *this @@ -197,22 +181,6 @@ MatrixBase::operator-=(const MatrixBase &other) return *this = *this - other; } -/** \relates MatrixBase - * - * \returns an expression of the sum of \c *this and \a other - * - * \note If you want to add a given scalar to all coefficients, see Cwise::operator+(). - * - * \sa class CwiseBinaryOp, MatrixBase::operator+=(), Cwise::operator+() - */ -template -template -EIGEN_STRONG_INLINE const CwiseBinaryOp::Scalar>, Derived, OtherDerived> -MatrixBase::operator+(const MatrixBase &other) const -{ - return CwiseBinaryOp, Derived, OtherDerived>(derived(), other.derived()); -} - /** replaces \c *this by \c *this + \a other. * * \returns a reference to \c *this @@ -225,111 +193,4 @@ MatrixBase::operator+=(const MatrixBase& other) return *this = *this + other; } -/** \returns an expression of the Schur product (coefficient wise product) of *this and \a other - * - * Example: \include Cwise_product.cpp - * Output: \verbinclude Cwise_product.out - * - * \sa class CwiseBinaryOp, operator/(), square() - */ -template class StorageBase> -template -EIGEN_STRONG_INLINE const EIGEN_CWISE_PRODUCT_RETURN_TYPE -Cwise::operator*(const AnyMatrixBase &other) const -{ - return EIGEN_CWISE_PRODUCT_RETURN_TYPE(_expression(), other.derived()); -} - -/** \returns an expression of the coefficient-wise quotient of *this and \a other - * - * Example: \include Cwise_quotient.cpp - * Output: \verbinclude Cwise_quotient.out - * - * \sa class CwiseBinaryOp, operator*(), inverse() - */ -template class StorageBase> -template -EIGEN_STRONG_INLINE const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_quotient_op) -Cwise::operator/(const StorageBase &other) const -{ - return EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_quotient_op)(_expression(), other.derived()); -} - -/** Replaces this expression by its coefficient-wise product with \a other. - * - * Example: \include Cwise_times_equal.cpp - * Output: \verbinclude Cwise_times_equal.out - * - * \sa operator*(), operator/=() - */ -template class StorageBase> -template -inline ExpressionType& Cwise::operator*=(const StorageBase &other) -{ - return m_matrix.const_cast_derived() = *this * other; -} - -/** Replaces this expression by its coefficient-wise quotient by \a other. - * - * Example: \include Cwise_slash_equal.cpp - * Output: \verbinclude Cwise_slash_equal.out - * - * \sa operator/(), operator*=() - */ -template class StorageBase> -template -inline ExpressionType& Cwise::operator/=(const StorageBase &other) -{ - return m_matrix.const_cast_derived() = *this / other; -} - -/** \returns an expression of the coefficient-wise min of *this and \a other - * - * Example: \include Cwise_min.cpp - * Output: \verbinclude Cwise_min.out - * - * \sa class CwiseBinaryOp - */ -template class StorageBase> -template -EIGEN_STRONG_INLINE const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_min_op) -Cwise::min(const StorageBase &other) const -{ - 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 - * - * Example: \include Cwise_max.cpp - * Output: \verbinclude Cwise_max.out - * - * \sa class CwiseBinaryOp - */ -template class StorageBase> -template -EIGEN_STRONG_INLINE const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_max_op) -Cwise::max(const StorageBase &other) const -{ - 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 - * - * The template parameter \a CustomBinaryOp is the type of the functor - * of the custom operator (see class CwiseBinaryOp for an example) - * - * Here is an example illustrating the use of custom functors: - * \include class_CwiseBinaryOp.cpp - * Output: \verbinclude class_CwiseBinaryOp.out - * - * \sa class CwiseBinaryOp, MatrixBase::operator+, MatrixBase::operator-, Cwise::operator*, Cwise::operator/ - */ -template -template -EIGEN_STRONG_INLINE const CwiseBinaryOp -MatrixBase::binaryExpr(const MatrixBase &other, const CustomBinaryOp& func) const -{ - return CwiseBinaryOp(derived(), other.derived(), func); -} - #endif // EIGEN_CWISE_BINARY_OP_H diff --git a/Eigen/src/Core/CwiseBinaryOps.h b/Eigen/src/Core/CwiseBinaryOps.h new file mode 100644 index 000000000..0b7fa2d8b --- /dev/null +++ b/Eigen/src/Core/CwiseBinaryOps.h @@ -0,0 +1,139 @@ +/** \returns an expression of the difference of \c *this and \a other + * + * \note If you want to substract a given scalar from all coefficients, see Cwise::operator-(). + * + * \sa class CwiseBinaryOp, MatrixBase::operator-=() + */ +template +EIGEN_STRONG_INLINE const CwiseBinaryOp::Scalar>, + Derived, OtherDerived> +operator-(const EIGEN_CURRENT_STORAGE_BASE_CLASS &other) const +{ + return CwiseBinaryOp, + Derived, OtherDerived>(derived(), other.derived()); +} + +/** \returns an expression of the sum of \c *this and \a other + * + * \note If you want to add a given scalar to all coefficients, see Cwise::operator+(). + * + * \sa class CwiseBinaryOp, MatrixBase::operator+=() + */ +template +EIGEN_STRONG_INLINE const CwiseBinaryOp::Scalar>, Derived, OtherDerived> +operator+(const EIGEN_CURRENT_STORAGE_BASE_CLASS &other) const +{ + return CwiseBinaryOp, Derived, OtherDerived>(derived(), other.derived()); +} + +/** \returns an expression of a custom coefficient-wise operator \a func of *this and \a other + * + * The template parameter \a CustomBinaryOp is the type of the functor + * of the custom operator (see class CwiseBinaryOp for an example) + * + * Here is an example illustrating the use of custom functors: + * \include class_CwiseBinaryOp.cpp + * Output: \verbinclude class_CwiseBinaryOp.out + * + * \sa class CwiseBinaryOp, MatrixBase::operator+, MatrixBase::operator-, MatrixBase::cwiseProduct + */ +template +EIGEN_STRONG_INLINE const CwiseBinaryOp +binaryExpr(const EIGEN_CURRENT_STORAGE_BASE_CLASS &other, const CustomBinaryOp& func = CustomBinaryOp()) const +{ + return CwiseBinaryOp(derived(), other.derived(), func); +} + +/** \returns an expression of the Schur product (coefficient wise product) of *this and \a other + * + * Example: \include MatrixBase_cwiseProduct.cpp + * Output: \verbinclude MatrixBase_cwiseProduct.out + * + * \sa class CwiseBinaryOp, cwiseAbs2 + */ +template +EIGEN_STRONG_INLINE const CwiseBinaryOp, Derived, OtherDerived> +cwiseProduct(const EIGEN_CURRENT_STORAGE_BASE_CLASS &other) const +{ + return CwiseBinaryOp, Derived, OtherDerived>(derived(), other.derived()); +} + +/** \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. + * In order to check for equality between two vectors or matrices with floating-point coefficients, it is + * generally a far better idea to use a fuzzy comparison as provided by MatrixBase::isApprox() and + * MatrixBase::isMuchSmallerThan(). + * + * Example: \include MatrixBase_cwiseEqual.cpp + * Output: \verbinclude MatrixBase_cwiseEqual.out + * + * \sa MatrixBase::cwiseNotEqual(), MatrixBase::isApprox(), MatrixBase::isMuchSmallerThan() + */ +template +inline const CwiseBinaryOp, Derived, OtherDerived> +cwiseEqual(const EIGEN_CURRENT_STORAGE_BASE_CLASS &other) const +{ + return CwiseBinaryOp, Derived, OtherDerived>(derived(), other.derived()); +} + +/** \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. + * In order to check for equality between two vectors or matrices with floating-point coefficients, it is + * generally a far better idea to use a fuzzy comparison as provided by MatrixBase::isApprox() and + * MatrixBase::isMuchSmallerThan(). + * + * Example: \include MatrixBase_cwiseNotEqual.cpp + * Output: \verbinclude MatrixBase_cwiseNotEqual.out + * + * \sa MatrixBase::cwiseEqual(), MatrixBase::isApprox(), MatrixBase::isMuchSmallerThan() + */ +template +inline const CwiseBinaryOp, Derived, OtherDerived> +cwiseNotEqual(const EIGEN_CURRENT_STORAGE_BASE_CLASS &other) const +{ + return CwiseBinaryOp, Derived, OtherDerived>(derived(), other.derived()); +} + +/** \returns an expression of the coefficient-wise min of *this and \a other + * + * Example: \include MatrixBase_cwiseMin.cpp + * Output: \verbinclude MatrixBase_cwiseMin.out + * + * \sa class CwiseBinaryOp, max() + */ +template +EIGEN_STRONG_INLINE const CwiseBinaryOp, Derived, OtherDerived> +cwiseMin(const EIGEN_CURRENT_STORAGE_BASE_CLASS &other) const +{ + return CwiseBinaryOp, Derived, OtherDerived>(derived(), other.derived()); +} + +/** \returns an expression of the coefficient-wise max of *this and \a other + * + * Example: \include MatrixBase_cwiseMax.cpp + * Output: \verbinclude MatrixBase_cwiseMax.out + * + * \sa class CwiseBinaryOp, min() + */ +template +EIGEN_STRONG_INLINE const CwiseBinaryOp, Derived, OtherDerived> +cwiseMax(const EIGEN_CURRENT_STORAGE_BASE_CLASS &other) const +{ + return CwiseBinaryOp, Derived, OtherDerived>(derived(), other.derived()); +} + +/** \returns an expression of the coefficient-wise quotient of *this and \a other + * + * Example: \include MatrixBase_cwiseQuotient.cpp + * Output: \verbinclude MatrixBase_cwiseQuotient.out + * + * \sa class CwiseBinaryOp, cwiseProduct(), cwiseInverse() + */ +template +EIGEN_STRONG_INLINE const CwiseBinaryOp, Derived, OtherDerived> +cwiseQuotient(const EIGEN_CURRENT_STORAGE_BASE_CLASS &other) const +{ + return CwiseBinaryOp, Derived, OtherDerived>(derived(), other.derived()); +} diff --git a/Eigen/src/Core/CwiseUnaryOp.h b/Eigen/src/Core/CwiseUnaryOp.h index 0ba7e1366..55f965b4e 100644 --- a/Eigen/src/Core/CwiseUnaryOp.h +++ b/Eigen/src/Core/CwiseUnaryOp.h @@ -128,60 +128,4 @@ class CwiseUnaryOpImpl : public MatrixBase class StorageBase> -EIGEN_STRONG_INLINE const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_abs_op) -Cwise::abs() const -{ - return _expression(); -} - -/** \returns an expression of the coefficient-wise squared absolute value of \c *this - * - * Example: \include Cwise_abs2.cpp - * Output: \verbinclude Cwise_abs2.out - * - * \sa abs(), square() - */ -template class StorageBase> -EIGEN_STRONG_INLINE const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_abs2_op) -Cwise::abs2() const -{ - return _expression(); -} - -/** \returns an expression of the coefficient-wise exponential of *this. - * - * Example: \include Cwise_exp.cpp - * Output: \verbinclude Cwise_exp.out - * - * \sa pow(), log(), sin(), cos() - */ -template class StorageBase> -inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_exp_op) -Cwise::exp() const -{ - return _expression(); -} - -/** \returns an expression of the coefficient-wise logarithm of *this. - * - * Example: \include Cwise_log.cpp - * Output: \verbinclude Cwise_log.out - * - * \sa exp() - */ -template class StorageBase> -inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_log_op) -Cwise::log() const -{ - return _expression(); -} - #endif // EIGEN_CWISE_UNARY_OP_H diff --git a/Eigen/src/Core/CwiseUnaryOps.h b/Eigen/src/Core/CwiseUnaryOps.h index cd58f1d43..39fd479b5 100644 --- a/Eigen/src/Core/CwiseUnaryOps.h +++ b/Eigen/src/Core/CwiseUnaryOps.h @@ -156,26 +156,58 @@ real() { return derived(); } EIGEN_STRONG_INLINE NonConstImagReturnType imag() { return derived(); } -/** \returns a Cwise wrapper of *this providing additional coefficient-wise operations +/** \returns an expression of the coefficient-wise absolute value of \c *this * - * Example: \include MatrixBase_cwise_const.cpp - * Output: \verbinclude MatrixBase_cwise_const.out + * Example: \include MatrixBase_cwiseAbs.cpp + * Output: \verbinclude MatrixBase_cwiseAbs.out * - * \sa class Cwise, cwise() + * \sa cwiseAbs2() */ -inline const Cwise cwise() const -{ - return derived(); -} +EIGEN_STRONG_INLINE const CwiseUnaryOp,Derived> +cwiseAbs() const { return derived(); } -/** \returns a Cwise wrapper of *this providing additional coefficient-wise operations +/** \returns an expression of the coefficient-wise squared absolute value of \c *this * - * Example: \include MatrixBase_cwise.cpp - * Output: \verbinclude MatrixBase_cwise.out + * Example: \include MatrixBase_cwiseAbs2.cpp + * Output: \verbinclude MatrixBase_cwiseAbs2.out * - * \sa class Cwise, cwise() const + * \sa cwiseAbs() */ -inline Cwise cwise() +EIGEN_STRONG_INLINE const CwiseUnaryOp,Derived> +cwiseAbs2() const { return derived(); } + +/** \returns an expression of the coefficient-wise square root of *this. + * + * Example: \include MatrixBase_cwiseSqrt.cpp + * Output: \verbinclude MatrixBase_cwiseSqrt.out + * + * \sa cwisePow(), cwiseSquare() + */ +inline const CwiseUnaryOp,Derived> +cwiseSqrt() const { return derived(); } + +/** \returns an expression of the coefficient-wise inverse of *this. + * + * Example: \include MatrixBase_cwiseInverse.cpp + * Output: \verbinclude MatrixBase_cwiseInverse.out + * + * \sa cwiseProduct() + */ +inline const CwiseUnaryOp,Derived> +cwiseInverse() const { return derived(); } + +/** \returns an expression of the coefficient-wise == operator of \c *this and a scalar \a s + * + * \warning this performs an exact comparison, which is generally a bad idea with floating-point types. + * In order to check for equality between two vectors or matrices with floating-point coefficients, it is + * generally a far better idea to use a fuzzy comparison as provided by MatrixBase::isApprox() and + * MatrixBase::isMuchSmallerThan(). + * + * \sa cwiseEqual(const MatrixBase &) const + */ +inline const CwiseUnaryOp >,Derived> +cwiseEqual(Scalar s) const { - return derived(); + return CwiseUnaryOp >,Derived> + (derived(), std::bind1st(std::equal_to(), s)); } diff --git a/Eigen/src/Core/DiagonalMatrix.h b/Eigen/src/Core/DiagonalMatrix.h index 1dec82229..6f93737ff 100644 --- a/Eigen/src/Core/DiagonalMatrix.h +++ b/Eigen/src/Core/DiagonalMatrix.h @@ -68,6 +68,12 @@ class DiagonalBase : public AnyMatrixBase template const DiagonalProduct operator*(const MatrixBase &matrix) const; + + inline const DiagonalWrapper, DiagonalVectorType> > > + inverse() const + { + return diagonal().cwiseInverse().nestByValue(); + } }; template diff --git a/Eigen/src/Core/Dot.h b/Eigen/src/Core/Dot.h index 631124f2b..4a164a99e 100644 --- a/Eigen/src/Core/Dot.h +++ b/Eigen/src/Core/Dot.h @@ -279,7 +279,7 @@ MatrixBase::dot(const MatrixBase& other) const template inline typename NumTraits::Scalar>::Real MatrixBase::squaredNorm() const { - return ei_real((*this).cwise().abs2().sum()); + return ei_real((*this).cwiseAbs2().sum()); } /** \returns the \em l2 norm of *this, i.e., for vectors, the square root of the dot product of *this with itself. diff --git a/Eigen/src/Core/Fuzzy.h b/Eigen/src/Core/Fuzzy.h index e10446398..13fcfcdab 100644 --- a/Eigen/src/Core/Fuzzy.h +++ b/Eigen/src/Core/Fuzzy.h @@ -54,7 +54,7 @@ bool MatrixBase::isApprox( { const typename ei_nested::type nested(derived()); const typename ei_nested::type otherNested(other.derived()); - return (nested - otherNested).cwise().abs2().sum() <= prec * prec * std::min(nested.cwise().abs2().sum(), otherNested.cwise().abs2().sum()); + return (nested - otherNested).cwiseAbs2().sum() <= prec * prec * std::min(nested.cwiseAbs2().sum(), otherNested.cwiseAbs2().sum()); } /** \returns \c true if the norm of \c *this is much smaller than \a other, @@ -76,7 +76,7 @@ bool MatrixBase::isMuchSmallerThan( RealScalar prec ) const { - return cwise().abs2().sum() <= prec * prec * other * other; + return cwiseAbs2().sum() <= prec * prec * other * other; } /** \returns \c true if the norm of \c *this is much smaller than the norm of \a other, @@ -96,7 +96,7 @@ bool MatrixBase::isMuchSmallerThan( RealScalar prec ) const { - return this->cwise().abs2().sum() <= prec * prec * other.cwise().abs2().sum(); + return cwiseAbs2().sum() <= prec * prec * other.cwiseAbs2().sum(); } #else diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h index 67e270af7..d653b25c5 100644 --- a/Eigen/src/Core/MatrixBase.h +++ b/Eigen/src/Core/MatrixBase.h @@ -247,6 +247,7 @@ template class MatrixBase #define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::MatrixBase #include "CwiseUnaryOps.h" + #include "CwiseBinaryOps.h" #undef EIGEN_CURRENT_STORAGE_BASE_CLASS /** Copies \a other into *this. \returns a reference to *this. */ @@ -275,12 +276,6 @@ template class MatrixBase template Derived& lazyAssign(const MatrixBase& other); - /** \deprecated because .lazy() is deprecated - * Overloaded for cache friendly product evaluation */ - template - Derived& lazyAssign(const Flagged& other) - { return lazyAssign(other._expression()); } - template Derived& lazyAssign(const ProductBase& other); @@ -342,15 +337,6 @@ template class MatrixBase Scalar& z(); Scalar& w(); - - template - const CwiseBinaryOp::Scalar>, Derived, OtherDerived> - operator+(const MatrixBase &other) const; - - template - const CwiseBinaryOp::Scalar>, Derived, OtherDerived> - operator-(const MatrixBase &other) const; - template Derived& operator+=(const MatrixBase& other); template @@ -373,14 +359,6 @@ template class MatrixBase const DiagonalProduct operator*(const DiagonalBase &diagonal) const; - template - typename ei_plain_matrix_type_column_major::type - solveTriangular(const MatrixBase& other) const; - - template - void solveTriangularInPlace(const MatrixBase& other) const; - - template Scalar dot(const MatrixBase& other) const; RealScalar squaredNorm() const; @@ -542,11 +520,11 @@ template class MatrixBase template inline bool operator==(const MatrixBase& other) const - { return (cwise() == other).all(); } + { return cwiseEqual(other).all(); } template inline bool operator!=(const MatrixBase& other) const - { return (cwise() != other).any(); } + { return cwiseNotEqual(other).all(); } /** \returns the matrix or vector obtained by evaluating this expression. @@ -560,10 +538,6 @@ template class MatrixBase template void swap(MatrixBase EIGEN_REF_TO_TEMPORARY other); - template - const Flagged marked() const; - const Flagged lazy() const; - NoAlias noalias(); /** \returns number of elements to skip to pass from one row (resp. column) to another @@ -575,12 +549,6 @@ template class MatrixBase inline const NestByValue nestByValue() const; - - template - const CwiseBinaryOp - binaryExpr(const MatrixBase &other, const CustomBinaryOp& func = CustomBinaryOp()) const; - - Scalar sum() const; Scalar mean() const; Scalar trace() const; @@ -736,6 +704,33 @@ template class MatrixBase #include EIGEN_MATRIXBASE_PLUGIN #endif +#ifdef EIGEN2_SUPPORT + /** \deprecated because .lazy() is deprecated + * Overloaded for cache friendly product evaluation */ + template + Derived& lazyAssign(const Flagged& other) + { return lazyAssign(other._expression()); } + + template + const Flagged marked() const; + const Flagged lazy() const; + + inline const Cwise cwise() const; + inline Cwise cwise(); + + // a workaround waiting the Array class + inline const Cwise array() const { return cwise(); } + // a workaround waiting the Array class + inline Cwise array() { return cwise(); } + + template + typename ei_plain_matrix_type_column_major::type + solveTriangular(const MatrixBase& other) const; + + template + void solveTriangularInPlace(const MatrixBase& other) const; +#endif + protected: /** Default constructor. Do nothing. */ MatrixBase() diff --git a/Eigen/src/Core/Product.h b/Eigen/src/Core/Product.h index cc751650d..7db35eaad 100644 --- a/Eigen/src/Core/Product.h +++ b/Eigen/src/Core/Product.h @@ -170,7 +170,7 @@ class GeneralProduct EIGEN_STRONG_INLINE Scalar value() const { - return (m_lhs.transpose().cwise()*m_rhs).sum(); + return (m_lhs.transpose().cwiseProduct(m_rhs)).sum(); } template void scaleAndAddTo(Dest& dst, Scalar alpha) const @@ -403,7 +403,7 @@ template<> struct ei_gemv_selector // TODO makes sure rhs is sequentially stored in memory, otherwise use a temp const int rows = prod.rows(); for(int i=0; i::operator*(const MatrixBase &other) const }; // note to the lost user: // * for a dot product use: v1.dot(v2) - // * for a coeff-wise product use: v1.cwise()*v2 + // * for a coeff-wise product use: v1.cwiseProduct(v2) EIGEN_STATIC_ASSERT(ProductIsValid || !(AreVectors && SameSizes), INVALID_VECTOR_VECTOR_PRODUCT__IF_YOU_WANTED_A_DOT_OR_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTIONS) EIGEN_STATIC_ASSERT(ProductIsValid || !(SameSizes && !AreVectors), diff --git a/Eigen/src/Core/SolveTriangular.h b/Eigen/src/Core/SolveTriangular.h index c7f0cd227..6e9dd30ec 100644 --- a/Eigen/src/Core/SolveTriangular.h +++ b/Eigen/src/Core/SolveTriangular.h @@ -78,8 +78,7 @@ struct ei_triangular_solver_selector0) - other.coeffRef(i) -= ((lhs.row(i).segment(s,k).transpose()) - .cwise()*(other.segment(s,k))).sum(); + other.coeffRef(i) -= (lhs.row(i).segment(s,k).transpose().cwiseProduct(other.segment(s,k))).sum(); if(!(Mode & UnitDiagBit)) other.coeffRef(i) /= lhs.coeff(i,i); @@ -180,8 +179,7 @@ struct ei_triangular_solver_unroller { static void run(const Lhs& lhs, Rhs& rhs) { if (Index>0) - rhs.coeffRef(I) -= ((lhs.row(I).template segment(S).transpose()) - .cwise()*(rhs.template segment(S))).sum(); + rhs.coeffRef(I) -= ((lhs.row(I).template segment(S).transpose()).cwiseProduct(rhs.template segment(S))).sum(); if(!(Mode & UnitDiagBit)) rhs.coeffRef(I) /= lhs.coeff(I,I); diff --git a/Eigen/src/Core/StableNorm.h b/Eigen/src/Core/StableNorm.h index f2d1e7240..b08f4a1ae 100644 --- a/Eigen/src/Core/StableNorm.h +++ b/Eigen/src/Core/StableNorm.h @@ -28,7 +28,7 @@ template inline void ei_stable_norm_kernel(const ExpressionType& bl, Scalar& ssq, Scalar& scale, Scalar& invScale) { - Scalar max = bl.cwise().abs().maxCoeff(); + Scalar max = bl.cwiseAbs().maxCoeff(); if (max>scale) { ssq = ssq * ei_abs2(scale/max); @@ -182,7 +182,7 @@ template inline typename NumTraits::Scalar>::Real MatrixBase::hypotNorm() const { - return this->cwise().abs().redux(ei_scalar_hypot_op()); + return this->cwiseAbs().redux(ei_scalar_hypot_op()); } #endif // EIGEN_STABLENORM_H diff --git a/Eigen/src/Core/util/ForwardDeclarations.h b/Eigen/src/Core/util/ForwardDeclarations.h index 2fedbbc07..541b5dd9f 100644 --- a/Eigen/src/Core/util/ForwardDeclarations.h +++ b/Eigen/src/Core/util/ForwardDeclarations.h @@ -60,7 +60,6 @@ template class Map; template class TriangularBase; template class TriangularView; template class SelfAdjointView; -template class StorageBase> class Cwise; template class WithFormat; template struct CommaInitializer; template class ReturnByValue; @@ -146,4 +145,8 @@ template class Translation; template class UniformScaling; template class Homogeneous; +#ifdef EIGEN2_SUPPORT +template class Cwise; +#endif + #endif // EIGEN_FORWARDDECLARATIONS_H diff --git a/Eigen/src/Core/Cwise.h b/Eigen/src/Eigen2Support/Cwise.h similarity index 81% rename from Eigen/src/Core/Cwise.h rename to Eigen/src/Eigen2Support/Cwise.h index 6cf548bc7..03472f051 100644 --- a/Eigen/src/Core/Cwise.h +++ b/Eigen/src/Eigen2Support/Cwise.h @@ -71,7 +71,7 @@ * * \sa MatrixBase::cwise() const, MatrixBase::cwise() */ -template class StorageBase> class Cwise +template class Cwise { public: @@ -87,19 +87,19 @@ template class StorageBase> class Cw template const EIGEN_CWISE_PRODUCT_RETURN_TYPE - operator*(const AnyMatrixBase &other) const; + operator*(const MatrixBase &other) const; template const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_quotient_op) - operator/(const StorageBase &other) const; + operator/(const MatrixBase &other) const; template const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_min_op) - min(const StorageBase &other) const; + min(const MatrixBase &other) const; template const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_max_op) - max(const StorageBase &other) const; + max(const MatrixBase &other) 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; @@ -129,28 +129,28 @@ template class StorageBase> class Cw ExpressionType& operator-=(const Scalar& scalar); template - inline ExpressionType& operator*=(const StorageBase &other); + inline ExpressionType& operator*=(const MatrixBase &other); template - inline ExpressionType& operator/=(const StorageBase &other); + inline ExpressionType& operator/=(const MatrixBase &other); template const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less) - operator<(const StorageBase& other) const; + operator<(const MatrixBase& other) const; template const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less_equal) - operator<=(const StorageBase& other) const; + operator<=(const MatrixBase& other) const; template const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater) - operator>(const StorageBase& other) const; + operator>(const MatrixBase& other) const; template const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater_equal) - operator>=(const StorageBase& other) const; + operator>=(const MatrixBase& other) const; template const EIGEN_CWISE_BINOP_RETURN_TYPE(std::equal_to) - operator==(const StorageBase& other) const; + operator==(const MatrixBase& other) const; template const EIGEN_CWISE_BINOP_RETURN_TYPE(std::not_equal_to) - operator!=(const StorageBase& other) const; + operator!=(const MatrixBase& other) const; // comparisons to a scalar value const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less) @@ -183,4 +183,31 @@ template class StorageBase> class Cw Cwise& operator=(const Cwise&); }; + +/** \returns a Cwise wrapper of *this providing additional coefficient-wise operations + * + * Example: \include MatrixBase_cwise_const.cpp + * Output: \verbinclude MatrixBase_cwise_const.out + * + * \sa class Cwise, cwise() + */ +template +inline const Cwise MatrixBase::cwise() const +{ + return derived(); +} + +/** \returns a Cwise wrapper of *this providing additional coefficient-wise operations + * + * Example: \include MatrixBase_cwise.cpp + * Output: \verbinclude MatrixBase_cwise.out + * + * \sa class Cwise, cwise() const + */ +template +inline Cwise MatrixBase::cwise() +{ + return derived(); +} + #endif // EIGEN_CWISE_H diff --git a/Eigen/src/Array/CwiseOperators.h b/Eigen/src/Eigen2Support/CwiseOperators.h similarity index 61% rename from Eigen/src/Array/CwiseOperators.h rename to Eigen/src/Eigen2Support/CwiseOperators.h index e74880c4e..fc5fe86c6 100644 --- a/Eigen/src/Array/CwiseOperators.h +++ b/Eigen/src/Eigen2Support/CwiseOperators.h @@ -25,6 +25,159 @@ #ifndef EIGEN_ARRAY_CWISE_OPERATORS_H #define EIGEN_ARRAY_CWISE_OPERATORS_H +/*************************************************************************** +* The following functions were defined in Core +***************************************************************************/ + + +/** \returns an expression of the coefficient-wise absolute value of \c *this + * + * Example: \include Cwise_abs.cpp + * Output: \verbinclude Cwise_abs.out + * + * \sa abs2() + */ +template +EIGEN_STRONG_INLINE const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_abs_op) +Cwise::abs() const +{ + return _expression(); +} + +/** \returns an expression of the coefficient-wise squared absolute value of \c *this + * + * Example: \include Cwise_abs2.cpp + * Output: \verbinclude Cwise_abs2.out + * + * \sa abs(), square() + */ +template +EIGEN_STRONG_INLINE const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_abs2_op) +Cwise::abs2() const +{ + return _expression(); +} + +/** \returns an expression of the coefficient-wise exponential of *this. + * + * Example: \include Cwise_exp.cpp + * Output: \verbinclude Cwise_exp.out + * + * \sa pow(), log(), sin(), cos() + */ +template +inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_exp_op) +Cwise::exp() const +{ + return _expression(); +} + +/** \returns an expression of the coefficient-wise logarithm of *this. + * + * Example: \include Cwise_log.cpp + * Output: \verbinclude Cwise_log.out + * + * \sa exp() + */ +template +inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_log_op) +Cwise::log() const +{ + return _expression(); +} + +/** \returns an expression of the Schur product (coefficient wise product) of *this and \a other + * + * Example: \include Cwise_product.cpp + * Output: \verbinclude Cwise_product.out + * + * \sa class CwiseBinaryOp, operator/(), square() + */ +template +template +EIGEN_STRONG_INLINE const EIGEN_CWISE_PRODUCT_RETURN_TYPE +Cwise::operator*(const MatrixBase &other) const +{ + return EIGEN_CWISE_PRODUCT_RETURN_TYPE(_expression(), other.derived()); +} + +/** \returns an expression of the coefficient-wise quotient of *this and \a other + * + * Example: \include Cwise_quotient.cpp + * Output: \verbinclude Cwise_quotient.out + * + * \sa class CwiseBinaryOp, operator*(), inverse() + */ +template +template +EIGEN_STRONG_INLINE const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_quotient_op) +Cwise::operator/(const MatrixBase &other) const +{ + return EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_quotient_op)(_expression(), other.derived()); +} + +/** Replaces this expression by its coefficient-wise product with \a other. + * + * Example: \include Cwise_times_equal.cpp + * Output: \verbinclude Cwise_times_equal.out + * + * \sa operator*(), operator/=() + */ +template +template +inline ExpressionType& Cwise::operator*=(const MatrixBase &other) +{ + return m_matrix.const_cast_derived() = *this * other; +} + +/** Replaces this expression by its coefficient-wise quotient by \a other. + * + * Example: \include Cwise_slash_equal.cpp + * Output: \verbinclude Cwise_slash_equal.out + * + * \sa operator/(), operator*=() + */ +template +template +inline ExpressionType& Cwise::operator/=(const MatrixBase &other) +{ + return m_matrix.const_cast_derived() = *this / other; +} + +/** \returns an expression of the coefficient-wise min of *this and \a other + * + * Example: \include Cwise_min.cpp + * Output: \verbinclude Cwise_min.out + * + * \sa class CwiseBinaryOp + */ +template +template +EIGEN_STRONG_INLINE const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_min_op) +Cwise::min(const MatrixBase &other) const +{ + 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 + * + * Example: \include Cwise_max.cpp + * Output: \verbinclude Cwise_max.out + * + * \sa class CwiseBinaryOp + */ +template +template +EIGEN_STRONG_INLINE const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_max_op) +Cwise::max(const MatrixBase &other) const +{ + return EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_max_op)(_expression(), other.derived()); +} + +/*************************************************************************** +* The following functions were defined in Array +***************************************************************************/ + // -- unary operators -- /** \array_module @@ -36,9 +189,9 @@ * * \sa pow(), square() */ -template class StorageBase> +template inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_sqrt_op) -Cwise::sqrt() const +Cwise::sqrt() const { return _expression(); } @@ -52,9 +205,9 @@ Cwise::sqrt() const * * \sa sin(), exp(), EIGEN_FAST_MATH */ -template class StorageBase> +template inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_cos_op) -Cwise::cos() const +Cwise::cos() const { return _expression(); } @@ -69,9 +222,9 @@ Cwise::cos() const * * \sa cos(), exp(), EIGEN_FAST_MATH */ -template class StorageBase> +template inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_sin_op) -Cwise::sin() const +Cwise::sin() const { return _expression(); } @@ -86,9 +239,9 @@ Cwise::sin() const * * \sa exp(), log() */ -template class StorageBase> +template inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_pow_op) -Cwise::pow(const Scalar& exponent) const +Cwise::pow(const Scalar& exponent) const { return EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_pow_op)(_expression(), ei_scalar_pow_op(exponent)); } @@ -103,9 +256,9 @@ Cwise::pow(const Scalar& exponent) const * * \sa operator/(), operator*() */ -template class StorageBase> +template inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_inverse_op) -Cwise::inverse() const +Cwise::inverse() const { return _expression(); } @@ -119,9 +272,9 @@ Cwise::inverse() const * * \sa operator/(), operator*(), abs2() */ -template class StorageBase> +template inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_square_op) -Cwise::square() const +Cwise::square() const { return _expression(); } @@ -135,9 +288,9 @@ Cwise::square() const * * \sa square(), pow() */ -template class StorageBase> +template inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_cube_op) -Cwise::cube() const +Cwise::cube() const { return _expression(); } @@ -154,10 +307,10 @@ Cwise::cube() const * * \sa MatrixBase::all(), MatrixBase::any(), operator>(), operator<=() */ -template class StorageBase> +template template inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less) -Cwise::operator<(const StorageBase &other) const +Cwise::operator<(const MatrixBase &other) const { return EIGEN_CWISE_BINOP_RETURN_TYPE(std::less)(_expression(), other.derived()); } @@ -171,10 +324,10 @@ Cwise::operator<(const StorageBase &ot * * \sa MatrixBase::all(), MatrixBase::any(), operator>=(), operator<() */ -template class StorageBase> +template template inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less_equal) -Cwise::operator<=(const StorageBase &other) const +Cwise::operator<=(const MatrixBase &other) const { return EIGEN_CWISE_BINOP_RETURN_TYPE(std::less_equal)(_expression(), other.derived()); } @@ -188,10 +341,10 @@ Cwise::operator<=(const StorageBase &o * * \sa MatrixBase::all(), MatrixBase::any(), operator>=(), operator<() */ -template class StorageBase> +template template inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater) -Cwise::operator>(const StorageBase &other) const +Cwise::operator>(const MatrixBase &other) const { return EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater)(_expression(), other.derived()); } @@ -205,10 +358,10 @@ Cwise::operator>(const StorageBase &ot * * \sa MatrixBase::all(), MatrixBase::any(), operator>(), operator<=() */ -template class StorageBase> +template template inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater_equal) -Cwise::operator>=(const StorageBase &other) const +Cwise::operator>=(const MatrixBase &other) const { return EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater_equal)(_expression(), other.derived()); } @@ -227,10 +380,10 @@ Cwise::operator>=(const StorageBase &o * * \sa MatrixBase::all(), MatrixBase::any(), MatrixBase::isApprox(), MatrixBase::isMuchSmallerThan() */ -template class StorageBase> +template template inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::equal_to) -Cwise::operator==(const StorageBase &other) const +Cwise::operator==(const MatrixBase &other) const { return EIGEN_CWISE_BINOP_RETURN_TYPE(std::equal_to)(_expression(), other.derived()); } @@ -249,10 +402,10 @@ Cwise::operator==(const StorageBase &o * * \sa MatrixBase::all(), MatrixBase::any(), MatrixBase::isApprox(), MatrixBase::isMuchSmallerThan() */ -template class StorageBase> +template template inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::not_equal_to) -Cwise::operator!=(const StorageBase &other) const +Cwise::operator!=(const MatrixBase &other) const { return EIGEN_CWISE_BINOP_RETURN_TYPE(std::not_equal_to)(_expression(), other.derived()); } @@ -265,9 +418,9 @@ Cwise::operator!=(const StorageBase &o * * \sa operator<(const MatrixBase &) const */ -template class StorageBase> +template inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less) -Cwise::operator<(Scalar s) const +Cwise::operator<(Scalar s) const { return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less)(_expression(), typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s)); @@ -279,9 +432,9 @@ Cwise::operator<(Scalar s) const * * \sa operator<=(const MatrixBase &) const */ -template class StorageBase> +template inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less_equal) -Cwise::operator<=(Scalar s) const +Cwise::operator<=(Scalar s) const { return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less_equal)(_expression(), typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s)); @@ -293,9 +446,9 @@ Cwise::operator<=(Scalar s) const * * \sa operator>(const MatrixBase &) const */ -template class StorageBase> +template inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater) -Cwise::operator>(Scalar s) const +Cwise::operator>(Scalar s) const { return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater)(_expression(), typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s)); @@ -307,9 +460,9 @@ Cwise::operator>(Scalar s) const * * \sa operator>=(const MatrixBase &) const */ -template class StorageBase> +template inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater_equal) -Cwise::operator>=(Scalar s) const +Cwise::operator>=(Scalar s) const { return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater_equal)(_expression(), typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s)); @@ -326,9 +479,9 @@ Cwise::operator>=(Scalar s) const * * \sa operator==(const MatrixBase &) const */ -template class StorageBase> +template inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::equal_to) -Cwise::operator==(Scalar s) const +Cwise::operator==(Scalar s) const { return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::equal_to)(_expression(), typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s)); @@ -345,9 +498,9 @@ Cwise::operator==(Scalar s) const * * \sa operator!=(const MatrixBase &) const */ -template class StorageBase> +template inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::not_equal_to) -Cwise::operator!=(Scalar s) const +Cwise::operator!=(Scalar s) const { return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::not_equal_to)(_expression(), typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s)); @@ -364,11 +517,11 @@ Cwise::operator!=(Scalar s) const * * \sa operator+=(), operator-() */ -template class StorageBase> -inline const typename Cwise::ScalarAddReturnType -Cwise::operator+(const Scalar& scalar) const +template +inline const typename Cwise::ScalarAddReturnType +Cwise::operator+(const Scalar& scalar) const { - return typename Cwise::ScalarAddReturnType(m_matrix, ei_scalar_add_op(scalar)); + return typename Cwise::ScalarAddReturnType(m_matrix, ei_scalar_add_op(scalar)); } /** \array_module @@ -380,8 +533,8 @@ Cwise::operator+(const Scalar& scalar) const * * \sa operator+(), operator-=() */ -template class StorageBase> -inline ExpressionType& Cwise::operator+=(const Scalar& scalar) +template +inline ExpressionType& Cwise::operator+=(const Scalar& scalar) { return m_matrix.const_cast_derived() = *this + scalar; } @@ -395,9 +548,9 @@ inline ExpressionType& Cwise::operator+=(const Scala * * \sa operator+(), operator-=() */ -template class StorageBase> -inline const typename Cwise::ScalarAddReturnType -Cwise::operator-(const Scalar& scalar) const +template +inline const typename Cwise::ScalarAddReturnType +Cwise::operator-(const Scalar& scalar) const { return *this + (-scalar); } @@ -412,8 +565,8 @@ Cwise::operator-(const Scalar& scalar) const * \sa operator+=(), operator-() */ -template class StorageBase> -inline ExpressionType& Cwise::operator-=(const Scalar& scalar) +template +inline ExpressionType& Cwise::operator-=(const Scalar& scalar) { return m_matrix.const_cast_derived() = *this - scalar; } diff --git a/Eigen/src/Core/Flagged.h b/Eigen/src/Eigen2Support/Flagged.h similarity index 100% rename from Eigen/src/Core/Flagged.h rename to Eigen/src/Eigen2Support/Flagged.h diff --git a/Eigen/src/Eigen2Support/Lazy.h b/Eigen/src/Eigen2Support/Lazy.h new file mode 100644 index 000000000..e69de29bb diff --git a/Eigen/src/Eigen2Support/TriangularSolver.h b/Eigen/src/Eigen2Support/TriangularSolver.h new file mode 100644 index 000000000..e69de29bb diff --git a/Eigen/src/Eigenvalues/ComplexEigenSolver.h b/Eigen/src/Eigenvalues/ComplexEigenSolver.h index 86206ce79..0441d4f02 100644 --- a/Eigen/src/Eigenvalues/ComplexEigenSolver.h +++ b/Eigen/src/Eigenvalues/ComplexEigenSolver.h @@ -133,7 +133,7 @@ void ComplexEigenSolver::compute(const MatrixType& matrix) for (int i=0; i::compute(const MatrixType& matrix, bool skipU) // compute the shift (the normalization by sf is to avoid under/overflow) Matrix t = m_matT.template block<2,2>(iu-1,iu-1); - sf = t.cwise().abs().sum(); + sf = t.cwiseAbs().sum(); t /= sf; c = t.determinant(); diff --git a/Eigen/src/Eigenvalues/EigenSolver.h b/Eigen/src/Eigenvalues/EigenSolver.h index 73d240de0..c9c239b98 100644 --- a/Eigen/src/Eigenvalues/EigenSolver.h +++ b/Eigen/src/Eigenvalues/EigenSolver.h @@ -225,7 +225,7 @@ void EigenSolver::orthes(MatrixType& matH, RealVectorType& ort) for (int m = low+1; m <= high-1; ++m) { // Scale column. - RealScalar scale = matH.block(m, m-1, high-m+1, 1).cwise().abs().sum(); + RealScalar scale = matH.block(m, m-1, high-m+1, 1).cwiseAbs().sum(); if (scale != 0.0) { // Compute Householder transformation. @@ -312,7 +312,7 @@ void EigenSolver::hqr2(MatrixType& matH) // Store roots isolated by balanc and compute matrix norm // FIXME to be efficient the following would requires a triangular reduxion code - // Scalar norm = matH.upper().cwise().abs().sum() + matH.corner(BottomLeft,n,n).diagonal().cwise().abs().sum(); + // Scalar norm = matH.upper().cwiseAbs().sum() + matH.corner(BottomLeft,n,n).diagonal().cwiseAbs().sum(); Scalar norm = 0.0; for (int j = 0; j < nn; ++j) { @@ -321,7 +321,7 @@ void EigenSolver::hqr2(MatrixType& matH) { m_eivalues.coeffRef(j) = Complex(matH.coeff(j,j), 0.0); } - norm += matH.row(j).segment(std::max(j-1,0), nn-std::max(j-1,0)).cwise().abs().sum(); + norm += matH.row(j).segment(std::max(j-1,0), nn-std::max(j-1,0)).cwiseAbs().sum(); } // Outer loop over eigenvalue index diff --git a/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h b/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h index 9e155de8f..336976517 100644 --- a/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h +++ b/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h @@ -112,7 +112,7 @@ template class SelfAdjointEigenSolver */ MatrixType operatorSqrt() const { - return m_eivec * m_eivalues.cwise().sqrt().asDiagonal() * m_eivec.adjoint(); + return m_eivec * m_eivalues.cwiseSqrt().asDiagonal() * m_eivec.adjoint(); } /** \returns the positive inverse square root of the matrix @@ -121,7 +121,7 @@ template class SelfAdjointEigenSolver */ MatrixType operatorInverseSqrt() const { - return m_eivec * m_eivalues.cwise().inverse().cwise().sqrt().asDiagonal() * m_eivec.adjoint(); + return m_eivec * m_eivalues.cwiseInverse().cwiseSqrt().asDiagonal() * m_eivec.adjoint(); } @@ -287,7 +287,7 @@ struct ei_operatorNorm_selector { // FIXME if it is really guaranteed that the eigenvalues are already sorted, // then we don't need to compute a maxCoeff() here, comparing the 1st and last ones is enough. - return m.eigenvalues().cwise().abs().maxCoeff(); + return m.eigenvalues().cwiseAbs().maxCoeff(); } }; diff --git a/Eigen/src/Geometry/AlignedBox.h b/Eigen/src/Geometry/AlignedBox.h index 94edc5561..003ceaad1 100644 --- a/Eigen/src/Geometry/AlignedBox.h +++ b/Eigen/src/Geometry/AlignedBox.h @@ -67,7 +67,7 @@ EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_AmbientDim) inline int dim() const { return AmbientDimAtCompileTime==Dynamic ? m_min.size()-1 : AmbientDimAtCompileTime; } /** \returns true if the box is null, i.e, empty. */ - inline bool isNull() const { return (m_min.cwise() > m_max).any(); } + inline bool isNull() const { return (m_min.array() > m_max).any(); } /** Makes \c *this a null/empty box. */ inline void setNull() @@ -90,31 +90,31 @@ EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_AmbientDim) /** \returns true if the point \a p is inside the box \c *this. */ inline bool contains(const VectorType& p) const - { return (m_min.cwise()<=p).all() && (p.cwise()<=m_max).all(); } + { return (m_min.array()<=p).all() && (p.array()<=m_max).all(); } /** \returns true if the box \a b is entirely inside the box \c *this. */ inline bool contains(const AlignedBox& b) const - { return (m_min.cwise()<=b.min()).all() && (b.max().cwise()<=m_max).all(); } + { return (m_min.array()<=b.min()).all() && (b.max().array()<=m_max).all(); } /** Extends \c *this such that it contains the point \a p and returns a reference to \c *this. */ inline AlignedBox& extend(const VectorType& p) - { m_min = m_min.cwise().min(p); m_max = m_max.cwise().max(p); return *this; } + { m_min = m_min.cwiseMin(p); m_max = m_max.cwiseMax(p); return *this; } /** Extends \c *this such that it contains the box \a b and returns a reference to \c *this. */ inline AlignedBox& extend(const AlignedBox& b) - { m_min = m_min.cwise().min(b.m_min); m_max = m_max.cwise().max(b.m_max); return *this; } + { m_min = m_min.cwiseMin(b.m_min); m_max = m_max.cwiseMax(b.m_max); return *this; } /** Clamps \c *this by the box \a b and returns a reference to \c *this. */ inline AlignedBox& clamp(const AlignedBox& b) - { m_min = m_min.cwise().max(b.m_min); m_max = m_max.cwise().min(b.m_max); return *this; } + { m_min = m_min.cwiseMax(b.m_min); m_max = m_max.cwiseMin(b.m_max); return *this; } /** Returns an AlignedBox that is the intersection of \a b and \c *this */ inline AlignedBox intersection(const AlignedBox &b) const - { return AlignedBox(m_min.cwise().max(b.m_min), m_max.cwise().min(b.m_max)); } + { return AlignedBox(m_min.cwiseMax(b.m_min), m_max.cwiseMin(b.m_max)); } /** Returns an AlignedBox that is the union of \a b and \c *this */ inline AlignedBox merged(const AlignedBox &b) const - { return AlignedBox(m_min.cwise().min(b.m_min), m_max.cwise().max(b.m_max)); } + { return AlignedBox(m_min.cwiseMin(b.m_min), m_max.cwiseMax(b.m_max)); } /** Translate \c *this by the vector \a t and returns a reference to \c *this. */ inline AlignedBox& translate(const VectorType& t) diff --git a/Eigen/src/Geometry/AngleAxis.h b/Eigen/src/Geometry/AngleAxis.h index ef86eb20d..d948ea40b 100644 --- a/Eigen/src/Geometry/AngleAxis.h +++ b/Eigen/src/Geometry/AngleAxis.h @@ -213,7 +213,7 @@ AngleAxis::toRotationMatrix(void) const res.coeffRef(1,2) = tmp - sin_axis.x(); res.coeffRef(2,1) = tmp + sin_axis.x(); - res.diagonal() = (cos1_axis.cwise() * m_axis).cwise() + c; + res.diagonal() = (cos1_axis.cwiseProduct(m_axis)).array() + c; return res; } diff --git a/Eigen/src/Geometry/Homogeneous.h b/Eigen/src/Geometry/Homogeneous.h index 17fbdd85d..f64c92bc1 100644 --- a/Eigen/src/Geometry/Homogeneous.h +++ b/Eigen/src/Geometry/Homogeneous.h @@ -194,7 +194,7 @@ VectorwiseOp::hnormalized() const return HNormalized_Block(_expression(),0,0, Direction==Vertical ? _expression().rows()-1 : _expression().rows(), Direction==Horizontal ? _expression().cols()-1 : _expression().cols()).nestByValue() - .cwise()/ + .cwiseQuotient( Replicate, Direction==Vertical ? HNormalized_SizeMinusOne : 1, Direction==Horizontal ? HNormalized_SizeMinusOne : 1> @@ -204,7 +204,7 @@ VectorwiseOp::hnormalized() const Direction==Vertical ? 1 : _expression().rows(), Direction==Horizontal ? 1 : _expression().cols()).nestByValue(), Direction==Vertical ? _expression().rows()-1 : 1, - Direction==Horizontal ? _expression().cols()-1 : 1).nestByValue(); + Direction==Horizontal ? _expression().cols()-1 : 1).nestByValue()); } template diff --git a/Eigen/src/Geometry/OrthoMethods.h b/Eigen/src/Geometry/OrthoMethods.h index 6d4a8f673..631b82bf5 100644 --- a/Eigen/src/Geometry/OrthoMethods.h +++ b/Eigen/src/Geometry/OrthoMethods.h @@ -142,7 +142,7 @@ struct ei_unitOrthogonal_selector VectorType perp = VectorType::Zero(src.size()); int maxi = 0; int sndi = 0; - src.cwise().abs().maxCoeff(&maxi); + src.cwiseAbs().maxCoeff(&maxi); if (maxi==0) sndi = 1; RealScalar invnm = RealScalar(1)/(Vector2() << src.coeff(sndi),src.coeff(maxi)).finished().norm(); diff --git a/Eigen/src/LU/FullPivLU.h b/Eigen/src/LU/FullPivLU.h index d8975b0b6..89eec38c7 100644 --- a/Eigen/src/LU/FullPivLU.h +++ b/Eigen/src/LU/FullPivLU.h @@ -89,7 +89,7 @@ template class FullPivLU * \returns a reference to *this */ FullPivLU& compute(const MatrixType& matrix); - + /** \returns the LU decomposition matrix: the upper-triangular part is U, the * unit-lower-triangular part is L (at least for square matrices; in the non-square * case, special care is needed, see the documentation of class FullPivLU). @@ -101,7 +101,7 @@ template class FullPivLU ei_assert(m_isInitialized && "LU is not initialized."); return m_lu; } - + /** \returns the number of nonzero pivots in the LU decomposition. * Here nonzero is meant in the exact sense, not in a fuzzy sense. * So that notion isn't really intrinsically interesting, but it is @@ -114,12 +114,12 @@ template class FullPivLU ei_assert(m_isInitialized && "LU is not initialized."); return m_nonzero_pivots; } - + /** \returns the absolute value of the biggest pivot, i.e. the biggest * diagonal coefficient of U. */ RealScalar maxPivot() const { return m_maxpivot; } - + /** \returns a vector of integers, whose size is the number of rows of the matrix being decomposed, * representing the P permutation i.e. the permutation of the rows. For its precise meaning, * see the examples given in the documentation of class FullPivLU. @@ -255,7 +255,7 @@ template class FullPivLU m_usePrescribedThreshold = true; m_prescribedThreshold = threshold; } - + /** Allows to come back to the default behavior, letting Eigen use its default formula for * determining the threshold. * @@ -268,7 +268,7 @@ template class FullPivLU { m_usePrescribedThreshold = false; } - + /** Returns the threshold that will be used by certain methods such as rank(). * * See the documentation of setThreshold(const RealScalar&). @@ -281,7 +281,7 @@ template class FullPivLU // and turns out to be identical to Higham's formula used already in LDLt. : epsilon() * m_lu.diagonalSize(); } - + /** \returns the rank of the matrix of which *this is the LU decomposition. * * \note This method has to determine which pivots should be considered nonzero. @@ -297,7 +297,7 @@ template class FullPivLU result += (ei_abs(m_lu.coeff(i,i)) > premultiplied_threshold); return result; } - + /** \returns the dimension of the kernel of the matrix of which *this is the LU decomposition. * * \note This method has to determine which pivots should be considered nonzero. @@ -365,7 +365,7 @@ template class FullPivLU inline int rows() const { return m_lu.rows(); } inline int cols() const { return m_lu.cols(); } - + protected: MatrixType m_lu; IntColVectorType m_p; @@ -416,7 +416,7 @@ FullPivLU& FullPivLU::compute(const MatrixType& matrix) int row_of_biggest_in_corner, col_of_biggest_in_corner; RealScalar biggest_in_corner; biggest_in_corner = m_lu.corner(Eigen::BottomRight, rows-k, cols-k) - .cwise().abs() + .cwiseAbs() .maxCoeff(&row_of_biggest_in_corner, &col_of_biggest_in_corner); row_of_biggest_in_corner += k; // correct the values! since they were computed in the corner, col_of_biggest_in_corner += k; // need to add k to them. @@ -453,7 +453,7 @@ FullPivLU& FullPivLU::compute(const MatrixType& matrix) // Now that the pivot is at the right location, we update the remaining // bottom-right corner by Gaussian elimination. - + if(k > dst.setZero(); return; } - + /* Let us use the following lemma: * * Lemma: If the matrix A has the LU decomposition PAQ = LU, @@ -575,7 +575,7 @@ struct ei_image_retval > : ei_image_retval_base > { EIGEN_MAKE_IMAGE_HELPERS(FullPivLU<_MatrixType>) - + enum { MaxSmallDimAtCompileTime = EIGEN_ENUM_MIN( MatrixType::MaxColsAtCompileTime, MatrixType::MaxRowsAtCompileTime) @@ -591,7 +591,7 @@ struct ei_image_retval > dst.setZero(); return; } - + Matrix pivots(rank()); RealScalar premultiplied_threshold = dec().maxPivot() * dec().threshold(); int p = 0; @@ -599,7 +599,7 @@ struct ei_image_retval > if(ei_abs(dec().matrixLU().coeff(i,i)) > premultiplied_threshold) pivots.coeffRef(p++) = i; ei_internal_assert(p == rank()); - + for(int i = 0; i < rank(); ++i) dst.col(i) = originalMatrix().col(dec().permutationQ().coeff(pivots.coeff(i))); } @@ -612,7 +612,7 @@ struct ei_solve_retval, Rhs> : ei_solve_retval_base, Rhs> { EIGEN_MAKE_SOLVE_HELPERS(FullPivLU<_MatrixType>,Rhs) - + template void evalTo(Dest& dst) const { /* The decomposition PAQ = LU can be rewritten as A = P^{-1} L U Q^{-1}. diff --git a/Eigen/src/LU/Inverse.h b/Eigen/src/LU/Inverse.h index 306b5f60a..13de19ace 100644 --- a/Eigen/src/LU/Inverse.h +++ b/Eigen/src/LU/Inverse.h @@ -148,7 +148,7 @@ struct ei_compute_inverse cofactors_col0.coeffRef(0) = matrix.minor(0,0).determinant(); cofactors_col0.coeffRef(1) = -matrix.minor(1,0).determinant(); cofactors_col0.coeffRef(2) = matrix.minor(2,0).determinant(); - const Scalar det = (cofactors_col0.cwise()*matrix.col(0)).sum(); + const Scalar det = (cofactors_col0.cwiseProduct(matrix.col(0))).sum(); const Scalar invdet = Scalar(1) / det; ei_compute_inverse_size3_helper(matrix, invdet, cofactors_col0, result); } @@ -170,7 +170,7 @@ struct ei_compute_inverse_and_det_with_check cofactors_col0.coeffRef(0) = matrix.minor(0,0).determinant(); cofactors_col0.coeffRef(1) = -matrix.minor(1,0).determinant(); cofactors_col0.coeffRef(2) = matrix.minor(2,0).determinant(); - determinant = (cofactors_col0.cwise()*matrix.col(0)).sum(); + determinant = (cofactors_col0.cwiseProduct(matrix.col(0))).sum(); invertible = ei_abs(determinant) > absDeterminantThreshold; if(!invertible) return; const Scalar invdet = Scalar(1) / determinant; @@ -256,7 +256,7 @@ struct ei_compute_inverse // now good_row0 and good_row1 are correctly set good: - + // do row permutations to move this 2x2 block to the top matrix.row(0).swap(matrix.row(good_row0)); matrix.row(1).swap(matrix.row(good_row1)); diff --git a/Eigen/src/LU/PartialPivLU.h b/Eigen/src/LU/PartialPivLU.h index 03c91456a..6c9097db0 100644 --- a/Eigen/src/LU/PartialPivLU.h +++ b/Eigen/src/LU/PartialPivLU.h @@ -233,7 +233,7 @@ struct ei_partial_lu_impl { int row_of_biggest_in_col; RealScalar biggest_in_corner - = lu.col(k).end(rows-k).cwise().abs().maxCoeff(&row_of_biggest_in_col); + = lu.col(k).end(rows-k).cwiseAbs().maxCoeff(&row_of_biggest_in_col); row_of_biggest_in_col += k; if(biggest_in_corner == 0) // the pivot is exactly zero: the matrix is singular @@ -412,7 +412,7 @@ struct ei_solve_retval, Rhs> : ei_solve_retval_base, Rhs> { EIGEN_MAKE_SOLVE_HELPERS(PartialPivLU<_MatrixType>,Rhs) - + template void evalTo(Dest& dst) const { /* The decomposition PA = LU can be rewritten as A = P^{-1} L U. @@ -421,7 +421,7 @@ struct ei_solve_retval, Rhs> * Step 2: replace c by the solution x to Lx = c. * Step 3: replace c by the solution x to Ux = c. */ - + const int size = dec().matrixLU().rows(); ei_assert(rhs().rows() == size); diff --git a/Eigen/src/Sparse/SparseCwiseBinaryOp.h b/Eigen/src/Sparse/SparseCwiseBinaryOp.h index 5dd7edc00..b1f228dbe 100644 --- a/Eigen/src/Sparse/SparseCwiseBinaryOp.h +++ b/Eigen/src/Sparse/SparseCwiseBinaryOp.h @@ -283,15 +283,15 @@ class ei_sparse_cwise_binary_op_inner_iterator_selector, * Implementation of SparseMatrixBase and SparseCwise functions/operators ***************************************************************************/ -template -template -EIGEN_STRONG_INLINE const CwiseBinaryOp::Scalar>, - Derived, OtherDerived> -SparseMatrixBase::operator-(const SparseMatrixBase &other) const -{ - return CwiseBinaryOp, - Derived, OtherDerived>(derived(), other.derived()); -} +// template +// template +// EIGEN_STRONG_INLINE const CwiseBinaryOp::Scalar>, +// Derived, OtherDerived> +// SparseMatrixBase::operator-(const SparseMatrixBase &other) const +// { +// return CwiseBinaryOp, +// Derived, OtherDerived>(derived(), other.derived()); +// } template template @@ -301,13 +301,13 @@ SparseMatrixBase::operator-=(const SparseMatrixBase &othe return *this = derived() - other.derived(); } -template -template -EIGEN_STRONG_INLINE const CwiseBinaryOp::Scalar>, Derived, OtherDerived> -SparseMatrixBase::operator+(const SparseMatrixBase &other) const -{ - return CwiseBinaryOp, Derived, OtherDerived>(derived(), other.derived()); -} +// template +// template +// EIGEN_STRONG_INLINE const CwiseBinaryOp::Scalar>, Derived, OtherDerived> +// SparseMatrixBase::operator+(const SparseMatrixBase &other) const +// { +// return CwiseBinaryOp, Derived, OtherDerived>(derived(), other.derived()); +// } template template diff --git a/Eigen/src/Sparse/SparseMatrixBase.h b/Eigen/src/Sparse/SparseMatrixBase.h index 2b6970818..77dba5e90 100644 --- a/Eigen/src/Sparse/SparseMatrixBase.h +++ b/Eigen/src/Sparse/SparseMatrixBase.h @@ -111,6 +111,7 @@ template class SparseMatrixBase : public AnyMatrixBase class SparseMatrixBase : public AnyMatrixBase::Scalar>,Derived> operator-() const; - template - const CwiseBinaryOp::Scalar>, Derived, OtherDerived> - operator+(const SparseMatrixBase &other) const; +// template +// const CwiseBinaryOp::Scalar>, Derived, OtherDerived> +// operator+(const SparseMatrixBase &other) const; - template - const CwiseBinaryOp::Scalar>, Derived, OtherDerived> - operator-(const SparseMatrixBase &other) const; +// template +// const CwiseBinaryOp::Scalar>, Derived, OtherDerived> +// operator-(const SparseMatrixBase &other) const; template Derived& operator+=(const SparseMatrixBase& other); diff --git a/test/array.cpp b/test/array.cpp index a18724d3a..9b349db49 100644 --- a/test/array.cpp +++ b/test/array.cpp @@ -22,6 +22,7 @@ // License and a copy of the GNU General Public License along with // Eigen. If not, see . +#define EIGEN2_SUPPORT #include "main.h" #include diff --git a/test/cwiseop.cpp b/test/cwiseop.cpp index 7574bcc4a..f5e825d39 100644 --- a/test/cwiseop.cpp +++ b/test/cwiseop.cpp @@ -23,6 +23,7 @@ // License and a copy of the GNU General Public License along with // Eigen. If not, see . +#define EIGEN2_SUPPORT #include "main.h" #include #include @@ -60,9 +61,9 @@ template void cwiseops(const MatrixType& m) int r = ei_random(0, rows-1), c = ei_random(0, cols-1); - + Scalar s1 = ei_random(); - + // test Zero, Ones, Constant, and the set* variants m3 = MatrixType::Constant(rows, cols, s1); for (int j=0; j void cwiseops(const MatrixType& m) VERIFY_IS_APPROX(m4.setOnes(rows,cols), mones); m4.fill(s1); VERIFY_IS_APPROX(m4, m3); - + VERIFY_IS_APPROX(v3.setConstant(rows, s1), VectorType::Constant(rows,s1)); VERIFY_IS_APPROX(v3.setZero(rows), vzero); VERIFY_IS_APPROX(v3.setOnes(rows), vones); @@ -107,7 +108,7 @@ template void cwiseops(const MatrixType& m) m3 = m1; m3.cwise() *= m2; VERIFY_IS_APPROX(m3, m1.cwise() * m2); - + VERIFY_IS_APPROX(mones, m2.cwise()/m2); if(NumTraits::HasFloatingPoint) { @@ -122,7 +123,7 @@ template void cwiseops(const MatrixType& m) VERIFY_IS_APPROX(m3.cwise().pow(-1), m3.cwise().inverse()); m3 = m1.cwise().abs(); VERIFY_IS_APPROX(m3.cwise().pow(RealScalar(0.5)), m3.cwise().sqrt()); - + // VERIFY_IS_APPROX(m1.cwise().tan(), m1.cwise().sin().cwise() / m1.cwise().cos()); VERIFY_IS_APPROX(mones, m1.cwise().sin().cwise().square() + m1.cwise().cos().cwise().square()); m3 = m1; @@ -139,7 +140,7 @@ template void cwiseops(const MatrixType& m) VERIFY_IS_APPROX( m1.cwise().max(m2), m2.cwise().max(m1) ); VERIFY_IS_APPROX( m1.cwise().max(m1-mones), m1 ); VERIFY_IS_APPROX( m1.cwise().max(m1+mones), m1+mones ); - + VERIFY( (m1.cwise() == m1).all() ); VERIFY( (m1.cwise() != m2).any() ); VERIFY(!(m1.cwise() == (m1+mones)).any() ); diff --git a/test/eigensolver_complex.cpp b/test/eigensolver_complex.cpp index 756527d57..11b7be5f7 100644 --- a/test/eigensolver_complex.cpp +++ b/test/eigensolver_complex.cpp @@ -52,7 +52,7 @@ template void eigensolver(const MatrixType& m) // Regression test for issue #66 MatrixType z = MatrixType::Zero(rows,cols); ComplexEigenSolver eiz(z); - VERIFY((eiz.eigenvalues().cwise()==0).all()); + VERIFY((eiz.eigenvalues().cwiseEqual(0)).all()); } void test_eigensolver_complex() diff --git a/test/eigensolver_selfadjoint.cpp b/test/eigensolver_selfadjoint.cpp index 632c1d2e7..f2146cb88 100644 --- a/test/eigensolver_selfadjoint.cpp +++ b/test/eigensolver_selfadjoint.cpp @@ -79,7 +79,7 @@ template void selfadjointeigensolver(const MatrixType& m) // compare with eigen VERIFY_IS_APPROX(_eval, eiSymm.eigenvalues()); - VERIFY_IS_APPROX(_evec.cwise().abs(), eiSymm.eigenvectors().cwise().abs()); + VERIFY_IS_APPROX(_evec.cwiseAbs(), eiSymm.eigenvectors().cwiseAbs()); // generalized pb Gsl::eigen_symm_gen(gSymmA, gSymmB, gEval, gEvec); @@ -92,7 +92,7 @@ template void selfadjointeigensolver(const MatrixType& m) // std::cerr << _eval.transpose() << "\n" << eiSymmGen.eigenvalues().transpose() << "\n\n"; // std::cerr << _evec.format(6) << "\n\n" << eiSymmGen.eigenvectors().format(6) << "\n\n\n"; VERIFY_IS_APPROX(_eval, eiSymmGen.eigenvalues()); - VERIFY_IS_APPROX(_evec.cwise().abs(), eiSymmGen.eigenvectors().cwise().abs()); + VERIFY_IS_APPROX(_evec.cwiseAbs(), eiSymmGen.eigenvectors().cwiseAbs()); Gsl::free(gSymmA); Gsl::free(gSymmB); diff --git a/test/geo_alignedbox.cpp b/test/geo_alignedbox.cpp index d496578da..d6b6e1bb3 100644 --- a/test/geo_alignedbox.cpp +++ b/test/geo_alignedbox.cpp @@ -22,6 +22,7 @@ // License and a copy of the GNU General Public License along with // Eigen. If not, see . +#define EIGEN2_SUPPORT #include "main.h" #include #include diff --git a/test/geo_eulerangles.cpp b/test/geo_eulerangles.cpp index 98cdf6a86..049652aab 100644 --- a/test/geo_eulerangles.cpp +++ b/test/geo_eulerangles.cpp @@ -22,6 +22,7 @@ // License and a copy of the GNU General Public License along with // Eigen. If not, see . +#define EIGEN2_SUPPORT #include "main.h" #include #include diff --git a/test/geo_homogeneous.cpp b/test/geo_homogeneous.cpp index 48d8cbcdf..6bae9c31a 100644 --- a/test/geo_homogeneous.cpp +++ b/test/geo_homogeneous.cpp @@ -22,6 +22,7 @@ // License and a copy of the GNU General Public License along with // Eigen. If not, see . +#define EIGEN2_SUPPORT #include "main.h" #include diff --git a/test/geo_hyperplane.cpp b/test/geo_hyperplane.cpp index 3cf5655c2..769bf3183 100644 --- a/test/geo_hyperplane.cpp +++ b/test/geo_hyperplane.cpp @@ -23,6 +23,7 @@ // License and a copy of the GNU General Public License along with // Eigen. If not, see . +#define EIGEN2_SUPPORT #include "main.h" #include #include diff --git a/test/geo_orthomethods.cpp b/test/geo_orthomethods.cpp index 54a6febab..cae860464 100644 --- a/test/geo_orthomethods.cpp +++ b/test/geo_orthomethods.cpp @@ -22,6 +22,7 @@ // License and a copy of the GNU General Public License along with // Eigen. If not, see . +#define EIGEN2_SUPPORT #include "main.h" #include #include diff --git a/test/geo_parametrizedline.cpp b/test/geo_parametrizedline.cpp index 137324a98..38496a6b0 100644 --- a/test/geo_parametrizedline.cpp +++ b/test/geo_parametrizedline.cpp @@ -23,6 +23,7 @@ // License and a copy of the GNU General Public License along with // Eigen. If not, see . +#define EIGEN2_SUPPORT #include "main.h" #include #include diff --git a/test/geo_quaternion.cpp b/test/geo_quaternion.cpp index 2e97fe295..9a06a7bd9 100644 --- a/test/geo_quaternion.cpp +++ b/test/geo_quaternion.cpp @@ -23,6 +23,7 @@ // License and a copy of the GNU General Public License along with // Eigen. If not, see . +#define EIGEN2_SUPPORT #include "main.h" #include #include diff --git a/test/geo_transformations.cpp b/test/geo_transformations.cpp index 84b3c5355..334771261 100644 --- a/test/geo_transformations.cpp +++ b/test/geo_transformations.cpp @@ -22,6 +22,7 @@ // License and a copy of the GNU General Public License along with // Eigen. If not, see . +#define EIGEN2_SUPPORT #include "main.h" #include #include @@ -109,7 +110,7 @@ template void transformations(void) t0.matrix().setZero(); t0 = Transform3::Identity(); VERIFY_IS_APPROX(t0.matrix(), Transform3::MatrixType::Identity()); - + t0.linear() = q1.toRotationMatrix(); t1.setIdentity(); t1.linear() = q1.toRotationMatrix(); @@ -351,7 +352,7 @@ template void transformations(void) VERIFY_IS_APPROX(r2d1f.template cast(),r2d1); Rotation2D r2d1d = r2d1.template cast(); VERIFY_IS_APPROX(r2d1d.template cast(),r2d1); - + } void test_geo_transformations()