From 30de359a406af68cf1ccb35d42bc8731ead8e622 Mon Sep 17 00:00:00 2001 From: Mark Abraham Date: Sat, 12 Mar 2016 15:29:42 +0100 Subject: [PATCH] Update use of isnan in linearalgebra In C++11, cmath now provides std::isnan, so we should use it. Change-Id: Id3c9f3103722c2ae94c93f09cea74a27852bcbc2 --- src/gromacs/linearalgebra/gmx_lapack/dlar1vx.cpp | 17 ++++------------- src/gromacs/linearalgebra/gmx_lapack/dlarrbx.cpp | 15 +++------------ src/gromacs/linearalgebra/gmx_lapack/dlarrex.cpp | 13 ++----------- src/gromacs/linearalgebra/gmx_lapack/dlarrfx.cpp | 13 ++----------- src/gromacs/linearalgebra/gmx_lapack/slar1vx.cpp | 17 ++++------------- src/gromacs/linearalgebra/gmx_lapack/slarrbx.cpp | 15 +++------------ src/gromacs/linearalgebra/gmx_lapack/slarrex.cpp | 13 ++----------- src/gromacs/linearalgebra/gmx_lapack/slarrfx.cpp | 13 ++----------- 8 files changed, 22 insertions(+), 94 deletions(-) diff --git a/src/gromacs/linearalgebra/gmx_lapack/dlar1vx.cpp b/src/gromacs/linearalgebra/gmx_lapack/dlar1vx.cpp index ad0704957f..f9e734d230 100644 --- a/src/gromacs/linearalgebra/gmx_lapack/dlar1vx.cpp +++ b/src/gromacs/linearalgebra/gmx_lapack/dlar1vx.cpp @@ -1,12 +1,3 @@ -#ifdef _MSC_VER -// MSVC does not provide isnan(), but it has _isnan() -# include -# define isnan _isnan -#else -// we borrow isnan from C since it is not in std:: until c++11 -# include -#endif - #include #include "gromacs/utility/real.h" @@ -100,12 +91,12 @@ L40: s = work[inds + i__] - *sigma; } - if (isnan(s)) { + if (std::isnan(s)) { sawnan = 1; j = *b1 + 1; L60: - if (!isnan(work[inds + j])) { + if (!std::isnan(work[inds + j])) { ++j; goto L60; } @@ -133,12 +124,12 @@ L60: work[indp + i__ - 1] = work[indp + i__] * tmp - *sigma; } tmp = work[indp + r1 - 1]; - if (isnan(tmp)) { + if (std::isnan(tmp)) { sawnan = 1; j = *bn - 3; L90: - if (!isnan(work[indp + j])) { + if (!std::isnan(work[indp + j])) { --j; goto L90; } diff --git a/src/gromacs/linearalgebra/gmx_lapack/dlarrbx.cpp b/src/gromacs/linearalgebra/gmx_lapack/dlarrbx.cpp index 7bd312cb6d..7bdb735a2d 100644 --- a/src/gromacs/linearalgebra/gmx_lapack/dlarrbx.cpp +++ b/src/gromacs/linearalgebra/gmx_lapack/dlarrbx.cpp @@ -1,12 +1,3 @@ -#ifdef _MSC_VER -// MSVC does not provide isnan(), but it has _isnan() -# include -# define isnan _isnan -#else -// we borrow isnan from C since it is not in std:: until c++11 -# include -#endif - #include #include "gromacs/utility/real.h" @@ -101,7 +92,7 @@ L40: if (dplus < 0.) { ++cnt; } - if (isnan(s)) { + if (std::isnan(s)) { cnt = 0; s = -left; @@ -148,7 +139,7 @@ L60: if (dplus < 0.) { ++cnt; } - if (isnan(s)) { + if (std::isnan(s)) { cnt = 0; s = -right; @@ -265,7 +256,7 @@ L80: if (dplus < 0.) { ++cnt; } - if (isnan(s)) { + if (std::isnan(s)) { cnt = 0; s = -mid; i__2 = *n - 1; diff --git a/src/gromacs/linearalgebra/gmx_lapack/dlarrex.cpp b/src/gromacs/linearalgebra/gmx_lapack/dlarrex.cpp index 6d4dfaca60..33f0a198dc 100644 --- a/src/gromacs/linearalgebra/gmx_lapack/dlarrex.cpp +++ b/src/gromacs/linearalgebra/gmx_lapack/dlarrex.cpp @@ -1,12 +1,3 @@ -#ifdef _MSC_VER -// MSVC does not provide isnan(), but it has _isnan() -# include -# define isnan _isnan -#else -// we borrow isnan from C since it is not in std:: until c++11 -# include -#endif - #include #include @@ -192,7 +183,7 @@ L60: } for (i__ = in; i__ >= 1; --i__) { tmp = sgndef * work[i__]; - if (tmp < 0. || std::abs(work[(in << 1) + i__])= 1; --i__) { tmp = sgndef * work[i__]; - if (tmp < 0. || std::abs(work[(in << 1) + i__]) -# define isnan _isnan -#else -// we borrow isnan from C since it is not in std:: until c++11 -# include -#endif - #include #include "gromacs/utility/real.h" @@ -62,7 +53,7 @@ L10: d__2 = dmax1, d__3 = std::abs(dplus[i__ + 1]); dmax1 = (d__2>d__3) ? d__2 : d__3; } - if (isnan(dmax1)) { + if (std::isnan(dmax1)) { *sigma -= std::abs(*sigma) * delta; delta *= 2.; goto L10; @@ -82,7 +73,7 @@ L30: d__2 = dmax2, d__3 = std::abs(work[i__ + 1]); dmax2 = (d__2>d__3) ? d__2 : d__3; } - if (isnan(dmax2)) { + if (std::isnan(dmax2)) { tmp += std::abs(tmp) * delta; delta *= 2.; goto L30; diff --git a/src/gromacs/linearalgebra/gmx_lapack/slar1vx.cpp b/src/gromacs/linearalgebra/gmx_lapack/slar1vx.cpp index 8c6f9318db..046524b248 100644 --- a/src/gromacs/linearalgebra/gmx_lapack/slar1vx.cpp +++ b/src/gromacs/linearalgebra/gmx_lapack/slar1vx.cpp @@ -1,12 +1,3 @@ -#ifdef _MSC_VER -// MSVC does not provide isnan(), but it has _isnan() -# include -# define isnan _isnan -#else -// we borrow isnan from C since it is not in std:: until c++11 -# include -#endif - #include #include "gromacs/utility/real.h" @@ -100,12 +91,12 @@ L40: s = work[inds + i__] - *sigma; } - if (isnan(s)) { + if (std::isnan(s)) { sawnan = 1; j = *b1 + 1; L60: - if (!isnan(work[inds + j])) { + if (!std::isnan(work[inds + j])) { ++j; goto L60; } @@ -133,12 +124,12 @@ L60: work[indp + i__ - 1] = work[indp + i__] * tmp - *sigma; } tmp = work[indp + r1 - 1]; - if (isnan(tmp)) { + if (std::isnan(tmp)) { sawnan = 1; j = *bn - 3; L90: - if (!isnan(work[indp + j])) { + if (!std::isnan(work[indp + j])) { --j; goto L90; } diff --git a/src/gromacs/linearalgebra/gmx_lapack/slarrbx.cpp b/src/gromacs/linearalgebra/gmx_lapack/slarrbx.cpp index 1dfe33300e..f03b658ab6 100644 --- a/src/gromacs/linearalgebra/gmx_lapack/slarrbx.cpp +++ b/src/gromacs/linearalgebra/gmx_lapack/slarrbx.cpp @@ -1,12 +1,3 @@ -#ifdef _MSC_VER -// MSVC does not provide isnan(), but it has _isnan() -# include -# define isnan _isnan -#else -// we borrow isnan from C since it is not in std:: until c++11 -# include -#endif - #include #include "gromacs/utility/real.h" @@ -101,7 +92,7 @@ L40: if (dplus < 0.) { ++cnt; } - if (isnan(s)) { + if (std::isnan(s)) { cnt = 0; s = -left; @@ -148,7 +139,7 @@ L60: if (dplus < 0.) { ++cnt; } - if (isnan(s)) { + if (std::isnan(s)) { cnt = 0; s = -right; @@ -265,7 +256,7 @@ L80: if (dplus < 0.) { ++cnt; } - if (isnan(s)) { + if (std::isnan(s)) { cnt = 0; s = -mid; i__2 = *n - 1; diff --git a/src/gromacs/linearalgebra/gmx_lapack/slarrex.cpp b/src/gromacs/linearalgebra/gmx_lapack/slarrex.cpp index bb64970a68..0f00faef48 100644 --- a/src/gromacs/linearalgebra/gmx_lapack/slarrex.cpp +++ b/src/gromacs/linearalgebra/gmx_lapack/slarrex.cpp @@ -1,12 +1,3 @@ -#ifdef _MSC_VER -// MSVC does not provide isnan(), but it has _isnan() -# include -# define isnan _isnan -#else -// we borrow isnan from C since it is not in std:: until c++11 -# include -#endif - #include #include @@ -192,7 +183,7 @@ L60: } for (i__ = in; i__ >= 1; --i__) { tmp = sgndef * work[i__]; - if (tmp < 0. || std::abs(work[(in << 1) + i__])= 1; --i__) { tmp = sgndef * work[i__]; - if (tmp < 0. || std::abs(work[(in << 1) + i__]) -# define isnan _isnan -#else -// we borrow isnan from C since it is not in std:: until c++11 -# include -#endif - #include #include "gromacs/utility/real.h" @@ -62,7 +53,7 @@ L10: d__2 = dmax1, d__3 = std::abs(dplus[i__ + 1]); dmax1 = (d__2>d__3) ? d__2 : d__3; } - if (isnan(dmax1)) { + if (std::isnan(dmax1)) { *sigma -= std::abs(*sigma) * delta; delta *= 2.; goto L10; @@ -82,7 +73,7 @@ L30: d__2 = dmax2, d__3 = std::abs(work[i__ + 1]); dmax2 = (d__2>d__3) ? d__2 : d__3; } - if (isnan(dmax2)) { + if (std::isnan(dmax2)) { tmp += std::abs(tmp) * delta; delta *= 2.; goto L30; -- 2.11.4.GIT