mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Protect further isnan/isfinite/isinf calls
This commit is contained in:
@@ -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 ); }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user