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