mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-04-18 19:30:38 +08:00
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:
parent
0529ecfe1b
commit
e3d890bc5a
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -23,6 +23,10 @@
|
||||
// License and a copy of the GNU General Public License along with
|
||||
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#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"
|
||||
|
57
Eigen/Eigen2Support
Normal file
57
Eigen/Eigen2Support
Normal 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
|
@ -31,7 +31,7 @@ struct ei_lpNorm_selector
|
||||
typedef typename NumTraits<typename ei_traits<Derived>::Scalar>::Real RealScalar;
|
||||
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)
|
||||
{
|
||||
return m.cwise().abs().sum();
|
||||
return m.cwiseAbs().sum();
|
||||
}
|
||||
};
|
||||
|
||||
@ -58,12 +58,12 @@ struct ei_lpNorm_selector<Derived, Infinity>
|
||||
{
|
||||
inline static typename NumTraits<typename ei_traits<Derived>::Scalar>::Real run(const MatrixBase<Derived>& 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.
|
||||
|
@ -81,7 +81,7 @@ template<typename _MatrixType> class LDLT
|
||||
|
||||
/** \returns the lower triangular matrix L */
|
||||
inline TriangularView<MatrixType, UnitLowerTriangular> matrixL(void) const
|
||||
{
|
||||
{
|
||||
ei_assert(m_isInitialized && "LDLT is not initialized.");
|
||||
return m_matrix;
|
||||
}
|
||||
@ -132,7 +132,7 @@ template<typename _MatrixType> class LDLT
|
||||
&& "LDLT::solve(): invalid number of rows of the right hand side matrix b");
|
||||
return ei_solve_retval<LDLT, Rhs>(*this, b.derived());
|
||||
}
|
||||
|
||||
|
||||
template<typename Derived>
|
||||
bool solveInPlace(MatrixBase<Derived> &bAndX) const;
|
||||
|
||||
@ -150,7 +150,7 @@ template<typename _MatrixType> 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<MatrixType>& LDLT<MatrixType>::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<MatrixType>::solveInPlace(MatrixBase<Derived> &bAndX) const
|
||||
m_matrix.template triangularView<UnitLowerTriangular>().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<UnitUpperTriangular>().solveInPlace(bAndX);
|
||||
|
@ -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.
|
||||
*
|
||||
* \returns a reference to \c *this
|
||||
@ -197,22 +181,6 @@ MatrixBase<Derived>::operator-=(const MatrixBase<OtherDerived> &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.
|
||||
*
|
||||
* \returns a reference to \c *this
|
||||
@ -225,111 +193,4 @@ MatrixBase<Derived>::operator+=(const MatrixBase<OtherDerived>& 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
|
||||
|
139
Eigen/src/Core/CwiseBinaryOps.h
Normal file
139
Eigen/src/Core/CwiseBinaryOps.h
Normal 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());
|
||||
}
|
@ -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
|
||||
|
@ -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<Derived,EIGEN_CURRENT_STORAGE_BASE_CLASS> cwise() const
|
||||
{
|
||||
return derived();
|
||||
}
|
||||
EIGEN_STRONG_INLINE const CwiseUnaryOp<ei_scalar_abs_op<Scalar>,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<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));
|
||||
}
|
||||
|
@ -68,6 +68,12 @@ class DiagonalBase : public AnyMatrixBase<Derived>
|
||||
template<typename MatrixDerived>
|
||||
const DiagonalProduct<MatrixDerived, Derived, OnTheLeft>
|
||||
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>
|
||||
|
@ -279,7 +279,7 @@ MatrixBase<Derived>::dot(const MatrixBase<OtherDerived>& other) const
|
||||
template<typename Derived>
|
||||
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.
|
||||
|
@ -54,7 +54,7 @@ bool MatrixBase<Derived>::isApprox(
|
||||
{
|
||||
const typename ei_nested<Derived,2>::type nested(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,
|
||||
@ -76,7 +76,7 @@ bool MatrixBase<Derived>::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<Derived>::isMuchSmallerThan(
|
||||
RealScalar prec
|
||||
) const
|
||||
{
|
||||
return this->cwise().abs2().sum() <= prec * prec * other.cwise().abs2().sum();
|
||||
return cwiseAbs2().sum() <= prec * prec * other.cwiseAbs2().sum();
|
||||
}
|
||||
|
||||
#else
|
||||
|
@ -247,6 +247,7 @@ template<typename Derived> 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<typename Derived> class MatrixBase
|
||||
template<typename OtherDerived>
|
||||
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>
|
||||
Derived& lazyAssign(const ProductBase<ProductDerived, Lhs,Rhs>& other);
|
||||
|
||||
@ -342,15 +337,6 @@ template<typename Derived> class MatrixBase
|
||||
Scalar& z();
|
||||
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>
|
||||
Derived& operator+=(const MatrixBase<OtherDerived>& other);
|
||||
template<typename OtherDerived>
|
||||
@ -373,14 +359,6 @@ template<typename Derived> class MatrixBase
|
||||
const DiagonalProduct<Derived, DiagonalDerived, OnTheRight>
|
||||
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>
|
||||
Scalar dot(const MatrixBase<OtherDerived>& other) const;
|
||||
RealScalar squaredNorm() const;
|
||||
@ -542,11 +520,11 @@ template<typename Derived> class MatrixBase
|
||||
|
||||
template<typename OtherDerived>
|
||||
inline bool operator==(const MatrixBase<OtherDerived>& other) const
|
||||
{ return (cwise() == other).all(); }
|
||||
{ return cwiseEqual(other).all(); }
|
||||
|
||||
template<typename OtherDerived>
|
||||
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.
|
||||
@ -560,10 +538,6 @@ template<typename Derived> class MatrixBase
|
||||
template<typename OtherDerived>
|
||||
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();
|
||||
|
||||
/** \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;
|
||||
|
||||
|
||||
template<typename CustomBinaryOp, typename OtherDerived>
|
||||
const CwiseBinaryOp<CustomBinaryOp, Derived, OtherDerived>
|
||||
binaryExpr(const MatrixBase<OtherDerived> &other, const CustomBinaryOp& func = CustomBinaryOp()) const;
|
||||
|
||||
|
||||
Scalar sum() const;
|
||||
Scalar mean() const;
|
||||
Scalar trace() const;
|
||||
@ -736,6 +704,33 @@ template<typename Derived> class MatrixBase
|
||||
#include EIGEN_MATRIXBASE_PLUGIN
|
||||
#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:
|
||||
/** Default constructor. Do nothing. */
|
||||
MatrixBase()
|
||||
|
@ -170,7 +170,7 @@ class GeneralProduct<Lhs, Rhs, InnerProduct>
|
||||
|
||||
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
|
||||
@ -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
|
||||
const int rows = prod.rows();
|
||||
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:
|
||||
// * 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),
|
||||
|
@ -78,8 +78,7 @@ struct ei_triangular_solver_selector<Lhs,Rhs,OnTheLeft,Mode,NoUnrolling,RowMajor
|
||||
int i = IsLowerTriangular ? pi+k : pi-k-1;
|
||||
int s = IsLowerTriangular ? pi : i+1;
|
||||
if (k>0)
|
||||
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<Lhs,Rhs,Mode,Index,Size,false> {
|
||||
static void run(const Lhs& lhs, Rhs& rhs)
|
||||
{
|
||||
if (Index>0)
|
||||
rhs.coeffRef(I) -= ((lhs.row(I).template segment<Index>(S).transpose())
|
||||
.cwise()*(rhs.template segment<Index>(S))).sum();
|
||||
rhs.coeffRef(I) -= ((lhs.row(I).template segment<Index>(S).transpose()).cwiseProduct(rhs.template segment<Index>(S))).sum();
|
||||
|
||||
if(!(Mode & UnitDiagBit))
|
||||
rhs.coeffRef(I) /= lhs.coeff(I,I);
|
||||
|
@ -28,7 +28,7 @@
|
||||
template<typename ExpressionType, typename Scalar>
|
||||
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<typename Derived>
|
||||
inline typename NumTraits<typename ei_traits<Derived>::Scalar>::Real
|
||||
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
|
||||
|
@ -60,7 +60,6 @@ template<typename MatrixType, int PacketAccess = AsRequested> class Map;
|
||||
template<typename Derived> class TriangularBase;
|
||||
template<typename MatrixType, unsigned int Mode> class TriangularView;
|
||||
template<typename MatrixType, unsigned int Mode> class SelfAdjointView;
|
||||
template<typename ExpressionType, template <typename> class StorageBase> class Cwise;
|
||||
template<typename ExpressionType> class WithFormat;
|
||||
template<typename MatrixType> struct CommaInitializer;
|
||||
template<typename Derived> class ReturnByValue;
|
||||
@ -146,4 +145,8 @@ template<typename Scalar,int Dim> class Translation;
|
||||
template<typename Scalar> class UniformScaling;
|
||||
template<typename MatrixType,int Direction> class Homogeneous;
|
||||
|
||||
#ifdef EIGEN2_SUPPORT
|
||||
template<typename ExpressionType> class Cwise;
|
||||
#endif
|
||||
|
||||
#endif // EIGEN_FORWARDDECLARATIONS_H
|
||||
|
@ -71,7 +71,7 @@
|
||||
*
|
||||
* \sa MatrixBase::cwise() const, MatrixBase::cwise()
|
||||
*/
|
||||
template<typename ExpressionType, template<typename> class StorageBase> class Cwise
|
||||
template<typename ExpressionType> class Cwise
|
||||
{
|
||||
public:
|
||||
|
||||
@ -87,19 +87,19 @@ template<typename ExpressionType, template<typename> class StorageBase> class Cw
|
||||
|
||||
template<typename OtherDerived>
|
||||
const EIGEN_CWISE_PRODUCT_RETURN_TYPE
|
||||
operator*(const AnyMatrixBase<OtherDerived> &other) const;
|
||||
operator*(const MatrixBase<OtherDerived> &other) const;
|
||||
|
||||
template<typename OtherDerived>
|
||||
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>
|
||||
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>
|
||||
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_abs2_op) abs2() const;
|
||||
@ -129,28 +129,28 @@ template<typename ExpressionType, template<typename> class StorageBase> class Cw
|
||||
ExpressionType& operator-=(const Scalar& scalar);
|
||||
|
||||
template<typename OtherDerived>
|
||||
inline ExpressionType& operator*=(const StorageBase<OtherDerived> &other);
|
||||
inline ExpressionType& operator*=(const MatrixBase<OtherDerived> &other);
|
||||
|
||||
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)
|
||||
operator<(const StorageBase<OtherDerived>& other) const;
|
||||
operator<(const MatrixBase<OtherDerived>& other) const;
|
||||
|
||||
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)
|
||||
operator>(const StorageBase<OtherDerived>& other) const;
|
||||
operator>(const MatrixBase<OtherDerived>& other) const;
|
||||
|
||||
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)
|
||||
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)
|
||||
operator!=(const StorageBase<OtherDerived>& other) const;
|
||||
operator!=(const MatrixBase<OtherDerived>& other) const;
|
||||
|
||||
// comparisons to a scalar value
|
||||
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&);
|
||||
};
|
||||
|
||||
|
||||
/** \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
|
@ -25,6 +25,159 @@
|
||||
#ifndef EIGEN_ARRAY_CWISE_OPERATORS_H
|
||||
#define EIGEN_ARRAY_CWISE_OPERATORS_H
|
||||
|
||||
/***************************************************************************
|
||||
* The following functions were defined in Core
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
/** \returns an expression of the coefficient-wise absolute value of \c *this
|
||||
*
|
||||
* Example: \include Cwise_abs.cpp
|
||||
* Output: \verbinclude Cwise_abs.out
|
||||
*
|
||||
* \sa abs2()
|
||||
*/
|
||||
template<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 --
|
||||
|
||||
/** \array_module
|
||||
@ -36,9 +189,9 @@
|
||||
*
|
||||
* \sa pow(), square()
|
||||
*/
|
||||
template<typename ExpressionType,template <typename> class StorageBase>
|
||||
template<typename ExpressionType>
|
||||
inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_sqrt_op)
|
||||
Cwise<ExpressionType,StorageBase>::sqrt() const
|
||||
Cwise<ExpressionType>::sqrt() const
|
||||
{
|
||||
return _expression();
|
||||
}
|
||||
@ -52,9 +205,9 @@ Cwise<ExpressionType,StorageBase>::sqrt() const
|
||||
*
|
||||
* \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)
|
||||
Cwise<ExpressionType,StorageBase>::cos() const
|
||||
Cwise<ExpressionType>::cos() const
|
||||
{
|
||||
return _expression();
|
||||
}
|
||||
@ -69,9 +222,9 @@ Cwise<ExpressionType,StorageBase>::cos() const
|
||||
*
|
||||
* \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)
|
||||
Cwise<ExpressionType,StorageBase>::sin() const
|
||||
Cwise<ExpressionType>::sin() const
|
||||
{
|
||||
return _expression();
|
||||
}
|
||||
@ -86,9 +239,9 @@ Cwise<ExpressionType,StorageBase>::sin() const
|
||||
*
|
||||
* \sa exp(), log()
|
||||
*/
|
||||
template<typename ExpressionType,template <typename> class StorageBase>
|
||||
template<typename ExpressionType>
|
||||
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));
|
||||
}
|
||||
@ -103,9 +256,9 @@ Cwise<ExpressionType,StorageBase>::pow(const Scalar& exponent) const
|
||||
*
|
||||
* \sa operator/(), operator*()
|
||||
*/
|
||||
template<typename ExpressionType,template <typename> class StorageBase>
|
||||
template<typename ExpressionType>
|
||||
inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_inverse_op)
|
||||
Cwise<ExpressionType,StorageBase>::inverse() const
|
||||
Cwise<ExpressionType>::inverse() const
|
||||
{
|
||||
return _expression();
|
||||
}
|
||||
@ -119,9 +272,9 @@ Cwise<ExpressionType,StorageBase>::inverse() const
|
||||
*
|
||||
* \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)
|
||||
Cwise<ExpressionType,StorageBase>::square() const
|
||||
Cwise<ExpressionType>::square() const
|
||||
{
|
||||
return _expression();
|
||||
}
|
||||
@ -135,9 +288,9 @@ Cwise<ExpressionType,StorageBase>::square() const
|
||||
*
|
||||
* \sa square(), pow()
|
||||
*/
|
||||
template<typename ExpressionType,template <typename> class StorageBase>
|
||||
template<typename ExpressionType>
|
||||
inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_cube_op)
|
||||
Cwise<ExpressionType,StorageBase>::cube() const
|
||||
Cwise<ExpressionType>::cube() const
|
||||
{
|
||||
return _expression();
|
||||
}
|
||||
@ -154,10 +307,10 @@ Cwise<ExpressionType,StorageBase>::cube() const
|
||||
*
|
||||
* \sa MatrixBase::all(), MatrixBase::any(), operator>(), operator<=()
|
||||
*/
|
||||
template<typename ExpressionType,template <typename> class StorageBase>
|
||||
template<typename ExpressionType>
|
||||
template<typename OtherDerived>
|
||||
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());
|
||||
}
|
||||
@ -171,10 +324,10 @@ Cwise<ExpressionType,StorageBase>::operator<(const StorageBase<OtherDerived> &ot
|
||||
*
|
||||
* \sa MatrixBase::all(), MatrixBase::any(), operator>=(), operator<()
|
||||
*/
|
||||
template<typename ExpressionType,template <typename> class StorageBase>
|
||||
template<typename ExpressionType>
|
||||
template<typename OtherDerived>
|
||||
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());
|
||||
}
|
||||
@ -188,10 +341,10 @@ Cwise<ExpressionType,StorageBase>::operator<=(const StorageBase<OtherDerived> &o
|
||||
*
|
||||
* \sa MatrixBase::all(), MatrixBase::any(), operator>=(), operator<()
|
||||
*/
|
||||
template<typename ExpressionType,template <typename> class StorageBase>
|
||||
template<typename ExpressionType>
|
||||
template<typename OtherDerived>
|
||||
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());
|
||||
}
|
||||
@ -205,10 +358,10 @@ Cwise<ExpressionType,StorageBase>::operator>(const StorageBase<OtherDerived> &ot
|
||||
*
|
||||
* \sa MatrixBase::all(), MatrixBase::any(), operator>(), operator<=()
|
||||
*/
|
||||
template<typename ExpressionType,template <typename> class StorageBase>
|
||||
template<typename ExpressionType>
|
||||
template<typename OtherDerived>
|
||||
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());
|
||||
}
|
||||
@ -227,10 +380,10 @@ Cwise<ExpressionType,StorageBase>::operator>=(const StorageBase<OtherDerived> &o
|
||||
*
|
||||
* \sa MatrixBase::all(), MatrixBase::any(), MatrixBase::isApprox(), MatrixBase::isMuchSmallerThan()
|
||||
*/
|
||||
template<typename ExpressionType,template <typename> class StorageBase>
|
||||
template<typename ExpressionType>
|
||||
template<typename OtherDerived>
|
||||
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());
|
||||
}
|
||||
@ -249,10 +402,10 @@ Cwise<ExpressionType,StorageBase>::operator==(const StorageBase<OtherDerived> &o
|
||||
*
|
||||
* \sa MatrixBase::all(), MatrixBase::any(), MatrixBase::isApprox(), MatrixBase::isMuchSmallerThan()
|
||||
*/
|
||||
template<typename ExpressionType,template <typename> class StorageBase>
|
||||
template<typename ExpressionType>
|
||||
template<typename OtherDerived>
|
||||
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());
|
||||
}
|
||||
@ -265,9 +418,9 @@ Cwise<ExpressionType,StorageBase>::operator!=(const StorageBase<OtherDerived> &o
|
||||
*
|
||||
* \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)
|
||||
Cwise<ExpressionType,StorageBase>::operator<(Scalar s) const
|
||||
Cwise<ExpressionType>::operator<(Scalar s) const
|
||||
{
|
||||
return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less)(_expression(),
|
||||
typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s));
|
||||
@ -279,9 +432,9 @@ Cwise<ExpressionType,StorageBase>::operator<(Scalar s) 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)
|
||||
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(),
|
||||
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
|
||||
*/
|
||||
template<typename ExpressionType,template <typename> class StorageBase>
|
||||
template<typename ExpressionType>
|
||||
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(),
|
||||
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
|
||||
*/
|
||||
template<typename ExpressionType,template <typename> class StorageBase>
|
||||
template<typename ExpressionType>
|
||||
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(),
|
||||
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
|
||||
*/
|
||||
template<typename ExpressionType,template <typename> class StorageBase>
|
||||
template<typename ExpressionType>
|
||||
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(),
|
||||
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
|
||||
*/
|
||||
template<typename ExpressionType,template <typename> class StorageBase>
|
||||
template<typename ExpressionType>
|
||||
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(),
|
||||
typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s));
|
||||
@ -364,11 +517,11 @@ Cwise<ExpressionType,StorageBase>::operator!=(Scalar s) const
|
||||
*
|
||||
* \sa operator+=(), operator-()
|
||||
*/
|
||||
template<typename ExpressionType,template <typename> class StorageBase>
|
||||
inline const typename Cwise<ExpressionType,StorageBase>::ScalarAddReturnType
|
||||
Cwise<ExpressionType,StorageBase>::operator+(const Scalar& scalar) const
|
||||
template<typename ExpressionType>
|
||||
inline const typename Cwise<ExpressionType>::ScalarAddReturnType
|
||||
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
|
||||
@ -380,8 +533,8 @@ Cwise<ExpressionType,StorageBase>::operator+(const Scalar& scalar) const
|
||||
*
|
||||
* \sa operator+(), operator-=()
|
||||
*/
|
||||
template<typename ExpressionType,template <typename> class StorageBase>
|
||||
inline ExpressionType& Cwise<ExpressionType,StorageBase>::operator+=(const Scalar& scalar)
|
||||
template<typename ExpressionType>
|
||||
inline ExpressionType& Cwise<ExpressionType>::operator+=(const Scalar& scalar)
|
||||
{
|
||||
return m_matrix.const_cast_derived() = *this + scalar;
|
||||
}
|
||||
@ -395,9 +548,9 @@ inline ExpressionType& Cwise<ExpressionType,StorageBase>::operator+=(const Scala
|
||||
*
|
||||
* \sa operator+(), operator-=()
|
||||
*/
|
||||
template<typename ExpressionType,template <typename> class StorageBase>
|
||||
inline const typename Cwise<ExpressionType,StorageBase>::ScalarAddReturnType
|
||||
Cwise<ExpressionType,StorageBase>::operator-(const Scalar& scalar) const
|
||||
template<typename ExpressionType>
|
||||
inline const typename Cwise<ExpressionType>::ScalarAddReturnType
|
||||
Cwise<ExpressionType>::operator-(const Scalar& scalar) const
|
||||
{
|
||||
return *this + (-scalar);
|
||||
}
|
||||
@ -412,8 +565,8 @@ Cwise<ExpressionType,StorageBase>::operator-(const Scalar& scalar) const
|
||||
* \sa operator+=(), operator-()
|
||||
*/
|
||||
|
||||
template<typename ExpressionType,template <typename> class StorageBase>
|
||||
inline ExpressionType& Cwise<ExpressionType,StorageBase>::operator-=(const Scalar& scalar)
|
||||
template<typename ExpressionType>
|
||||
inline ExpressionType& Cwise<ExpressionType>::operator-=(const Scalar& scalar)
|
||||
{
|
||||
return m_matrix.const_cast_derived() = *this - scalar;
|
||||
}
|
0
Eigen/src/Eigen2Support/Lazy.h
Normal file
0
Eigen/src/Eigen2Support/Lazy.h
Normal file
0
Eigen/src/Eigen2Support/TriangularSolver.h
Normal file
0
Eigen/src/Eigen2Support/TriangularSolver.h
Normal file
@ -133,7 +133,7 @@ void ComplexEigenSolver<MatrixType>::compute(const MatrixType& matrix)
|
||||
for (int i=0; i<n; i++)
|
||||
{
|
||||
int k;
|
||||
m_eivalues.cwise().abs().end(n-i).minCoeff(&k);
|
||||
m_eivalues.cwiseAbs().end(n-i).minCoeff(&k);
|
||||
if (k != 0)
|
||||
{
|
||||
k += i;
|
||||
|
@ -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)
|
||||
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;
|
||||
|
||||
c = t.determinant();
|
||||
|
@ -225,7 +225,7 @@ void EigenSolver<MatrixType>::orthes(MatrixType& matH, RealVectorType& ort)
|
||||
for (int m = low+1; m <= high-1; ++m)
|
||||
{
|
||||
// Scale column.
|
||||
RealScalar scale = matH.block(m, m-1, high-m+1, 1).cwise().abs().sum();
|
||||
RealScalar scale = matH.block(m, m-1, high-m+1, 1).cwiseAbs().sum();
|
||||
if (scale != 0.0)
|
||||
{
|
||||
// Compute Householder transformation.
|
||||
@ -312,7 +312,7 @@ void EigenSolver<MatrixType>::hqr2(MatrixType& matH)
|
||||
|
||||
// Store roots isolated by balanc and compute matrix norm
|
||||
// FIXME to be efficient the following would requires a triangular reduxion code
|
||||
// Scalar norm = matH.upper().cwise().abs().sum() + matH.corner(BottomLeft,n,n).diagonal().cwise().abs().sum();
|
||||
// Scalar norm = matH.upper().cwiseAbs().sum() + matH.corner(BottomLeft,n,n).diagonal().cwiseAbs().sum();
|
||||
Scalar norm = 0.0;
|
||||
for (int j = 0; j < nn; ++j)
|
||||
{
|
||||
@ -321,7 +321,7 @@ void EigenSolver<MatrixType>::hqr2(MatrixType& matH)
|
||||
{
|
||||
m_eivalues.coeffRef(j) = Complex(matH.coeff(j,j), 0.0);
|
||||
}
|
||||
norm += matH.row(j).segment(std::max(j-1,0), nn-std::max(j-1,0)).cwise().abs().sum();
|
||||
norm += matH.row(j).segment(std::max(j-1,0), nn-std::max(j-1,0)).cwiseAbs().sum();
|
||||
}
|
||||
|
||||
// Outer loop over eigenvalue index
|
||||
|
@ -112,7 +112,7 @@ template<typename _MatrixType> class SelfAdjointEigenSolver
|
||||
*/
|
||||
MatrixType operatorSqrt() const
|
||||
{
|
||||
return m_eivec * m_eivalues.cwise().sqrt().asDiagonal() * m_eivec.adjoint();
|
||||
return m_eivec * m_eivalues.cwiseSqrt().asDiagonal() * m_eivec.adjoint();
|
||||
}
|
||||
|
||||
/** \returns the positive inverse square root of the matrix
|
||||
@ -121,7 +121,7 @@ template<typename _MatrixType> class SelfAdjointEigenSolver
|
||||
*/
|
||||
MatrixType operatorInverseSqrt() const
|
||||
{
|
||||
return m_eivec * m_eivalues.cwise().inverse().cwise().sqrt().asDiagonal() * m_eivec.adjoint();
|
||||
return m_eivec * m_eivalues.cwiseInverse().cwiseSqrt().asDiagonal() * m_eivec.adjoint();
|
||||
}
|
||||
|
||||
|
||||
@ -287,7 +287,7 @@ struct ei_operatorNorm_selector
|
||||
{
|
||||
// FIXME if it is really guaranteed that the eigenvalues are already sorted,
|
||||
// then we don't need to compute a maxCoeff() here, comparing the 1st and last ones is enough.
|
||||
return m.eigenvalues().cwise().abs().maxCoeff();
|
||||
return m.eigenvalues().cwiseAbs().maxCoeff();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -67,7 +67,7 @@ EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_AmbientDim)
|
||||
inline int dim() const { return AmbientDimAtCompileTime==Dynamic ? m_min.size()-1 : AmbientDimAtCompileTime; }
|
||||
|
||||
/** \returns true if the box is null, i.e, empty. */
|
||||
inline bool isNull() const { return (m_min.cwise() > m_max).any(); }
|
||||
inline bool isNull() const { return (m_min.array() > m_max).any(); }
|
||||
|
||||
/** Makes \c *this a null/empty box. */
|
||||
inline void setNull()
|
||||
@ -90,31 +90,31 @@ EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_AmbientDim)
|
||||
|
||||
/** \returns true if the point \a p is inside the box \c *this. */
|
||||
inline bool contains(const VectorType& p) const
|
||||
{ return (m_min.cwise()<=p).all() && (p.cwise()<=m_max).all(); }
|
||||
{ return (m_min.array()<=p).all() && (p.array()<=m_max).all(); }
|
||||
|
||||
/** \returns true if the box \a b is entirely inside the box \c *this. */
|
||||
inline bool contains(const AlignedBox& b) const
|
||||
{ return (m_min.cwise()<=b.min()).all() && (b.max().cwise()<=m_max).all(); }
|
||||
{ return (m_min.array()<=b.min()).all() && (b.max().array()<=m_max).all(); }
|
||||
|
||||
/** Extends \c *this such that it contains the point \a p and returns a reference to \c *this. */
|
||||
inline AlignedBox& extend(const VectorType& p)
|
||||
{ m_min = m_min.cwise().min(p); m_max = m_max.cwise().max(p); return *this; }
|
||||
{ m_min = m_min.cwiseMin(p); m_max = m_max.cwiseMax(p); return *this; }
|
||||
|
||||
/** Extends \c *this such that it contains the box \a b and returns a reference to \c *this. */
|
||||
inline AlignedBox& extend(const AlignedBox& b)
|
||||
{ m_min = m_min.cwise().min(b.m_min); m_max = m_max.cwise().max(b.m_max); return *this; }
|
||||
{ m_min = m_min.cwiseMin(b.m_min); m_max = m_max.cwiseMax(b.m_max); return *this; }
|
||||
|
||||
/** Clamps \c *this by the box \a b and returns a reference to \c *this. */
|
||||
inline AlignedBox& clamp(const AlignedBox& b)
|
||||
{ m_min = m_min.cwise().max(b.m_min); m_max = m_max.cwise().min(b.m_max); return *this; }
|
||||
{ m_min = m_min.cwiseMax(b.m_min); m_max = m_max.cwiseMin(b.m_max); return *this; }
|
||||
|
||||
/** Returns an AlignedBox that is the intersection of \a b and \c *this */
|
||||
inline AlignedBox intersection(const AlignedBox &b) const
|
||||
{ return AlignedBox(m_min.cwise().max(b.m_min), m_max.cwise().min(b.m_max)); }
|
||||
{ return AlignedBox(m_min.cwiseMax(b.m_min), m_max.cwiseMin(b.m_max)); }
|
||||
|
||||
/** Returns an AlignedBox that is the union of \a b and \c *this */
|
||||
inline AlignedBox merged(const AlignedBox &b) const
|
||||
{ return AlignedBox(m_min.cwise().min(b.m_min), m_max.cwise().max(b.m_max)); }
|
||||
{ return AlignedBox(m_min.cwiseMin(b.m_min), m_max.cwiseMax(b.m_max)); }
|
||||
|
||||
/** Translate \c *this by the vector \a t and returns a reference to \c *this. */
|
||||
inline AlignedBox& translate(const VectorType& t)
|
||||
|
@ -213,7 +213,7 @@ AngleAxis<Scalar>::toRotationMatrix(void) const
|
||||
res.coeffRef(1,2) = tmp - sin_axis.x();
|
||||
res.coeffRef(2,1) = tmp + sin_axis.x();
|
||||
|
||||
res.diagonal() = (cos1_axis.cwise() * m_axis).cwise() + c;
|
||||
res.diagonal() = (cos1_axis.cwiseProduct(m_axis)).array() + c;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -194,7 +194,7 @@ VectorwiseOp<ExpressionType,Direction>::hnormalized() const
|
||||
return HNormalized_Block(_expression(),0,0,
|
||||
Direction==Vertical ? _expression().rows()-1 : _expression().rows(),
|
||||
Direction==Horizontal ? _expression().cols()-1 : _expression().cols()).nestByValue()
|
||||
.cwise()/
|
||||
.cwiseQuotient(
|
||||
Replicate<NestByValue<HNormalized_Factors>,
|
||||
Direction==Vertical ? HNormalized_SizeMinusOne : 1,
|
||||
Direction==Horizontal ? HNormalized_SizeMinusOne : 1>
|
||||
@ -204,7 +204,7 @@ VectorwiseOp<ExpressionType,Direction>::hnormalized() const
|
||||
Direction==Vertical ? 1 : _expression().rows(),
|
||||
Direction==Horizontal ? 1 : _expression().cols()).nestByValue(),
|
||||
Direction==Vertical ? _expression().rows()-1 : 1,
|
||||
Direction==Horizontal ? _expression().cols()-1 : 1).nestByValue();
|
||||
Direction==Horizontal ? _expression().cols()-1 : 1).nestByValue());
|
||||
}
|
||||
|
||||
template<typename MatrixType,typename Lhs>
|
||||
|
@ -142,7 +142,7 @@ struct ei_unitOrthogonal_selector
|
||||
VectorType perp = VectorType::Zero(src.size());
|
||||
int maxi = 0;
|
||||
int sndi = 0;
|
||||
src.cwise().abs().maxCoeff(&maxi);
|
||||
src.cwiseAbs().maxCoeff(&maxi);
|
||||
if (maxi==0)
|
||||
sndi = 1;
|
||||
RealScalar invnm = RealScalar(1)/(Vector2() << src.coeff(sndi),src.coeff(maxi)).finished().norm();
|
||||
|
@ -89,7 +89,7 @@ template<typename _MatrixType> class FullPivLU
|
||||
* \returns a reference to *this
|
||||
*/
|
||||
FullPivLU& compute(const MatrixType& matrix);
|
||||
|
||||
|
||||
/** \returns the LU decomposition matrix: the upper-triangular part is U, the
|
||||
* unit-lower-triangular part is L (at least for square matrices; in the non-square
|
||||
* case, special care is needed, see the documentation of class FullPivLU).
|
||||
@ -101,7 +101,7 @@ template<typename _MatrixType> class FullPivLU
|
||||
ei_assert(m_isInitialized && "LU is not initialized.");
|
||||
return m_lu;
|
||||
}
|
||||
|
||||
|
||||
/** \returns the number of nonzero pivots in the LU decomposition.
|
||||
* Here nonzero is meant in the exact sense, not in a fuzzy sense.
|
||||
* So that notion isn't really intrinsically interesting, but it is
|
||||
@ -114,12 +114,12 @@ template<typename _MatrixType> class FullPivLU
|
||||
ei_assert(m_isInitialized && "LU is not initialized.");
|
||||
return m_nonzero_pivots;
|
||||
}
|
||||
|
||||
|
||||
/** \returns the absolute value of the biggest pivot, i.e. the biggest
|
||||
* diagonal coefficient of U.
|
||||
*/
|
||||
RealScalar maxPivot() const { return m_maxpivot; }
|
||||
|
||||
|
||||
/** \returns a vector of integers, whose size is the number of rows of the matrix being decomposed,
|
||||
* representing the P permutation i.e. the permutation of the rows. For its precise meaning,
|
||||
* see the examples given in the documentation of class FullPivLU.
|
||||
@ -255,7 +255,7 @@ template<typename _MatrixType> class FullPivLU
|
||||
m_usePrescribedThreshold = true;
|
||||
m_prescribedThreshold = threshold;
|
||||
}
|
||||
|
||||
|
||||
/** Allows to come back to the default behavior, letting Eigen use its default formula for
|
||||
* determining the threshold.
|
||||
*
|
||||
@ -268,7 +268,7 @@ template<typename _MatrixType> class FullPivLU
|
||||
{
|
||||
m_usePrescribedThreshold = false;
|
||||
}
|
||||
|
||||
|
||||
/** Returns the threshold that will be used by certain methods such as rank().
|
||||
*
|
||||
* See the documentation of setThreshold(const RealScalar&).
|
||||
@ -281,7 +281,7 @@ template<typename _MatrixType> class FullPivLU
|
||||
// and turns out to be identical to Higham's formula used already in LDLt.
|
||||
: epsilon<Scalar>() * m_lu.diagonalSize();
|
||||
}
|
||||
|
||||
|
||||
/** \returns the rank of the matrix of which *this is the LU decomposition.
|
||||
*
|
||||
* \note This method has to determine which pivots should be considered nonzero.
|
||||
@ -297,7 +297,7 @@ template<typename _MatrixType> class FullPivLU
|
||||
result += (ei_abs(m_lu.coeff(i,i)) > premultiplied_threshold);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/** \returns the dimension of the kernel of the matrix of which *this is the LU decomposition.
|
||||
*
|
||||
* \note This method has to determine which pivots should be considered nonzero.
|
||||
@ -365,7 +365,7 @@ template<typename _MatrixType> class FullPivLU
|
||||
|
||||
inline int rows() const { return m_lu.rows(); }
|
||||
inline int cols() const { return m_lu.cols(); }
|
||||
|
||||
|
||||
protected:
|
||||
MatrixType m_lu;
|
||||
IntColVectorType m_p;
|
||||
@ -416,7 +416,7 @@ FullPivLU<MatrixType>& FullPivLU<MatrixType>::compute(const MatrixType& matrix)
|
||||
int row_of_biggest_in_corner, col_of_biggest_in_corner;
|
||||
RealScalar biggest_in_corner;
|
||||
biggest_in_corner = m_lu.corner(Eigen::BottomRight, rows-k, cols-k)
|
||||
.cwise().abs()
|
||||
.cwiseAbs()
|
||||
.maxCoeff(&row_of_biggest_in_corner, &col_of_biggest_in_corner);
|
||||
row_of_biggest_in_corner += k; // correct the values! since they were computed in the corner,
|
||||
col_of_biggest_in_corner += k; // need to add k to them.
|
||||
@ -453,7 +453,7 @@ FullPivLU<MatrixType>& FullPivLU<MatrixType>::compute(const MatrixType& matrix)
|
||||
|
||||
// Now that the pivot is at the right location, we update the remaining
|
||||
// bottom-right corner by Gaussian elimination.
|
||||
|
||||
|
||||
if(k<rows-1)
|
||||
m_lu.col(k).end(rows-k-1) /= m_lu.coeff(k,k);
|
||||
if(k<size-1)
|
||||
@ -507,7 +507,7 @@ struct ei_kernel_retval<FullPivLU<_MatrixType> >
|
||||
dst.setZero();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* Let us use the following lemma:
|
||||
*
|
||||
* Lemma: If the matrix A has the LU decomposition PAQ = LU,
|
||||
@ -575,7 +575,7 @@ struct ei_image_retval<FullPivLU<_MatrixType> >
|
||||
: ei_image_retval_base<FullPivLU<_MatrixType> >
|
||||
{
|
||||
EIGEN_MAKE_IMAGE_HELPERS(FullPivLU<_MatrixType>)
|
||||
|
||||
|
||||
enum { MaxSmallDimAtCompileTime = EIGEN_ENUM_MIN(
|
||||
MatrixType::MaxColsAtCompileTime,
|
||||
MatrixType::MaxRowsAtCompileTime)
|
||||
@ -591,7 +591,7 @@ struct ei_image_retval<FullPivLU<_MatrixType> >
|
||||
dst.setZero();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Matrix<int, Dynamic, 1, 0, MaxSmallDimAtCompileTime, 1> pivots(rank());
|
||||
RealScalar premultiplied_threshold = dec().maxPivot() * dec().threshold();
|
||||
int p = 0;
|
||||
@ -599,7 +599,7 @@ struct ei_image_retval<FullPivLU<_MatrixType> >
|
||||
if(ei_abs(dec().matrixLU().coeff(i,i)) > premultiplied_threshold)
|
||||
pivots.coeffRef(p++) = i;
|
||||
ei_internal_assert(p == rank());
|
||||
|
||||
|
||||
for(int i = 0; i < rank(); ++i)
|
||||
dst.col(i) = originalMatrix().col(dec().permutationQ().coeff(pivots.coeff(i)));
|
||||
}
|
||||
@ -612,7 +612,7 @@ struct ei_solve_retval<FullPivLU<_MatrixType>, Rhs>
|
||||
: ei_solve_retval_base<FullPivLU<_MatrixType>, Rhs>
|
||||
{
|
||||
EIGEN_MAKE_SOLVE_HELPERS(FullPivLU<_MatrixType>,Rhs)
|
||||
|
||||
|
||||
template<typename Dest> void evalTo(Dest& dst) const
|
||||
{
|
||||
/* The decomposition PAQ = LU can be rewritten as A = P^{-1} L U Q^{-1}.
|
||||
|
@ -148,7 +148,7 @@ struct ei_compute_inverse<MatrixType, ResultType, 3>
|
||||
cofactors_col0.coeffRef(0) = matrix.minor(0,0).determinant();
|
||||
cofactors_col0.coeffRef(1) = -matrix.minor(1,0).determinant();
|
||||
cofactors_col0.coeffRef(2) = matrix.minor(2,0).determinant();
|
||||
const Scalar det = (cofactors_col0.cwise()*matrix.col(0)).sum();
|
||||
const Scalar det = (cofactors_col0.cwiseProduct(matrix.col(0))).sum();
|
||||
const Scalar invdet = Scalar(1) / det;
|
||||
ei_compute_inverse_size3_helper(matrix, invdet, cofactors_col0, result);
|
||||
}
|
||||
@ -170,7 +170,7 @@ struct ei_compute_inverse_and_det_with_check<MatrixType, ResultType, 3>
|
||||
cofactors_col0.coeffRef(0) = matrix.minor(0,0).determinant();
|
||||
cofactors_col0.coeffRef(1) = -matrix.minor(1,0).determinant();
|
||||
cofactors_col0.coeffRef(2) = matrix.minor(2,0).determinant();
|
||||
determinant = (cofactors_col0.cwise()*matrix.col(0)).sum();
|
||||
determinant = (cofactors_col0.cwiseProduct(matrix.col(0))).sum();
|
||||
invertible = ei_abs(determinant) > absDeterminantThreshold;
|
||||
if(!invertible) return;
|
||||
const Scalar invdet = Scalar(1) / determinant;
|
||||
@ -256,7 +256,7 @@ struct ei_compute_inverse<MatrixType, ResultType, 4>
|
||||
|
||||
// now good_row0 and good_row1 are correctly set
|
||||
good:
|
||||
|
||||
|
||||
// do row permutations to move this 2x2 block to the top
|
||||
matrix.row(0).swap(matrix.row(good_row0));
|
||||
matrix.row(1).swap(matrix.row(good_row1));
|
||||
|
@ -233,7 +233,7 @@ struct ei_partial_lu_impl
|
||||
{
|
||||
int row_of_biggest_in_col;
|
||||
RealScalar biggest_in_corner
|
||||
= lu.col(k).end(rows-k).cwise().abs().maxCoeff(&row_of_biggest_in_col);
|
||||
= lu.col(k).end(rows-k).cwiseAbs().maxCoeff(&row_of_biggest_in_col);
|
||||
row_of_biggest_in_col += k;
|
||||
|
||||
if(biggest_in_corner == 0) // the pivot is exactly zero: the matrix is singular
|
||||
@ -412,7 +412,7 @@ struct ei_solve_retval<PartialPivLU<_MatrixType>, Rhs>
|
||||
: ei_solve_retval_base<PartialPivLU<_MatrixType>, Rhs>
|
||||
{
|
||||
EIGEN_MAKE_SOLVE_HELPERS(PartialPivLU<_MatrixType>,Rhs)
|
||||
|
||||
|
||||
template<typename Dest> void evalTo(Dest& dst) const
|
||||
{
|
||||
/* The decomposition PA = LU can be rewritten as A = P^{-1} L U.
|
||||
@ -421,7 +421,7 @@ struct ei_solve_retval<PartialPivLU<_MatrixType>, Rhs>
|
||||
* Step 2: replace c by the solution x to Lx = c.
|
||||
* Step 3: replace c by the solution x to Ux = c.
|
||||
*/
|
||||
|
||||
|
||||
const int size = dec().matrixLU().rows();
|
||||
ei_assert(rhs().rows() == size);
|
||||
|
||||
|
@ -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
|
||||
***************************************************************************/
|
||||
|
||||
template<typename Derived>
|
||||
template<typename OtherDerived>
|
||||
EIGEN_STRONG_INLINE const CwiseBinaryOp<ei_scalar_difference_op<typename ei_traits<Derived>::Scalar>,
|
||||
Derived, OtherDerived>
|
||||
SparseMatrixBase<Derived>::operator-(const SparseMatrixBase<OtherDerived> &other) const
|
||||
{
|
||||
return CwiseBinaryOp<ei_scalar_difference_op<Scalar>,
|
||||
Derived, OtherDerived>(derived(), other.derived());
|
||||
}
|
||||
// template<typename Derived>
|
||||
// template<typename OtherDerived>
|
||||
// EIGEN_STRONG_INLINE const CwiseBinaryOp<ei_scalar_difference_op<typename ei_traits<Derived>::Scalar>,
|
||||
// Derived, OtherDerived>
|
||||
// SparseMatrixBase<Derived>::operator-(const SparseMatrixBase<OtherDerived> &other) const
|
||||
// {
|
||||
// return CwiseBinaryOp<ei_scalar_difference_op<Scalar>,
|
||||
// Derived, OtherDerived>(derived(), other.derived());
|
||||
// }
|
||||
|
||||
template<typename Derived>
|
||||
template<typename OtherDerived>
|
||||
@ -301,13 +301,13 @@ SparseMatrixBase<Derived>::operator-=(const SparseMatrixBase<OtherDerived> &othe
|
||||
return *this = derived() - other.derived();
|
||||
}
|
||||
|
||||
template<typename Derived>
|
||||
template<typename 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
|
||||
{
|
||||
return CwiseBinaryOp<ei_scalar_sum_op<Scalar>, Derived, OtherDerived>(derived(), other.derived());
|
||||
}
|
||||
// template<typename Derived>
|
||||
// template<typename 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
|
||||
// {
|
||||
// return CwiseBinaryOp<ei_scalar_sum_op<Scalar>, Derived, OtherDerived>(derived(), other.derived());
|
||||
// }
|
||||
|
||||
template<typename Derived>
|
||||
template<typename OtherDerived>
|
||||
|
@ -111,6 +111,7 @@ template<typename Derived> class SparseMatrixBase : public AnyMatrixBase<Derived
|
||||
|
||||
#define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::SparseMatrixBase
|
||||
#include "../Core/CwiseUnaryOps.h"
|
||||
#include "../Core/CwiseBinaryOps.h"
|
||||
#undef EIGEN_CURRENT_STORAGE_BASE_CLASS
|
||||
|
||||
#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;
|
||||
|
||||
template<typename OtherDerived>
|
||||
const CwiseBinaryOp<ei_scalar_sum_op<typename ei_traits<Derived>::Scalar>, Derived, OtherDerived>
|
||||
operator+(const SparseMatrixBase<OtherDerived> &other) const;
|
||||
// template<typename OtherDerived>
|
||||
// const CwiseBinaryOp<ei_scalar_sum_op<typename ei_traits<Derived>::Scalar>, Derived, OtherDerived>
|
||||
// operator+(const SparseMatrixBase<OtherDerived> &other) const;
|
||||
|
||||
template<typename OtherDerived>
|
||||
const CwiseBinaryOp<ei_scalar_difference_op<typename ei_traits<Derived>::Scalar>, Derived, OtherDerived>
|
||||
operator-(const SparseMatrixBase<OtherDerived> &other) const;
|
||||
// template<typename OtherDerived>
|
||||
// const CwiseBinaryOp<ei_scalar_difference_op<typename ei_traits<Derived>::Scalar>, Derived, OtherDerived>
|
||||
// operator-(const SparseMatrixBase<OtherDerived> &other) const;
|
||||
|
||||
template<typename OtherDerived>
|
||||
Derived& operator+=(const SparseMatrixBase<OtherDerived>& other);
|
||||
|
@ -22,6 +22,7 @@
|
||||
// License and a copy of the GNU General Public License along with
|
||||
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#define EIGEN2_SUPPORT
|
||||
#include "main.h"
|
||||
#include <Eigen/Array>
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
// License and a copy of the GNU General Public License along with
|
||||
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#define EIGEN2_SUPPORT
|
||||
#include "main.h"
|
||||
#include <functional>
|
||||
#include <Eigen/Array>
|
||||
@ -60,9 +61,9 @@ template<typename MatrixType> void cwiseops(const MatrixType& m)
|
||||
|
||||
int r = ei_random<int>(0, rows-1),
|
||||
c = ei_random<int>(0, cols-1);
|
||||
|
||||
|
||||
Scalar s1 = ei_random<Scalar>();
|
||||
|
||||
|
||||
// test Zero, Ones, Constant, and the set* variants
|
||||
m3 = MatrixType::Constant(rows, cols, s1);
|
||||
for (int j=0; j<cols; ++j)
|
||||
@ -84,7 +85,7 @@ template<typename MatrixType> void cwiseops(const MatrixType& m)
|
||||
VERIFY_IS_APPROX(m4.setOnes(rows,cols), mones);
|
||||
m4.fill(s1);
|
||||
VERIFY_IS_APPROX(m4, m3);
|
||||
|
||||
|
||||
VERIFY_IS_APPROX(v3.setConstant(rows, s1), VectorType::Constant(rows,s1));
|
||||
VERIFY_IS_APPROX(v3.setZero(rows), vzero);
|
||||
VERIFY_IS_APPROX(v3.setOnes(rows), vones);
|
||||
@ -107,7 +108,7 @@ template<typename MatrixType> void cwiseops(const MatrixType& m)
|
||||
m3 = m1;
|
||||
m3.cwise() *= m2;
|
||||
VERIFY_IS_APPROX(m3, m1.cwise() * m2);
|
||||
|
||||
|
||||
VERIFY_IS_APPROX(mones, m2.cwise()/m2);
|
||||
if(NumTraits<Scalar>::HasFloatingPoint)
|
||||
{
|
||||
@ -122,7 +123,7 @@ template<typename MatrixType> void cwiseops(const MatrixType& m)
|
||||
VERIFY_IS_APPROX(m3.cwise().pow(-1), m3.cwise().inverse());
|
||||
m3 = m1.cwise().abs();
|
||||
VERIFY_IS_APPROX(m3.cwise().pow(RealScalar(0.5)), m3.cwise().sqrt());
|
||||
|
||||
|
||||
// VERIFY_IS_APPROX(m1.cwise().tan(), m1.cwise().sin().cwise() / m1.cwise().cos());
|
||||
VERIFY_IS_APPROX(mones, m1.cwise().sin().cwise().square() + m1.cwise().cos().cwise().square());
|
||||
m3 = m1;
|
||||
@ -139,7 +140,7 @@ template<typename MatrixType> void cwiseops(const MatrixType& m)
|
||||
VERIFY_IS_APPROX( m1.cwise().max(m2), m2.cwise().max(m1) );
|
||||
VERIFY_IS_APPROX( m1.cwise().max(m1-mones), m1 );
|
||||
VERIFY_IS_APPROX( m1.cwise().max(m1+mones), m1+mones );
|
||||
|
||||
|
||||
VERIFY( (m1.cwise() == m1).all() );
|
||||
VERIFY( (m1.cwise() != m2).any() );
|
||||
VERIFY(!(m1.cwise() == (m1+mones)).any() );
|
||||
|
@ -52,7 +52,7 @@ template<typename MatrixType> void eigensolver(const MatrixType& m)
|
||||
// Regression test for issue #66
|
||||
MatrixType z = MatrixType::Zero(rows,cols);
|
||||
ComplexEigenSolver<MatrixType> eiz(z);
|
||||
VERIFY((eiz.eigenvalues().cwise()==0).all());
|
||||
VERIFY((eiz.eigenvalues().cwiseEqual(0)).all());
|
||||
}
|
||||
|
||||
void test_eigensolver_complex()
|
||||
|
@ -79,7 +79,7 @@ template<typename MatrixType> void selfadjointeigensolver(const MatrixType& m)
|
||||
|
||||
// compare with eigen
|
||||
VERIFY_IS_APPROX(_eval, eiSymm.eigenvalues());
|
||||
VERIFY_IS_APPROX(_evec.cwise().abs(), eiSymm.eigenvectors().cwise().abs());
|
||||
VERIFY_IS_APPROX(_evec.cwiseAbs(), eiSymm.eigenvectors().cwiseAbs());
|
||||
|
||||
// generalized pb
|
||||
Gsl::eigen_symm_gen(gSymmA, gSymmB, gEval, gEvec);
|
||||
@ -92,7 +92,7 @@ template<typename MatrixType> void selfadjointeigensolver(const MatrixType& m)
|
||||
// std::cerr << _eval.transpose() << "\n" << eiSymmGen.eigenvalues().transpose() << "\n\n";
|
||||
// std::cerr << _evec.format(6) << "\n\n" << eiSymmGen.eigenvectors().format(6) << "\n\n\n";
|
||||
VERIFY_IS_APPROX(_eval, eiSymmGen.eigenvalues());
|
||||
VERIFY_IS_APPROX(_evec.cwise().abs(), eiSymmGen.eigenvectors().cwise().abs());
|
||||
VERIFY_IS_APPROX(_evec.cwiseAbs(), eiSymmGen.eigenvectors().cwiseAbs());
|
||||
|
||||
Gsl::free(gSymmA);
|
||||
Gsl::free(gSymmB);
|
||||
|
@ -22,6 +22,7 @@
|
||||
// License and a copy of the GNU General Public License along with
|
||||
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#define EIGEN2_SUPPORT
|
||||
#include "main.h"
|
||||
#include <Eigen/Geometry>
|
||||
#include <Eigen/LU>
|
||||
|
@ -22,6 +22,7 @@
|
||||
// License and a copy of the GNU General Public License along with
|
||||
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#define EIGEN2_SUPPORT
|
||||
#include "main.h"
|
||||
#include <Eigen/Geometry>
|
||||
#include <Eigen/LU>
|
||||
|
@ -22,6 +22,7 @@
|
||||
// License and a copy of the GNU General Public License along with
|
||||
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#define EIGEN2_SUPPORT
|
||||
#include "main.h"
|
||||
#include <Eigen/Geometry>
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
// License and a copy of the GNU General Public License along with
|
||||
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#define EIGEN2_SUPPORT
|
||||
#include "main.h"
|
||||
#include <Eigen/Geometry>
|
||||
#include <Eigen/LU>
|
||||
|
@ -22,6 +22,7 @@
|
||||
// License and a copy of the GNU General Public License along with
|
||||
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#define EIGEN2_SUPPORT
|
||||
#include "main.h"
|
||||
#include <Eigen/Geometry>
|
||||
#include <Eigen/LU>
|
||||
|
@ -23,6 +23,7 @@
|
||||
// License and a copy of the GNU General Public License along with
|
||||
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#define EIGEN2_SUPPORT
|
||||
#include "main.h"
|
||||
#include <Eigen/Geometry>
|
||||
#include <Eigen/LU>
|
||||
|
@ -23,6 +23,7 @@
|
||||
// License and a copy of the GNU General Public License along with
|
||||
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#define EIGEN2_SUPPORT
|
||||
#include "main.h"
|
||||
#include <Eigen/Geometry>
|
||||
#include <Eigen/LU>
|
||||
|
@ -22,6 +22,7 @@
|
||||
// License and a copy of the GNU General Public License along with
|
||||
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#define EIGEN2_SUPPORT
|
||||
#include "main.h"
|
||||
#include <Eigen/Geometry>
|
||||
#include <Eigen/LU>
|
||||
@ -109,7 +110,7 @@ template<typename Scalar, int Mode> void transformations(void)
|
||||
t0.matrix().setZero();
|
||||
t0 = Transform3::Identity();
|
||||
VERIFY_IS_APPROX(t0.matrix(), Transform3::MatrixType::Identity());
|
||||
|
||||
|
||||
t0.linear() = q1.toRotationMatrix();
|
||||
t1.setIdentity();
|
||||
t1.linear() = q1.toRotationMatrix();
|
||||
@ -351,7 +352,7 @@ template<typename Scalar, int Mode> void transformations(void)
|
||||
VERIFY_IS_APPROX(r2d1f.template cast<Scalar>(),r2d1);
|
||||
Rotation2D<double> r2d1d = r2d1.template cast<double>();
|
||||
VERIFY_IS_APPROX(r2d1d.template cast<Scalar>(),r2d1);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void test_geo_transformations()
|
||||
|
Loading…
x
Reference in New Issue
Block a user