Add a portable floating point classification API

Ceres has traditionally battled with portability issues
when trying to classify floating point values as one
type or another. For example, in C99 'isnan' is a
macro. Since it is a macro, it is impossible to
override the name in other namespaces.

Instead of trying to use preprocessor hacks to work
around the issue, define our own set of camel-case
names for use internally and by Ceres clients. For
example do this:

  template<typename T>
  void MyFunction(T x, T y) {
    if (ceres::IsNaN(x)) {
      ...
    }
  }

instead of using "isnan" or "std::isnan". Note that
while GCC and Apple GCC both import 'isnan' into
the std namespace, it is not standard until C++11
which Ceres will not require for some years.

Change-Id: Ibcc96a8bb4ba63aa67cbbc58658b2e5671cd5824
diff --git a/internal/ceres/conjugate_gradients_solver.cc b/internal/ceres/conjugate_gradients_solver.cc
index 09a0279..7501bb2 100644
--- a/internal/ceres/conjugate_gradients_solver.cc
+++ b/internal/ceres/conjugate_gradients_solver.cc
@@ -42,6 +42,7 @@
 #include <cmath>
 #include <cstddef>
 #include <glog/logging.h>
+#include "ceres/fpclassify.h"
 #include "ceres/linear_operator.h"
 #include "ceres/internal/eigen.h"
 #include "ceres/types.h"
@@ -51,7 +52,7 @@
 namespace {
 
 bool IsZeroOrInfinity(double x) {
-  return ((x == 0.0) || (isinf(x)));
+  return ((x == 0.0) || (IsInfinite(x)));
 }
 
 // Constant used in the MATLAB implementation ~ 2 * eps.
@@ -150,14 +151,14 @@
     A->RightMultiply(p.data(), q.data());
     double pq = p.dot(q);
 
-    if ((pq <= 0) || isinf(pq))  {
+    if ((pq <= 0) || IsInfinite(pq))  {
       LOG(ERROR) << "Numerical failure. pq = " << pq;
       summary.termination_type = FAILURE;
       break;
     }
 
     double alpha = rho / pq;
-    if (isinf(alpha)) {
+    if (IsInfinite(alpha)) {
       LOG(ERROR) << "Numerical failure. alpha " << alpha;
       summary.termination_type = FAILURE;
       break;