mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-04-22 17:49:36 +08:00
merge
This commit is contained in:
commit
dc2c103b3b
@ -14,7 +14,7 @@
|
||||
#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) { \
|
||||
(NAME)(const Eigen::ArrayBase<Derived>& x) { \
|
||||
return Eigen::CwiseUnaryOp<Eigen::internal::FUNCTOR<typename Derived::Scalar>, const Derived>(x.derived()); \
|
||||
}
|
||||
|
||||
|
@ -788,7 +788,7 @@ bool (isfinite)(const T& x)
|
||||
{
|
||||
#if EIGEN_HAS_CXX11_MATH
|
||||
using std::isfinite;
|
||||
return isfinite(x);
|
||||
return isfinite EIGEN_NOT_A_MACRO (x);
|
||||
#else
|
||||
return x<NumTraits<T>::highest() && x>NumTraits<T>::lowest();
|
||||
#endif
|
||||
@ -800,7 +800,7 @@ bool (isnan)(const T& x)
|
||||
{
|
||||
#if EIGEN_HAS_CXX11_MATH
|
||||
using std::isnan;
|
||||
return isnan(x);
|
||||
return isnan EIGEN_NOT_A_MACRO (x);
|
||||
#else
|
||||
return x != x;
|
||||
#endif
|
||||
@ -812,7 +812,7 @@ bool (isinf)(const T& x)
|
||||
{
|
||||
#if EIGEN_HAS_CXX11_MATH
|
||||
using std::isinf;
|
||||
return isinf(x);
|
||||
return isinf EIGEN_NOT_A_MACRO (x);
|
||||
#else
|
||||
return x>NumTraits<T>::highest() || x<NumTraits<T>::lowest();
|
||||
#endif
|
||||
@ -821,19 +821,19 @@ bool (isinf)(const T& x)
|
||||
template<typename T>
|
||||
bool (isfinite)(const std::complex<T>& x)
|
||||
{
|
||||
return numext::isfinite(numext::real(x)) && numext::isfinite(numext::imag(x));
|
||||
return (numext::isfinite)(numext::real(x)) && (numext::isfinite)(numext::imag(x));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool (isnan)(const std::complex<T>& x)
|
||||
{
|
||||
return numext::isnan(numext::real(x)) || numext::isnan(numext::imag(x));
|
||||
return (numext::isnan)(numext::real(x)) || (numext::isnan)(numext::imag(x));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool (isinf)(const std::complex<T>& x)
|
||||
{
|
||||
return (numext::isinf(numext::real(x)) || numext::isinf(numext::imag(x))) && (!numext::isnan(x));
|
||||
return ((numext::isinf)(numext::real(x)) || (numext::isinf)(numext::imag(x))) && (!(numext::isnan)(x));
|
||||
}
|
||||
|
||||
template<typename Scalar>
|
||||
|
@ -591,7 +591,7 @@ struct functor_traits<scalar_ceil_op<Scalar> >
|
||||
template<typename Scalar> struct scalar_isnan_op {
|
||||
EIGEN_EMPTY_STRUCT_CTOR(scalar_isnan_op)
|
||||
typedef bool result_type;
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE result_type operator() (const Scalar& a) const { return numext::isnan(a); }
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE result_type operator() (const Scalar& a) const { return (numext::isnan)(a); }
|
||||
};
|
||||
template<typename Scalar>
|
||||
struct functor_traits<scalar_isnan_op<Scalar> >
|
||||
@ -609,7 +609,7 @@ struct functor_traits<scalar_isnan_op<Scalar> >
|
||||
template<typename Scalar> struct scalar_isinf_op {
|
||||
EIGEN_EMPTY_STRUCT_CTOR(scalar_isinf_op)
|
||||
typedef bool result_type;
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE result_type operator() (const Scalar& a) const { return numext::isinf(a); }
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE result_type operator() (const Scalar& a) const { return (numext::isinf)(a); }
|
||||
};
|
||||
template<typename Scalar>
|
||||
struct functor_traits<scalar_isinf_op<Scalar> >
|
||||
@ -627,7 +627,7 @@ struct functor_traits<scalar_isinf_op<Scalar> >
|
||||
template<typename Scalar> struct scalar_isfinite_op {
|
||||
EIGEN_EMPTY_STRUCT_CTOR(scalar_isfinite_op)
|
||||
typedef bool result_type;
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE result_type operator() (const Scalar& a) const { return numext::isfinite(a); }
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE result_type operator() (const Scalar& a) const { return (numext::isfinite)(a); }
|
||||
};
|
||||
template<typename Scalar>
|
||||
struct functor_traits<scalar_isfinite_op<Scalar> >
|
||||
|
@ -370,6 +370,15 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Does the compiler support proper C++11 containers?
|
||||
#ifndef EIGEN_HAS_CXX11_CONTAINERS
|
||||
#if ((__cplusplus >= 201103L) && (EIGEN_COMP_GNUC_STRICT || EIGEN_COMP_CLANG)) || EIGEN_COMP_MSVC >= 1900
|
||||
#define EIGEN_HAS_CXX11_CONTAINERS 1
|
||||
#else
|
||||
#define EIGEN_HAS_CXX11_CONTAINERS 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/** Allows to disable some optimizations which might affect the accuracy of the result.
|
||||
* Such optimization are enabled by default, and set EIGEN_FAST_MATH to 0 to disable them.
|
||||
* They currently include:
|
||||
|
@ -399,7 +399,7 @@ EigenSolver<MatrixType>::compute(const MatrixType& matrix, bool computeEigenvect
|
||||
if (i == matrix.cols() - 1 || m_matT.coeff(i+1, i) == Scalar(0))
|
||||
{
|
||||
m_eivalues.coeffRef(i) = m_matT.coeff(i, i);
|
||||
if(!isfinite(m_eivalues.coeffRef(i)))
|
||||
if(!(isfinite)(m_eivalues.coeffRef(i)))
|
||||
{
|
||||
m_isInitialized = true;
|
||||
m_eigenvectorsOk = false;
|
||||
@ -426,7 +426,7 @@ EigenSolver<MatrixType>::compute(const MatrixType& matrix, bool computeEigenvect
|
||||
|
||||
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);
|
||||
if(!(isfinite(m_eivalues.coeffRef(i)) && isfinite(m_eivalues.coeffRef(i+1))))
|
||||
if(!((isfinite)(m_eivalues.coeffRef(i)) && (isfinite)(m_eivalues.coeffRef(i+1))))
|
||||
{
|
||||
m_isInitialized = true;
|
||||
m_eigenvectorsOk = false;
|
||||
|
@ -53,7 +53,7 @@ namespace std \
|
||||
}
|
||||
|
||||
// check whether we really need the std::deque specialization
|
||||
#if !(defined(_GLIBCXX_DEQUE) && (!EIGEN_GNUC_AT_LEAST(4,1))) /* Note that before gcc-4.1 we already have: std::deque::resize(size_type,const T&). */
|
||||
#if !EIGEN_HAS_CXX11_CONTAINERS && !(defined(_GLIBCXX_DEQUE) && (!EIGEN_GNUC_AT_LEAST(4,1))) /* Note that before gcc-4.1 we already have: std::deque::resize(size_type,const T&). */
|
||||
|
||||
namespace std {
|
||||
|
||||
|
@ -51,8 +51,8 @@ namespace std \
|
||||
}; \
|
||||
}
|
||||
|
||||
// check whether we really need the std::vector specialization
|
||||
#if !(defined(_GLIBCXX_VECTOR) && (!EIGEN_GNUC_AT_LEAST(4,1))) /* Note that before gcc-4.1 we already have: std::list::resize(size_type,const T&). */
|
||||
// check whether we really need the std::list specialization
|
||||
#if !EIGEN_HAS_CXX11_CONTAINERS && !(defined(_GLIBCXX_LIST) && (!EIGEN_GNUC_AT_LEAST(4,1))) /* Note that before gcc-4.1 we already have: std::list::resize(size_type,const T&). */
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
@ -44,6 +44,9 @@ namespace std \
|
||||
}; \
|
||||
}
|
||||
|
||||
// Don't specialize if containers are implemented according to C++11
|
||||
#if !EIGEN_HAS_CXX11_CONTAINERS
|
||||
|
||||
namespace std {
|
||||
|
||||
#define EIGEN_STD_VECTOR_SPECIALIZATION_BODY \
|
||||
@ -122,5 +125,7 @@ namespace std {
|
||||
#endif
|
||||
};
|
||||
}
|
||||
#endif // !EIGEN_HAS_CXX11_CONTAINERS
|
||||
|
||||
|
||||
#endif // EIGEN_STDVECTOR_H
|
||||
|
@ -367,23 +367,15 @@ macro(ei_get_compilerver VAR)
|
||||
# on all other system we rely on ${CMAKE_CXX_COMPILER}
|
||||
# supporting a "--version" or "/version" flag
|
||||
|
||||
if(WIN32 AND NOT CYGWIN AND NOT MINGW)
|
||||
if(WIN32 AND ${CMAKE_CXX_COMPILER_ID} EQUAL "Intel")
|
||||
set(EIGEN_CXX_FLAG_VERSION "/version")
|
||||
else()
|
||||
set(EIGEN_CXX_FLAG_VERSION "--version")
|
||||
endif()
|
||||
|
||||
# check whether the head command exists
|
||||
find_program(HEAD_EXE head NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_PATH NO_CMAKE_SYSTEM_PATH)
|
||||
if(HEAD_EXE)
|
||||
execute_process(COMMAND ${CMAKE_CXX_COMPILER} ${EIGEN_CXX_FLAG_VERSION}
|
||||
COMMAND head -n 1
|
||||
OUTPUT_VARIABLE eigen_cxx_compiler_version_string OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
else()
|
||||
execute_process(COMMAND ${CMAKE_CXX_COMPILER} ${EIGEN_CXX_FLAG_VERSION}
|
||||
OUTPUT_VARIABLE eigen_cxx_compiler_version_string OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
string(REGEX REPLACE "[\n\r].*" "" eigen_cxx_compiler_version_string ${eigen_cxx_compiler_version_string})
|
||||
endif()
|
||||
|
||||
ei_get_compilerver_from_cxx_version_string("${eigen_cxx_compiler_version_string}" CNAME CVER)
|
||||
set(${VAR} "${CNAME}-${CVER}")
|
||||
|
@ -8,7 +8,7 @@ Some Eigen's algorithms can exploit the multiple cores present in your hardware.
|
||||
* GCC: \c -fopenmp
|
||||
* ICC: \c -openmp
|
||||
* MSVC: check the respective option in the build properties.
|
||||
You can control the number of thread that will be used using either the OpenMP API or Eiegn's API using the following priority:
|
||||
You can control the number of thread that will be used using either the OpenMP API or Eigen's API using the following priority:
|
||||
\code
|
||||
OMP_NUM_THREADS=n ./my_program
|
||||
omp_set_num_threads(n);
|
||||
|
@ -221,9 +221,9 @@ template<typename ArrayType> void array_real(const ArrayType& m)
|
||||
VERIFY_IS_APPROX(m1.round(), round(m1));
|
||||
VERIFY_IS_APPROX(m1.floor(), floor(m1));
|
||||
VERIFY_IS_APPROX(m1.ceil(), ceil(m1));
|
||||
VERIFY((m1.isNaN() == Eigen::isnan(m1)).all());
|
||||
VERIFY((m1.isInf() == Eigen::isinf(m1)).all());
|
||||
VERIFY((m1.isFinite() == Eigen::isfinite(m1)).all());
|
||||
VERIFY((m1.isNaN() == (Eigen::isnan)(m1)).all());
|
||||
VERIFY((m1.isInf() == (Eigen::isinf)(m1)).all());
|
||||
VERIFY((m1.isFinite() == (Eigen::isfinite)(m1)).all());
|
||||
VERIFY_IS_APPROX(m1.inverse(), inverse(m1));
|
||||
VERIFY_IS_APPROX(m1.abs(), abs(m1));
|
||||
VERIFY_IS_APPROX(m1.abs2(), abs2(m1));
|
||||
@ -249,9 +249,9 @@ template<typename ArrayType> void array_real(const ArrayType& m)
|
||||
VERIFY_IS_APPROX(tanh(m1), (0.5*(exp(m1)-exp(-m1)))/(0.5*(exp(m1)+exp(-m1))));
|
||||
VERIFY_IS_APPROX(arg(m1), ((ArrayType)(m1<0))*std::acos(-1.0));
|
||||
VERIFY((round(m1) <= ceil(m1) && round(m1) >= floor(m1)).all());
|
||||
VERIFY(Eigen::isnan((m1*0.0)/0.0).all());
|
||||
VERIFY(Eigen::isinf(m4/0.0).all());
|
||||
VERIFY((Eigen::isfinite(m1) && (!Eigen::isfinite(m1*0.0/0.0)) && (!Eigen::isfinite(m4/0.0))).all());
|
||||
VERIFY((Eigen::isnan)((m1*0.0)/0.0).all());
|
||||
VERIFY((Eigen::isinf)(m4/0.0).all());
|
||||
VERIFY(((Eigen::isfinite)(m1) && (!(Eigen::isfinite)(m1*0.0/0.0)) && (!(Eigen::isfinite)(m4/0.0))).all());
|
||||
VERIFY_IS_APPROX(inverse(inverse(m1)),m1);
|
||||
VERIFY((abs(m1) == m1 || abs(m1) == -m1).all());
|
||||
VERIFY_IS_APPROX(m3, sqrt(abs2(m1)));
|
||||
@ -336,9 +336,9 @@ template<typename ArrayType> void array_complex(const ArrayType& m)
|
||||
VERIFY_IS_APPROX(m1.cosh(), cosh(m1));
|
||||
VERIFY_IS_APPROX(m1.tanh(), tanh(m1));
|
||||
VERIFY_IS_APPROX(m1.arg(), arg(m1));
|
||||
VERIFY((m1.isNaN() == Eigen::isnan(m1)).all());
|
||||
VERIFY((m1.isInf() == Eigen::isinf(m1)).all());
|
||||
VERIFY((m1.isFinite() == Eigen::isfinite(m1)).all());
|
||||
VERIFY((m1.isNaN() == (Eigen::isnan)(m1)).all());
|
||||
VERIFY((m1.isInf() == (Eigen::isinf)(m1)).all());
|
||||
VERIFY((m1.isFinite() == (Eigen::isfinite)(m1)).all());
|
||||
VERIFY_IS_APPROX(m1.inverse(), inverse(m1));
|
||||
VERIFY_IS_APPROX(m1.log(), log(m1));
|
||||
VERIFY_IS_APPROX(m1.log10(), log10(m1));
|
||||
@ -364,20 +364,20 @@ template<typename ArrayType> void array_complex(const ArrayType& m)
|
||||
VERIFY_IS_APPROX(arg(m1), m3);
|
||||
|
||||
std::complex<RealScalar> zero(0.0,0.0);
|
||||
VERIFY(Eigen::isnan(m1*zero/zero).all());
|
||||
VERIFY((Eigen::isnan)(m1*zero/zero).all());
|
||||
#if EIGEN_COMP_CLANG
|
||||
// clang's complex division is notoriously broken
|
||||
if(numext::isinf(m4(0,0)/RealScalar(0))) {
|
||||
if((numext::isinf)(m4(0,0)/RealScalar(0))) {
|
||||
#endif
|
||||
VERIFY(Eigen::isinf(m4/zero).all());
|
||||
VERIFY((Eigen::isinf)(m4/zero).all());
|
||||
#if EIGEN_COMP_CLANG
|
||||
}
|
||||
else
|
||||
{
|
||||
VERIFY(Eigen::isinf(m4.real()/zero.real()).all());
|
||||
VERIFY((Eigen::isinf)(m4.real()/zero.real()).all());
|
||||
}
|
||||
#endif
|
||||
VERIFY((Eigen::isfinite(m1) && (!Eigen::isfinite(m1*zero/zero)) && (!Eigen::isfinite(m1/zero))).all());
|
||||
VERIFY(((Eigen::isfinite)(m1) && (!(Eigen::isfinite)(m1*zero/zero)) && (!(Eigen::isfinite)(m1/zero))).all());
|
||||
|
||||
VERIFY_IS_APPROX(inverse(inverse(m1)),m1);
|
||||
VERIFY_IS_APPROX(conj(m1.conjugate()), m1);
|
||||
|
@ -55,6 +55,9 @@
|
||||
// compiler error.
|
||||
#define min(A,B) please_protect_your_min_with_parentheses
|
||||
#define max(A,B) please_protect_your_max_with_parentheses
|
||||
#define isnan(X) please_protect_your_isnan_with_parentheses
|
||||
#define isinf(X) please_protect_your_isinf_with_parentheses
|
||||
#define isfinite(X) please_protect_your_isfinite_with_parentheses
|
||||
|
||||
#define FORBIDDEN_IDENTIFIER (this_identifier_is_forbidden_to_avoid_clashes) this_identifier_is_forbidden_to_avoid_clashes
|
||||
// B0 is defined in POSIX header termios.h
|
||||
|
@ -318,7 +318,7 @@ template<typename Scalar> void packetmath_real()
|
||||
data1[1] = std::numeric_limits<Scalar>::epsilon();
|
||||
packet_helper<internal::packet_traits<Scalar>::HasExp,Packet> h;
|
||||
h.store(data2, internal::pexp(h.load(data1)));
|
||||
VERIFY(numext::isnan(data2[0]));
|
||||
VERIFY((numext::isnan)(data2[0]));
|
||||
VERIFY_IS_EQUAL(std::exp(std::numeric_limits<Scalar>::epsilon()), data2[1]);
|
||||
|
||||
data1[0] = -std::numeric_limits<Scalar>::epsilon();
|
||||
@ -354,34 +354,34 @@ template<typename Scalar> void packetmath_real()
|
||||
data1[1] = std::numeric_limits<Scalar>::epsilon();
|
||||
packet_helper<internal::packet_traits<Scalar>::HasLog,Packet> h;
|
||||
h.store(data2, internal::plog(h.load(data1)));
|
||||
VERIFY(std::isnan(data2[0]));
|
||||
VERIFY((numext::isnan)(data2[0]));
|
||||
// VERIFY_IS_EQUAL(std::log(std::numeric_limits<Scalar>::epsilon()), data2[1]);
|
||||
|
||||
data1[0] = -std::numeric_limits<Scalar>::epsilon();
|
||||
data1[1] = 0;
|
||||
h.store(data2, internal::plog(h.load(data1)));
|
||||
VERIFY(std::isnan(data2[0]));
|
||||
VERIFY((numext::isnan)(data2[0]));
|
||||
// VERIFY_IS_EQUAL(std::log(0), data2[1]);
|
||||
|
||||
data1[0] = (std::numeric_limits<Scalar>::min)();
|
||||
data1[1] = -(std::numeric_limits<Scalar>::min)();
|
||||
h.store(data2, internal::plog(h.load(data1)));
|
||||
VERIFY_IS_EQUAL(std::log((std::numeric_limits<Scalar>::min)()), data2[0]);
|
||||
// VERIFY(std::isnan(data2[1]));
|
||||
// VERIFY((numext::isnan)(data2[1]));
|
||||
|
||||
data1[0] = std::numeric_limits<Scalar>::denorm_min();
|
||||
data1[1] = -std::numeric_limits<Scalar>::denorm_min();
|
||||
h.store(data2, internal::plog(h.load(data1)));
|
||||
// VERIFY_IS_EQUAL(std::log(std::numeric_limits<Scalar>::denorm_min()), data2[0]);
|
||||
// VERIFY(std::isnan(data2[1]));
|
||||
// VERIFY((numext::isnan)(data2[1]));
|
||||
|
||||
data1[0] = -1.0f;
|
||||
h.store(data2, internal::plog(h.load(data1)));
|
||||
VERIFY(std::isnan(data2[0]));
|
||||
VERIFY((numext::isnan)(data2[0]));
|
||||
#if !EIGEN_FAST_MATH
|
||||
h.store(data2, internal::psqrt(h.load(data1)));
|
||||
VERIFY(numext::isnan(data2[0]));
|
||||
VERIFY(numext::isnan(data2[1]));
|
||||
VERIFY((numext::isnan)(data2[0]));
|
||||
VERIFY((numext::isnan)(data2[1]));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ template<typename MatrixType> void stable_norm(const MatrixType& m)
|
||||
&& "the stable norm algorithm cannot be guaranteed on this computer");
|
||||
|
||||
Scalar inf = std::numeric_limits<RealScalar>::infinity();
|
||||
if(NumTraits<Scalar>::IsComplex && numext::isnan(inf*RealScalar(1)) )
|
||||
if(NumTraits<Scalar>::IsComplex && (numext::isnan)(inf*RealScalar(1)) )
|
||||
{
|
||||
complex_real_product_ok = false;
|
||||
static bool first = true;
|
||||
@ -81,18 +81,18 @@ template<typename MatrixType> void stable_norm(const MatrixType& m)
|
||||
RealScalar size = static_cast<RealScalar>(m.size());
|
||||
|
||||
// test numext::isfinite
|
||||
VERIFY(!numext::isfinite( std::numeric_limits<RealScalar>::infinity()));
|
||||
VERIFY(!numext::isfinite(sqrt(-abs(big))));
|
||||
VERIFY(!(numext::isfinite)( std::numeric_limits<RealScalar>::infinity()));
|
||||
VERIFY(!(numext::isfinite)(sqrt(-abs(big))));
|
||||
|
||||
// test overflow
|
||||
VERIFY(numext::isfinite(sqrt(size)*abs(big)));
|
||||
VERIFY((numext::isfinite)(sqrt(size)*abs(big)));
|
||||
VERIFY_IS_NOT_APPROX(sqrt(copy(vbig.squaredNorm())), abs(sqrt(size)*big)); // here the default norm must fail
|
||||
VERIFY_IS_APPROX(vbig.stableNorm(), sqrt(size)*abs(big));
|
||||
VERIFY_IS_APPROX(vbig.blueNorm(), sqrt(size)*abs(big));
|
||||
VERIFY_IS_APPROX(vbig.hypotNorm(), sqrt(size)*abs(big));
|
||||
|
||||
// test underflow
|
||||
VERIFY(numext::isfinite(sqrt(size)*abs(small)));
|
||||
VERIFY((numext::isfinite)(sqrt(size)*abs(small)));
|
||||
VERIFY_IS_NOT_APPROX(sqrt(copy(vsmall.squaredNorm())), abs(sqrt(size)*small)); // here the default norm must fail
|
||||
VERIFY_IS_APPROX(vsmall.stableNorm(), sqrt(size)*abs(small));
|
||||
VERIFY_IS_APPROX(vsmall.blueNorm(), sqrt(size)*abs(small));
|
||||
@ -115,39 +115,39 @@ template<typename MatrixType> void stable_norm(const MatrixType& m)
|
||||
{
|
||||
v = vrand;
|
||||
v(i,j) = std::numeric_limits<RealScalar>::quiet_NaN();
|
||||
VERIFY(!numext::isfinite(v.squaredNorm())); VERIFY(numext::isnan(v.squaredNorm()));
|
||||
VERIFY(!numext::isfinite(v.norm())); VERIFY(numext::isnan(v.norm()));
|
||||
VERIFY(!numext::isfinite(v.stableNorm())); VERIFY(numext::isnan(v.stableNorm()));
|
||||
VERIFY(!numext::isfinite(v.blueNorm())); VERIFY(numext::isnan(v.blueNorm()));
|
||||
VERIFY(!numext::isfinite(v.hypotNorm())); VERIFY(numext::isnan(v.hypotNorm()));
|
||||
VERIFY(!(numext::isfinite)(v.squaredNorm())); VERIFY((numext::isnan)(v.squaredNorm()));
|
||||
VERIFY(!(numext::isfinite)(v.norm())); VERIFY((numext::isnan)(v.norm()));
|
||||
VERIFY(!(numext::isfinite)(v.stableNorm())); VERIFY((numext::isnan)(v.stableNorm()));
|
||||
VERIFY(!(numext::isfinite)(v.blueNorm())); VERIFY((numext::isnan)(v.blueNorm()));
|
||||
VERIFY(!(numext::isfinite)(v.hypotNorm())); VERIFY((numext::isnan)(v.hypotNorm()));
|
||||
}
|
||||
|
||||
// +inf
|
||||
{
|
||||
v = vrand;
|
||||
v(i,j) = std::numeric_limits<RealScalar>::infinity();
|
||||
VERIFY(!numext::isfinite(v.squaredNorm())); VERIFY(isPlusInf(v.squaredNorm()));
|
||||
VERIFY(!numext::isfinite(v.norm())); VERIFY(isPlusInf(v.norm()));
|
||||
VERIFY(!numext::isfinite(v.stableNorm()));
|
||||
VERIFY(!(numext::isfinite)(v.squaredNorm())); VERIFY(isPlusInf(v.squaredNorm()));
|
||||
VERIFY(!(numext::isfinite)(v.norm())); VERIFY(isPlusInf(v.norm()));
|
||||
VERIFY(!(numext::isfinite)(v.stableNorm()));
|
||||
if(complex_real_product_ok){
|
||||
VERIFY(isPlusInf(v.stableNorm()));
|
||||
}
|
||||
VERIFY(!numext::isfinite(v.blueNorm())); VERIFY(isPlusInf(v.blueNorm()));
|
||||
VERIFY(!numext::isfinite(v.hypotNorm())); VERIFY(isPlusInf(v.hypotNorm()));
|
||||
VERIFY(!(numext::isfinite)(v.blueNorm())); VERIFY(isPlusInf(v.blueNorm()));
|
||||
VERIFY(!(numext::isfinite)(v.hypotNorm())); VERIFY(isPlusInf(v.hypotNorm()));
|
||||
}
|
||||
|
||||
// -inf
|
||||
{
|
||||
v = vrand;
|
||||
v(i,j) = -std::numeric_limits<RealScalar>::infinity();
|
||||
VERIFY(!numext::isfinite(v.squaredNorm())); VERIFY(isPlusInf(v.squaredNorm()));
|
||||
VERIFY(!numext::isfinite(v.norm())); VERIFY(isPlusInf(v.norm()));
|
||||
VERIFY(!numext::isfinite(v.stableNorm()));
|
||||
VERIFY(!(numext::isfinite)(v.squaredNorm())); VERIFY(isPlusInf(v.squaredNorm()));
|
||||
VERIFY(!(numext::isfinite)(v.norm())); VERIFY(isPlusInf(v.norm()));
|
||||
VERIFY(!(numext::isfinite)(v.stableNorm()));
|
||||
if(complex_real_product_ok) {
|
||||
VERIFY(isPlusInf(v.stableNorm()));
|
||||
}
|
||||
VERIFY(!numext::isfinite(v.blueNorm())); VERIFY(isPlusInf(v.blueNorm()));
|
||||
VERIFY(!numext::isfinite(v.hypotNorm())); VERIFY(isPlusInf(v.hypotNorm()));
|
||||
VERIFY(!(numext::isfinite)(v.blueNorm())); VERIFY(isPlusInf(v.blueNorm()));
|
||||
VERIFY(!(numext::isfinite)(v.hypotNorm())); VERIFY(isPlusInf(v.hypotNorm()));
|
||||
}
|
||||
|
||||
// mix
|
||||
@ -157,11 +157,11 @@ template<typename MatrixType> void stable_norm(const MatrixType& m)
|
||||
v = vrand;
|
||||
v(i,j) = -std::numeric_limits<RealScalar>::infinity();
|
||||
v(i2,j2) = std::numeric_limits<RealScalar>::quiet_NaN();
|
||||
VERIFY(!numext::isfinite(v.squaredNorm())); VERIFY(numext::isnan(v.squaredNorm()));
|
||||
VERIFY(!numext::isfinite(v.norm())); VERIFY(numext::isnan(v.norm()));
|
||||
VERIFY(!numext::isfinite(v.stableNorm())); VERIFY(numext::isnan(v.stableNorm()));
|
||||
VERIFY(!numext::isfinite(v.blueNorm())); VERIFY(numext::isnan(v.blueNorm()));
|
||||
VERIFY(!numext::isfinite(v.hypotNorm())); VERIFY(numext::isnan(v.hypotNorm()));
|
||||
VERIFY(!(numext::isfinite)(v.squaredNorm())); VERIFY((numext::isnan)(v.squaredNorm()));
|
||||
VERIFY(!(numext::isfinite)(v.norm())); VERIFY((numext::isnan)(v.norm()));
|
||||
VERIFY(!(numext::isfinite)(v.stableNorm())); VERIFY((numext::isnan)(v.stableNorm()));
|
||||
VERIFY(!(numext::isfinite)(v.blueNorm())); VERIFY((numext::isnan)(v.blueNorm()));
|
||||
VERIFY(!(numext::isfinite)(v.hypotNorm())); VERIFY((numext::isnan)(v.hypotNorm()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -126,7 +126,7 @@ static void test_contraction_corner_cases()
|
||||
m_result = m_left.transpose() * m_right;
|
||||
|
||||
for (ptrdiff_t i = 0; i < t_result.size(); i++) {
|
||||
assert(!std::isnan(t_result.data()[i]));
|
||||
assert(!(numext::isnan)(t_result.data()[i]));
|
||||
if (fabs(t_result.data()[i] - m_result.data()[i]) >= 1e-4) {
|
||||
std::cout << "mismatch detected at index " << i << " : " << t_result.data()[i] << " vs " << m_result.data()[i] << std::endl;
|
||||
assert(false);
|
||||
@ -141,7 +141,7 @@ static void test_contraction_corner_cases()
|
||||
new(&m_left) MapXf(t_left.data(), 32, 1);
|
||||
m_result = m_left.transpose() * m_right;
|
||||
for (ptrdiff_t i = 0; i < t_result.size(); i++) {
|
||||
assert(!std::isnan(t_result.data()[i]));
|
||||
assert(!(numext::isnan)(t_result.data()[i]));
|
||||
if (fabs(t_result.data()[i] - m_result.data()[i]) >= 1e-4) {
|
||||
std::cout << "mismatch detected: " << t_result.data()[i] << " vs " << m_result.data()[i] << std::endl;
|
||||
assert(false);
|
||||
@ -159,7 +159,7 @@ static void test_contraction_corner_cases()
|
||||
new(&m_right) MapXf(t_right.data(), 32, 4);
|
||||
m_result = m_left.transpose() * m_right;
|
||||
for (ptrdiff_t i = 0; i < t_result.size(); i++) {
|
||||
assert(!std::isnan(t_result.data()[i]));
|
||||
assert(!(numext::isnan)(t_result.data()[i]));
|
||||
if (fabs(t_result.data()[i] - m_result.data()[i]) >= 1e-4) {
|
||||
std::cout << "mismatch detected: " << t_result.data()[i] << " vs " << m_result.data()[i] << std::endl;
|
||||
assert(false);
|
||||
@ -177,7 +177,7 @@ static void test_contraction_corner_cases()
|
||||
new(&m_right) MapXf(t_right.data(), 32, 4);
|
||||
m_result = m_left.transpose() * m_right;
|
||||
for (ptrdiff_t i = 0; i < t_result.size(); i++) {
|
||||
assert(!std::isnan(t_result.data()[i]));
|
||||
assert(!(numext::isnan)(t_result.data()[i]));
|
||||
if (fabs(t_result.data()[i] - m_result.data()[i]) >= 1e-4) {
|
||||
std::cout << "mismatch detected: " << t_result.data()[i] << " vs " << m_result.data()[i] << std::endl;
|
||||
assert(false);
|
||||
|
@ -72,13 +72,13 @@
|
||||
|
||||
// Detect compiler using signatures from http://predef.sourceforge.net/
|
||||
#if defined(__GNUC__) && defined(__INTEL_COMPILER)
|
||||
#define IsInf(x) isinf(x) // Intel ICC compiler on Linux
|
||||
#define IsInf(x) (isinf)(x) // Intel ICC compiler on Linux
|
||||
|
||||
#elif defined(_MSC_VER) // Microsoft Visual C++
|
||||
#define IsInf(x) (!_finite(x))
|
||||
|
||||
#else
|
||||
#define IsInf(x) std::isinf(x) // GNU C/C++ (and/or other compilers), just hope for C99 conformance
|
||||
#define IsInf(x) (std::isinf)(x) // GNU C/C++ (and/or other compilers), just hope for C99 conformance
|
||||
#endif
|
||||
|
||||
// A Clang feature extension to determine compiler features.
|
||||
@ -530,9 +530,9 @@ public:
|
||||
#endif
|
||||
|
||||
// Instance Checkers
|
||||
friend bool isnan (const mpreal& v);
|
||||
friend bool isinf (const mpreal& v);
|
||||
friend bool isfinite (const mpreal& v);
|
||||
friend bool (isnan) (const mpreal& v);
|
||||
friend bool (isinf) (const mpreal& v);
|
||||
friend bool (isfinite) (const mpreal& v);
|
||||
|
||||
friend bool isnum (const mpreal& v);
|
||||
friend bool iszero (const mpreal& v);
|
||||
@ -1687,9 +1687,9 @@ inline bool operator == (const mpreal& a, const long double b ){ return
|
||||
inline bool operator == (const mpreal& a, const double b ){ return (mpfr_cmp_d (a.mpfr_srcptr(),b) == 0 ); }
|
||||
|
||||
|
||||
inline bool isnan (const mpreal& op){ return (mpfr_nan_p (op.mpfr_srcptr()) != 0 ); }
|
||||
inline bool isinf (const mpreal& op){ return (mpfr_inf_p (op.mpfr_srcptr()) != 0 ); }
|
||||
inline bool isfinite (const mpreal& op){ return (mpfr_number_p (op.mpfr_srcptr()) != 0 ); }
|
||||
inline bool (isnan) (const mpreal& op){ return (mpfr_nan_p (op.mpfr_srcptr()) != 0 ); }
|
||||
inline bool (isinf) (const mpreal& op){ return (mpfr_inf_p (op.mpfr_srcptr()) != 0 ); }
|
||||
inline bool (isfinite) (const mpreal& op){ return (mpfr_number_p (op.mpfr_srcptr()) != 0 ); }
|
||||
inline bool iszero (const mpreal& op){ return (mpfr_zero_p (op.mpfr_srcptr()) != 0 ); }
|
||||
inline bool isint (const mpreal& op){ return (mpfr_integer_p(op.mpfr_srcptr()) != 0 ); }
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user