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
This commit is contained in:
Gael Guennebaud 2009-11-18 18:15:19 +01:00
parent 0529ecfe1b
commit e3d890bc5a
48 changed files with 634 additions and 408 deletions

View File

@ -28,7 +28,6 @@ namespace Eigen {
* \endcode * \endcode
*/ */
#include "src/Array/CwiseOperators.h"
#include "src/Array/Functors.h" #include "src/Array/Functors.h"
#include "src/Array/BooleanRedux.h" #include "src/Array/BooleanRedux.h"
#include "src/Array/Select.h" #include "src/Array/Select.h"

View File

@ -31,7 +31,6 @@ namespace Eigen {
*/ */
#include "src/misc/Solve.h" #include "src/misc/Solve.h"
#include "src/Array/CwiseOperators.h"
#include "src/Array/Functors.h" #include "src/Array/Functors.h"
#include "src/Cholesky/LLT.h" #include "src/Cholesky/LLT.h"
#include "src/Cholesky/LDLT.h" #include "src/Cholesky/LDLT.h"

View File

@ -23,6 +23,10 @@
// License and a copy of the GNU General Public License along with // License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>. // Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifdef EIGEN2_SUPPORT
#include "Eigen2Support"
#endif
#ifndef EIGEN_CORE_H #ifndef EIGEN_CORE_H
#define EIGEN_CORE_H #define EIGEN_CORE_H
@ -161,10 +165,8 @@ struct Dense {};
#include "src/Core/MatrixStorage.h" #include "src/Core/MatrixStorage.h"
#include "src/Core/NestByValue.h" #include "src/Core/NestByValue.h"
#include "src/Core/ReturnByValue.h" #include "src/Core/ReturnByValue.h"
#include "src/Core/Flagged.h"
#include "src/Core/NoAlias.h" #include "src/Core/NoAlias.h"
#include "src/Core/Matrix.h" #include "src/Core/Matrix.h"
#include "src/Core/Cwise.h"
#include "src/Core/CwiseBinaryOp.h" #include "src/Core/CwiseBinaryOp.h"
#include "src/Core/CwiseUnaryOp.h" #include "src/Core/CwiseUnaryOp.h"
#include "src/Core/CwiseNullaryOp.h" #include "src/Core/CwiseNullaryOp.h"

57
Eigen/Eigen2Support Normal file
View File

@ -0,0 +1,57 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
// Copyright (C) 2009 Gael Guennebaud <g.gael@free.fr>
//
// 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 <http://www.gnu.org/licenses/>.
#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 <Eigen/Eigen2Support>
* \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

View File

@ -31,7 +31,7 @@ struct ei_lpNorm_selector
typedef typename NumTraits<typename ei_traits<Derived>::Scalar>::Real RealScalar; typedef typename NumTraits<typename ei_traits<Derived>::Scalar>::Real RealScalar;
inline static RealScalar run(const MatrixBase<Derived>& m) inline static RealScalar run(const MatrixBase<Derived>& 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<Derived, 1>
{ {
inline static typename NumTraits<typename ei_traits<Derived>::Scalar>::Real run(const MatrixBase<Derived>& m) inline static typename NumTraits<typename ei_traits<Derived>::Scalar>::Real run(const MatrixBase<Derived>& m)
{ {
return m.cwise().abs().sum(); return m.cwiseAbs().sum();
} }
}; };
@ -58,7 +58,7 @@ struct ei_lpNorm_selector<Derived, Infinity>
{ {
inline static typename NumTraits<typename ei_traits<Derived>::Scalar>::Real run(const MatrixBase<Derived>& m) inline static typename NumTraits<typename ei_traits<Derived>::Scalar>::Real run(const MatrixBase<Derived>& m)
{ {
return m.cwise().abs().maxCoeff(); return m.cwiseAbs().maxCoeff();
} }
}; };

View File

@ -194,7 +194,7 @@ LDLT<MatrixType>& LDLT<MatrixType>::compute(const MatrixType& a)
{ {
// Find largest diagonal element // Find largest diagonal element
int index_of_biggest_in_corner; 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); .maxCoeff(&index_of_biggest_in_corner);
index_of_biggest_in_corner += j; index_of_biggest_in_corner += j;
@ -304,7 +304,7 @@ bool LDLT<MatrixType>::solveInPlace(MatrixBase<Derived> &bAndX) const
m_matrix.template triangularView<UnitLowerTriangular>().solveInPlace(bAndX); m_matrix.template triangularView<UnitLowerTriangular>().solveInPlace(bAndX);
// w = D^-1 y // w = D^-1 y
bAndX = (m_matrix.diagonal().cwise().inverse().asDiagonal() * bAndX).lazy(); bAndX = m_matrix.diagonal().asDiagonal().inverse() * bAndX;
// u = L^-T w // u = L^-T w
m_matrix.adjoint().template triangularView<UnitUpperTriangular>().solveInPlace(bAndX); m_matrix.adjoint().template triangularView<UnitUpperTriangular>().solveInPlace(bAndX);

View File

@ -169,22 +169,6 @@ class CwiseBinaryOpImpl<BinaryOp, Lhs, Rhs, Dense>
} }
}; };
/**\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<typename Derived>
template<typename OtherDerived>
EIGEN_STRONG_INLINE const CwiseBinaryOp<ei_scalar_difference_op<typename ei_traits<Derived>::Scalar>,
Derived, OtherDerived>
MatrixBase<Derived>::operator-(const MatrixBase<OtherDerived> &other) const
{
return CwiseBinaryOp<ei_scalar_difference_op<Scalar>,
Derived, OtherDerived>(derived(), other.derived());
}
/** replaces \c *this by \c *this - \a other. /** replaces \c *this by \c *this - \a other.
* *
* \returns a reference to \c *this * \returns a reference to \c *this
@ -197,22 +181,6 @@ MatrixBase<Derived>::operator-=(const MatrixBase<OtherDerived> &other)
return *this = *this - 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<typename Derived>
template<typename OtherDerived>
EIGEN_STRONG_INLINE const CwiseBinaryOp<ei_scalar_sum_op<typename ei_traits<Derived>::Scalar>, Derived, OtherDerived>
MatrixBase<Derived>::operator+(const MatrixBase<OtherDerived> &other) const
{
return CwiseBinaryOp<ei_scalar_sum_op<Scalar>, Derived, OtherDerived>(derived(), other.derived());
}
/** replaces \c *this by \c *this + \a other. /** replaces \c *this by \c *this + \a other.
* *
* \returns a reference to \c *this * \returns a reference to \c *this
@ -225,111 +193,4 @@ MatrixBase<Derived>::operator+=(const MatrixBase<OtherDerived>& other)
return *this = *this + 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<typename ExpressionType,template <typename> class StorageBase>
template<typename OtherDerived>
EIGEN_STRONG_INLINE const EIGEN_CWISE_PRODUCT_RETURN_TYPE
Cwise<ExpressionType,StorageBase>::operator*(const AnyMatrixBase<OtherDerived> &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<typename ExpressionType,template <typename> class StorageBase>
template<typename OtherDerived>
EIGEN_STRONG_INLINE const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_quotient_op)
Cwise<ExpressionType,StorageBase>::operator/(const StorageBase<OtherDerived> &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<typename ExpressionType,template <typename> class StorageBase>
template<typename OtherDerived>
inline ExpressionType& Cwise<ExpressionType,StorageBase>::operator*=(const StorageBase<OtherDerived> &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<typename ExpressionType,template <typename> class StorageBase>
template<typename OtherDerived>
inline ExpressionType& Cwise<ExpressionType,StorageBase>::operator/=(const StorageBase<OtherDerived> &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<typename ExpressionType,template <typename> class StorageBase>
template<typename OtherDerived>
EIGEN_STRONG_INLINE const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_min_op)
Cwise<ExpressionType,StorageBase>::min(const StorageBase<OtherDerived> &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<typename ExpressionType,template <typename> class StorageBase>
template<typename OtherDerived>
EIGEN_STRONG_INLINE const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_max_op)
Cwise<ExpressionType,StorageBase>::max(const StorageBase<OtherDerived> &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<typename Derived>
template<typename CustomBinaryOp, typename OtherDerived>
EIGEN_STRONG_INLINE const CwiseBinaryOp<CustomBinaryOp, Derived, OtherDerived>
MatrixBase<Derived>::binaryExpr(const MatrixBase<OtherDerived> &other, const CustomBinaryOp& func) const
{
return CwiseBinaryOp<CustomBinaryOp, Derived, OtherDerived>(derived(), other.derived(), func);
}
#endif // EIGEN_CWISE_BINARY_OP_H #endif // EIGEN_CWISE_BINARY_OP_H

View File

@ -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<typename OtherDerived>
EIGEN_STRONG_INLINE const CwiseBinaryOp<ei_scalar_difference_op<typename ei_traits<Derived>::Scalar>,
Derived, OtherDerived>
operator-(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
{
return CwiseBinaryOp<ei_scalar_difference_op<Scalar>,
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<typename OtherDerived>
EIGEN_STRONG_INLINE const CwiseBinaryOp<ei_scalar_sum_op<typename ei_traits<Derived>::Scalar>, Derived, OtherDerived>
operator+(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
{
return CwiseBinaryOp<ei_scalar_sum_op<Scalar>, 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<typename CustomBinaryOp, typename OtherDerived>
EIGEN_STRONG_INLINE const CwiseBinaryOp<CustomBinaryOp, Derived, OtherDerived>
binaryExpr(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other, const CustomBinaryOp& func = CustomBinaryOp()) const
{
return CwiseBinaryOp<CustomBinaryOp, Derived, OtherDerived>(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<typename OtherDerived>
EIGEN_STRONG_INLINE const CwiseBinaryOp<ei_scalar_product_op<Scalar>, Derived, OtherDerived>
cwiseProduct(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
{
return CwiseBinaryOp<ei_scalar_product_op<Scalar>, 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<typename OtherDerived>
inline const CwiseBinaryOp<std::equal_to<Scalar>, Derived, OtherDerived>
cwiseEqual(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
{
return CwiseBinaryOp<std::equal_to<Scalar>, 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<typename OtherDerived>
inline const CwiseBinaryOp<std::not_equal_to<Scalar>, Derived, OtherDerived>
cwiseNotEqual(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
{
return CwiseBinaryOp<std::not_equal_to<Scalar>, 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<typename OtherDerived>
EIGEN_STRONG_INLINE const CwiseBinaryOp<ei_scalar_min_op<Scalar>, Derived, OtherDerived>
cwiseMin(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
{
return CwiseBinaryOp<ei_scalar_min_op<Scalar>, 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<typename OtherDerived>
EIGEN_STRONG_INLINE const CwiseBinaryOp<ei_scalar_max_op<Scalar>, Derived, OtherDerived>
cwiseMax(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
{
return CwiseBinaryOp<ei_scalar_max_op<Scalar>, 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<typename OtherDerived>
EIGEN_STRONG_INLINE const CwiseBinaryOp<ei_scalar_quotient_op<Scalar>, Derived, OtherDerived>
cwiseQuotient(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
{
return CwiseBinaryOp<ei_scalar_quotient_op<Scalar>, Derived, OtherDerived>(derived(), other.derived());
}

View File

@ -128,60 +128,4 @@ class CwiseUnaryOpImpl<UnaryOp,MatrixType,Dense> : public MatrixBase<CwiseUnaryO
} }
}; };
/** \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<typename ExpressionType,template <typename> class StorageBase>
EIGEN_STRONG_INLINE const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_abs_op)
Cwise<ExpressionType,StorageBase>::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<typename ExpressionType,template <typename> class StorageBase>
EIGEN_STRONG_INLINE const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_abs2_op)
Cwise<ExpressionType,StorageBase>::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<typename ExpressionType,template <typename> class StorageBase>
inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_exp_op)
Cwise<ExpressionType,StorageBase>::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<typename ExpressionType,template <typename> class StorageBase>
inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_log_op)
Cwise<ExpressionType,StorageBase>::log() const
{
return _expression();
}
#endif // EIGEN_CWISE_UNARY_OP_H #endif // EIGEN_CWISE_UNARY_OP_H

View File

@ -156,26 +156,58 @@ real() { return derived(); }
EIGEN_STRONG_INLINE NonConstImagReturnType EIGEN_STRONG_INLINE NonConstImagReturnType
imag() { return derived(); } 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 * Example: \include MatrixBase_cwiseAbs.cpp
* Output: \verbinclude MatrixBase_cwise_const.out * Output: \verbinclude MatrixBase_cwiseAbs.out
* *
* \sa class Cwise, cwise() * \sa cwiseAbs2()
*/ */
inline const Cwise<Derived,EIGEN_CURRENT_STORAGE_BASE_CLASS> cwise() const EIGEN_STRONG_INLINE const CwiseUnaryOp<ei_scalar_abs_op<Scalar>,Derived>
{ cwiseAbs() const { return derived(); }
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 * Example: \include MatrixBase_cwiseAbs2.cpp
* Output: \verbinclude MatrixBase_cwise.out * Output: \verbinclude MatrixBase_cwiseAbs2.out
* *
* \sa class Cwise, cwise() const * \sa cwiseAbs()
*/ */
inline Cwise<Derived,EIGEN_CURRENT_STORAGE_BASE_CLASS> cwise() EIGEN_STRONG_INLINE const CwiseUnaryOp<ei_scalar_abs2_op<Scalar>,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<ei_scalar_sqrt_op<Scalar>,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<ei_scalar_inverse_op<Scalar>,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<OtherDerived> &) const
*/
inline const CwiseUnaryOp<std::binder1st<std::equal_to<Scalar> >,Derived>
cwiseEqual(Scalar s) const
{ {
return derived(); return CwiseUnaryOp<std::binder1st<std::equal_to<Scalar> >,Derived>
(derived(), std::bind1st(std::equal_to<Scalar>(), s));
} }

View File

@ -68,6 +68,12 @@ class DiagonalBase : public AnyMatrixBase<Derived>
template<typename MatrixDerived> template<typename MatrixDerived>
const DiagonalProduct<MatrixDerived, Derived, OnTheLeft> const DiagonalProduct<MatrixDerived, Derived, OnTheLeft>
operator*(const MatrixBase<MatrixDerived> &matrix) const; operator*(const MatrixBase<MatrixDerived> &matrix) const;
inline const DiagonalWrapper<NestByValue<CwiseUnaryOp<ei_scalar_inverse_op<Scalar>, DiagonalVectorType> > >
inverse() const
{
return diagonal().cwiseInverse().nestByValue();
}
}; };
template<typename Derived> template<typename Derived>

View File

@ -279,7 +279,7 @@ MatrixBase<Derived>::dot(const MatrixBase<OtherDerived>& other) const
template<typename Derived> template<typename Derived>
inline typename NumTraits<typename ei_traits<Derived>::Scalar>::Real MatrixBase<Derived>::squaredNorm() const inline typename NumTraits<typename ei_traits<Derived>::Scalar>::Real MatrixBase<Derived>::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. /** \returns the \em l2 norm of *this, i.e., for vectors, the square root of the dot product of *this with itself.

View File

@ -54,7 +54,7 @@ bool MatrixBase<Derived>::isApprox(
{ {
const typename ei_nested<Derived,2>::type nested(derived()); const typename ei_nested<Derived,2>::type nested(derived());
const typename ei_nested<OtherDerived,2>::type otherNested(other.derived()); const typename ei_nested<OtherDerived,2>::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, /** \returns \c true if the norm of \c *this is much smaller than \a other,
@ -76,7 +76,7 @@ bool MatrixBase<Derived>::isMuchSmallerThan(
RealScalar prec RealScalar prec
) const ) 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, /** \returns \c true if the norm of \c *this is much smaller than the norm of \a other,
@ -96,7 +96,7 @@ bool MatrixBase<Derived>::isMuchSmallerThan(
RealScalar prec RealScalar prec
) const ) const
{ {
return this->cwise().abs2().sum() <= prec * prec * other.cwise().abs2().sum(); return cwiseAbs2().sum() <= prec * prec * other.cwiseAbs2().sum();
} }
#else #else

View File

@ -247,6 +247,7 @@ template<typename Derived> class MatrixBase
#define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::MatrixBase #define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::MatrixBase
#include "CwiseUnaryOps.h" #include "CwiseUnaryOps.h"
#include "CwiseBinaryOps.h"
#undef EIGEN_CURRENT_STORAGE_BASE_CLASS #undef EIGEN_CURRENT_STORAGE_BASE_CLASS
/** Copies \a other into *this. \returns a reference to *this. */ /** Copies \a other into *this. \returns a reference to *this. */
@ -275,12 +276,6 @@ template<typename Derived> class MatrixBase
template<typename OtherDerived> template<typename OtherDerived>
Derived& lazyAssign(const MatrixBase<OtherDerived>& other); Derived& lazyAssign(const MatrixBase<OtherDerived>& other);
/** \deprecated because .lazy() is deprecated
* Overloaded for cache friendly product evaluation */
template<typename OtherDerived>
Derived& lazyAssign(const Flagged<OtherDerived, 0, EvalBeforeAssigningBit>& other)
{ return lazyAssign(other._expression()); }
template<typename ProductDerived, typename Lhs, typename Rhs> template<typename ProductDerived, typename Lhs, typename Rhs>
Derived& lazyAssign(const ProductBase<ProductDerived, Lhs,Rhs>& other); Derived& lazyAssign(const ProductBase<ProductDerived, Lhs,Rhs>& other);
@ -342,15 +337,6 @@ template<typename Derived> class MatrixBase
Scalar& z(); Scalar& z();
Scalar& w(); Scalar& w();
template<typename OtherDerived>
const CwiseBinaryOp<ei_scalar_sum_op<typename ei_traits<Derived>::Scalar>, Derived, OtherDerived>
operator+(const MatrixBase<OtherDerived> &other) const;
template<typename OtherDerived>
const CwiseBinaryOp<ei_scalar_difference_op<typename ei_traits<Derived>::Scalar>, Derived, OtherDerived>
operator-(const MatrixBase<OtherDerived> &other) const;
template<typename OtherDerived> template<typename OtherDerived>
Derived& operator+=(const MatrixBase<OtherDerived>& other); Derived& operator+=(const MatrixBase<OtherDerived>& other);
template<typename OtherDerived> template<typename OtherDerived>
@ -373,14 +359,6 @@ template<typename Derived> class MatrixBase
const DiagonalProduct<Derived, DiagonalDerived, OnTheRight> const DiagonalProduct<Derived, DiagonalDerived, OnTheRight>
operator*(const DiagonalBase<DiagonalDerived> &diagonal) const; operator*(const DiagonalBase<DiagonalDerived> &diagonal) const;
template<typename OtherDerived>
typename ei_plain_matrix_type_column_major<OtherDerived>::type
solveTriangular(const MatrixBase<OtherDerived>& other) const;
template<typename OtherDerived>
void solveTriangularInPlace(const MatrixBase<OtherDerived>& other) const;
template<typename OtherDerived> template<typename OtherDerived>
Scalar dot(const MatrixBase<OtherDerived>& other) const; Scalar dot(const MatrixBase<OtherDerived>& other) const;
RealScalar squaredNorm() const; RealScalar squaredNorm() const;
@ -542,11 +520,11 @@ template<typename Derived> class MatrixBase
template<typename OtherDerived> template<typename OtherDerived>
inline bool operator==(const MatrixBase<OtherDerived>& other) const inline bool operator==(const MatrixBase<OtherDerived>& other) const
{ return (cwise() == other).all(); } { return cwiseEqual(other).all(); }
template<typename OtherDerived> template<typename OtherDerived>
inline bool operator!=(const MatrixBase<OtherDerived>& other) const inline bool operator!=(const MatrixBase<OtherDerived>& other) const
{ return (cwise() != other).any(); } { return cwiseNotEqual(other).all(); }
/** \returns the matrix or vector obtained by evaluating this expression. /** \returns the matrix or vector obtained by evaluating this expression.
@ -560,10 +538,6 @@ template<typename Derived> class MatrixBase
template<typename OtherDerived> template<typename OtherDerived>
void swap(MatrixBase<OtherDerived> EIGEN_REF_TO_TEMPORARY other); void swap(MatrixBase<OtherDerived> EIGEN_REF_TO_TEMPORARY other);
template<unsigned int Added>
const Flagged<Derived, Added, 0> marked() const;
const Flagged<Derived, 0, EvalBeforeAssigningBit> lazy() const;
NoAlias<Derived,Eigen::MatrixBase > noalias(); NoAlias<Derived,Eigen::MatrixBase > noalias();
/** \returns number of elements to skip to pass from one row (resp. column) to another /** \returns number of elements to skip to pass from one row (resp. column) to another
@ -575,12 +549,6 @@ template<typename Derived> class MatrixBase
inline const NestByValue<Derived> nestByValue() const; inline const NestByValue<Derived> nestByValue() const;
template<typename CustomBinaryOp, typename OtherDerived>
const CwiseBinaryOp<CustomBinaryOp, Derived, OtherDerived>
binaryExpr(const MatrixBase<OtherDerived> &other, const CustomBinaryOp& func = CustomBinaryOp()) const;
Scalar sum() const; Scalar sum() const;
Scalar mean() const; Scalar mean() const;
Scalar trace() const; Scalar trace() const;
@ -736,6 +704,33 @@ template<typename Derived> class MatrixBase
#include EIGEN_MATRIXBASE_PLUGIN #include EIGEN_MATRIXBASE_PLUGIN
#endif #endif
#ifdef EIGEN2_SUPPORT
/** \deprecated because .lazy() is deprecated
* Overloaded for cache friendly product evaluation */
template<typename OtherDerived>
Derived& lazyAssign(const Flagged<OtherDerived, 0, EvalBeforeAssigningBit>& other)
{ return lazyAssign(other._expression()); }
template<unsigned int Added>
const Flagged<Derived, Added, 0> marked() const;
const Flagged<Derived, 0, EvalBeforeAssigningBit> lazy() const;
inline const Cwise<Derived> cwise() const;
inline Cwise<Derived> cwise();
// a workaround waiting the Array class
inline const Cwise<Derived> array() const { return cwise(); }
// a workaround waiting the Array class
inline Cwise<Derived> array() { return cwise(); }
template<typename OtherDerived>
typename ei_plain_matrix_type_column_major<OtherDerived>::type
solveTriangular(const MatrixBase<OtherDerived>& other) const;
template<typename OtherDerived>
void solveTriangularInPlace(const MatrixBase<OtherDerived>& other) const;
#endif
protected: protected:
/** Default constructor. Do nothing. */ /** Default constructor. Do nothing. */
MatrixBase() MatrixBase()

View File

@ -170,7 +170,7 @@ class GeneralProduct<Lhs, Rhs, InnerProduct>
EIGEN_STRONG_INLINE Scalar value() const EIGEN_STRONG_INLINE Scalar value() const
{ {
return (m_lhs.transpose().cwise()*m_rhs).sum(); return (m_lhs.transpose().cwiseProduct(m_rhs)).sum();
} }
template<typename Dest> void scaleAndAddTo(Dest& dst, Scalar alpha) const template<typename Dest> void scaleAndAddTo(Dest& dst, Scalar alpha) const
@ -403,7 +403,7 @@ template<> struct ei_gemv_selector<OnTheRight,RowMajor,false>
// TODO makes sure rhs is sequentially stored in memory, otherwise use a temp // TODO makes sure rhs is sequentially stored in memory, otherwise use a temp
const int rows = prod.rows(); const int rows = prod.rows();
for(int i=0; i<rows; ++i) for(int i=0; i<rows; ++i)
dest.coeffRef(i) += alpha * (prod.lhs().row(i).cwise() * prod.rhs().transpose()).sum(); dest.coeffRef(i) += alpha * (prod.lhs().row(i).cwiseProduct(prod.rhs().transpose())).sum();
} }
}; };
@ -431,7 +431,7 @@ MatrixBase<Derived>::operator*(const MatrixBase<OtherDerived> &other) const
}; };
// note to the lost user: // note to the lost user:
// * for a dot product use: v1.dot(v2) // * 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), 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) 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), EIGEN_STATIC_ASSERT(ProductIsValid || !(SameSizes && !AreVectors),

View File

@ -78,8 +78,7 @@ struct ei_triangular_solver_selector<Lhs,Rhs,OnTheLeft,Mode,NoUnrolling,RowMajor
int i = IsLowerTriangular ? pi+k : pi-k-1; int i = IsLowerTriangular ? pi+k : pi-k-1;
int s = IsLowerTriangular ? pi : i+1; int s = IsLowerTriangular ? pi : i+1;
if (k>0) if (k>0)
other.coeffRef(i) -= ((lhs.row(i).segment(s,k).transpose()) other.coeffRef(i) -= (lhs.row(i).segment(s,k).transpose().cwiseProduct(other.segment(s,k))).sum();
.cwise()*(other.segment(s,k))).sum();
if(!(Mode & UnitDiagBit)) if(!(Mode & UnitDiagBit))
other.coeffRef(i) /= lhs.coeff(i,i); other.coeffRef(i) /= lhs.coeff(i,i);
@ -180,8 +179,7 @@ struct ei_triangular_solver_unroller<Lhs,Rhs,Mode,Index,Size,false> {
static void run(const Lhs& lhs, Rhs& rhs) static void run(const Lhs& lhs, Rhs& rhs)
{ {
if (Index>0) if (Index>0)
rhs.coeffRef(I) -= ((lhs.row(I).template segment<Index>(S).transpose()) rhs.coeffRef(I) -= ((lhs.row(I).template segment<Index>(S).transpose()).cwiseProduct(rhs.template segment<Index>(S))).sum();
.cwise()*(rhs.template segment<Index>(S))).sum();
if(!(Mode & UnitDiagBit)) if(!(Mode & UnitDiagBit))
rhs.coeffRef(I) /= lhs.coeff(I,I); rhs.coeffRef(I) /= lhs.coeff(I,I);

View File

@ -28,7 +28,7 @@
template<typename ExpressionType, typename Scalar> template<typename ExpressionType, typename Scalar>
inline void ei_stable_norm_kernel(const ExpressionType& bl, Scalar& ssq, Scalar& scale, Scalar& invScale) 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) if (max>scale)
{ {
ssq = ssq * ei_abs2(scale/max); ssq = ssq * ei_abs2(scale/max);
@ -182,7 +182,7 @@ template<typename Derived>
inline typename NumTraits<typename ei_traits<Derived>::Scalar>::Real inline typename NumTraits<typename ei_traits<Derived>::Scalar>::Real
MatrixBase<Derived>::hypotNorm() const MatrixBase<Derived>::hypotNorm() const
{ {
return this->cwise().abs().redux(ei_scalar_hypot_op<RealScalar>()); return this->cwiseAbs().redux(ei_scalar_hypot_op<RealScalar>());
} }
#endif // EIGEN_STABLENORM_H #endif // EIGEN_STABLENORM_H

View File

@ -60,7 +60,6 @@ template<typename MatrixType, int PacketAccess = AsRequested> class Map;
template<typename Derived> class TriangularBase; template<typename Derived> class TriangularBase;
template<typename MatrixType, unsigned int Mode> class TriangularView; template<typename MatrixType, unsigned int Mode> class TriangularView;
template<typename MatrixType, unsigned int Mode> class SelfAdjointView; template<typename MatrixType, unsigned int Mode> class SelfAdjointView;
template<typename ExpressionType, template <typename> class StorageBase> class Cwise;
template<typename ExpressionType> class WithFormat; template<typename ExpressionType> class WithFormat;
template<typename MatrixType> struct CommaInitializer; template<typename MatrixType> struct CommaInitializer;
template<typename Derived> class ReturnByValue; template<typename Derived> class ReturnByValue;
@ -146,4 +145,8 @@ template<typename Scalar,int Dim> class Translation;
template<typename Scalar> class UniformScaling; template<typename Scalar> class UniformScaling;
template<typename MatrixType,int Direction> class Homogeneous; template<typename MatrixType,int Direction> class Homogeneous;
#ifdef EIGEN2_SUPPORT
template<typename ExpressionType> class Cwise;
#endif
#endif // EIGEN_FORWARDDECLARATIONS_H #endif // EIGEN_FORWARDDECLARATIONS_H

View File

@ -71,7 +71,7 @@
* *
* \sa MatrixBase::cwise() const, MatrixBase::cwise() * \sa MatrixBase::cwise() const, MatrixBase::cwise()
*/ */
template<typename ExpressionType, template<typename> class StorageBase> class Cwise template<typename ExpressionType> class Cwise
{ {
public: public:
@ -87,19 +87,19 @@ template<typename ExpressionType, template<typename> class StorageBase> class Cw
template<typename OtherDerived> template<typename OtherDerived>
const EIGEN_CWISE_PRODUCT_RETURN_TYPE const EIGEN_CWISE_PRODUCT_RETURN_TYPE
operator*(const AnyMatrixBase<OtherDerived> &other) const; operator*(const MatrixBase<OtherDerived> &other) const;
template<typename OtherDerived> template<typename OtherDerived>
const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_quotient_op) const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_quotient_op)
operator/(const StorageBase<OtherDerived> &other) const; operator/(const MatrixBase<OtherDerived> &other) const;
template<typename OtherDerived> template<typename OtherDerived>
const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_min_op) const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_min_op)
min(const StorageBase<OtherDerived> &other) const; min(const MatrixBase<OtherDerived> &other) const;
template<typename OtherDerived> template<typename OtherDerived>
const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_max_op) const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_max_op)
max(const StorageBase<OtherDerived> &other) const; max(const MatrixBase<OtherDerived> &other) const;
const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_abs_op) abs() const; const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_abs_op) abs() const;
const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_abs2_op) abs2() const; const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_abs2_op) abs2() const;
@ -129,28 +129,28 @@ template<typename ExpressionType, template<typename> class StorageBase> class Cw
ExpressionType& operator-=(const Scalar& scalar); ExpressionType& operator-=(const Scalar& scalar);
template<typename OtherDerived> template<typename OtherDerived>
inline ExpressionType& operator*=(const StorageBase<OtherDerived> &other); inline ExpressionType& operator*=(const MatrixBase<OtherDerived> &other);
template<typename OtherDerived> template<typename OtherDerived>
inline ExpressionType& operator/=(const StorageBase<OtherDerived> &other); inline ExpressionType& operator/=(const MatrixBase<OtherDerived> &other);
template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less) template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less)
operator<(const StorageBase<OtherDerived>& other) const; operator<(const MatrixBase<OtherDerived>& other) const;
template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less_equal) template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less_equal)
operator<=(const StorageBase<OtherDerived>& other) const; operator<=(const MatrixBase<OtherDerived>& other) const;
template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater) template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater)
operator>(const StorageBase<OtherDerived>& other) const; operator>(const MatrixBase<OtherDerived>& other) const;
template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater_equal) template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater_equal)
operator>=(const StorageBase<OtherDerived>& other) const; operator>=(const MatrixBase<OtherDerived>& other) const;
template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::equal_to) template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::equal_to)
operator==(const StorageBase<OtherDerived>& other) const; operator==(const MatrixBase<OtherDerived>& other) const;
template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::not_equal_to) template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::not_equal_to)
operator!=(const StorageBase<OtherDerived>& other) const; operator!=(const MatrixBase<OtherDerived>& other) const;
// comparisons to a scalar value // comparisons to a scalar value
const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less) const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less)
@ -183,4 +183,31 @@ template<typename ExpressionType, template<typename> class StorageBase> class Cw
Cwise& operator=(const Cwise&); 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<typename Derived>
inline const Cwise<Derived> MatrixBase<Derived>::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<typename Derived>
inline Cwise<Derived> MatrixBase<Derived>::cwise()
{
return derived();
}
#endif // EIGEN_CWISE_H #endif // EIGEN_CWISE_H

View File

@ -25,6 +25,159 @@
#ifndef EIGEN_ARRAY_CWISE_OPERATORS_H #ifndef EIGEN_ARRAY_CWISE_OPERATORS_H
#define 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<typename ExpressionType>
EIGEN_STRONG_INLINE const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_abs_op)
Cwise<ExpressionType>::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<typename ExpressionType>
EIGEN_STRONG_INLINE const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_abs2_op)
Cwise<ExpressionType>::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<typename ExpressionType>
inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_exp_op)
Cwise<ExpressionType>::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<typename ExpressionType>
inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_log_op)
Cwise<ExpressionType>::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<typename ExpressionType>
template<typename OtherDerived>
EIGEN_STRONG_INLINE const EIGEN_CWISE_PRODUCT_RETURN_TYPE
Cwise<ExpressionType>::operator*(const MatrixBase<OtherDerived> &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<typename ExpressionType>
template<typename OtherDerived>
EIGEN_STRONG_INLINE const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_quotient_op)
Cwise<ExpressionType>::operator/(const MatrixBase<OtherDerived> &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<typename ExpressionType>
template<typename OtherDerived>
inline ExpressionType& Cwise<ExpressionType>::operator*=(const MatrixBase<OtherDerived> &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<typename ExpressionType>
template<typename OtherDerived>
inline ExpressionType& Cwise<ExpressionType>::operator/=(const MatrixBase<OtherDerived> &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<typename ExpressionType>
template<typename OtherDerived>
EIGEN_STRONG_INLINE const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_min_op)
Cwise<ExpressionType>::min(const MatrixBase<OtherDerived> &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<typename ExpressionType>
template<typename OtherDerived>
EIGEN_STRONG_INLINE const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_max_op)
Cwise<ExpressionType>::max(const MatrixBase<OtherDerived> &other) const
{
return EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_max_op)(_expression(), other.derived());
}
/***************************************************************************
* The following functions were defined in Array
***************************************************************************/
// -- unary operators -- // -- unary operators --
/** \array_module /** \array_module
@ -36,9 +189,9 @@
* *
* \sa pow(), square() * \sa pow(), square()
*/ */
template<typename ExpressionType,template <typename> class StorageBase> template<typename ExpressionType>
inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_sqrt_op) inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_sqrt_op)
Cwise<ExpressionType,StorageBase>::sqrt() const Cwise<ExpressionType>::sqrt() const
{ {
return _expression(); return _expression();
} }
@ -52,9 +205,9 @@ Cwise<ExpressionType,StorageBase>::sqrt() const
* *
* \sa sin(), exp(), EIGEN_FAST_MATH * \sa sin(), exp(), EIGEN_FAST_MATH
*/ */
template<typename ExpressionType,template <typename> class StorageBase> template<typename ExpressionType>
inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_cos_op) inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_cos_op)
Cwise<ExpressionType,StorageBase>::cos() const Cwise<ExpressionType>::cos() const
{ {
return _expression(); return _expression();
} }
@ -69,9 +222,9 @@ Cwise<ExpressionType,StorageBase>::cos() const
* *
* \sa cos(), exp(), EIGEN_FAST_MATH * \sa cos(), exp(), EIGEN_FAST_MATH
*/ */
template<typename ExpressionType,template <typename> class StorageBase> template<typename ExpressionType>
inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_sin_op) inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_sin_op)
Cwise<ExpressionType,StorageBase>::sin() const Cwise<ExpressionType>::sin() const
{ {
return _expression(); return _expression();
} }
@ -86,9 +239,9 @@ Cwise<ExpressionType,StorageBase>::sin() const
* *
* \sa exp(), log() * \sa exp(), log()
*/ */
template<typename ExpressionType,template <typename> class StorageBase> template<typename ExpressionType>
inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_pow_op) inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_pow_op)
Cwise<ExpressionType,StorageBase>::pow(const Scalar& exponent) const Cwise<ExpressionType>::pow(const Scalar& exponent) const
{ {
return EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_pow_op)(_expression(), ei_scalar_pow_op<Scalar>(exponent)); return EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_pow_op)(_expression(), ei_scalar_pow_op<Scalar>(exponent));
} }
@ -103,9 +256,9 @@ Cwise<ExpressionType,StorageBase>::pow(const Scalar& exponent) const
* *
* \sa operator/(), operator*() * \sa operator/(), operator*()
*/ */
template<typename ExpressionType,template <typename> class StorageBase> template<typename ExpressionType>
inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_inverse_op) inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_inverse_op)
Cwise<ExpressionType,StorageBase>::inverse() const Cwise<ExpressionType>::inverse() const
{ {
return _expression(); return _expression();
} }
@ -119,9 +272,9 @@ Cwise<ExpressionType,StorageBase>::inverse() const
* *
* \sa operator/(), operator*(), abs2() * \sa operator/(), operator*(), abs2()
*/ */
template<typename ExpressionType,template <typename> class StorageBase> template<typename ExpressionType>
inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_square_op) inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_square_op)
Cwise<ExpressionType,StorageBase>::square() const Cwise<ExpressionType>::square() const
{ {
return _expression(); return _expression();
} }
@ -135,9 +288,9 @@ Cwise<ExpressionType,StorageBase>::square() const
* *
* \sa square(), pow() * \sa square(), pow()
*/ */
template<typename ExpressionType,template <typename> class StorageBase> template<typename ExpressionType>
inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_cube_op) inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_cube_op)
Cwise<ExpressionType,StorageBase>::cube() const Cwise<ExpressionType>::cube() const
{ {
return _expression(); return _expression();
} }
@ -154,10 +307,10 @@ Cwise<ExpressionType,StorageBase>::cube() const
* *
* \sa MatrixBase::all(), MatrixBase::any(), operator>(), operator<=() * \sa MatrixBase::all(), MatrixBase::any(), operator>(), operator<=()
*/ */
template<typename ExpressionType,template <typename> class StorageBase> template<typename ExpressionType>
template<typename OtherDerived> template<typename OtherDerived>
inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less) inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less)
Cwise<ExpressionType,StorageBase>::operator<(const StorageBase<OtherDerived> &other) const Cwise<ExpressionType>::operator<(const MatrixBase<OtherDerived> &other) const
{ {
return EIGEN_CWISE_BINOP_RETURN_TYPE(std::less)(_expression(), other.derived()); return EIGEN_CWISE_BINOP_RETURN_TYPE(std::less)(_expression(), other.derived());
} }
@ -171,10 +324,10 @@ Cwise<ExpressionType,StorageBase>::operator<(const StorageBase<OtherDerived> &ot
* *
* \sa MatrixBase::all(), MatrixBase::any(), operator>=(), operator<() * \sa MatrixBase::all(), MatrixBase::any(), operator>=(), operator<()
*/ */
template<typename ExpressionType,template <typename> class StorageBase> template<typename ExpressionType>
template<typename OtherDerived> template<typename OtherDerived>
inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less_equal) inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less_equal)
Cwise<ExpressionType,StorageBase>::operator<=(const StorageBase<OtherDerived> &other) const Cwise<ExpressionType>::operator<=(const MatrixBase<OtherDerived> &other) const
{ {
return EIGEN_CWISE_BINOP_RETURN_TYPE(std::less_equal)(_expression(), other.derived()); return EIGEN_CWISE_BINOP_RETURN_TYPE(std::less_equal)(_expression(), other.derived());
} }
@ -188,10 +341,10 @@ Cwise<ExpressionType,StorageBase>::operator<=(const StorageBase<OtherDerived> &o
* *
* \sa MatrixBase::all(), MatrixBase::any(), operator>=(), operator<() * \sa MatrixBase::all(), MatrixBase::any(), operator>=(), operator<()
*/ */
template<typename ExpressionType,template <typename> class StorageBase> template<typename ExpressionType>
template<typename OtherDerived> template<typename OtherDerived>
inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater) inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater)
Cwise<ExpressionType,StorageBase>::operator>(const StorageBase<OtherDerived> &other) const Cwise<ExpressionType>::operator>(const MatrixBase<OtherDerived> &other) const
{ {
return EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater)(_expression(), other.derived()); return EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater)(_expression(), other.derived());
} }
@ -205,10 +358,10 @@ Cwise<ExpressionType,StorageBase>::operator>(const StorageBase<OtherDerived> &ot
* *
* \sa MatrixBase::all(), MatrixBase::any(), operator>(), operator<=() * \sa MatrixBase::all(), MatrixBase::any(), operator>(), operator<=()
*/ */
template<typename ExpressionType,template <typename> class StorageBase> template<typename ExpressionType>
template<typename OtherDerived> template<typename OtherDerived>
inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater_equal) inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater_equal)
Cwise<ExpressionType,StorageBase>::operator>=(const StorageBase<OtherDerived> &other) const Cwise<ExpressionType>::operator>=(const MatrixBase<OtherDerived> &other) const
{ {
return EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater_equal)(_expression(), other.derived()); return EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater_equal)(_expression(), other.derived());
} }
@ -227,10 +380,10 @@ Cwise<ExpressionType,StorageBase>::operator>=(const StorageBase<OtherDerived> &o
* *
* \sa MatrixBase::all(), MatrixBase::any(), MatrixBase::isApprox(), MatrixBase::isMuchSmallerThan() * \sa MatrixBase::all(), MatrixBase::any(), MatrixBase::isApprox(), MatrixBase::isMuchSmallerThan()
*/ */
template<typename ExpressionType,template <typename> class StorageBase> template<typename ExpressionType>
template<typename OtherDerived> template<typename OtherDerived>
inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::equal_to) inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::equal_to)
Cwise<ExpressionType,StorageBase>::operator==(const StorageBase<OtherDerived> &other) const Cwise<ExpressionType>::operator==(const MatrixBase<OtherDerived> &other) const
{ {
return EIGEN_CWISE_BINOP_RETURN_TYPE(std::equal_to)(_expression(), other.derived()); return EIGEN_CWISE_BINOP_RETURN_TYPE(std::equal_to)(_expression(), other.derived());
} }
@ -249,10 +402,10 @@ Cwise<ExpressionType,StorageBase>::operator==(const StorageBase<OtherDerived> &o
* *
* \sa MatrixBase::all(), MatrixBase::any(), MatrixBase::isApprox(), MatrixBase::isMuchSmallerThan() * \sa MatrixBase::all(), MatrixBase::any(), MatrixBase::isApprox(), MatrixBase::isMuchSmallerThan()
*/ */
template<typename ExpressionType,template <typename> class StorageBase> template<typename ExpressionType>
template<typename OtherDerived> template<typename OtherDerived>
inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::not_equal_to) inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::not_equal_to)
Cwise<ExpressionType,StorageBase>::operator!=(const StorageBase<OtherDerived> &other) const Cwise<ExpressionType>::operator!=(const MatrixBase<OtherDerived> &other) const
{ {
return EIGEN_CWISE_BINOP_RETURN_TYPE(std::not_equal_to)(_expression(), other.derived()); return EIGEN_CWISE_BINOP_RETURN_TYPE(std::not_equal_to)(_expression(), other.derived());
} }
@ -265,9 +418,9 @@ Cwise<ExpressionType,StorageBase>::operator!=(const StorageBase<OtherDerived> &o
* *
* \sa operator<(const MatrixBase<OtherDerived> &) const * \sa operator<(const MatrixBase<OtherDerived> &) const
*/ */
template<typename ExpressionType,template <typename> class StorageBase> template<typename ExpressionType>
inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less) inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less)
Cwise<ExpressionType,StorageBase>::operator<(Scalar s) const Cwise<ExpressionType>::operator<(Scalar s) const
{ {
return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less)(_expression(), return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less)(_expression(),
typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s)); typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s));
@ -279,9 +432,9 @@ Cwise<ExpressionType,StorageBase>::operator<(Scalar s) const
* *
* \sa operator<=(const MatrixBase<OtherDerived> &) const * \sa operator<=(const MatrixBase<OtherDerived> &) const
*/ */
template<typename ExpressionType,template <typename> class StorageBase> template<typename ExpressionType>
inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less_equal) inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less_equal)
Cwise<ExpressionType,StorageBase>::operator<=(Scalar s) const Cwise<ExpressionType>::operator<=(Scalar s) const
{ {
return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less_equal)(_expression(), return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less_equal)(_expression(),
typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s)); typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s));
@ -293,9 +446,9 @@ Cwise<ExpressionType,StorageBase>::operator<=(Scalar s) const
* *
* \sa operator>(const MatrixBase<OtherDerived> &) const * \sa operator>(const MatrixBase<OtherDerived> &) const
*/ */
template<typename ExpressionType,template <typename> class StorageBase> template<typename ExpressionType>
inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater) inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater)
Cwise<ExpressionType,StorageBase>::operator>(Scalar s) const Cwise<ExpressionType>::operator>(Scalar s) const
{ {
return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater)(_expression(), return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater)(_expression(),
typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s)); typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s));
@ -307,9 +460,9 @@ Cwise<ExpressionType,StorageBase>::operator>(Scalar s) const
* *
* \sa operator>=(const MatrixBase<OtherDerived> &) const * \sa operator>=(const MatrixBase<OtherDerived> &) const
*/ */
template<typename ExpressionType,template <typename> class StorageBase> template<typename ExpressionType>
inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater_equal) inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater_equal)
Cwise<ExpressionType,StorageBase>::operator>=(Scalar s) const Cwise<ExpressionType>::operator>=(Scalar s) const
{ {
return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater_equal)(_expression(), return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater_equal)(_expression(),
typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s)); typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s));
@ -326,9 +479,9 @@ Cwise<ExpressionType,StorageBase>::operator>=(Scalar s) const
* *
* \sa operator==(const MatrixBase<OtherDerived> &) const * \sa operator==(const MatrixBase<OtherDerived> &) const
*/ */
template<typename ExpressionType,template <typename> class StorageBase> template<typename ExpressionType>
inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::equal_to) inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::equal_to)
Cwise<ExpressionType,StorageBase>::operator==(Scalar s) const Cwise<ExpressionType>::operator==(Scalar s) const
{ {
return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::equal_to)(_expression(), return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::equal_to)(_expression(),
typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s)); typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s));
@ -345,9 +498,9 @@ Cwise<ExpressionType,StorageBase>::operator==(Scalar s) const
* *
* \sa operator!=(const MatrixBase<OtherDerived> &) const * \sa operator!=(const MatrixBase<OtherDerived> &) const
*/ */
template<typename ExpressionType,template <typename> class StorageBase> template<typename ExpressionType>
inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::not_equal_to) inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::not_equal_to)
Cwise<ExpressionType,StorageBase>::operator!=(Scalar s) const Cwise<ExpressionType>::operator!=(Scalar s) const
{ {
return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::not_equal_to)(_expression(), return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::not_equal_to)(_expression(),
typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s)); typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s));
@ -364,11 +517,11 @@ Cwise<ExpressionType,StorageBase>::operator!=(Scalar s) const
* *
* \sa operator+=(), operator-() * \sa operator+=(), operator-()
*/ */
template<typename ExpressionType,template <typename> class StorageBase> template<typename ExpressionType>
inline const typename Cwise<ExpressionType,StorageBase>::ScalarAddReturnType inline const typename Cwise<ExpressionType>::ScalarAddReturnType
Cwise<ExpressionType,StorageBase>::operator+(const Scalar& scalar) const Cwise<ExpressionType>::operator+(const Scalar& scalar) const
{ {
return typename Cwise<ExpressionType,StorageBase>::ScalarAddReturnType(m_matrix, ei_scalar_add_op<Scalar>(scalar)); return typename Cwise<ExpressionType>::ScalarAddReturnType(m_matrix, ei_scalar_add_op<Scalar>(scalar));
} }
/** \array_module /** \array_module
@ -380,8 +533,8 @@ Cwise<ExpressionType,StorageBase>::operator+(const Scalar& scalar) const
* *
* \sa operator+(), operator-=() * \sa operator+(), operator-=()
*/ */
template<typename ExpressionType,template <typename> class StorageBase> template<typename ExpressionType>
inline ExpressionType& Cwise<ExpressionType,StorageBase>::operator+=(const Scalar& scalar) inline ExpressionType& Cwise<ExpressionType>::operator+=(const Scalar& scalar)
{ {
return m_matrix.const_cast_derived() = *this + scalar; return m_matrix.const_cast_derived() = *this + scalar;
} }
@ -395,9 +548,9 @@ inline ExpressionType& Cwise<ExpressionType,StorageBase>::operator+=(const Scala
* *
* \sa operator+(), operator-=() * \sa operator+(), operator-=()
*/ */
template<typename ExpressionType,template <typename> class StorageBase> template<typename ExpressionType>
inline const typename Cwise<ExpressionType,StorageBase>::ScalarAddReturnType inline const typename Cwise<ExpressionType>::ScalarAddReturnType
Cwise<ExpressionType,StorageBase>::operator-(const Scalar& scalar) const Cwise<ExpressionType>::operator-(const Scalar& scalar) const
{ {
return *this + (-scalar); return *this + (-scalar);
} }
@ -412,8 +565,8 @@ Cwise<ExpressionType,StorageBase>::operator-(const Scalar& scalar) const
* \sa operator+=(), operator-() * \sa operator+=(), operator-()
*/ */
template<typename ExpressionType,template <typename> class StorageBase> template<typename ExpressionType>
inline ExpressionType& Cwise<ExpressionType,StorageBase>::operator-=(const Scalar& scalar) inline ExpressionType& Cwise<ExpressionType>::operator-=(const Scalar& scalar)
{ {
return m_matrix.const_cast_derived() = *this - scalar; return m_matrix.const_cast_derived() = *this - scalar;
} }

View File

View File

@ -133,7 +133,7 @@ void ComplexEigenSolver<MatrixType>::compute(const MatrixType& matrix)
for (int i=0; i<n; i++) for (int i=0; i<n; i++)
{ {
int k; int k;
m_eivalues.cwise().abs().end(n-i).minCoeff(&k); m_eivalues.cwiseAbs().end(n-i).minCoeff(&k);
if (k != 0) if (k != 0)
{ {
k += i; k += i;

View File

@ -204,7 +204,7 @@ void ComplexSchur<MatrixType>::compute(const MatrixType& matrix, bool skipU)
// compute the shift (the normalization by sf is to avoid under/overflow) // compute the shift (the normalization by sf is to avoid under/overflow)
Matrix<Scalar,2,2> t = m_matT.template block<2,2>(iu-1,iu-1); Matrix<Scalar,2,2> t = m_matT.template block<2,2>(iu-1,iu-1);
sf = t.cwise().abs().sum(); sf = t.cwiseAbs().sum();
t /= sf; t /= sf;
c = t.determinant(); c = t.determinant();

View File

@ -225,7 +225,7 @@ void EigenSolver<MatrixType>::orthes(MatrixType& matH, RealVectorType& ort)
for (int m = low+1; m <= high-1; ++m) for (int m = low+1; m <= high-1; ++m)
{ {
// Scale column. // 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) if (scale != 0.0)
{ {
// Compute Householder transformation. // Compute Householder transformation.
@ -312,7 +312,7 @@ void EigenSolver<MatrixType>::hqr2(MatrixType& matH)
// Store roots isolated by balanc and compute matrix norm // Store roots isolated by balanc and compute matrix norm
// FIXME to be efficient the following would requires a triangular reduxion code // 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; Scalar norm = 0.0;
for (int j = 0; j < nn; ++j) for (int j = 0; j < nn; ++j)
{ {
@ -321,7 +321,7 @@ void EigenSolver<MatrixType>::hqr2(MatrixType& matH)
{ {
m_eivalues.coeffRef(j) = Complex(matH.coeff(j,j), 0.0); 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 // Outer loop over eigenvalue index

View File

@ -112,7 +112,7 @@ template<typename _MatrixType> class SelfAdjointEigenSolver
*/ */
MatrixType operatorSqrt() const 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 /** \returns the positive inverse square root of the matrix
@ -121,7 +121,7 @@ template<typename _MatrixType> class SelfAdjointEigenSolver
*/ */
MatrixType operatorInverseSqrt() const 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, // 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. // 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();
} }
}; };

View File

@ -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; } inline int dim() const { return AmbientDimAtCompileTime==Dynamic ? m_min.size()-1 : AmbientDimAtCompileTime; }
/** \returns true if the box is null, i.e, empty. */ /** \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. */ /** Makes \c *this a null/empty box. */
inline void setNull() 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. */ /** \returns true if the point \a p is inside the box \c *this. */
inline bool contains(const VectorType& p) const 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. */ /** \returns true if the box \a b is entirely inside the box \c *this. */
inline bool contains(const AlignedBox& b) const 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. */ /** Extends \c *this such that it contains the point \a p and returns a reference to \c *this. */
inline AlignedBox& extend(const VectorType& p) 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. */ /** Extends \c *this such that it contains the box \a b and returns a reference to \c *this. */
inline AlignedBox& extend(const AlignedBox& b) 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. */ /** Clamps \c *this by the box \a b and returns a reference to \c *this. */
inline AlignedBox& clamp(const AlignedBox& b) 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 */ /** Returns an AlignedBox that is the intersection of \a b and \c *this */
inline AlignedBox intersection(const AlignedBox &b) const 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 */ /** Returns an AlignedBox that is the union of \a b and \c *this */
inline AlignedBox merged(const AlignedBox &b) const 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. */ /** Translate \c *this by the vector \a t and returns a reference to \c *this. */
inline AlignedBox& translate(const VectorType& t) inline AlignedBox& translate(const VectorType& t)

View File

@ -213,7 +213,7 @@ AngleAxis<Scalar>::toRotationMatrix(void) const
res.coeffRef(1,2) = tmp - sin_axis.x(); res.coeffRef(1,2) = tmp - sin_axis.x();
res.coeffRef(2,1) = 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; return res;
} }

View File

@ -194,7 +194,7 @@ VectorwiseOp<ExpressionType,Direction>::hnormalized() const
return HNormalized_Block(_expression(),0,0, return HNormalized_Block(_expression(),0,0,
Direction==Vertical ? _expression().rows()-1 : _expression().rows(), Direction==Vertical ? _expression().rows()-1 : _expression().rows(),
Direction==Horizontal ? _expression().cols()-1 : _expression().cols()).nestByValue() Direction==Horizontal ? _expression().cols()-1 : _expression().cols()).nestByValue()
.cwise()/ .cwiseQuotient(
Replicate<NestByValue<HNormalized_Factors>, Replicate<NestByValue<HNormalized_Factors>,
Direction==Vertical ? HNormalized_SizeMinusOne : 1, Direction==Vertical ? HNormalized_SizeMinusOne : 1,
Direction==Horizontal ? HNormalized_SizeMinusOne : 1> Direction==Horizontal ? HNormalized_SizeMinusOne : 1>
@ -204,7 +204,7 @@ VectorwiseOp<ExpressionType,Direction>::hnormalized() const
Direction==Vertical ? 1 : _expression().rows(), Direction==Vertical ? 1 : _expression().rows(),
Direction==Horizontal ? 1 : _expression().cols()).nestByValue(), Direction==Horizontal ? 1 : _expression().cols()).nestByValue(),
Direction==Vertical ? _expression().rows()-1 : 1, Direction==Vertical ? _expression().rows()-1 : 1,
Direction==Horizontal ? _expression().cols()-1 : 1).nestByValue(); Direction==Horizontal ? _expression().cols()-1 : 1).nestByValue());
} }
template<typename MatrixType,typename Lhs> template<typename MatrixType,typename Lhs>

View File

@ -142,7 +142,7 @@ struct ei_unitOrthogonal_selector
VectorType perp = VectorType::Zero(src.size()); VectorType perp = VectorType::Zero(src.size());
int maxi = 0; int maxi = 0;
int sndi = 0; int sndi = 0;
src.cwise().abs().maxCoeff(&maxi); src.cwiseAbs().maxCoeff(&maxi);
if (maxi==0) if (maxi==0)
sndi = 1; sndi = 1;
RealScalar invnm = RealScalar(1)/(Vector2() << src.coeff(sndi),src.coeff(maxi)).finished().norm(); RealScalar invnm = RealScalar(1)/(Vector2() << src.coeff(sndi),src.coeff(maxi)).finished().norm();

View File

@ -416,7 +416,7 @@ FullPivLU<MatrixType>& FullPivLU<MatrixType>::compute(const MatrixType& matrix)
int row_of_biggest_in_corner, col_of_biggest_in_corner; int row_of_biggest_in_corner, col_of_biggest_in_corner;
RealScalar biggest_in_corner; RealScalar biggest_in_corner;
biggest_in_corner = m_lu.corner(Eigen::BottomRight, rows-k, cols-k) 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); .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, 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. col_of_biggest_in_corner += k; // need to add k to them.

View File

@ -148,7 +148,7 @@ struct ei_compute_inverse<MatrixType, ResultType, 3>
cofactors_col0.coeffRef(0) = matrix.minor(0,0).determinant(); cofactors_col0.coeffRef(0) = matrix.minor(0,0).determinant();
cofactors_col0.coeffRef(1) = -matrix.minor(1,0).determinant(); cofactors_col0.coeffRef(1) = -matrix.minor(1,0).determinant();
cofactors_col0.coeffRef(2) = matrix.minor(2,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; const Scalar invdet = Scalar(1) / det;
ei_compute_inverse_size3_helper(matrix, invdet, cofactors_col0, result); ei_compute_inverse_size3_helper(matrix, invdet, cofactors_col0, result);
} }
@ -170,7 +170,7 @@ struct ei_compute_inverse_and_det_with_check<MatrixType, ResultType, 3>
cofactors_col0.coeffRef(0) = matrix.minor(0,0).determinant(); cofactors_col0.coeffRef(0) = matrix.minor(0,0).determinant();
cofactors_col0.coeffRef(1) = -matrix.minor(1,0).determinant(); cofactors_col0.coeffRef(1) = -matrix.minor(1,0).determinant();
cofactors_col0.coeffRef(2) = matrix.minor(2,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; invertible = ei_abs(determinant) > absDeterminantThreshold;
if(!invertible) return; if(!invertible) return;
const Scalar invdet = Scalar(1) / determinant; const Scalar invdet = Scalar(1) / determinant;

View File

@ -233,7 +233,7 @@ struct ei_partial_lu_impl
{ {
int row_of_biggest_in_col; int row_of_biggest_in_col;
RealScalar biggest_in_corner 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; row_of_biggest_in_col += k;
if(biggest_in_corner == 0) // the pivot is exactly zero: the matrix is singular if(biggest_in_corner == 0) // the pivot is exactly zero: the matrix is singular

View File

@ -283,15 +283,15 @@ class ei_sparse_cwise_binary_op_inner_iterator_selector<ei_scalar_product_op<T>,
* Implementation of SparseMatrixBase and SparseCwise functions/operators * Implementation of SparseMatrixBase and SparseCwise functions/operators
***************************************************************************/ ***************************************************************************/
template<typename Derived> // template<typename Derived>
template<typename OtherDerived> // template<typename OtherDerived>
EIGEN_STRONG_INLINE const CwiseBinaryOp<ei_scalar_difference_op<typename ei_traits<Derived>::Scalar>, // EIGEN_STRONG_INLINE const CwiseBinaryOp<ei_scalar_difference_op<typename ei_traits<Derived>::Scalar>,
Derived, OtherDerived> // Derived, OtherDerived>
SparseMatrixBase<Derived>::operator-(const SparseMatrixBase<OtherDerived> &other) const // SparseMatrixBase<Derived>::operator-(const SparseMatrixBase<OtherDerived> &other) const
{ // {
return CwiseBinaryOp<ei_scalar_difference_op<Scalar>, // return CwiseBinaryOp<ei_scalar_difference_op<Scalar>,
Derived, OtherDerived>(derived(), other.derived()); // Derived, OtherDerived>(derived(), other.derived());
} // }
template<typename Derived> template<typename Derived>
template<typename OtherDerived> template<typename OtherDerived>
@ -301,13 +301,13 @@ SparseMatrixBase<Derived>::operator-=(const SparseMatrixBase<OtherDerived> &othe
return *this = derived() - other.derived(); return *this = derived() - other.derived();
} }
template<typename Derived> // template<typename Derived>
template<typename OtherDerived> // template<typename OtherDerived>
EIGEN_STRONG_INLINE const CwiseBinaryOp<ei_scalar_sum_op<typename ei_traits<Derived>::Scalar>, Derived, OtherDerived> // EIGEN_STRONG_INLINE const CwiseBinaryOp<ei_scalar_sum_op<typename ei_traits<Derived>::Scalar>, Derived, OtherDerived>
SparseMatrixBase<Derived>::operator+(const SparseMatrixBase<OtherDerived> &other) const // SparseMatrixBase<Derived>::operator+(const SparseMatrixBase<OtherDerived> &other) const
{ // {
return CwiseBinaryOp<ei_scalar_sum_op<Scalar>, Derived, OtherDerived>(derived(), other.derived()); // return CwiseBinaryOp<ei_scalar_sum_op<Scalar>, Derived, OtherDerived>(derived(), other.derived());
} // }
template<typename Derived> template<typename Derived>
template<typename OtherDerived> template<typename OtherDerived>

View File

@ -111,6 +111,7 @@ template<typename Derived> class SparseMatrixBase : public AnyMatrixBase<Derived
#define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::SparseMatrixBase #define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::SparseMatrixBase
#include "../Core/CwiseUnaryOps.h" #include "../Core/CwiseUnaryOps.h"
#include "../Core/CwiseBinaryOps.h"
#undef EIGEN_CURRENT_STORAGE_BASE_CLASS #undef EIGEN_CURRENT_STORAGE_BASE_CLASS
#ifndef EIGEN_PARSED_BY_DOXYGEN #ifndef EIGEN_PARSED_BY_DOXYGEN
@ -290,13 +291,13 @@ template<typename Derived> class SparseMatrixBase : public AnyMatrixBase<Derived
// const SparseCwiseUnaryOp<ei_scalar_opposite_op<typename ei_traits<Derived>::Scalar>,Derived> operator-() const; // const SparseCwiseUnaryOp<ei_scalar_opposite_op<typename ei_traits<Derived>::Scalar>,Derived> operator-() const;
template<typename OtherDerived> // template<typename OtherDerived>
const CwiseBinaryOp<ei_scalar_sum_op<typename ei_traits<Derived>::Scalar>, Derived, OtherDerived> // const CwiseBinaryOp<ei_scalar_sum_op<typename ei_traits<Derived>::Scalar>, Derived, OtherDerived>
operator+(const SparseMatrixBase<OtherDerived> &other) const; // operator+(const SparseMatrixBase<OtherDerived> &other) const;
template<typename OtherDerived> // template<typename OtherDerived>
const CwiseBinaryOp<ei_scalar_difference_op<typename ei_traits<Derived>::Scalar>, Derived, OtherDerived> // const CwiseBinaryOp<ei_scalar_difference_op<typename ei_traits<Derived>::Scalar>, Derived, OtherDerived>
operator-(const SparseMatrixBase<OtherDerived> &other) const; // operator-(const SparseMatrixBase<OtherDerived> &other) const;
template<typename OtherDerived> template<typename OtherDerived>
Derived& operator+=(const SparseMatrixBase<OtherDerived>& other); Derived& operator+=(const SparseMatrixBase<OtherDerived>& other);

View File

@ -22,6 +22,7 @@
// License and a copy of the GNU General Public License along with // License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>. // Eigen. If not, see <http://www.gnu.org/licenses/>.
#define EIGEN2_SUPPORT
#include "main.h" #include "main.h"
#include <Eigen/Array> #include <Eigen/Array>

View File

@ -23,6 +23,7 @@
// License and a copy of the GNU General Public License along with // License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>. // Eigen. If not, see <http://www.gnu.org/licenses/>.
#define EIGEN2_SUPPORT
#include "main.h" #include "main.h"
#include <functional> #include <functional>
#include <Eigen/Array> #include <Eigen/Array>

View File

@ -52,7 +52,7 @@ template<typename MatrixType> void eigensolver(const MatrixType& m)
// Regression test for issue #66 // Regression test for issue #66
MatrixType z = MatrixType::Zero(rows,cols); MatrixType z = MatrixType::Zero(rows,cols);
ComplexEigenSolver<MatrixType> eiz(z); ComplexEigenSolver<MatrixType> eiz(z);
VERIFY((eiz.eigenvalues().cwise()==0).all()); VERIFY((eiz.eigenvalues().cwiseEqual(0)).all());
} }
void test_eigensolver_complex() void test_eigensolver_complex()

View File

@ -79,7 +79,7 @@ template<typename MatrixType> void selfadjointeigensolver(const MatrixType& m)
// compare with eigen // compare with eigen
VERIFY_IS_APPROX(_eval, eiSymm.eigenvalues()); 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 // generalized pb
Gsl::eigen_symm_gen(gSymmA, gSymmB, gEval, gEvec); Gsl::eigen_symm_gen(gSymmA, gSymmB, gEval, gEvec);
@ -92,7 +92,7 @@ template<typename MatrixType> void selfadjointeigensolver(const MatrixType& m)
// std::cerr << _eval.transpose() << "\n" << eiSymmGen.eigenvalues().transpose() << "\n\n"; // std::cerr << _eval.transpose() << "\n" << eiSymmGen.eigenvalues().transpose() << "\n\n";
// std::cerr << _evec.format(6) << "\n\n" << eiSymmGen.eigenvectors().format(6) << "\n\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(_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(gSymmA);
Gsl::free(gSymmB); Gsl::free(gSymmB);

View File

@ -22,6 +22,7 @@
// License and a copy of the GNU General Public License along with // License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>. // Eigen. If not, see <http://www.gnu.org/licenses/>.
#define EIGEN2_SUPPORT
#include "main.h" #include "main.h"
#include <Eigen/Geometry> #include <Eigen/Geometry>
#include <Eigen/LU> #include <Eigen/LU>

View File

@ -22,6 +22,7 @@
// License and a copy of the GNU General Public License along with // License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>. // Eigen. If not, see <http://www.gnu.org/licenses/>.
#define EIGEN2_SUPPORT
#include "main.h" #include "main.h"
#include <Eigen/Geometry> #include <Eigen/Geometry>
#include <Eigen/LU> #include <Eigen/LU>

View File

@ -22,6 +22,7 @@
// License and a copy of the GNU General Public License along with // License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>. // Eigen. If not, see <http://www.gnu.org/licenses/>.
#define EIGEN2_SUPPORT
#include "main.h" #include "main.h"
#include <Eigen/Geometry> #include <Eigen/Geometry>

View File

@ -23,6 +23,7 @@
// License and a copy of the GNU General Public License along with // License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>. // Eigen. If not, see <http://www.gnu.org/licenses/>.
#define EIGEN2_SUPPORT
#include "main.h" #include "main.h"
#include <Eigen/Geometry> #include <Eigen/Geometry>
#include <Eigen/LU> #include <Eigen/LU>

View File

@ -22,6 +22,7 @@
// License and a copy of the GNU General Public License along with // License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>. // Eigen. If not, see <http://www.gnu.org/licenses/>.
#define EIGEN2_SUPPORT
#include "main.h" #include "main.h"
#include <Eigen/Geometry> #include <Eigen/Geometry>
#include <Eigen/LU> #include <Eigen/LU>

View File

@ -23,6 +23,7 @@
// License and a copy of the GNU General Public License along with // License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>. // Eigen. If not, see <http://www.gnu.org/licenses/>.
#define EIGEN2_SUPPORT
#include "main.h" #include "main.h"
#include <Eigen/Geometry> #include <Eigen/Geometry>
#include <Eigen/LU> #include <Eigen/LU>

View File

@ -23,6 +23,7 @@
// License and a copy of the GNU General Public License along with // License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>. // Eigen. If not, see <http://www.gnu.org/licenses/>.
#define EIGEN2_SUPPORT
#include "main.h" #include "main.h"
#include <Eigen/Geometry> #include <Eigen/Geometry>
#include <Eigen/LU> #include <Eigen/LU>

View File

@ -22,6 +22,7 @@
// License and a copy of the GNU General Public License along with // License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>. // Eigen. If not, see <http://www.gnu.org/licenses/>.
#define EIGEN2_SUPPORT
#include "main.h" #include "main.h"
#include <Eigen/Geometry> #include <Eigen/Geometry>
#include <Eigen/LU> #include <Eigen/LU>