]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Detect whether std::isfinite is available.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Wed, 15 Mar 2006 20:41:24 +0000 (20:41 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Wed, 15 Mar 2006 20:41:24 +0000 (20:41 +0000)
git-svn-id: https://svn.dealii.org/trunk@12599 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/aclocal.m4
deal.II/base/include/base/config.h.in
deal.II/configure
deal.II/configure.in
deal.II/doc/news/changes.html

index 34360303aaffa294ce6eae458abd25445846347e..9349cdda25ca49dd1dc42f8b29f83b137040fd2c 100644 (file)
@@ -2174,6 +2174,41 @@ AC_DEFUN(DEAL_II_CHECK_ISNAN_FLAG, dnl
 
 
 
+dnl -------------------------------------------------------------
+dnl See if the isfinite function is available in namespace std
+dnl (this function is C99 and therefore not part of C++98, but
+dnl some implementations provide it nevertheless).
+dnl
+dnl Usage: DEAL_II_CHECK_ISFINITE
+dnl
+dnl -------------------------------------------------------------
+AC_DEFUN(DEAL_II_CHECK_ISFINITE, dnl
+[
+  AC_MSG_CHECKING(for std::isfinite)
+  AC_LANG(C++)
+  CXXFLAGS=$CXXFLAGSG
+  AC_TRY_COMPILE(
+    [
+#include <cmath>
+    ],
+    [
+       double d=0;
+       std::isfinite (d);
+    ],
+    [
+       AC_MSG_RESULT(yes)
+       AC_DEFINE(DEAL_II_HAVE_ISFINITE, 1,
+                  [Defined if std::isfinite is available])
+    ],
+    [
+        AC_MSG_RESULT(no)
+    ])
+])
+
+
+
+
+
 dnl -------------------------------------------------------------
 dnl rand_r is defined for some compiler flag combinations, but not for
 dnl others. check that. note that since these are C++ flags, we can't
index edb929fef63f19a627b14ac34ae32e5443ffa490..485ac968abe5f842f6329ce27257440a1fb76deb 100644 (file)
@@ -74,6 +74,9 @@
    aclocal.m4 in the top-level directory. */
 #undef DEAL_II_FUNPTR_TEMPLATE_TEMPLATE_BUG
 
+/* Defined if std::isfinite is available */
+#undef DEAL_II_HAVE_ISFINITE
+
 /* Flag indicating whether the library shall be compiled to use the NetCDF
    interface */
 #undef DEAL_II_HAVE_NETCDF
@@ -400,6 +403,14 @@ namespace deal_II_numbers {
                                               * 1/sqrt(2)
                                               */
   static const double  SQRT1_2 = 0.70710678118654752440;
+
+                                            /**
+                                             * Return @p true if the given
+                                             * value is a finite floating point
+                                             * number, i.e. is neither plus or
+                                             * minus infinity nor NaN (not a
+                                             * number).
+                                             */
+  bool is_finite (const double x);
 }
-#endif
 
index c470db4595963e624b569678b83128e30998b8e0..1755bb1c459335df6bbeb3cc0a16b25690b51de8 100755 (executable)
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.in Revision: 1.219 .
+# From configure.in Revision: 1.220 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.59 for deal.II 5.3.pre.
 #
@@ -8401,6 +8401,78 @@ echo "${ECHO_T}using $testflag" >&6
 
 
 
+  echo "$as_me:$LINENO: checking for std::isfinite" >&5
+echo $ECHO_N "checking for std::isfinite... $ECHO_C" >&6
+  ac_ext=cc
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+  CXXFLAGS=$CXXFLAGSG
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+#include <cmath>
+
+int
+main ()
+{
+
+       double d=0;
+       std::isfinite (d);
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+        { ac_try='test -z "$ac_cxx_werror_flag"
+                        || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+        { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+       echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+cat >>confdefs.h <<\_ACEOF
+#define DEAL_II_HAVE_ISFINITE 1
+_ACEOF
+
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+        echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+
+
   echo "$as_me:$LINENO: checking for rand_r" >&5
 echo $ECHO_N "checking for rand_r... $ECHO_C" >&6
   ac_ext=cc
index e7d96cd28324de0a6e343935c53d662c2847d71b..5e46b3a5e1b7a3fd406eea66320949f0972d7db3 100644 (file)
@@ -204,6 +204,7 @@ DEAL_II_CHECK_MIN_VECTOR_CAPACITY
 DEAL_II_CHECK_ABORT
 DEAL_II_CHECK_GETRUSAGE
 DEAL_II_CHECK_ISNAN
+DEAL_II_CHECK_ISFINITE
 DEAL_II_CHECK_RAND_R
 DEAL_II_CHECK_QUAD_DEFINE
 DEAL_II_CHECK_ERROR_CODES_DEFINITION
@@ -689,8 +690,16 @@ namespace deal_II_numbers {
                                               * 1/sqrt(2)
                                               */
   static const double  SQRT1_2 = 0.70710678118654752440;
+
+                                            /**
+                                             * Return @p true if the given
+                                             * value is a finite floating point
+                                             * number, i.e. is neither plus or
+                                             * minus infinity nor NaN (not a
+                                             * number).
+                                             */
+  bool is_finite (const double x);
 }
-#endif
 ])
 
 
index 8eb0ad7a3f6a7612b135992aaa23736bb5b8a683..5d6ed580506bd9c7013b454d194010059dc0f91a 100644 (file)
@@ -259,6 +259,14 @@ inconvenience this causes.
 
 <ol>
 
+  <li> <p> New: The new <code
+       class="member">deal_II_numbers::is_finite</code> function can
+       be used to check whether a floating point number is finite,
+       i.e. neither plus or minus infinite nor NaN (not a number).
+       <br>
+       (WB 2006/03/15)
+       </p>
+
   <li> <p> Improved: If the C++ runtime environment allows it, we now
        demangle stacktraces generated whenever an exception is thrown.
        <br>

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.