mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Fix bug #314:
- remove most of the metaprogramming kung fu in MathFunctions.h (only keep functions that differs from the std) - remove the overloads for array expression that were in the std namespace
This commit is contained in:
@@ -248,6 +248,7 @@ template<> struct ldlt_inplace<Lower>
|
||||
template<typename MatrixType, typename TranspositionType, typename Workspace>
|
||||
static bool unblocked(MatrixType& mat, TranspositionType& transpositions, Workspace& temp, int* sign=0)
|
||||
{
|
||||
using std::abs;
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
typedef typename MatrixType::RealScalar RealScalar;
|
||||
typedef typename MatrixType::Index Index;
|
||||
|
||||
@@ -190,6 +190,7 @@ template<typename Scalar, int UpLo> struct llt_inplace;
|
||||
template<typename MatrixType, typename VectorType>
|
||||
static typename MatrixType::Index llt_rank_update_lower(MatrixType& mat, const VectorType& vec, const typename MatrixType::RealScalar& sigma)
|
||||
{
|
||||
using std::sqrt;
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
typedef typename MatrixType::RealScalar RealScalar;
|
||||
typedef typename MatrixType::Index Index;
|
||||
@@ -263,6 +264,7 @@ template<typename Scalar> struct llt_inplace<Scalar, Lower>
|
||||
template<typename MatrixType>
|
||||
static typename MatrixType::Index unblocked(MatrixType& mat)
|
||||
{
|
||||
using std::sqrt;
|
||||
typedef typename MatrixType::Index Index;
|
||||
|
||||
eigen_assert(mat.rows()==mat.cols());
|
||||
|
||||
@@ -286,11 +286,12 @@ MatrixBase<Derived>::asDiagonal() const
|
||||
template<typename Derived>
|
||||
bool MatrixBase<Derived>::isDiagonal(const RealScalar& prec) const
|
||||
{
|
||||
using std::abs;
|
||||
if(cols() != rows()) return false;
|
||||
RealScalar maxAbsOnDiagonal = static_cast<RealScalar>(-1);
|
||||
for(Index j = 0; j < cols(); ++j)
|
||||
{
|
||||
RealScalar absOnDiagonal = internal::abs(coeff(j,j));
|
||||
RealScalar absOnDiagonal = abs(coeff(j,j));
|
||||
if(absOnDiagonal > maxAbsOnDiagonal) maxAbsOnDiagonal = absOnDiagonal;
|
||||
}
|
||||
for(Index j = 0; j < cols(); ++j)
|
||||
|
||||
@@ -124,7 +124,8 @@ EIGEN_STRONG_INLINE typename NumTraits<typename internal::traits<Derived>::Scala
|
||||
template<typename Derived>
|
||||
inline typename NumTraits<typename internal::traits<Derived>::Scalar>::Real MatrixBase<Derived>::norm() const
|
||||
{
|
||||
return internal::sqrt(squaredNorm());
|
||||
using std::sqrt;
|
||||
return sqrt(squaredNorm());
|
||||
}
|
||||
|
||||
/** \returns an expression of the quotient of *this by its own norm.
|
||||
|
||||
@@ -287,7 +287,7 @@ struct functor_traits<scalar_opposite_op<Scalar> >
|
||||
template<typename Scalar> struct scalar_abs_op {
|
||||
EIGEN_EMPTY_STRUCT_CTOR(scalar_abs_op)
|
||||
typedef typename NumTraits<Scalar>::Real result_type;
|
||||
EIGEN_STRONG_INLINE const result_type operator() (const Scalar& a) const { return internal::abs(a); }
|
||||
EIGEN_STRONG_INLINE const result_type operator() (const Scalar& a) const { using std::abs; return abs(a); }
|
||||
template<typename Packet>
|
||||
EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a) const
|
||||
{ return internal::pabs(a); }
|
||||
@@ -325,7 +325,7 @@ struct functor_traits<scalar_abs2_op<Scalar> >
|
||||
*/
|
||||
template<typename Scalar> struct scalar_conjugate_op {
|
||||
EIGEN_EMPTY_STRUCT_CTOR(scalar_conjugate_op)
|
||||
EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a) const { return internal::conj(a); }
|
||||
EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a) const { using internal::conj; return conj(a); }
|
||||
template<typename Packet>
|
||||
EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a) const { return internal::pconj(a); }
|
||||
};
|
||||
@@ -421,7 +421,7 @@ struct functor_traits<scalar_imag_ref_op<Scalar> >
|
||||
*/
|
||||
template<typename Scalar> struct scalar_exp_op {
|
||||
EIGEN_EMPTY_STRUCT_CTOR(scalar_exp_op)
|
||||
inline const Scalar operator() (const Scalar& a) const { return internal::exp(a); }
|
||||
inline const Scalar operator() (const Scalar& a) const { using std::exp; return exp(a); }
|
||||
typedef typename packet_traits<Scalar>::type Packet;
|
||||
inline Packet packetOp(const Packet& a) const { return internal::pexp(a); }
|
||||
};
|
||||
@@ -437,7 +437,7 @@ struct functor_traits<scalar_exp_op<Scalar> >
|
||||
*/
|
||||
template<typename Scalar> struct scalar_log_op {
|
||||
EIGEN_EMPTY_STRUCT_CTOR(scalar_log_op)
|
||||
inline const Scalar operator() (const Scalar& a) const { return internal::log(a); }
|
||||
inline const Scalar operator() (const Scalar& a) const { using std::log; return log(a); }
|
||||
typedef typename packet_traits<Scalar>::type Packet;
|
||||
inline Packet packetOp(const Packet& a) const { return internal::plog(a); }
|
||||
};
|
||||
@@ -674,7 +674,7 @@ struct functor_traits<scalar_add_op<Scalar> >
|
||||
*/
|
||||
template<typename Scalar> struct scalar_sqrt_op {
|
||||
EIGEN_EMPTY_STRUCT_CTOR(scalar_sqrt_op)
|
||||
inline const Scalar operator() (const Scalar& a) const { return internal::sqrt(a); }
|
||||
inline const Scalar operator() (const Scalar& a) const { using std::sqrt; return sqrt(a); }
|
||||
typedef typename packet_traits<Scalar>::type Packet;
|
||||
inline Packet packetOp(const Packet& a) const { return internal::psqrt(a); }
|
||||
};
|
||||
@@ -692,7 +692,7 @@ struct functor_traits<scalar_sqrt_op<Scalar> >
|
||||
*/
|
||||
template<typename Scalar> struct scalar_cos_op {
|
||||
EIGEN_EMPTY_STRUCT_CTOR(scalar_cos_op)
|
||||
inline Scalar operator() (const Scalar& a) const { return internal::cos(a); }
|
||||
inline Scalar operator() (const Scalar& a) const { using std::cos; return cos(a); }
|
||||
typedef typename packet_traits<Scalar>::type Packet;
|
||||
inline Packet packetOp(const Packet& a) const { return internal::pcos(a); }
|
||||
};
|
||||
@@ -711,7 +711,7 @@ struct functor_traits<scalar_cos_op<Scalar> >
|
||||
*/
|
||||
template<typename Scalar> struct scalar_sin_op {
|
||||
EIGEN_EMPTY_STRUCT_CTOR(scalar_sin_op)
|
||||
inline const Scalar operator() (const Scalar& a) const { return internal::sin(a); }
|
||||
inline const Scalar operator() (const Scalar& a) const { using std::sin; return sin(a); }
|
||||
typedef typename packet_traits<Scalar>::type Packet;
|
||||
inline Packet packetOp(const Packet& a) const { return internal::psin(a); }
|
||||
};
|
||||
@@ -731,7 +731,7 @@ struct functor_traits<scalar_sin_op<Scalar> >
|
||||
*/
|
||||
template<typename Scalar> struct scalar_tan_op {
|
||||
EIGEN_EMPTY_STRUCT_CTOR(scalar_tan_op)
|
||||
inline const Scalar operator() (const Scalar& a) const { return internal::tan(a); }
|
||||
inline const Scalar operator() (const Scalar& a) const { using std::tan; return tan(a); }
|
||||
typedef typename packet_traits<Scalar>::type Packet;
|
||||
inline Packet packetOp(const Packet& a) const { return internal::ptan(a); }
|
||||
};
|
||||
@@ -750,7 +750,7 @@ struct functor_traits<scalar_tan_op<Scalar> >
|
||||
*/
|
||||
template<typename Scalar> struct scalar_acos_op {
|
||||
EIGEN_EMPTY_STRUCT_CTOR(scalar_acos_op)
|
||||
inline const Scalar operator() (const Scalar& a) const { return internal::acos(a); }
|
||||
inline const Scalar operator() (const Scalar& a) const { using std::acos; return acos(a); }
|
||||
typedef typename packet_traits<Scalar>::type Packet;
|
||||
inline Packet packetOp(const Packet& a) const { return internal::pacos(a); }
|
||||
};
|
||||
@@ -769,7 +769,7 @@ struct functor_traits<scalar_acos_op<Scalar> >
|
||||
*/
|
||||
template<typename Scalar> struct scalar_asin_op {
|
||||
EIGEN_EMPTY_STRUCT_CTOR(scalar_asin_op)
|
||||
inline const Scalar operator() (const Scalar& a) const { return internal::asin(a); }
|
||||
inline const Scalar operator() (const Scalar& a) const { using std::asin; return asin(a); }
|
||||
typedef typename packet_traits<Scalar>::type Packet;
|
||||
inline Packet packetOp(const Packet& a) const { return internal::pasin(a); }
|
||||
};
|
||||
|
||||
@@ -130,7 +130,7 @@ pmax(const Packet& a,
|
||||
|
||||
/** \internal \returns the absolute value of \a a */
|
||||
template<typename Packet> inline Packet
|
||||
pabs(const Packet& a) { return abs(a); }
|
||||
pabs(const Packet& a) { using std::abs; return abs(a); }
|
||||
|
||||
/** \internal \returns the bitwise and of \a a and \a b */
|
||||
template<typename Packet> inline Packet
|
||||
@@ -215,7 +215,12 @@ template<typename Packet> inline Packet preverse(const Packet& a)
|
||||
|
||||
/** \internal \returns \a a with real and imaginary part flipped (for complex type only) */
|
||||
template<typename Packet> inline Packet pcplxflip(const Packet& a)
|
||||
{ return Packet(imag(a),real(a)); }
|
||||
{
|
||||
// FIXME: uncomment the following in case we drop the internal imag and real functions.
|
||||
// using std::imag;
|
||||
// using std::real;
|
||||
return Packet(imag(a),real(a));
|
||||
}
|
||||
|
||||
/**************************
|
||||
* Special math functions
|
||||
@@ -223,35 +228,35 @@ template<typename Packet> inline Packet pcplxflip(const Packet& a)
|
||||
|
||||
/** \internal \returns the sine of \a a (coeff-wise) */
|
||||
template<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS
|
||||
Packet psin(const Packet& a) { return sin(a); }
|
||||
Packet psin(const Packet& a) { using std::sin; return sin(a); }
|
||||
|
||||
/** \internal \returns the cosine of \a a (coeff-wise) */
|
||||
template<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS
|
||||
Packet pcos(const Packet& a) { return cos(a); }
|
||||
Packet pcos(const Packet& a) { using std::cos; return cos(a); }
|
||||
|
||||
/** \internal \returns the tan of \a a (coeff-wise) */
|
||||
template<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS
|
||||
Packet ptan(const Packet& a) { return tan(a); }
|
||||
Packet ptan(const Packet& a) { using std::tan; return tan(a); }
|
||||
|
||||
/** \internal \returns the arc sine of \a a (coeff-wise) */
|
||||
template<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS
|
||||
Packet pasin(const Packet& a) { return asin(a); }
|
||||
Packet pasin(const Packet& a) { using std::asin; return asin(a); }
|
||||
|
||||
/** \internal \returns the arc cosine of \a a (coeff-wise) */
|
||||
template<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS
|
||||
Packet pacos(const Packet& a) { return acos(a); }
|
||||
Packet pacos(const Packet& a) { using std::acos; return acos(a); }
|
||||
|
||||
/** \internal \returns the exp of \a a (coeff-wise) */
|
||||
template<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS
|
||||
Packet pexp(const Packet& a) { return exp(a); }
|
||||
Packet pexp(const Packet& a) { using std::exp; return exp(a); }
|
||||
|
||||
/** \internal \returns the log of \a a (coeff-wise) */
|
||||
template<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS
|
||||
Packet plog(const Packet& a) { return log(a); }
|
||||
Packet plog(const Packet& a) { using std::log; return log(a); }
|
||||
|
||||
/** \internal \returns the square-root of \a a (coeff-wise) */
|
||||
template<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS
|
||||
Packet psqrt(const Packet& a) { return sqrt(a); }
|
||||
Packet psqrt(const Packet& a) { using std::sqrt; return sqrt(a); }
|
||||
|
||||
/***************************************************************************
|
||||
* The following functions might not have to be overwritten for vectorized types
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// This file is part of Eigen, a lightweight C++ template library
|
||||
// for linear algebra.
|
||||
//
|
||||
// Copyright (C) 2010 Gael Guennebaud <gael.guennebaud@inria.fr>
|
||||
// Copyright (C) 2010-2012 Gael Guennebaud <gael.guennebaud@inria.fr>
|
||||
// Copyright (C) 2010 Benoit Jacob <jacob.benoit.1@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla
|
||||
@@ -11,7 +11,7 @@
|
||||
#ifndef EIGEN_GLOBAL_FUNCTIONS_H
|
||||
#define EIGEN_GLOBAL_FUNCTIONS_H
|
||||
|
||||
#define EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(NAME,FUNCTOR) \
|
||||
#define EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(NAME,FUNCTOR) \
|
||||
template<typename Derived> \
|
||||
inline const Eigen::CwiseUnaryOp<Eigen::internal::FUNCTOR<typename Derived::Scalar>, const Derived> \
|
||||
NAME(const Eigen::ArrayBase<Derived>& x) { \
|
||||
@@ -35,20 +35,20 @@
|
||||
};
|
||||
|
||||
|
||||
namespace std
|
||||
namespace Eigen
|
||||
{
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(real,scalar_real_op)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(imag,scalar_imag_op)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(sin,scalar_sin_op)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(cos,scalar_cos_op)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(asin,scalar_asin_op)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(acos,scalar_acos_op)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(tan,scalar_tan_op)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(exp,scalar_exp_op)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(log,scalar_log_op)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(abs,scalar_abs_op)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(sqrt,scalar_sqrt_op)
|
||||
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(real,scalar_real_op)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(imag,scalar_imag_op)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(sin,scalar_sin_op)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(cos,scalar_cos_op)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(asin,scalar_asin_op)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(acos,scalar_acos_op)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(tan,scalar_tan_op)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(exp,scalar_exp_op)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(log,scalar_log_op)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(abs,scalar_abs_op)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(sqrt,scalar_sqrt_op)
|
||||
|
||||
template<typename Derived>
|
||||
inline const Eigen::CwiseUnaryOp<Eigen::internal::scalar_pow_op<typename Derived::Scalar>, const Derived>
|
||||
pow(const Eigen::ArrayBase<Derived>& x, const typename Derived::Scalar& exponent) {
|
||||
@@ -64,10 +64,7 @@ namespace std
|
||||
exponents.derived()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
namespace Eigen
|
||||
{
|
||||
|
||||
/**
|
||||
* \brief Component-wise division of a scalar by array elements.
|
||||
**/
|
||||
@@ -85,16 +82,7 @@ namespace Eigen
|
||||
{
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(real,scalar_real_op)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(imag,scalar_imag_op)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(sin,scalar_sin_op)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(cos,scalar_cos_op)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(asin,scalar_asin_op)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(acos,scalar_acos_op)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(tan,scalar_tan_op)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(exp,scalar_exp_op)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(log,scalar_log_op)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(abs,scalar_abs_op)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(abs2,scalar_abs2_op)
|
||||
EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(sqrt,scalar_sqrt_op)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -250,33 +250,6 @@ inline EIGEN_MATHFUNC_RETVAL(conj, Scalar) conj(const Scalar& x)
|
||||
return EIGEN_MATHFUNC_IMPL(conj, Scalar)::run(x);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation of abs *
|
||||
****************************************************************************/
|
||||
|
||||
template<typename Scalar>
|
||||
struct abs_impl
|
||||
{
|
||||
typedef typename NumTraits<Scalar>::Real RealScalar;
|
||||
static inline RealScalar run(const Scalar& x)
|
||||
{
|
||||
using std::abs;
|
||||
return abs(x);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Scalar>
|
||||
struct abs_retval
|
||||
{
|
||||
typedef typename NumTraits<Scalar>::Real type;
|
||||
};
|
||||
|
||||
template<typename Scalar>
|
||||
inline EIGEN_MATHFUNC_RETVAL(abs, Scalar) abs(const Scalar& x)
|
||||
{
|
||||
return EIGEN_MATHFUNC_IMPL(abs, Scalar)::run(x);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation of abs2 *
|
||||
****************************************************************************/
|
||||
@@ -322,6 +295,7 @@ struct norm1_default_impl
|
||||
typedef typename NumTraits<Scalar>::Real RealScalar;
|
||||
static inline RealScalar run(const Scalar& x)
|
||||
{
|
||||
using std::abs;
|
||||
return abs(real(x)) + abs(imag(x));
|
||||
}
|
||||
};
|
||||
@@ -331,6 +305,7 @@ struct norm1_default_impl<Scalar, false>
|
||||
{
|
||||
static inline Scalar run(const Scalar& x)
|
||||
{
|
||||
using std::abs;
|
||||
return abs(x);
|
||||
}
|
||||
};
|
||||
@@ -362,6 +337,7 @@ struct hypot_impl
|
||||
{
|
||||
using std::max;
|
||||
using std::min;
|
||||
using std::abs;
|
||||
RealScalar _x = abs(x);
|
||||
RealScalar _y = abs(y);
|
||||
RealScalar p = (max)(_x, _y);
|
||||
@@ -404,121 +380,6 @@ inline NewType cast(const OldType& x)
|
||||
return cast_impl<OldType, NewType>::run(x);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation of sqrt *
|
||||
****************************************************************************/
|
||||
|
||||
template<typename Scalar, bool IsInteger>
|
||||
struct sqrt_default_impl
|
||||
{
|
||||
static inline Scalar run(const Scalar& x)
|
||||
{
|
||||
using std::sqrt;
|
||||
return sqrt(x);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Scalar>
|
||||
struct sqrt_default_impl<Scalar, true>
|
||||
{
|
||||
static inline Scalar run(const Scalar&)
|
||||
{
|
||||
#ifdef EIGEN2_SUPPORT
|
||||
eigen_assert(!NumTraits<Scalar>::IsInteger);
|
||||
#else
|
||||
EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar)
|
||||
#endif
|
||||
return Scalar(0);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Scalar>
|
||||
struct sqrt_impl : sqrt_default_impl<Scalar, NumTraits<Scalar>::IsInteger> {};
|
||||
|
||||
template<typename Scalar>
|
||||
struct sqrt_retval
|
||||
{
|
||||
typedef Scalar type;
|
||||
};
|
||||
|
||||
template<typename Scalar>
|
||||
inline EIGEN_MATHFUNC_RETVAL(sqrt, Scalar) sqrt(const Scalar& x)
|
||||
{
|
||||
return EIGEN_MATHFUNC_IMPL(sqrt, Scalar)::run(x);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation of standard unary real functions (exp, log, sin, cos, ... *
|
||||
****************************************************************************/
|
||||
|
||||
// This macro instanciate all the necessary template mechanism which is common to all unary real functions.
|
||||
#define EIGEN_MATHFUNC_STANDARD_REAL_UNARY(NAME) \
|
||||
template<typename Scalar, bool IsInteger> struct NAME##_default_impl { \
|
||||
static inline Scalar run(const Scalar& x) { using std::NAME; return NAME(x); } \
|
||||
}; \
|
||||
template<typename Scalar> struct NAME##_default_impl<Scalar, true> { \
|
||||
static inline Scalar run(const Scalar&) { \
|
||||
EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar) \
|
||||
return Scalar(0); \
|
||||
} \
|
||||
}; \
|
||||
template<typename Scalar> struct NAME##_impl \
|
||||
: NAME##_default_impl<Scalar, NumTraits<Scalar>::IsInteger> \
|
||||
{}; \
|
||||
template<typename Scalar> struct NAME##_retval { typedef Scalar type; }; \
|
||||
template<typename Scalar> \
|
||||
inline EIGEN_MATHFUNC_RETVAL(NAME, Scalar) NAME(const Scalar& x) { \
|
||||
return EIGEN_MATHFUNC_IMPL(NAME, Scalar)::run(x); \
|
||||
}
|
||||
|
||||
EIGEN_MATHFUNC_STANDARD_REAL_UNARY(exp)
|
||||
EIGEN_MATHFUNC_STANDARD_REAL_UNARY(log)
|
||||
EIGEN_MATHFUNC_STANDARD_REAL_UNARY(sin)
|
||||
EIGEN_MATHFUNC_STANDARD_REAL_UNARY(cos)
|
||||
EIGEN_MATHFUNC_STANDARD_REAL_UNARY(tan)
|
||||
EIGEN_MATHFUNC_STANDARD_REAL_UNARY(asin)
|
||||
EIGEN_MATHFUNC_STANDARD_REAL_UNARY(acos)
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation of atan2 *
|
||||
****************************************************************************/
|
||||
|
||||
template<typename Scalar, bool IsInteger>
|
||||
struct atan2_default_impl
|
||||
{
|
||||
typedef Scalar retval;
|
||||
static inline Scalar run(const Scalar& x, const Scalar& y)
|
||||
{
|
||||
using std::atan2;
|
||||
return atan2(x, y);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Scalar>
|
||||
struct atan2_default_impl<Scalar, true>
|
||||
{
|
||||
static inline Scalar run(const Scalar&, const Scalar&)
|
||||
{
|
||||
EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar)
|
||||
return Scalar(0);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Scalar>
|
||||
struct atan2_impl : atan2_default_impl<Scalar, NumTraits<Scalar>::IsInteger> {};
|
||||
|
||||
template<typename Scalar>
|
||||
struct atan2_retval
|
||||
{
|
||||
typedef Scalar type;
|
||||
};
|
||||
|
||||
template<typename Scalar>
|
||||
inline EIGEN_MATHFUNC_RETVAL(atan2, Scalar) atan2(const Scalar& x, const Scalar& y)
|
||||
{
|
||||
return EIGEN_MATHFUNC_IMPL(atan2, Scalar)::run(x, y);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation of atanh2 *
|
||||
****************************************************************************/
|
||||
@@ -765,11 +626,13 @@ struct scalar_fuzzy_default_impl<Scalar, false, false>
|
||||
template<typename OtherScalar>
|
||||
static inline bool isMuchSmallerThan(const Scalar& x, const OtherScalar& y, const RealScalar& prec)
|
||||
{
|
||||
using std::abs;
|
||||
return abs(x) <= abs(y) * prec;
|
||||
}
|
||||
static inline bool isApprox(const Scalar& x, const Scalar& y, const RealScalar& prec)
|
||||
{
|
||||
using std::min;
|
||||
using std::abs;
|
||||
return abs(x - y) <= (min)(abs(x), abs(y)) * prec;
|
||||
}
|
||||
static inline bool isApproxOrLessThan(const Scalar& x, const Scalar& y, const RealScalar& prec)
|
||||
|
||||
@@ -44,6 +44,7 @@ inline typename NumTraits<typename internal::traits<Derived>::Scalar>::Real
|
||||
MatrixBase<Derived>::stableNorm() const
|
||||
{
|
||||
using std::min;
|
||||
using std::sqrt;
|
||||
const Index blockSize = 4096;
|
||||
RealScalar scale(0);
|
||||
RealScalar invScale(1);
|
||||
@@ -57,7 +58,7 @@ MatrixBase<Derived>::stableNorm() const
|
||||
internal::stable_norm_kernel(this->head(bi), ssq, scale, invScale);
|
||||
for (; bi<n; bi+=blockSize)
|
||||
internal::stable_norm_kernel(this->segment(bi,(min)(blockSize, n - bi)).template forceAlignedAccessIf<Alignment>(), ssq, scale, invScale);
|
||||
return scale * internal::sqrt(ssq);
|
||||
return scale * sqrt(ssq);
|
||||
}
|
||||
|
||||
/** \returns the \em l2 norm of \c *this using the Blue's algorithm.
|
||||
@@ -76,6 +77,8 @@ MatrixBase<Derived>::blueNorm() const
|
||||
using std::pow;
|
||||
using std::min;
|
||||
using std::max;
|
||||
using std::sqrt;
|
||||
using std::abs;
|
||||
static Index nmax = -1;
|
||||
static RealScalar b1, b2, s1m, s2m, overfl, rbig, relerr;
|
||||
if(nmax <= 0)
|
||||
@@ -109,7 +112,7 @@ MatrixBase<Derived>::blueNorm() const
|
||||
|
||||
overfl = rbig*s2m; // overflow boundary for abig
|
||||
eps = RealScalar(pow(double(ibeta), 1-it));
|
||||
relerr = internal::sqrt(eps); // tolerance for neglecting asml
|
||||
relerr = sqrt(eps); // tolerance for neglecting asml
|
||||
abig = RealScalar(1.0/eps - 1.0);
|
||||
if (RealScalar(nbig)>abig) nmax = int(abig); // largest safe n
|
||||
else nmax = nbig;
|
||||
@@ -121,14 +124,14 @@ MatrixBase<Derived>::blueNorm() const
|
||||
RealScalar abig = RealScalar(0);
|
||||
for(Index j=0; j<n; ++j)
|
||||
{
|
||||
RealScalar ax = internal::abs(coeff(j));
|
||||
RealScalar ax = abs(coeff(j));
|
||||
if(ax > ab2) abig += internal::abs2(ax*s2m);
|
||||
else if(ax < b1) asml += internal::abs2(ax*s1m);
|
||||
else amed += internal::abs2(ax);
|
||||
}
|
||||
if(abig > RealScalar(0))
|
||||
{
|
||||
abig = internal::sqrt(abig);
|
||||
abig = sqrt(abig);
|
||||
if(abig > overfl)
|
||||
{
|
||||
return rbig;
|
||||
@@ -136,7 +139,7 @@ MatrixBase<Derived>::blueNorm() const
|
||||
if(amed > RealScalar(0))
|
||||
{
|
||||
abig = abig/s2m;
|
||||
amed = internal::sqrt(amed);
|
||||
amed = sqrt(amed);
|
||||
}
|
||||
else
|
||||
return abig/s2m;
|
||||
@@ -145,20 +148,20 @@ MatrixBase<Derived>::blueNorm() const
|
||||
{
|
||||
if (amed > RealScalar(0))
|
||||
{
|
||||
abig = internal::sqrt(amed);
|
||||
amed = internal::sqrt(asml) / s1m;
|
||||
abig = sqrt(amed);
|
||||
amed = sqrt(asml) / s1m;
|
||||
}
|
||||
else
|
||||
return internal::sqrt(asml)/s1m;
|
||||
return sqrt(asml)/s1m;
|
||||
}
|
||||
else
|
||||
return internal::sqrt(amed);
|
||||
return sqrt(amed);
|
||||
asml = (min)(abig, amed);
|
||||
abig = (max)(abig, amed);
|
||||
if(asml <= abig*relerr)
|
||||
return abig;
|
||||
else
|
||||
return abig * internal::sqrt(RealScalar(1) + internal::abs2(asml/abig));
|
||||
return abig * sqrt(RealScalar(1) + internal::abs2(asml/abig));
|
||||
}
|
||||
|
||||
/** \returns the \em l2 norm of \c *this avoiding undeflow and overflow.
|
||||
|
||||
@@ -781,20 +781,21 @@ MatrixBase<Derived>::triangularView() const
|
||||
template<typename Derived>
|
||||
bool MatrixBase<Derived>::isUpperTriangular(const RealScalar& prec) const
|
||||
{
|
||||
using std::abs;
|
||||
RealScalar maxAbsOnUpperPart = static_cast<RealScalar>(-1);
|
||||
for(Index j = 0; j < cols(); ++j)
|
||||
{
|
||||
Index maxi = (std::min)(j, rows()-1);
|
||||
for(Index i = 0; i <= maxi; ++i)
|
||||
{
|
||||
RealScalar absValue = internal::abs(coeff(i,j));
|
||||
RealScalar absValue = abs(coeff(i,j));
|
||||
if(absValue > maxAbsOnUpperPart) maxAbsOnUpperPart = absValue;
|
||||
}
|
||||
}
|
||||
RealScalar threshold = maxAbsOnUpperPart * prec;
|
||||
for(Index j = 0; j < cols(); ++j)
|
||||
for(Index i = j+1; i < rows(); ++i)
|
||||
if(internal::abs(coeff(i, j)) > threshold) return false;
|
||||
if(abs(coeff(i, j)) > threshold) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -806,11 +807,12 @@ bool MatrixBase<Derived>::isUpperTriangular(const RealScalar& prec) const
|
||||
template<typename Derived>
|
||||
bool MatrixBase<Derived>::isLowerTriangular(const RealScalar& prec) const
|
||||
{
|
||||
using std::abs;
|
||||
RealScalar maxAbsOnLowerPart = static_cast<RealScalar>(-1);
|
||||
for(Index j = 0; j < cols(); ++j)
|
||||
for(Index i = j; i < rows(); ++i)
|
||||
{
|
||||
RealScalar absValue = internal::abs(coeff(i,j));
|
||||
RealScalar absValue = abs(coeff(i,j));
|
||||
if(absValue > maxAbsOnLowerPart) maxAbsOnLowerPart = absValue;
|
||||
}
|
||||
RealScalar threshold = maxAbsOnLowerPart * prec;
|
||||
@@ -818,7 +820,7 @@ bool MatrixBase<Derived>::isLowerTriangular(const RealScalar& prec) const
|
||||
{
|
||||
Index maxi = (std::min)(j, rows()-1);
|
||||
for(Index i = 0; i < maxi; ++i)
|
||||
if(internal::abs(coeff(i, j)) > threshold) return false;
|
||||
if(abs(coeff(i, j)) > threshold) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -15,14 +15,14 @@ namespace Eigen {
|
||||
template<typename T> inline typename NumTraits<T>::Real ei_real(const T& x) { return internal::real(x); }
|
||||
template<typename T> inline typename NumTraits<T>::Real ei_imag(const T& x) { return internal::imag(x); }
|
||||
template<typename T> inline T ei_conj(const T& x) { return internal::conj(x); }
|
||||
template<typename T> inline typename NumTraits<T>::Real ei_abs (const T& x) { return internal::abs(x); }
|
||||
template<typename T> inline typename NumTraits<T>::Real ei_abs (const T& x) { using std::abs; return abs(x); }
|
||||
template<typename T> inline typename NumTraits<T>::Real ei_abs2(const T& x) { return internal::abs2(x); }
|
||||
template<typename T> inline T ei_sqrt(const T& x) { return internal::sqrt(x); }
|
||||
template<typename T> inline T ei_exp (const T& x) { return internal::exp(x); }
|
||||
template<typename T> inline T ei_log (const T& x) { return internal::log(x); }
|
||||
template<typename T> inline T ei_sin (const T& x) { return internal::sin(x); }
|
||||
template<typename T> inline T ei_cos (const T& x) { return internal::cos(x); }
|
||||
template<typename T> inline T ei_atan2(const T& x,const T& y) { return internal::atan2(x,y); }
|
||||
template<typename T> inline T ei_sqrt(const T& x) { using std::sqrt; return sqrt(x); }
|
||||
template<typename T> inline T ei_exp (const T& x) { using std::exp; return exp(x); }
|
||||
template<typename T> inline T ei_log (const T& x) { using std::log; return log(x); }
|
||||
template<typename T> inline T ei_sin (const T& x) { using std::sin; return sin(x); }
|
||||
template<typename T> inline T ei_cos (const T& x) { using std::cos; return cos(x); }
|
||||
template<typename T> inline T ei_atan2(const T& x,const T& y) { using std::atan2; return atan2(x,y); }
|
||||
template<typename T> inline T ei_pow (const T& x,const T& y) { return internal::pow(x,y); }
|
||||
template<typename T> inline T ei_random () { return internal::random<T>(); }
|
||||
template<typename T> inline T ei_random (const T& x, const T& y) { return internal::random(x, y); }
|
||||
|
||||
@@ -258,10 +258,11 @@ inline bool ComplexSchur<MatrixType>::subdiagonalEntryIsNeglegible(Index i)
|
||||
template<typename MatrixType>
|
||||
typename ComplexSchur<MatrixType>::ComplexScalar ComplexSchur<MatrixType>::computeShift(Index iu, Index iter)
|
||||
{
|
||||
using std::abs;
|
||||
if (iter == 10 || iter == 20)
|
||||
{
|
||||
// exceptional shift, taken from http://www.netlib.org/eispack/comqr.f
|
||||
return internal::abs(internal::real(m_matT.coeff(iu,iu-1))) + internal::abs(internal::real(m_matT.coeff(iu-1,iu-2)));
|
||||
return abs(internal::real(m_matT.coeff(iu,iu-1))) + abs(internal::real(m_matT.coeff(iu-1,iu-2)));
|
||||
}
|
||||
|
||||
// compute the shift as one of the eigenvalues of t, the 2x2
|
||||
|
||||
@@ -364,6 +364,8 @@ template<typename MatrixType>
|
||||
EigenSolver<MatrixType>&
|
||||
EigenSolver<MatrixType>::compute(const MatrixType& matrix, bool computeEigenvectors)
|
||||
{
|
||||
using std::sqrt;
|
||||
using std::abs;
|
||||
assert(matrix.cols() == matrix.rows());
|
||||
|
||||
// Reduce to real Schur form.
|
||||
@@ -388,7 +390,7 @@ EigenSolver<MatrixType>::compute(const MatrixType& matrix, bool computeEigenvect
|
||||
else
|
||||
{
|
||||
Scalar p = Scalar(0.5) * (m_matT.coeff(i, i) - m_matT.coeff(i+1, i+1));
|
||||
Scalar z = internal::sqrt(internal::abs(p * p + m_matT.coeff(i+1, i) * m_matT.coeff(i, i+1)));
|
||||
Scalar z = sqrt(abs(p * p + m_matT.coeff(i+1, i) * m_matT.coeff(i, i+1)));
|
||||
m_eivalues.coeffRef(i) = ComplexScalar(m_matT.coeff(i+1, i+1) + p, z);
|
||||
m_eivalues.coeffRef(i+1) = ComplexScalar(m_matT.coeff(i+1, i+1) + p, -z);
|
||||
i += 2;
|
||||
@@ -410,8 +412,9 @@ EigenSolver<MatrixType>::compute(const MatrixType& matrix, bool computeEigenvect
|
||||
template<typename Scalar>
|
||||
std::complex<Scalar> cdiv(Scalar xr, Scalar xi, Scalar yr, Scalar yi)
|
||||
{
|
||||
using std::abs;
|
||||
Scalar r,d;
|
||||
if (internal::abs(yr) > internal::abs(yi))
|
||||
if (abs(yr) > abs(yi))
|
||||
{
|
||||
r = yi/yr;
|
||||
d = yr + r*yi;
|
||||
@@ -429,6 +432,7 @@ std::complex<Scalar> cdiv(Scalar xr, Scalar xi, Scalar yr, Scalar yi)
|
||||
template<typename MatrixType>
|
||||
void EigenSolver<MatrixType>::doComputeEigenvectors()
|
||||
{
|
||||
using std::abs;
|
||||
const Index size = m_eivec.cols();
|
||||
const Scalar eps = NumTraits<Scalar>::epsilon();
|
||||
|
||||
@@ -484,14 +488,14 @@ void EigenSolver<MatrixType>::doComputeEigenvectors()
|
||||
Scalar denom = (m_eivalues.coeff(i).real() - p) * (m_eivalues.coeff(i).real() - p) + m_eivalues.coeff(i).imag() * m_eivalues.coeff(i).imag();
|
||||
Scalar t = (x * lastr - lastw * r) / denom;
|
||||
m_matT.coeffRef(i,n) = t;
|
||||
if (internal::abs(x) > internal::abs(lastw))
|
||||
if (abs(x) > abs(lastw))
|
||||
m_matT.coeffRef(i+1,n) = (-r - w * t) / x;
|
||||
else
|
||||
m_matT.coeffRef(i+1,n) = (-lastr - y * t) / lastw;
|
||||
}
|
||||
|
||||
// Overflow control
|
||||
Scalar t = internal::abs(m_matT.coeff(i,n));
|
||||
Scalar t = abs(m_matT.coeff(i,n));
|
||||
if ((eps * t) * t > Scalar(1))
|
||||
m_matT.col(n).tail(size-i) /= t;
|
||||
}
|
||||
@@ -503,7 +507,7 @@ void EigenSolver<MatrixType>::doComputeEigenvectors()
|
||||
Index l = n-1;
|
||||
|
||||
// Last vector component imaginary so matrix is triangular
|
||||
if (internal::abs(m_matT.coeff(n,n-1)) > internal::abs(m_matT.coeff(n-1,n)))
|
||||
if (abs(m_matT.coeff(n,n-1)) > abs(m_matT.coeff(n-1,n)))
|
||||
{
|
||||
m_matT.coeffRef(n-1,n-1) = q / m_matT.coeff(n,n-1);
|
||||
m_matT.coeffRef(n-1,n) = -(m_matT.coeff(n,n) - p) / m_matT.coeff(n,n-1);
|
||||
@@ -545,12 +549,12 @@ void EigenSolver<MatrixType>::doComputeEigenvectors()
|
||||
Scalar vr = (m_eivalues.coeff(i).real() - p) * (m_eivalues.coeff(i).real() - p) + m_eivalues.coeff(i).imag() * m_eivalues.coeff(i).imag() - q * q;
|
||||
Scalar vi = (m_eivalues.coeff(i).real() - p) * Scalar(2) * q;
|
||||
if ((vr == 0.0) && (vi == 0.0))
|
||||
vr = eps * norm * (internal::abs(w) + internal::abs(q) + internal::abs(x) + internal::abs(y) + internal::abs(lastw));
|
||||
vr = eps * norm * (abs(w) + abs(q) + abs(x) + abs(y) + abs(lastw));
|
||||
|
||||
std::complex<Scalar> cc = cdiv(x*lastra-lastw*ra+q*sa,x*lastsa-lastw*sa-q*ra,vr,vi);
|
||||
m_matT.coeffRef(i,n-1) = internal::real(cc);
|
||||
m_matT.coeffRef(i,n) = internal::imag(cc);
|
||||
if (internal::abs(x) > (internal::abs(lastw) + internal::abs(q)))
|
||||
if (abs(x) > (abs(lastw) + abs(q)))
|
||||
{
|
||||
m_matT.coeffRef(i+1,n-1) = (-ra - w * m_matT.coeff(i,n-1) + q * m_matT.coeff(i,n)) / x;
|
||||
m_matT.coeffRef(i+1,n) = (-sa - w * m_matT.coeff(i,n) - q * m_matT.coeff(i,n-1)) / x;
|
||||
@@ -565,7 +569,7 @@ void EigenSolver<MatrixType>::doComputeEigenvectors()
|
||||
|
||||
// Overflow control
|
||||
using std::max;
|
||||
Scalar t = (max)(internal::abs(m_matT.coeff(i,n-1)),internal::abs(m_matT.coeff(i,n)));
|
||||
Scalar t = (max)(abs(m_matT.coeff(i,n-1)),abs(m_matT.coeff(i,n)));
|
||||
if ((eps * t) * t > Scalar(1))
|
||||
m_matT.block(i, n-1, size-i, 2) /= t;
|
||||
|
||||
|
||||
@@ -290,6 +290,8 @@ template<typename MatrixType>
|
||||
GeneralizedEigenSolver<MatrixType>&
|
||||
GeneralizedEigenSolver<MatrixType>::compute(const MatrixType& A, const MatrixType& B, bool computeEigenvectors)
|
||||
{
|
||||
using std::sqrt;
|
||||
using std::abs;
|
||||
eigen_assert(A.cols() == A.rows() && B.cols() == A.rows() && B.cols() == B.rows());
|
||||
|
||||
// Reduce to generalized real Schur form:
|
||||
@@ -317,7 +319,7 @@ GeneralizedEigenSolver<MatrixType>::compute(const MatrixType& A, const MatrixTyp
|
||||
else
|
||||
{
|
||||
Scalar p = Scalar(0.5) * (m_matS.coeff(i, i) - m_matS.coeff(i+1, i+1));
|
||||
Scalar z = internal::sqrt(internal::abs(p * p + m_matS.coeff(i+1, i) * m_matS.coeff(i, i+1)));
|
||||
Scalar z = sqrt(abs(p * p + m_matS.coeff(i+1, i) * m_matS.coeff(i, i+1)));
|
||||
m_alphas.coeffRef(i) = ComplexScalar(m_matS.coeff(i+1, i+1) + p, z);
|
||||
m_alphas.coeffRef(i+1) = ComplexScalar(m_matS.coeff(i+1, i+1) + p, -z);
|
||||
|
||||
|
||||
@@ -121,10 +121,11 @@ template<typename Derived>
|
||||
inline typename MatrixBase<Derived>::RealScalar
|
||||
MatrixBase<Derived>::operatorNorm() const
|
||||
{
|
||||
using std::sqrt;
|
||||
typename Derived::PlainObject m_eval(derived());
|
||||
// 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 internal::sqrt((m_eval*m_eval.adjoint())
|
||||
return sqrt((m_eval*m_eval.adjoint())
|
||||
.eval()
|
||||
.template selfadjointView<Lower>()
|
||||
.eigenvalues()
|
||||
|
||||
@@ -278,13 +278,14 @@ namespace Eigen {
|
||||
template<typename MatrixType>
|
||||
inline typename MatrixType::Index RealQZ<MatrixType>::findSmallSubdiagEntry(Index iu)
|
||||
{
|
||||
using std::abs;
|
||||
Index res = iu;
|
||||
while (res > 0)
|
||||
{
|
||||
Scalar s = internal::abs(m_S.coeff(res-1,res-1)) + internal::abs(m_S.coeff(res,res));
|
||||
Scalar s = abs(m_S.coeff(res-1,res-1)) + abs(m_S.coeff(res,res));
|
||||
if (s == Scalar(0.0))
|
||||
s = m_normOfS;
|
||||
if (internal::abs(m_S.coeff(res,res-1)) < NumTraits<Scalar>::epsilon() * s)
|
||||
if (abs(m_S.coeff(res,res-1)) < NumTraits<Scalar>::epsilon() * s)
|
||||
break;
|
||||
res--;
|
||||
}
|
||||
@@ -295,9 +296,10 @@ namespace Eigen {
|
||||
template<typename MatrixType>
|
||||
inline typename MatrixType::Index RealQZ<MatrixType>::findSmallDiagEntry(Index f, Index l)
|
||||
{
|
||||
using std::abs;
|
||||
Index res = l;
|
||||
while (res >= f) {
|
||||
if (internal::abs(m_T.coeff(res,res)) <= NumTraits<Scalar>::epsilon() * m_normOfT)
|
||||
if (abs(m_T.coeff(res,res)) <= NumTraits<Scalar>::epsilon() * m_normOfT)
|
||||
break;
|
||||
res--;
|
||||
}
|
||||
@@ -308,8 +310,10 @@ namespace Eigen {
|
||||
template<typename MatrixType>
|
||||
inline void RealQZ<MatrixType>::splitOffTwoRows(Index i)
|
||||
{
|
||||
using std::abs;
|
||||
using std::sqrt;
|
||||
const Index dim=m_S.cols();
|
||||
if (internal::abs(m_S.coeff(i+1,i)==Scalar(0)))
|
||||
if (abs(m_S.coeff(i+1,i)==Scalar(0)))
|
||||
return;
|
||||
Index z = findSmallDiagEntry(i,i+1);
|
||||
if (z==i-1)
|
||||
@@ -320,7 +324,7 @@ namespace Eigen {
|
||||
Scalar p = Scalar(0.5)*(STi(0,0)-STi(1,1));
|
||||
Scalar q = p*p + STi(1,0)*STi(0,1);
|
||||
if (q>=0) {
|
||||
Scalar z = internal::sqrt(q);
|
||||
Scalar z = sqrt(q);
|
||||
// one QR-like iteration for ABi - lambda I
|
||||
// is enough - when we know exact eigenvalue in advance,
|
||||
// convergence is immediate
|
||||
@@ -393,7 +397,9 @@ namespace Eigen {
|
||||
|
||||
/** \internal QR-like iterative step for block f..l */
|
||||
template<typename MatrixType>
|
||||
inline void RealQZ<MatrixType>::step(Index f, Index l, Index iter) {
|
||||
inline void RealQZ<MatrixType>::step(Index f, Index l, Index iter)
|
||||
{
|
||||
using std::abs;
|
||||
const Index dim = m_S.cols();
|
||||
|
||||
// x, y, z
|
||||
@@ -411,7 +417,7 @@ namespace Eigen {
|
||||
a98=m_S.coeff(l-0,l-1),
|
||||
b77i=Scalar(1.0)/m_T.coeff(l-2,l-2),
|
||||
b88i=Scalar(1.0)/m_T.coeff(l-1,l-1);
|
||||
Scalar ss = internal::abs(a87*b77i) + internal::abs(a98*b88i),
|
||||
Scalar ss = abs(a87*b77i) + abs(a98*b88i),
|
||||
lpl = Scalar(1.5)*ss,
|
||||
ll = ss*ss;
|
||||
x = ll + a11*a11*b11i*b11i - lpl*a11*b11i + a12*a21*b11i*b22i
|
||||
|
||||
@@ -345,13 +345,14 @@ inline typename MatrixType::Scalar RealSchur<MatrixType>::computeNormOfT()
|
||||
template<typename MatrixType>
|
||||
inline typename MatrixType::Index RealSchur<MatrixType>::findSmallSubdiagEntry(Index iu, Scalar norm)
|
||||
{
|
||||
using std::abs;
|
||||
Index res = iu;
|
||||
while (res > 0)
|
||||
{
|
||||
Scalar s = internal::abs(m_matT.coeff(res-1,res-1)) + internal::abs(m_matT.coeff(res,res));
|
||||
Scalar s = abs(m_matT.coeff(res-1,res-1)) + abs(m_matT.coeff(res,res));
|
||||
if (s == 0.0)
|
||||
s = norm;
|
||||
if (internal::abs(m_matT.coeff(res,res-1)) < NumTraits<Scalar>::epsilon() * s)
|
||||
if (abs(m_matT.coeff(res,res-1)) < NumTraits<Scalar>::epsilon() * s)
|
||||
break;
|
||||
res--;
|
||||
}
|
||||
@@ -362,6 +363,8 @@ inline typename MatrixType::Index RealSchur<MatrixType>::findSmallSubdiagEntry(I
|
||||
template<typename MatrixType>
|
||||
inline void RealSchur<MatrixType>::splitOffTwoRows(Index iu, bool computeU, Scalar exshift)
|
||||
{
|
||||
using std::sqrt;
|
||||
using std::abs;
|
||||
const Index size = m_matT.cols();
|
||||
|
||||
// The eigenvalues of the 2x2 matrix [a b; c d] are
|
||||
@@ -373,7 +376,7 @@ inline void RealSchur<MatrixType>::splitOffTwoRows(Index iu, bool computeU, Scal
|
||||
|
||||
if (q >= Scalar(0)) // Two real eigenvalues
|
||||
{
|
||||
Scalar z = internal::sqrt(internal::abs(q));
|
||||
Scalar z = sqrt(abs(q));
|
||||
JacobiRotation<Scalar> rot;
|
||||
if (p >= Scalar(0))
|
||||
rot.makeGivens(p + z, m_matT.coeff(iu, iu-1));
|
||||
@@ -395,6 +398,8 @@ inline void RealSchur<MatrixType>::splitOffTwoRows(Index iu, bool computeU, Scal
|
||||
template<typename MatrixType>
|
||||
inline void RealSchur<MatrixType>::computeShift(Index iu, Index iter, Scalar& exshift, Vector3s& shiftInfo)
|
||||
{
|
||||
using std::sqrt;
|
||||
using std::abs;
|
||||
shiftInfo.coeffRef(0) = m_matT.coeff(iu,iu);
|
||||
shiftInfo.coeffRef(1) = m_matT.coeff(iu-1,iu-1);
|
||||
shiftInfo.coeffRef(2) = m_matT.coeff(iu,iu-1) * m_matT.coeff(iu-1,iu);
|
||||
@@ -405,7 +410,7 @@ inline void RealSchur<MatrixType>::computeShift(Index iu, Index iter, Scalar& ex
|
||||
exshift += shiftInfo.coeff(0);
|
||||
for (Index i = 0; i <= iu; ++i)
|
||||
m_matT.coeffRef(i,i) -= shiftInfo.coeff(0);
|
||||
Scalar s = internal::abs(m_matT.coeff(iu,iu-1)) + internal::abs(m_matT.coeff(iu-1,iu-2));
|
||||
Scalar s = abs(m_matT.coeff(iu,iu-1)) + abs(m_matT.coeff(iu-1,iu-2));
|
||||
shiftInfo.coeffRef(0) = Scalar(0.75) * s;
|
||||
shiftInfo.coeffRef(1) = Scalar(0.75) * s;
|
||||
shiftInfo.coeffRef(2) = Scalar(-0.4375) * s * s;
|
||||
@@ -418,7 +423,7 @@ inline void RealSchur<MatrixType>::computeShift(Index iu, Index iter, Scalar& ex
|
||||
s = s * s + shiftInfo.coeff(2);
|
||||
if (s > Scalar(0))
|
||||
{
|
||||
s = internal::sqrt(s);
|
||||
s = sqrt(s);
|
||||
if (shiftInfo.coeff(1) < shiftInfo.coeff(0))
|
||||
s = -s;
|
||||
s = s + (shiftInfo.coeff(1) - shiftInfo.coeff(0)) / Scalar(2.0);
|
||||
@@ -435,6 +440,7 @@ inline void RealSchur<MatrixType>::computeShift(Index iu, Index iter, Scalar& ex
|
||||
template<typename MatrixType>
|
||||
inline void RealSchur<MatrixType>::initFrancisQRStep(Index il, Index iu, const Vector3s& shiftInfo, Index& im, Vector3s& firstHouseholderVector)
|
||||
{
|
||||
using std::abs;
|
||||
Vector3s& v = firstHouseholderVector; // alias to save typing
|
||||
|
||||
for (im = iu-2; im >= il; --im)
|
||||
@@ -448,9 +454,9 @@ inline void RealSchur<MatrixType>::initFrancisQRStep(Index il, Index iu, const V
|
||||
if (im == il) {
|
||||
break;
|
||||
}
|
||||
const Scalar lhs = m_matT.coeff(im,im-1) * (internal::abs(v.coeff(1)) + internal::abs(v.coeff(2)));
|
||||
const Scalar rhs = v.coeff(0) * (internal::abs(m_matT.coeff(im-1,im-1)) + internal::abs(Tmm) + internal::abs(m_matT.coeff(im+1,im+1)));
|
||||
if (internal::abs(lhs) < NumTraits<Scalar>::epsilon() * rhs)
|
||||
const Scalar lhs = m_matT.coeff(im,im-1) * (abs(v.coeff(1)) + abs(v.coeff(2)));
|
||||
const Scalar rhs = v.coeff(0) * (abs(m_matT.coeff(im-1,im-1)) + abs(Tmm) + abs(m_matT.coeff(im+1,im+1)));
|
||||
if (abs(lhs) < NumTraits<Scalar>::epsilon() * rhs)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -384,6 +384,7 @@ template<typename MatrixType>
|
||||
SelfAdjointEigenSolver<MatrixType>& SelfAdjointEigenSolver<MatrixType>
|
||||
::compute(const MatrixType& matrix, int options)
|
||||
{
|
||||
using std::abs;
|
||||
eigen_assert(matrix.cols() == matrix.rows());
|
||||
eigen_assert((options&~(EigVecMask|GenEigMask))==0
|
||||
&& (options&EigVecMask)!=EigVecMask
|
||||
@@ -421,7 +422,7 @@ SelfAdjointEigenSolver<MatrixType>& SelfAdjointEigenSolver<MatrixType>
|
||||
while (end>0)
|
||||
{
|
||||
for (Index i = start; i<end; ++i)
|
||||
if (internal::isMuchSmallerThan(internal::abs(m_subdiag[i]),(internal::abs(diag[i])+internal::abs(diag[i+1]))))
|
||||
if (internal::isMuchSmallerThan(abs(m_subdiag[i]),(abs(diag[i])+abs(diag[i+1]))))
|
||||
m_subdiag[i] = 0;
|
||||
|
||||
// find the largest unreduced block
|
||||
@@ -675,6 +676,7 @@ template<typename SolverType> struct direct_selfadjoint_eigenvalues<SolverType,2
|
||||
|
||||
static inline void run(SolverType& solver, const MatrixType& mat, int options)
|
||||
{
|
||||
using std::sqrt;
|
||||
eigen_assert(mat.cols() == 2 && mat.cols() == mat.rows());
|
||||
eigen_assert((options&~(EigVecMask|GenEigMask))==0
|
||||
&& (options&EigVecMask)!=EigVecMask
|
||||
@@ -736,6 +738,7 @@ namespace internal {
|
||||
template<int StorageOrder,typename RealScalar, typename Scalar, typename Index>
|
||||
static void tridiagonal_qr_step(RealScalar* diag, RealScalar* subdiag, Index start, Index end, Scalar* matrixQ, Index n)
|
||||
{
|
||||
using std::abs;
|
||||
RealScalar td = (diag[end-1] - diag[end])*RealScalar(0.5);
|
||||
RealScalar e = subdiag[end-1];
|
||||
// Note that thanks to scaling, e^2 or td^2 cannot overflow, however they can still
|
||||
|
||||
@@ -345,6 +345,7 @@ namespace internal {
|
||||
template<typename MatrixType, typename CoeffVectorType>
|
||||
void tridiagonalization_inplace(MatrixType& matA, CoeffVectorType& hCoeffs)
|
||||
{
|
||||
using internal::conj;
|
||||
typedef typename MatrixType::Index Index;
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
typedef typename MatrixType::RealScalar RealScalar;
|
||||
@@ -467,6 +468,7 @@ struct tridiagonalization_inplace_selector<MatrixType,3,false>
|
||||
template<typename DiagonalType, typename SubDiagonalType>
|
||||
static void run(MatrixType& mat, DiagonalType& diag, SubDiagonalType& subdiag, bool extractQ)
|
||||
{
|
||||
using std::sqrt;
|
||||
diag[0] = mat(0,0);
|
||||
RealScalar v1norm2 = abs2(mat(2,0));
|
||||
if(v1norm2 == RealScalar(0))
|
||||
|
||||
@@ -248,14 +248,14 @@ EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_AmbientDim)
|
||||
*/
|
||||
template<typename Derived>
|
||||
inline NonInteger exteriorDistance(const MatrixBase<Derived>& p) const
|
||||
{ return internal::sqrt(NonInteger(squaredExteriorDistance(p))); }
|
||||
{ using std::sqrt; return sqrt(NonInteger(squaredExteriorDistance(p))); }
|
||||
|
||||
/** \returns the distance between the boxes \a b and \c *this,
|
||||
* and zero if the boxes intersect.
|
||||
* \sa squaredExteriorDistance()
|
||||
*/
|
||||
inline NonInteger exteriorDistance(const AlignedBox& b) const
|
||||
{ return internal::sqrt(NonInteger(squaredExteriorDistance(b))); }
|
||||
{ using std::sqrt; return sqrt(NonInteger(squaredExteriorDistance(b))); }
|
||||
|
||||
/** \returns \c *this with scalar type casted to \a NewScalarType
|
||||
*
|
||||
|
||||
@@ -161,6 +161,7 @@ AngleAxis<Scalar>& AngleAxis<Scalar>::operator=(const QuaternionBase<QuatDerived
|
||||
using std::acos;
|
||||
using std::min;
|
||||
using std::max;
|
||||
using std::sqrt;
|
||||
Scalar n2 = q.vec().squaredNorm();
|
||||
if (n2 < NumTraits<Scalar>::dummy_precision()*NumTraits<Scalar>::dummy_precision())
|
||||
{
|
||||
@@ -170,7 +171,7 @@ AngleAxis<Scalar>& AngleAxis<Scalar>::operator=(const QuaternionBase<QuatDerived
|
||||
else
|
||||
{
|
||||
m_angle = Scalar(2)*acos((min)((max)(Scalar(-1),q.w()),Scalar(1)));
|
||||
m_axis = q.vec() / internal::sqrt(n2);
|
||||
m_axis = q.vec() / sqrt(n2);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
@@ -202,9 +203,11 @@ template<typename Scalar>
|
||||
typename AngleAxis<Scalar>::Matrix3
|
||||
AngleAxis<Scalar>::toRotationMatrix(void) const
|
||||
{
|
||||
using std::sin;
|
||||
using std::cos;
|
||||
Matrix3 res;
|
||||
Vector3 sin_axis = internal::sin(m_angle) * m_axis;
|
||||
Scalar c = internal::cos(m_angle);
|
||||
Vector3 sin_axis = sin(m_angle) * m_axis;
|
||||
Scalar c = cos(m_angle);
|
||||
Vector3 cos1_axis = (Scalar(1)-c) * m_axis;
|
||||
|
||||
Scalar tmp;
|
||||
|
||||
@@ -32,6 +32,7 @@ template<typename Derived>
|
||||
inline Matrix<typename MatrixBase<Derived>::Scalar,3,1>
|
||||
MatrixBase<Derived>::eulerAngles(Index a0, Index a1, Index a2) const
|
||||
{
|
||||
using std::atan2;
|
||||
/* Implemented from Graphics Gems IV */
|
||||
EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Derived,3,3)
|
||||
|
||||
@@ -47,31 +48,31 @@ MatrixBase<Derived>::eulerAngles(Index a0, Index a1, Index a2) const
|
||||
if (a0==a2)
|
||||
{
|
||||
Scalar s = Vector2(coeff(j,i) , coeff(k,i)).norm();
|
||||
res[1] = internal::atan2(s, coeff(i,i));
|
||||
res[1] = atan2(s, coeff(i,i));
|
||||
if (s > epsilon)
|
||||
{
|
||||
res[0] = internal::atan2(coeff(j,i), coeff(k,i));
|
||||
res[2] = internal::atan2(coeff(i,j),-coeff(i,k));
|
||||
res[0] = atan2(coeff(j,i), coeff(k,i));
|
||||
res[2] = atan2(coeff(i,j),-coeff(i,k));
|
||||
}
|
||||
else
|
||||
{
|
||||
res[0] = Scalar(0);
|
||||
res[2] = (coeff(i,i)>0?1:-1)*internal::atan2(-coeff(k,j), coeff(j,j));
|
||||
res[2] = (coeff(i,i)>0?1:-1)*atan2(-coeff(k,j), coeff(j,j));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Scalar c = Vector2(coeff(i,i) , coeff(i,j)).norm();
|
||||
res[1] = internal::atan2(-coeff(i,k), c);
|
||||
res[1] = atan2(-coeff(i,k), c);
|
||||
if (c > epsilon)
|
||||
{
|
||||
res[0] = internal::atan2(coeff(j,k), coeff(k,k));
|
||||
res[2] = internal::atan2(coeff(i,j), coeff(i,i));
|
||||
res[0] = atan2(coeff(j,k), coeff(k,k));
|
||||
res[2] = atan2(coeff(i,j), coeff(i,i));
|
||||
}
|
||||
else
|
||||
{
|
||||
res[0] = Scalar(0);
|
||||
res[2] = (coeff(i,k)>0?1:-1)*internal::atan2(-coeff(k,j), coeff(j,j));
|
||||
res[2] = (coeff(i,k)>0?1:-1)*atan2(-coeff(k,j), coeff(j,j));
|
||||
}
|
||||
}
|
||||
if (!odd)
|
||||
|
||||
@@ -135,7 +135,7 @@ public:
|
||||
/** \returns the absolute distance between the plane \c *this and a point \a p.
|
||||
* \sa signedDistance()
|
||||
*/
|
||||
inline Scalar absDistance(const VectorType& p) const { return internal::abs(signedDistance(p)); }
|
||||
inline Scalar absDistance(const VectorType& p) const { using std::abs; return abs(signedDistance(p)); }
|
||||
|
||||
/** \returns the projection of a point \a p onto the plane \c *this.
|
||||
*/
|
||||
@@ -178,13 +178,14 @@ public:
|
||||
*/
|
||||
VectorType intersection(const Hyperplane& other) const
|
||||
{
|
||||
using std::abs;
|
||||
EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(VectorType, 2)
|
||||
Scalar det = coeffs().coeff(0) * other.coeffs().coeff(1) - coeffs().coeff(1) * other.coeffs().coeff(0);
|
||||
// since the line equations ax+by=c are normalized with a^2+b^2=1, the following tests
|
||||
// whether the two lines are approximately parallel.
|
||||
if(internal::isMuchSmallerThan(det, Scalar(1)))
|
||||
{ // special case where the two lines are approximately parallel. Pick any point on the first line.
|
||||
if(internal::abs(coeffs().coeff(1))>internal::abs(coeffs().coeff(0)))
|
||||
if(abs(coeffs().coeff(1))>abs(coeffs().coeff(0)))
|
||||
return VectorType(coeffs().coeff(1), -coeffs().coeff(2)/coeffs().coeff(1)-coeffs().coeff(0));
|
||||
else
|
||||
return VectorType(-coeffs().coeff(2)/coeffs().coeff(0)-coeffs().coeff(1), coeffs().coeff(0));
|
||||
|
||||
@@ -87,7 +87,7 @@ public:
|
||||
/** \returns the distance of a point \a p to its projection onto the line \c *this.
|
||||
* \sa squaredDistance()
|
||||
*/
|
||||
RealScalar distance(const VectorType& p) const { return internal::sqrt(squaredDistance(p)); }
|
||||
RealScalar distance(const VectorType& p) const { using std::sqrt; return sqrt(squaredDistance(p)); }
|
||||
|
||||
/** \returns the projection of a point \a p onto the line \c *this. */
|
||||
VectorType projection(const VectorType& p) const
|
||||
|
||||
@@ -505,9 +505,11 @@ EIGEN_STRONG_INLINE Derived& QuaternionBase<Derived>::operator=(const Quaternion
|
||||
template<class Derived>
|
||||
EIGEN_STRONG_INLINE Derived& QuaternionBase<Derived>::operator=(const AngleAxisType& aa)
|
||||
{
|
||||
using std::cos;
|
||||
using std::sin;
|
||||
Scalar ha = Scalar(0.5)*aa.angle(); // Scalar(0.5) to suppress precision loss warnings
|
||||
this->w() = internal::cos(ha);
|
||||
this->vec() = internal::sin(ha) * aa.axis();
|
||||
this->w() = cos(ha);
|
||||
this->vec() = sin(ha) * aa.axis();
|
||||
return derived();
|
||||
}
|
||||
|
||||
@@ -581,6 +583,7 @@ template<typename Derived1, typename Derived2>
|
||||
inline Derived& QuaternionBase<Derived>::setFromTwoVectors(const MatrixBase<Derived1>& a, const MatrixBase<Derived2>& b)
|
||||
{
|
||||
using std::max;
|
||||
using std::sqrt;
|
||||
Vector3 v0 = a.normalized();
|
||||
Vector3 v1 = b.normalized();
|
||||
Scalar c = v1.dot(v0);
|
||||
@@ -601,12 +604,12 @@ inline Derived& QuaternionBase<Derived>::setFromTwoVectors(const MatrixBase<Deri
|
||||
Vector3 axis = svd.matrixV().col(2);
|
||||
|
||||
Scalar w2 = (Scalar(1)+c)*Scalar(0.5);
|
||||
this->w() = internal::sqrt(w2);
|
||||
this->vec() = axis * internal::sqrt(Scalar(1) - w2);
|
||||
this->w() = sqrt(w2);
|
||||
this->vec() = axis * sqrt(Scalar(1) - w2);
|
||||
return derived();
|
||||
}
|
||||
Vector3 axis = v0.cross(v1);
|
||||
Scalar s = internal::sqrt((Scalar(1)+c)*Scalar(2));
|
||||
Scalar s = sqrt((Scalar(1)+c)*Scalar(2));
|
||||
Scalar invs = Scalar(1)/s;
|
||||
this->vec() = axis * invs;
|
||||
this->w() = s * Scalar(0.5);
|
||||
@@ -677,7 +680,8 @@ inline typename internal::traits<Derived>::Scalar
|
||||
QuaternionBase<Derived>::angularDistance(const QuaternionBase<OtherDerived>& other) const
|
||||
{
|
||||
using std::acos;
|
||||
double d = internal::abs(this->dot(other));
|
||||
using std::abs;
|
||||
double d = abs(this->dot(other));
|
||||
if (d>=1.0)
|
||||
return Scalar(0);
|
||||
return static_cast<Scalar>(2 * acos(d));
|
||||
@@ -692,9 +696,11 @@ Quaternion<typename internal::traits<Derived>::Scalar>
|
||||
QuaternionBase<Derived>::slerp(Scalar t, const QuaternionBase<OtherDerived>& other) const
|
||||
{
|
||||
using std::acos;
|
||||
using std::sin;
|
||||
using std::abs;
|
||||
static const Scalar one = Scalar(1) - NumTraits<Scalar>::epsilon();
|
||||
Scalar d = this->dot(other);
|
||||
Scalar absD = internal::abs(d);
|
||||
Scalar absD = abs(d);
|
||||
|
||||
Scalar scale0;
|
||||
Scalar scale1;
|
||||
@@ -708,10 +714,10 @@ QuaternionBase<Derived>::slerp(Scalar t, const QuaternionBase<OtherDerived>& oth
|
||||
{
|
||||
// theta is the angle between the 2 quaternions
|
||||
Scalar theta = acos(absD);
|
||||
Scalar sinTheta = internal::sin(theta);
|
||||
Scalar sinTheta = sin(theta);
|
||||
|
||||
scale0 = internal::sin( ( Scalar(1) - t ) * theta) / sinTheta;
|
||||
scale1 = internal::sin( ( t * theta) ) / sinTheta;
|
||||
scale0 = sin( ( Scalar(1) - t ) * theta) / sinTheta;
|
||||
scale1 = sin( ( t * theta) ) / sinTheta;
|
||||
}
|
||||
if(d<0) scale1 = -scale1;
|
||||
|
||||
@@ -728,6 +734,7 @@ struct quaternionbase_assign_impl<Other,3,3>
|
||||
typedef DenseIndex Index;
|
||||
template<class Derived> static inline void run(QuaternionBase<Derived>& q, const Other& mat)
|
||||
{
|
||||
using std::sqrt;
|
||||
// This algorithm comes from "Quaternion Calculus and Fast Animation",
|
||||
// Ken Shoemake, 1987 SIGGRAPH course notes
|
||||
Scalar t = mat.trace();
|
||||
|
||||
@@ -133,8 +133,9 @@ template<typename Scalar>
|
||||
template<typename Derived>
|
||||
Rotation2D<Scalar>& Rotation2D<Scalar>::fromRotationMatrix(const MatrixBase<Derived>& mat)
|
||||
{
|
||||
using std::atan2;
|
||||
EIGEN_STATIC_ASSERT(Derived::RowsAtCompileTime==2 && Derived::ColsAtCompileTime==2,YOU_MADE_A_PROGRAMMING_MISTAKE)
|
||||
m_angle = internal::atan2(mat.coeff(1,0), mat.coeff(0,0));
|
||||
m_angle = atan2(mat.coeff(1,0), mat.coeff(0,0));
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -144,8 +145,10 @@ template<typename Scalar>
|
||||
typename Rotation2D<Scalar>::Matrix2
|
||||
Rotation2D<Scalar>::toRotationMatrix(void) const
|
||||
{
|
||||
Scalar sinA = internal::sin(m_angle);
|
||||
Scalar cosA = internal::cos(m_angle);
|
||||
using std::sin;
|
||||
using std::cos;
|
||||
Scalar sinA = sin(m_angle);
|
||||
Scalar cosA = cos(m_angle);
|
||||
return (Matrix2() << cosA, -sinA, sinA, cosA).finished();
|
||||
}
|
||||
|
||||
|
||||
@@ -67,6 +67,9 @@ void MatrixBase<Derived>::makeHouseholder(
|
||||
Scalar& tau,
|
||||
RealScalar& beta) const
|
||||
{
|
||||
using std::sqrt;
|
||||
using internal::conj;
|
||||
|
||||
EIGEN_STATIC_ASSERT_VECTOR_ONLY(EssentialPart)
|
||||
VectorBlock<const Derived, EssentialPart::SizeAtCompileTime> tail(derived(), 1, size()-1);
|
||||
|
||||
@@ -81,11 +84,11 @@ void MatrixBase<Derived>::makeHouseholder(
|
||||
}
|
||||
else
|
||||
{
|
||||
beta = internal::sqrt(internal::abs2(c0) + tailSqNorm);
|
||||
beta = sqrt(internal::abs2(c0) + tailSqNorm);
|
||||
if (internal::real(c0)>=RealScalar(0))
|
||||
beta = -beta;
|
||||
essential = tail / (c0 - beta);
|
||||
tau = internal::conj((beta - c0) / beta);
|
||||
tau = conj((beta - c0) / beta);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -50,15 +50,16 @@ template<typename Scalar> class JacobiRotation
|
||||
/** Concatenates two planar rotation */
|
||||
JacobiRotation operator*(const JacobiRotation& other)
|
||||
{
|
||||
return JacobiRotation(m_c * other.m_c - internal::conj(m_s) * other.m_s,
|
||||
internal::conj(m_c * internal::conj(other.m_s) + internal::conj(m_s) * internal::conj(other.m_c)));
|
||||
using internal::conj;
|
||||
return JacobiRotation(m_c * other.m_c - conj(m_s) * other.m_s,
|
||||
conj(m_c * conj(other.m_s) + conj(m_s) * conj(other.m_c)));
|
||||
}
|
||||
|
||||
/** Returns the transposed transformation */
|
||||
JacobiRotation transpose() const { return JacobiRotation(m_c, -internal::conj(m_s)); }
|
||||
JacobiRotation transpose() const { using internal::conj; return JacobiRotation(m_c, -conj(m_s)); }
|
||||
|
||||
/** Returns the adjoint transformation */
|
||||
JacobiRotation adjoint() const { return JacobiRotation(internal::conj(m_c), -m_s); }
|
||||
JacobiRotation adjoint() const { using internal::conj; return JacobiRotation(conj(m_c), -m_s); }
|
||||
|
||||
template<typename Derived>
|
||||
bool makeJacobi(const MatrixBase<Derived>&, typename Derived::Index p, typename Derived::Index q);
|
||||
@@ -81,6 +82,8 @@ template<typename Scalar> class JacobiRotation
|
||||
template<typename Scalar>
|
||||
bool JacobiRotation<Scalar>::makeJacobi(RealScalar x, Scalar y, RealScalar z)
|
||||
{
|
||||
using std::sqrt;
|
||||
using std::abs;
|
||||
typedef typename NumTraits<Scalar>::Real RealScalar;
|
||||
if(y == Scalar(0))
|
||||
{
|
||||
@@ -90,8 +93,8 @@ bool JacobiRotation<Scalar>::makeJacobi(RealScalar x, Scalar y, RealScalar z)
|
||||
}
|
||||
else
|
||||
{
|
||||
RealScalar tau = (x-z)/(RealScalar(2)*internal::abs(y));
|
||||
RealScalar w = internal::sqrt(internal::abs2(tau) + RealScalar(1));
|
||||
RealScalar tau = (x-z)/(RealScalar(2)*abs(y));
|
||||
RealScalar w = sqrt(internal::abs2(tau) + RealScalar(1));
|
||||
RealScalar t;
|
||||
if(tau>RealScalar(0))
|
||||
{
|
||||
@@ -102,8 +105,8 @@ bool JacobiRotation<Scalar>::makeJacobi(RealScalar x, Scalar y, RealScalar z)
|
||||
t = RealScalar(1) / (tau - w);
|
||||
}
|
||||
RealScalar sign_t = t > RealScalar(0) ? RealScalar(1) : RealScalar(-1);
|
||||
RealScalar n = RealScalar(1) / internal::sqrt(internal::abs2(t)+RealScalar(1));
|
||||
m_s = - sign_t * (internal::conj(y) / internal::abs(y)) * internal::abs(t) * n;
|
||||
RealScalar n = RealScalar(1) / sqrt(internal::abs2(t)+RealScalar(1));
|
||||
m_s = - sign_t * (internal::conj(y) / abs(y)) * abs(t) * n;
|
||||
m_c = n;
|
||||
return true;
|
||||
}
|
||||
@@ -152,6 +155,10 @@ void JacobiRotation<Scalar>::makeGivens(const Scalar& p, const Scalar& q, Scalar
|
||||
template<typename Scalar>
|
||||
void JacobiRotation<Scalar>::makeGivens(const Scalar& p, const Scalar& q, Scalar* r, internal::true_type)
|
||||
{
|
||||
using std::sqrt;
|
||||
using std::abs;
|
||||
using internal::conj;
|
||||
|
||||
if(q==Scalar(0))
|
||||
{
|
||||
m_c = internal::real(p)<0 ? Scalar(-1) : Scalar(1);
|
||||
@@ -161,8 +168,8 @@ void JacobiRotation<Scalar>::makeGivens(const Scalar& p, const Scalar& q, Scalar
|
||||
else if(p==Scalar(0))
|
||||
{
|
||||
m_c = 0;
|
||||
m_s = -q/internal::abs(q);
|
||||
if(r) *r = internal::abs(q);
|
||||
m_s = -q/abs(q);
|
||||
if(r) *r = abs(q);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -175,12 +182,12 @@ void JacobiRotation<Scalar>::makeGivens(const Scalar& p, const Scalar& q, Scalar
|
||||
Scalar qs = q / p1;
|
||||
RealScalar q2 = internal::abs2(qs);
|
||||
|
||||
RealScalar u = internal::sqrt(RealScalar(1) + q2/p2);
|
||||
RealScalar u = sqrt(RealScalar(1) + q2/p2);
|
||||
if(internal::real(p)<RealScalar(0))
|
||||
u = -u;
|
||||
|
||||
m_c = Scalar(1)/u;
|
||||
m_s = -qs*internal::conj(ps)*(m_c/p2);
|
||||
m_s = -qs*conj(ps)*(m_c/p2);
|
||||
if(r) *r = p * u;
|
||||
}
|
||||
else
|
||||
@@ -190,14 +197,14 @@ void JacobiRotation<Scalar>::makeGivens(const Scalar& p, const Scalar& q, Scalar
|
||||
Scalar qs = q / q1;
|
||||
RealScalar q2 = internal::abs2(qs);
|
||||
|
||||
RealScalar u = q1 * internal::sqrt(p2 + q2);
|
||||
RealScalar u = q1 * sqrt(p2 + q2);
|
||||
if(internal::real(p)<RealScalar(0))
|
||||
u = -u;
|
||||
|
||||
p1 = internal::abs(p);
|
||||
p1 = abs(p);
|
||||
ps = p/p1;
|
||||
m_c = p1/u;
|
||||
m_s = -internal::conj(ps) * (q/u);
|
||||
m_s = -conj(ps) * (q/u);
|
||||
if(r) *r = ps * u;
|
||||
}
|
||||
}
|
||||
@@ -207,22 +214,24 @@ void JacobiRotation<Scalar>::makeGivens(const Scalar& p, const Scalar& q, Scalar
|
||||
template<typename Scalar>
|
||||
void JacobiRotation<Scalar>::makeGivens(const Scalar& p, const Scalar& q, Scalar* r, internal::false_type)
|
||||
{
|
||||
using std::sqrt;
|
||||
using std::abs;
|
||||
if(q==Scalar(0))
|
||||
{
|
||||
m_c = p<Scalar(0) ? Scalar(-1) : Scalar(1);
|
||||
m_s = Scalar(0);
|
||||
if(r) *r = internal::abs(p);
|
||||
if(r) *r = abs(p);
|
||||
}
|
||||
else if(p==Scalar(0))
|
||||
{
|
||||
m_c = Scalar(0);
|
||||
m_s = q<Scalar(0) ? Scalar(1) : Scalar(-1);
|
||||
if(r) *r = internal::abs(q);
|
||||
if(r) *r = abs(q);
|
||||
}
|
||||
else if(internal::abs(p) > internal::abs(q))
|
||||
else if(abs(p) > abs(q))
|
||||
{
|
||||
Scalar t = q/p;
|
||||
Scalar u = internal::sqrt(Scalar(1) + internal::abs2(t));
|
||||
Scalar u = sqrt(Scalar(1) + internal::abs2(t));
|
||||
if(p<Scalar(0))
|
||||
u = -u;
|
||||
m_c = Scalar(1)/u;
|
||||
@@ -232,7 +241,7 @@ void JacobiRotation<Scalar>::makeGivens(const Scalar& p, const Scalar& q, Scalar
|
||||
else
|
||||
{
|
||||
Scalar t = p/q;
|
||||
Scalar u = internal::sqrt(Scalar(1) + internal::abs2(t));
|
||||
Scalar u = sqrt(Scalar(1) + internal::abs2(t));
|
||||
if(q<Scalar(0))
|
||||
u = -u;
|
||||
m_s = -Scalar(1)/u;
|
||||
|
||||
@@ -293,11 +293,12 @@ template<typename _MatrixType> class FullPivLU
|
||||
*/
|
||||
inline Index rank() const
|
||||
{
|
||||
using std::abs;
|
||||
eigen_assert(m_isInitialized && "LU is not initialized.");
|
||||
RealScalar premultiplied_threshold = internal::abs(m_maxpivot) * threshold();
|
||||
RealScalar premultiplied_threshold = abs(m_maxpivot) * threshold();
|
||||
Index result = 0;
|
||||
for(Index i = 0; i < m_nonzero_pivots; ++i)
|
||||
result += (internal::abs(m_lu.coeff(i,i)) > premultiplied_threshold);
|
||||
result += (abs(m_lu.coeff(i,i)) > premultiplied_threshold);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -547,6 +548,7 @@ struct kernel_retval<FullPivLU<_MatrixType> >
|
||||
|
||||
template<typename Dest> void evalTo(Dest& dst) const
|
||||
{
|
||||
using std::abs;
|
||||
const Index cols = dec().matrixLU().cols(), dimker = cols - rank();
|
||||
if(dimker == 0)
|
||||
{
|
||||
@@ -632,6 +634,7 @@ struct image_retval<FullPivLU<_MatrixType> >
|
||||
|
||||
template<typename Dest> void evalTo(Dest& dst) const
|
||||
{
|
||||
using std::abs;
|
||||
if(rank() == 0)
|
||||
{
|
||||
// The Image is just {0}, so it doesn't have a basis properly speaking, but let's
|
||||
|
||||
@@ -55,6 +55,7 @@ struct compute_inverse_and_det_with_check<MatrixType, ResultType, 1>
|
||||
bool& invertible
|
||||
)
|
||||
{
|
||||
using std::abs;
|
||||
determinant = matrix.coeff(0,0);
|
||||
invertible = abs(determinant) > absDeterminantThreshold;
|
||||
if(invertible) result.coeffRef(0,0) = typename ResultType::Scalar(1) / determinant;
|
||||
@@ -98,6 +99,7 @@ struct compute_inverse_and_det_with_check<MatrixType, ResultType, 2>
|
||||
bool& invertible
|
||||
)
|
||||
{
|
||||
using std::abs;
|
||||
typedef typename ResultType::Scalar Scalar;
|
||||
determinant = matrix.determinant();
|
||||
invertible = abs(determinant) > absDeterminantThreshold;
|
||||
@@ -167,6 +169,7 @@ struct compute_inverse_and_det_with_check<MatrixType, ResultType, 3>
|
||||
bool& invertible
|
||||
)
|
||||
{
|
||||
using std::abs;
|
||||
typedef typename ResultType::Scalar Scalar;
|
||||
Matrix<Scalar,3,1> cofactors_col0;
|
||||
cofactors_col0.coeffRef(0) = cofactor_3x3<MatrixType,0,0>(matrix);
|
||||
@@ -251,6 +254,7 @@ struct compute_inverse_and_det_with_check<MatrixType, ResultType, 4>
|
||||
bool& invertible
|
||||
)
|
||||
{
|
||||
using std::abs;
|
||||
determinant = matrix.determinant();
|
||||
invertible = abs(determinant) > absDeterminantThreshold;
|
||||
if(invertible) compute_inverse<MatrixType, ResultType>::run(matrix, inverse);
|
||||
|
||||
@@ -181,11 +181,12 @@ template<typename _MatrixType> class ColPivHouseholderQR
|
||||
*/
|
||||
inline Index rank() const
|
||||
{
|
||||
using std::abs;
|
||||
eigen_assert(m_isInitialized && "ColPivHouseholderQR is not initialized.");
|
||||
RealScalar premultiplied_threshold = internal::abs(m_maxpivot) * threshold();
|
||||
RealScalar premultiplied_threshold = abs(m_maxpivot) * threshold();
|
||||
Index result = 0;
|
||||
for(Index i = 0; i < m_nonzero_pivots; ++i)
|
||||
result += (internal::abs(m_qr.coeff(i,i)) > premultiplied_threshold);
|
||||
result += (abs(m_qr.coeff(i,i)) > premultiplied_threshold);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -342,9 +343,10 @@ template<typename _MatrixType> class ColPivHouseholderQR
|
||||
template<typename MatrixType>
|
||||
typename MatrixType::RealScalar ColPivHouseholderQR<MatrixType>::absDeterminant() const
|
||||
{
|
||||
using std::abs;
|
||||
eigen_assert(m_isInitialized && "ColPivHouseholderQR is not initialized.");
|
||||
eigen_assert(m_qr.rows() == m_qr.cols() && "You can't take the determinant of a non-square matrix!");
|
||||
return internal::abs(m_qr.diagonal().prod());
|
||||
return abs(m_qr.diagonal().prod());
|
||||
}
|
||||
|
||||
template<typename MatrixType>
|
||||
@@ -358,6 +360,7 @@ typename MatrixType::RealScalar ColPivHouseholderQR<MatrixType>::logAbsDetermina
|
||||
template<typename MatrixType>
|
||||
ColPivHouseholderQR<MatrixType>& ColPivHouseholderQR<MatrixType>::compute(const MatrixType& matrix)
|
||||
{
|
||||
using std::abs;
|
||||
Index rows = matrix.rows();
|
||||
Index cols = matrix.cols();
|
||||
Index size = matrix.diagonalSize();
|
||||
@@ -426,7 +429,7 @@ ColPivHouseholderQR<MatrixType>& ColPivHouseholderQR<MatrixType>::compute(const
|
||||
m_qr.coeffRef(k,k) = beta;
|
||||
|
||||
// remember the maximum absolute value of diagonal coefficients
|
||||
if(internal::abs(beta) > m_maxpivot) m_maxpivot = internal::abs(beta);
|
||||
if(abs(beta) > m_maxpivot) m_maxpivot = abs(beta);
|
||||
|
||||
// apply the householder transformation
|
||||
m_qr.bottomRightCorner(rows-k, cols-k-1)
|
||||
|
||||
@@ -47,6 +47,7 @@ ColPivHouseholderQR<Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW, Dynamic, Dynami
|
||||
const Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW, Dynamic, Dynamic>& matrix) \
|
||||
\
|
||||
{ \
|
||||
using std::abs; \
|
||||
typedef Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW, Dynamic, Dynamic> MatrixType; \
|
||||
typedef MatrixType::Scalar Scalar; \
|
||||
typedef MatrixType::RealScalar RealScalar; \
|
||||
@@ -71,10 +72,10 @@ ColPivHouseholderQR<Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW, Dynamic, Dynami
|
||||
m_isInitialized = true; \
|
||||
m_maxpivot=m_qr.diagonal().cwiseAbs().maxCoeff(); \
|
||||
m_hCoeffs.adjointInPlace(); \
|
||||
RealScalar premultiplied_threshold = internal::abs(m_maxpivot) * threshold(); \
|
||||
RealScalar premultiplied_threshold = abs(m_maxpivot) * threshold(); \
|
||||
lapack_int *perm = m_colsPermutation.indices().data(); \
|
||||
for(i=0;i<size;i++) { \
|
||||
m_nonzero_pivots += (internal::abs(m_qr.coeff(i,i)) > premultiplied_threshold);\
|
||||
m_nonzero_pivots += (abs(m_qr.coeff(i,i)) > premultiplied_threshold);\
|
||||
} \
|
||||
for(i=0;i<cols;i++) perm[i]--;\
|
||||
\
|
||||
|
||||
@@ -201,11 +201,12 @@ template<typename _MatrixType> class FullPivHouseholderQR
|
||||
*/
|
||||
inline Index rank() const
|
||||
{
|
||||
using std::abs;
|
||||
eigen_assert(m_isInitialized && "FullPivHouseholderQR is not initialized.");
|
||||
RealScalar premultiplied_threshold = internal::abs(m_maxpivot) * threshold();
|
||||
RealScalar premultiplied_threshold = abs(m_maxpivot) * threshold();
|
||||
Index result = 0;
|
||||
for(Index i = 0; i < m_nonzero_pivots; ++i)
|
||||
result += (internal::abs(m_qr.coeff(i,i)) > premultiplied_threshold);
|
||||
result += (abs(m_qr.coeff(i,i)) > premultiplied_threshold);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -362,9 +363,10 @@ template<typename _MatrixType> class FullPivHouseholderQR
|
||||
template<typename MatrixType>
|
||||
typename MatrixType::RealScalar FullPivHouseholderQR<MatrixType>::absDeterminant() const
|
||||
{
|
||||
using std::abs;
|
||||
eigen_assert(m_isInitialized && "FullPivHouseholderQR is not initialized.");
|
||||
eigen_assert(m_qr.rows() == m_qr.cols() && "You can't take the determinant of a non-square matrix!");
|
||||
return internal::abs(m_qr.diagonal().prod());
|
||||
return abs(m_qr.diagonal().prod());
|
||||
}
|
||||
|
||||
template<typename MatrixType>
|
||||
@@ -378,6 +380,7 @@ typename MatrixType::RealScalar FullPivHouseholderQR<MatrixType>::logAbsDetermin
|
||||
template<typename MatrixType>
|
||||
FullPivHouseholderQR<MatrixType>& FullPivHouseholderQR<MatrixType>::compute(const MatrixType& matrix)
|
||||
{
|
||||
using std::abs;
|
||||
Index rows = matrix.rows();
|
||||
Index cols = matrix.cols();
|
||||
Index size = (std::min)(rows,cols);
|
||||
@@ -439,7 +442,7 @@ FullPivHouseholderQR<MatrixType>& FullPivHouseholderQR<MatrixType>::compute(cons
|
||||
m_qr.coeffRef(k,k) = beta;
|
||||
|
||||
// remember the maximum absolute value of diagonal coefficients
|
||||
if(internal::abs(beta) > m_maxpivot) m_maxpivot = internal::abs(beta);
|
||||
if(abs(beta) > m_maxpivot) m_maxpivot = abs(beta);
|
||||
|
||||
m_qr.bottomRightCorner(rows-k, cols-k-1)
|
||||
.applyHouseholderOnTheLeft(m_qr.col(k).tail(rows-k-1), m_hCoeffs.coeffRef(k), &m_temp.coeffRef(k+1));
|
||||
@@ -544,6 +547,7 @@ public:
|
||||
template <typename ResultType>
|
||||
void evalTo(ResultType& result, WorkVectorType& workspace) const
|
||||
{
|
||||
using internal::conj;
|
||||
// compute the product H'_0 H'_1 ... H'_n-1,
|
||||
// where H_k is the k-th Householder transformation I - h_k v_k v_k'
|
||||
// and v_k is the k-th Householder vector [1,m_qr(k+1,k), m_qr(k+2,k), ...]
|
||||
@@ -555,7 +559,7 @@ public:
|
||||
for (Index k = size-1; k >= 0; k--)
|
||||
{
|
||||
result.block(k, k, rows-k, rows-k)
|
||||
.applyHouseholderOnTheLeft(m_qr.col(k).tail(rows-k-1), internal::conj(m_hCoeffs.coeff(k)), &workspace.coeffRef(k));
|
||||
.applyHouseholderOnTheLeft(m_qr.col(k).tail(rows-k-1), conj(m_hCoeffs.coeff(k)), &workspace.coeffRef(k));
|
||||
result.row(k).swap(result.row(m_rowsTranspositions.coeff(k)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,9 +181,10 @@ template<typename _MatrixType> class HouseholderQR
|
||||
template<typename MatrixType>
|
||||
typename MatrixType::RealScalar HouseholderQR<MatrixType>::absDeterminant() const
|
||||
{
|
||||
using std::abs;
|
||||
eigen_assert(m_isInitialized && "HouseholderQR is not initialized.");
|
||||
eigen_assert(m_qr.rows() == m_qr.cols() && "You can't take the determinant of a non-square matrix!");
|
||||
return internal::abs(m_qr.diagonal().prod());
|
||||
return abs(m_qr.diagonal().prod());
|
||||
}
|
||||
|
||||
template<typename MatrixType>
|
||||
|
||||
@@ -359,6 +359,7 @@ struct svd_precondition_2x2_block_to_be_real<MatrixType, QRPreconditioner, true>
|
||||
typedef typename SVD::Index Index;
|
||||
static void run(typename SVD::WorkMatrixType& work_matrix, SVD& svd, Index p, Index q)
|
||||
{
|
||||
using std::sqrt;
|
||||
Scalar z;
|
||||
JacobiRotation<Scalar> rot;
|
||||
RealScalar n = sqrt(abs2(work_matrix.coeff(p,p)) + abs2(work_matrix.coeff(q,p)));
|
||||
@@ -398,6 +399,7 @@ void real_2x2_jacobi_svd(const MatrixType& matrix, Index p, Index q,
|
||||
JacobiRotation<RealScalar> *j_left,
|
||||
JacobiRotation<RealScalar> *j_right)
|
||||
{
|
||||
using std::sqrt;
|
||||
Matrix<RealScalar,2,2> m;
|
||||
m << real(matrix.coeff(p,p)), real(matrix.coeff(p,q)),
|
||||
real(matrix.coeff(q,p)), real(matrix.coeff(q,q));
|
||||
@@ -727,6 +729,7 @@ template<typename MatrixType, int QRPreconditioner>
|
||||
JacobiSVD<MatrixType, QRPreconditioner>&
|
||||
JacobiSVD<MatrixType, QRPreconditioner>::compute(const MatrixType& matrix, unsigned int computationOptions)
|
||||
{
|
||||
using std::abs;
|
||||
allocate(matrix.rows(), matrix.cols(), computationOptions);
|
||||
|
||||
// currently we stop when we reach precision 2*epsilon as the last bit of precision can require an unreasonable number of iterations,
|
||||
@@ -764,9 +767,9 @@ JacobiSVD<MatrixType, QRPreconditioner>::compute(const MatrixType& matrix, unsig
|
||||
// notice that this comparison will evaluate to false if any NaN is involved, ensuring that NaN's don't
|
||||
// keep us iterating forever. Similarly, small denormal numbers are considered zero.
|
||||
using std::max;
|
||||
RealScalar threshold = (max)(considerAsZero, precision * (max)(internal::abs(m_workMatrix.coeff(p,p)),
|
||||
internal::abs(m_workMatrix.coeff(q,q))));
|
||||
if((max)(internal::abs(m_workMatrix.coeff(p,q)),internal::abs(m_workMatrix.coeff(q,p))) > threshold)
|
||||
RealScalar threshold = (max)(considerAsZero, precision * (max)(abs(m_workMatrix.coeff(p,p)),
|
||||
abs(m_workMatrix.coeff(q,q))));
|
||||
if((max)(abs(m_workMatrix.coeff(p,q)),abs(m_workMatrix.coeff(q,p))) > threshold)
|
||||
{
|
||||
finished = false;
|
||||
|
||||
@@ -790,7 +793,7 @@ JacobiSVD<MatrixType, QRPreconditioner>::compute(const MatrixType& matrix, unsig
|
||||
|
||||
for(Index i = 0; i < m_diagSize; ++i)
|
||||
{
|
||||
RealScalar a = internal::abs(m_workMatrix.coeff(i,i));
|
||||
RealScalar a = abs(m_workMatrix.coeff(i,i));
|
||||
m_singularValues.coeffRef(i) = a;
|
||||
if(computeU() && (a!=RealScalar(0))) m_matrixU.col(i) *= m_workMatrix.coeff(i,i)/a;
|
||||
}
|
||||
|
||||
@@ -746,6 +746,8 @@ template<typename Derived>
|
||||
template<bool DoLDLT>
|
||||
void SimplicialCholeskyBase<Derived>::factorize_preordered(const CholMatrixType& ap)
|
||||
{
|
||||
using std::sqrt;
|
||||
|
||||
eigen_assert(m_analysisIsOk && "You must first call analyzePattern()");
|
||||
eigen_assert(ap.rows()==ap.cols());
|
||||
const Index size = ap.rows();
|
||||
@@ -830,7 +832,7 @@ void SimplicialCholeskyBase<Derived>::factorize_preordered(const CholMatrixType&
|
||||
ok = false; /* failure, matrix is not positive definite */
|
||||
break;
|
||||
}
|
||||
Lx[p] = internal::sqrt(d) ;
|
||||
Lx[p] = sqrt(d) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -291,6 +291,7 @@ class AmbiVector<_Scalar,_Index>::Iterator
|
||||
Iterator(const AmbiVector& vec, RealScalar epsilon = 0)
|
||||
: m_vector(vec)
|
||||
{
|
||||
using std::abs;
|
||||
m_epsilon = epsilon;
|
||||
m_isDense = m_vector.m_mode==IsDense;
|
||||
if (m_isDense)
|
||||
@@ -304,7 +305,7 @@ class AmbiVector<_Scalar,_Index>::Iterator
|
||||
{
|
||||
ListEl* EIGEN_RESTRICT llElements = reinterpret_cast<ListEl*>(m_vector.m_buffer);
|
||||
m_currentEl = m_vector.m_llStart;
|
||||
while (m_currentEl>=0 && internal::abs(llElements[m_currentEl].value)<=m_epsilon)
|
||||
while (m_currentEl>=0 && abs(llElements[m_currentEl].value)<=m_epsilon)
|
||||
m_currentEl = llElements[m_currentEl].next;
|
||||
if (m_currentEl<0)
|
||||
{
|
||||
@@ -326,11 +327,12 @@ class AmbiVector<_Scalar,_Index>::Iterator
|
||||
|
||||
Iterator& operator++()
|
||||
{
|
||||
using std::abs;
|
||||
if (m_isDense)
|
||||
{
|
||||
do {
|
||||
++m_cachedIndex;
|
||||
} while (m_cachedIndex<m_vector.m_end && internal::abs(m_vector.m_buffer[m_cachedIndex])<m_epsilon);
|
||||
} while (m_cachedIndex<m_vector.m_end && abs(m_vector.m_buffer[m_cachedIndex])<m_epsilon);
|
||||
if (m_cachedIndex<m_vector.m_end)
|
||||
m_cachedValue = m_vector.m_buffer[m_cachedIndex];
|
||||
else
|
||||
@@ -341,7 +343,7 @@ class AmbiVector<_Scalar,_Index>::Iterator
|
||||
ListEl* EIGEN_RESTRICT llElements = reinterpret_cast<ListEl*>(m_vector.m_buffer);
|
||||
do {
|
||||
m_currentEl = llElements[m_currentEl].next;
|
||||
} while (m_currentEl>=0 && internal::abs(llElements[m_currentEl].value)<m_epsilon);
|
||||
} while (m_currentEl>=0 && abs(llElements[m_currentEl].value)<m_epsilon);
|
||||
if (m_currentEl<0)
|
||||
{
|
||||
m_cachedIndex = -1;
|
||||
|
||||
@@ -86,7 +86,8 @@ template<typename Derived>
|
||||
inline typename NumTraits<typename internal::traits<Derived>::Scalar>::Real
|
||||
SparseMatrixBase<Derived>::norm() const
|
||||
{
|
||||
return internal::sqrt(squaredNorm());
|
||||
using std::sqrt;
|
||||
return sqrt(squaredNorm());
|
||||
}
|
||||
|
||||
} // end namespace Eigen
|
||||
|
||||
@@ -107,7 +107,8 @@ class SparseSparseProduct : internal::no_assignment_operator,
|
||||
|
||||
SparseSparseProduct pruned(const Scalar& reference = 0, const RealScalar& epsilon = NumTraits<RealScalar>::dummy_precision()) const
|
||||
{
|
||||
return SparseSparseProduct(m_lhs,m_rhs,internal::abs(reference)*epsilon);
|
||||
using std::abs;
|
||||
return SparseSparseProduct(m_lhs,m_rhs,abs(reference)*epsilon);
|
||||
}
|
||||
|
||||
template<typename Dest>
|
||||
|
||||
Reference in New Issue
Block a user