changeset 21782:2aef506f3fec

use namespace for lo-mappers.h functions * lo-mappers.h, lo-mappers.cc (acos, arg, asin, atan, ceil, conj, copysign, exp2, finite, fix, floor, imag, is_NA, is_NaN_or_NA, isinf, isinteger, isnan, log2, max, min, mod, negative_sign, nint, nint_big, positive_sign, rc_acos, rc_acosh, rc_asin, rc_atanh, rc_log, rc_log10, rc_log2, rc_sqrt, real, rem, round, roundb, signbit, signum, trunc, x_nint): Define in octave::math namespace. Deprecate old names. Change all uses. * oct-inttypes.h: Put round and isnan functions in octave::math namespace and rename from xround and xisnan. Change all uses.
author John W. Eaton <jwe@octave.org>
date Wed, 25 May 2016 16:51:16 -0400
parents da4554d2342d
children 58a4c5633efd
files examples/code/make_int.cc libgui/graphics/BaseControl.cc libgui/graphics/Container.cc libgui/graphics/ContextMenu.cc libgui/graphics/Figure.cc libgui/graphics/ListBoxControl.cc libgui/graphics/Panel.cc libgui/graphics/QtHandlesUtils.cc libgui/graphics/SliderControl.cc libinterp/corefcn/__contourc__.cc libinterp/corefcn/__magick_read__.cc libinterp/corefcn/colloc.cc libinterp/corefcn/data.cc libinterp/corefcn/fft.cc libinterp/corefcn/fft2.cc libinterp/corefcn/fftn.cc libinterp/corefcn/find.cc libinterp/corefcn/ft-text-renderer.cc libinterp/corefcn/gcd.cc libinterp/corefcn/getgrent.cc libinterp/corefcn/getpwent.cc libinterp/corefcn/gl-render.cc libinterp/corefcn/gl-render.h libinterp/corefcn/graphics.cc libinterp/corefcn/graphics.in.h libinterp/corefcn/jit-typeinfo.cc libinterp/corefcn/ls-mat5.cc libinterp/corefcn/mgorth.cc libinterp/corefcn/oct-handle.h libinterp/corefcn/oct-stream.cc libinterp/corefcn/pr-output.cc libinterp/corefcn/quad.cc libinterp/corefcn/quadcc.cc libinterp/corefcn/rand.cc libinterp/corefcn/sparse-xpow.cc libinterp/corefcn/spparms.cc libinterp/corefcn/sysdep.cc libinterp/corefcn/urlwrite.cc libinterp/corefcn/utils.cc libinterp/corefcn/xpow.cc libinterp/dldfcn/__glpk__.cc libinterp/dldfcn/audioread.cc libinterp/octave-value/ov-base-scalar.cc libinterp/octave-value/ov-base.cc libinterp/octave-value/ov-complex.cc libinterp/octave-value/ov-complex.h libinterp/octave-value/ov-cx-mat.cc libinterp/octave-value/ov-cx-sparse.cc libinterp/octave-value/ov-float.cc libinterp/octave-value/ov-float.h libinterp/octave-value/ov-flt-complex.cc libinterp/octave-value/ov-flt-complex.h libinterp/octave-value/ov-flt-cx-mat.cc libinterp/octave-value/ov-flt-re-diag.cc libinterp/octave-value/ov-flt-re-mat.cc libinterp/octave-value/ov-re-diag.cc libinterp/octave-value/ov-re-mat.cc libinterp/octave-value/ov-re-sparse.cc libinterp/octave-value/ov-scalar.cc libinterp/octave-value/ov-scalar.h libinterp/octave-value/ov-usr-fcn.cc libinterp/operators/op-cs-cs.cc libinterp/operators/op-fcs-fcs.cc libinterp/operators/op-fs-fs.cc libinterp/operators/op-s-s.cc libinterp/operators/ops.h liboctave/array/Array-C.cc liboctave/array/Array-d.cc liboctave/array/Array-f.cc liboctave/array/Array-fC.cc liboctave/array/Array.cc liboctave/array/CMatrix.cc liboctave/array/CNDArray.cc liboctave/array/CSparse.cc liboctave/array/Range.cc liboctave/array/Range.h liboctave/array/Sparse-C.cc liboctave/array/Sparse-d.cc liboctave/array/chNDArray.cc liboctave/array/dMatrix.cc liboctave/array/dNDArray.cc liboctave/array/dSparse.cc liboctave/array/fCMatrix.cc liboctave/array/fCNDArray.cc liboctave/array/fMatrix.cc liboctave/array/fNDArray.cc liboctave/array/idx-vector.cc liboctave/numeric/CollocWt.cc liboctave/numeric/DASPK.cc liboctave/numeric/DET.h liboctave/numeric/eigs-base.cc liboctave/numeric/lo-mappers.cc liboctave/numeric/lo-mappers.h liboctave/numeric/lo-specfun.cc liboctave/numeric/oct-norm.cc liboctave/numeric/oct-rand.cc liboctave/numeric/sparse-lu.cc liboctave/operators/mx-inlines.cc liboctave/operators/mx-op-defs.h liboctave/util/lo-utils.cc liboctave/util/oct-inttypes.cc liboctave/util/oct-inttypes.h
diffstat 102 files changed, 2017 insertions(+), 1643 deletions(-) [+]
line wrap: on
line diff
--- a/examples/code/make_int.cc	Fri May 27 10:20:48 2016 -0400
+++ b/examples/code/make_int.cc	Wed May 25 16:51:16 2016 -0400
@@ -286,7 +286,7 @@
     {
       double d = args(0).double_value ();
 
-      retval = octave_value (new octave_integer (NINT (d)));
+      retval = octave_value (new octave_integer (octave::math::nint (d)));
     }
   else
     print_usage ();
--- a/libgui/graphics/BaseControl.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libgui/graphics/BaseControl.cc	Wed May 25 16:51:16 2016 -0400
@@ -84,8 +84,8 @@
   uicontrol::properties& up = properties<uicontrol> ();
 
   Matrix bb = up.get_boundingbox (false);
-  w->setGeometry (xround (bb(0)), xround (bb(1)),
-                  xround (bb(2)), xround (bb(3)));
+  w->setGeometry (octave::math::round (bb(0)), octave::math::round (bb(1)),
+                  octave::math::round (bb(2)), octave::math::round (bb(3)));
   w->setFont (Utils::computeFont<uicontrol> (up, bb(3)));
   updatePalette (up, w);
   w->setEnabled (up.enable_is ("on"));
@@ -113,8 +113,8 @@
     case uicontrol::properties::ID_POSITION:
         {
           Matrix bb = up.get_boundingbox (false);
-          w->setGeometry (xround (bb(0)), xround (bb(1)),
-                          xround (bb(2)), xround (bb(3)));
+          w->setGeometry (octave::math::round (bb(0)), octave::math::round (bb(1)),
+                          octave::math::round (bb(2)), octave::math::round (bb(3)));
         }
       break;
 
--- a/libgui/graphics/Container.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libgui/graphics/Container.cc	Wed May 25 16:51:16 2016 -0400
@@ -92,8 +92,8 @@
               Matrix bb = obj->properties ().get_boundingbox (false);
 
               obj->qWidget<QWidget> ()
-                ->setGeometry (xround (bb(0)), xround (bb(1)),
-                               xround (bb(2)), xround (bb(3)));
+                ->setGeometry (octave::math::round (bb(0)), octave::math::round (bb(1)),
+                               octave::math::round (bb(2)), octave::math::round (bb(3)));
             }
         }
     }
--- a/libgui/graphics/ContextMenu.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libgui/graphics/ContextMenu.cc	Wed May 25 16:51:16 2016 -0400
@@ -76,8 +76,8 @@
           QWidget* parentW = xmenu->parentWidget ();
           QPoint pt;
 
-          pt.rx () = xround (pos(0));
-          pt.ry () = parentW->height () - xround (pos(1));
+          pt.rx () = octave::math::round (pos(0));
+          pt.ry () = parentW->height () - octave::math::round (pos(1));
           pt = parentW->mapToGlobal (pt);
 
           xmenu->popup (pt);
--- a/libgui/graphics/Figure.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libgui/graphics/Figure.cc	Wed May 25 16:51:16 2016 -0400
@@ -108,8 +108,8 @@
 
   if (bb.numel () == 4)
     {
-      r = QRect (xround (bb(0)), xround (bb(1)),
-                 xround (bb(2)), xround (bb(3)));
+      r = QRect (octave::math::round (bb(0)), octave::math::round (bb(1)),
+                 octave::math::round (bb(2)), octave::math::round (bb(3)));
       if (! r.isValid ())
         r = QRect ();
     }
--- a/libgui/graphics/ListBoxControl.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libgui/graphics/ListBoxControl.cc	Wed May 25 16:51:16 2016 -0400
@@ -43,7 +43,7 @@
 
   for (octave_idx_type i = 0; i < n; i++)
     {
-      int idx = xround (value(i));
+      int idx = octave::math::round (value(i));
 
       if (1 <= idx && idx <= lc)
         {
@@ -96,7 +96,7 @@
 
       for (octave_idx_type i = 0; i < n; i++)
         {
-          int idx = xround (value(i));
+          int idx = octave::math::round (value(i));
 
           if (1 <= idx && idx <= lc)
             {
--- a/libgui/graphics/Panel.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libgui/graphics/Panel.cc	Wed May 25 16:51:16 2016 -0400
@@ -76,7 +76,7 @@
 
   if (! pp.bordertype_is ("none"))
     {
-      bw = xround (pp.get_borderwidth ());
+      bw = octave::math::round (pp.get_borderwidth ());
       if (pp.bordertype_is ("etchedin") || pp.bordertype_is ("etchedout"))
         bw *= 2;
     }
@@ -108,10 +108,10 @@
   frame->setObjectName ("UIPanel");
   frame->setAutoFillBackground (true);
   Matrix bb = pp.get_boundingbox (false);
-  frame->setGeometry (xround (bb(0)), xround (bb(1)),
-                      xround (bb(2)), xround (bb(3)));
+  frame->setGeometry (octave::math::round (bb(0)), octave::math::round (bb(1)),
+                      octave::math::round (bb(2)), octave::math::round (bb(3)));
   frame->setFrameStyle (frameStyleFromProperties (pp));
-  frame->setLineWidth (xround (pp.get_borderwidth ()));
+  frame->setLineWidth (octave::math::round (pp.get_borderwidth ()));
   QPalette pal = frame->palette ();
   setupPalette (pp, pal);
   frame->setPalette (pal);
@@ -236,14 +236,14 @@
       {
         Matrix bb = pp.get_boundingbox (false);
 
-        frame->setGeometry (xround (bb(0)), xround (bb(1)),
-                            xround (bb(2)), xround (bb(3)));
+        frame->setGeometry (octave::math::round (bb(0)), octave::math::round (bb(1)),
+                            octave::math::round (bb(2)), octave::math::round (bb(3)));
         updateLayout ();
       }
       break;
 
     case uipanel::properties::ID_BORDERWIDTH:
-      frame->setLineWidth (xround (pp.get_borderwidth ()));
+      frame->setLineWidth (octave::math::round (pp.get_borderwidth ()));
       updateLayout ();
       break;
 
@@ -345,10 +345,10 @@
   Matrix bb = pp.get_boundingbox (true);
   int bw = borderWidthFromProperties (pp);
 
-  frame->setFrameRect (QRect (xround (bb(0)) - bw, xround (bb(1)) - bw,
-                              xround (bb(2)) + 2*bw, xround (bb(3)) + 2*bw));
-  m_container->setGeometry (xround (bb(0)), xround (bb(1)),
-                            xround (bb(2)), xround (bb(3)));
+  frame->setFrameRect (QRect (octave::math::round (bb(0)) - bw, octave::math::round (bb(1)) - bw,
+                              octave::math::round (bb(2)) + 2*bw, octave::math::round (bb(3)) + 2*bw));
+  m_container->setGeometry (octave::math::round (bb(0)), octave::math::round (bb(1)),
+                            octave::math::round (bb(2)), octave::math::round (bb(3)));
 
   if (m_blockUpdates)
     pp.update_boundingbox ();
--- a/libgui/graphics/QtHandlesUtils.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libgui/graphics/QtHandlesUtils.cc	Wed May 25 16:51:16 2016 -0400
@@ -313,12 +313,12 @@
                 float r = f(j, i, 0);
                 float g = f(j, i, 1);
                 float b = f(j, i, 2);
-                int a = (xisnan (r) || xisnan (g) || xisnan (b) ? 0 : 255);
+                int a = (octave::math::isnan (r) || octave::math::isnan (g) || octave::math::isnan (b) ? 0 : 255);
 
                 img.setPixel (x_off + i, y_off + j,
-                              qRgba (xround (r * 255),
-                                     xround (g * 255),
-                                     xround (b * 255),
+                              qRgba (octave::math::round (r * 255),
+                                     octave::math::round (g * 255),
+                                     octave::math::round (b * 255),
                                      a));
               }
         }
@@ -332,12 +332,12 @@
                 double r = d(j, i, 0);
                 double g = d(j, i, 1);
                 double b = d(j, i, 2);
-                int a = (xisnan (r) || xisnan (g) || xisnan (b) ? 0 : 255);
+                int a = (octave::math::isnan (r) || octave::math::isnan (g) || octave::math::isnan (b) ? 0 : 255);
 
                 img.setPixel (x_off + i, y_off + j,
-                              qRgba (xround (r * 255),
-                                     xround (g * 255),
-                                     xround (b * 255),
+                              qRgba (octave::math::round (r * 255),
+                                     octave::math::round (g * 255),
+                                     octave::math::round (b * 255),
                                      a));
               }
         }
--- a/libgui/graphics/SliderControl.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libgui/graphics/SliderControl.cc	Wed May 25 16:51:16 2016 -0400
@@ -63,14 +63,14 @@
   Matrix steps = up.get_sliderstep ().matrix_value ();
   slider->setMinimum (0);
   slider->setMaximum (RANGE_INT_MAX);
-  slider->setSingleStep (xround (steps(0) * RANGE_INT_MAX));
-  slider->setPageStep (xround (steps(1) * RANGE_INT_MAX));
+  slider->setSingleStep (octave::math::round (steps(0) * RANGE_INT_MAX));
+  slider->setPageStep (octave::math::round (steps(1) * RANGE_INT_MAX));
   Matrix value = up.get_value ().matrix_value ();
   if (value.numel () > 0)
     {
       double dmin = up.get_min (), dmax = up.get_max ();
 
-      slider->setValue (xround (((value(0) - dmin) / (dmax - dmin))
+      slider->setValue (octave::math::round (((value(0) - dmin) / (dmax - dmin))
                                 * RANGE_INT_MAX));
     }
 
@@ -93,8 +93,8 @@
       {
         Matrix steps = up.get_sliderstep ().matrix_value ();
 
-        slider->setSingleStep (xround (steps(0) * RANGE_INT_MAX));
-        slider->setPageStep (xround (steps(1) * RANGE_INT_MAX));
+        slider->setSingleStep (octave::math::round (steps(0) * RANGE_INT_MAX));
+        slider->setPageStep (octave::math::round (steps(1) * RANGE_INT_MAX));
       }
       break;
 
@@ -105,7 +105,7 @@
 
         if (value.numel () > 0)
           {
-            int ival = xround (((value(0) - dmin) / (dmax - dmin))
+            int ival = octave::math::round (((value(0) - dmin) / (dmax - dmin))
                                * RANGE_INT_MAX);
 
             m_blockUpdates = true;
@@ -137,7 +137,7 @@
           double dmin = up.get_min (), dmax = up.get_max ();
 
           int ival_tmp = (value.numel () > 0 ?
-                          xround (((value(0) - dmin) / (dmax - dmin))
+                          octave::math::round (((value(0) - dmin) / (dmax - dmin))
                                   * RANGE_INT_MAX) :
                           0);
 
--- a/libinterp/corefcn/__contourc__.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/corefcn/__contourc__.cc	Wed May 25 16:51:16 2016 -0400
@@ -152,7 +152,7 @@
         {
           tmp = fabs (pz[pt[1]]) / fabs (pz[pt[0]]);
 
-          if (xisnan (tmp))
+          if (octave::math::isnan (tmp))
             ct_x = ct_y = 0.5;
           else
             {
@@ -181,7 +181,7 @@
       pt[1] = (pt[0] + 1) % 4;
       tmp = fabs (pz[pt[1]]) / fabs (pz[pt[0]]);
 
-      if (xisnan (tmp))
+      if (octave::math::isnan (tmp))
         ct_x = ct_y = 0.5;
       else
         {
--- a/libinterp/corefcn/__magick_read__.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/corefcn/__magick_read__.cc	Wed May 25 16:51:16 2016 -0400
@@ -1115,7 +1115,7 @@
               {
                 for (octave_idx_type row = 0; row < nRows; row++)
                   {
-                    const double grey = xround (double (*img_fvec) / divisor);
+                    const double grey = octave::math::round (double (*img_fvec) / divisor);
                     Magick::Color c (grey, grey, grey);
                     pix[GM_idx] = c;
                     img_fvec++;
@@ -1145,9 +1145,9 @@
               {
                 for (octave_idx_type row = 0; row < nRows; row++)
                   {
-                    double grey = xround (double (*img_fvec) / divisor);
+                    double grey = octave::math::round (double (*img_fvec) / divisor);
                     Magick::Color c (grey, grey, grey,
-                                     MaxRGB - xround (double (*a_fvec) / divisor));
+                                     MaxRGB - octave::math::round (double (*a_fvec) / divisor));
                     pix[GM_idx] = c;
                     img_fvec++;
                     a_fvec++;
@@ -1180,9 +1180,9 @@
               {
                 for (octave_idx_type row = 0; row < nRows; row++)
                   {
-                    Magick::Color c (xround (double (*img_fvec)          / divisor),
-                                     xround (double (img_fvec[G_offset]) / divisor),
-                                     xround (double (img_fvec[B_offset]) / divisor));
+                    Magick::Color c (octave::math::round (double (*img_fvec)          / divisor),
+                                     octave::math::round (double (img_fvec[G_offset]) / divisor),
+                                     octave::math::round (double (img_fvec[B_offset]) / divisor));
                     pix[GM_idx] = c;
                     img_fvec++;
                     GM_idx += nCols;
@@ -1215,10 +1215,10 @@
               {
                 for (octave_idx_type row = 0; row < nRows; row++)
                   {
-                    Magick::Color c (xround (double (*img_fvec)          / divisor),
-                                     xround (double (img_fvec[G_offset]) / divisor),
-                                     xround (double (img_fvec[B_offset]) / divisor),
-                                     MaxRGB - xround (double (*a_fvec) / divisor));
+                    Magick::Color c (octave::math::round (double (*img_fvec)          / divisor),
+                                     octave::math::round (double (img_fvec[G_offset]) / divisor),
+                                     octave::math::round (double (img_fvec[B_offset]) / divisor),
+                                     MaxRGB - octave::math::round (double (*a_fvec) / divisor));
                     pix[GM_idx] = c;
                     img_fvec++;
                     a_fvec++;
@@ -1253,10 +1253,10 @@
               {
                 for (octave_idx_type row = 0; row < nRows; row++)
                   {
-                    Magick::Color c (xround (double (*img_fvec)          / divisor),
-                                     xround (double (img_fvec[M_offset]) / divisor),
-                                     xround (double (img_fvec[Y_offset]) / divisor),
-                                     xround (double (img_fvec[K_offset]) / divisor));
+                    Magick::Color c (octave::math::round (double (*img_fvec)          / divisor),
+                                     octave::math::round (double (img_fvec[M_offset]) / divisor),
+                                     octave::math::round (double (img_fvec[Y_offset]) / divisor),
+                                     octave::math::round (double (img_fvec[K_offset]) / divisor));
                     pix[GM_idx] = c;
                     img_fvec++;
                     GM_idx += nCols;
@@ -1291,12 +1291,12 @@
               {
                 for (octave_idx_type row = 0; row < nRows; row++)
                   {
-                    Magick::Color c (xround (double (*img_fvec)          / divisor),
-                                     xround (double (img_fvec[M_offset]) / divisor),
-                                     xround (double (img_fvec[Y_offset]) / divisor),
-                                     xround (double (img_fvec[K_offset]) / divisor));
+                    Magick::Color c (octave::math::round (double (*img_fvec)          / divisor),
+                                     octave::math::round (double (img_fvec[M_offset]) / divisor),
+                                     octave::math::round (double (img_fvec[Y_offset]) / divisor),
+                                     octave::math::round (double (img_fvec[K_offset]) / divisor));
                     pix[GM_idx] = c;
-                    ind[GM_idx] = MaxRGB - xround (double (*a_fvec) / divisor);
+                    ind[GM_idx] = MaxRGB - octave::math::round (double (*a_fvec) / divisor);
                     img_fvec++;
                     a_fvec++;
                     GM_idx += nCols;
--- a/libinterp/corefcn/colloc.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/corefcn/colloc.cc	Wed May 25 16:51:16 2016 -0400
@@ -52,10 +52,10 @@
     error ("colloc: N must be a scalar");
 
   double tmp = args(0).double_value ();
-  if (xisnan (tmp))
+  if (octave::math::isnan (tmp))
     error ("colloc: N cannot be NaN");
 
-  octave_idx_type ncol = NINTbig (tmp);
+  octave_idx_type ncol = octave::math::nint_big (tmp);
   if (ncol < 0)
     error ("colloc: N must be positive");
 
--- a/libinterp/corefcn/data.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/corefcn/data.cc	Wed May 25 16:51:16 2016 -0400
@@ -470,7 +470,7 @@
   for (octave_idx_type i = 0; i < x.numel (); i++)
     {
       int exp;
-      f.xelem (i) = xlog2 (x(i), exp);
+      f.xelem (i) = octave::math::log2 (x(i), exp);
       e.xelem (i) = exp;
     }
 }
@@ -664,29 +664,29 @@
   else if (args(0).is_single_type () || args(1).is_single_type ())
     {
       if (args(0).is_scalar_type () && args(1).is_scalar_type ())
-        retval = xrem (args(0).float_value (), args(1).float_value ());
+        retval = octave::math::rem (args(0).float_value (), args(1).float_value ());
       else
         {
           FloatNDArray a0 = args(0).float_array_value ();
           FloatNDArray a1 = args(1).float_array_value ();
-          retval = binmap<float> (a0, a1, xrem<float>, "rem");
+          retval = binmap<float> (a0, a1, octave::math::rem<float>, "rem");
         }
     }
   else
     {
       if (args(0).is_scalar_type () && args(1).is_scalar_type ())
-        retval = xrem (args(0).scalar_value (), args(1).scalar_value ());
+        retval = octave::math::rem (args(0).scalar_value (), args(1).scalar_value ());
       else if (args(0).is_sparse_type () || args(1).is_sparse_type ())
         {
           SparseMatrix m0 = args(0).sparse_matrix_value ();
           SparseMatrix m1 = args(1).sparse_matrix_value ();
-          retval = binmap<double> (m0, m1, xrem<double>, "rem");
+          retval = binmap<double> (m0, m1, octave::math::rem<double>, "rem");
         }
       else
         {
           NDArray a0 = args(0).array_value ();
           NDArray a1 = args(1).array_value ();
-          retval = binmap<double> (a0, a1, xrem<double>, "rem");
+          retval = binmap<double> (a0, a1, octave::math::rem<double>, "rem");
         }
     }
 
@@ -845,29 +845,29 @@
   else if (args(0).is_single_type () || args(1).is_single_type ())
     {
       if (args(0).is_scalar_type () && args(1).is_scalar_type ())
-        retval = xmod (args(0).float_value (), args(1).float_value ());
+        retval = octave::math::mod (args(0).float_value (), args(1).float_value ());
       else
         {
           FloatNDArray a0 = args(0).float_array_value ();
           FloatNDArray a1 = args(1).float_array_value ();
-          retval = binmap<float> (a0, a1, xmod<float>, "mod");
+          retval = binmap<float> (a0, a1, octave::math::mod<float>, "mod");
         }
     }
   else
     {
       if (args(0).is_scalar_type () && args(1).is_scalar_type ())
-        retval = xmod (args(0).scalar_value (), args(1).scalar_value ());
+        retval = octave::math::mod (args(0).scalar_value (), args(1).scalar_value ());
       else if (args(0).is_sparse_type () || args(1).is_sparse_type ())
         {
           SparseMatrix m0 = args(0).sparse_matrix_value ();
           SparseMatrix m1 = args(1).sparse_matrix_value ();
-          retval = binmap<double> (m0, m1, xmod<double>, "mod");
+          retval = binmap<double> (m0, m1, octave::math::mod<double>, "mod");
         }
       else
         {
           NDArray a0 = args(0).array_value ();
           NDArray a1 = args(1).array_value ();
-          retval = binmap<double> (a0, a1, xmod<double>, "mod");
+          retval = binmap<double> (a0, a1, octave::math::mod<double>, "mod");
         }
     }
 
@@ -4540,7 +4540,7 @@
           for (octave_idx_type i = 0; i < x.numel (); i++)
             {
               float val = ::fabsf (x(i));
-              if (xisnan (val) || xisinf (val))
+              if (octave::math::isnan (val) || octave::math::isinf (val))
                 epsval(i) = lo_ieee_nan_value ();
               else if (val < std::numeric_limits<float>::min ())
                 epsval(i) = powf (2.0, -149e0);
@@ -4564,7 +4564,7 @@
           for (octave_idx_type i = 0; i < x.numel (); i++)
             {
               double val = ::fabs (x(i));
-              if (xisnan (val) || xisinf (val))
+              if (octave::math::isnan (val) || octave::math::isinf (val))
                 epsval(i) = lo_ieee_nan_value ();
               else if (val < std::numeric_limits<double>::min ())
                 epsval(i) = pow (2.0, -1074e0);
--- a/libinterp/corefcn/fft.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/corefcn/fft.cc	Wed May 25 16:51:16 2016 -0400
@@ -58,10 +58,10 @@
       if (! args(1).is_empty ())
         {
           double dval = args(1).double_value ();
-          if (xisnan (dval))
+          if (octave::math::isnan (dval))
             error ("%s: number of points (N) cannot be NaN", fcn);
 
-          n_points = NINTbig (dval);
+          n_points = octave::math::nint_big (dval);
           if (n_points < 0)
             error ("%s: number of points (N) must be greater than zero", fcn);
         }
@@ -70,14 +70,14 @@
   if (nargin > 2)
     {
       double dval = args(2).double_value ();
-      if (xisnan (dval))
+      if (octave::math::isnan (dval))
         error ("%s: DIM cannot be NaN", fcn);
       else if (dval < 1 || dval > dims.ndims ())
         error ("%s: DIM must be a valid dimension along which to perform FFT",
                fcn);
       else
         // to be safe, cast it back to int since dim is an int
-        dim = NINT (dval) - 1;
+        dim = octave::math::nint (dval) - 1;
     }
 
   for (octave_idx_type i = 0; i < dims.ndims (); i++)
--- a/libinterp/corefcn/fft2.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/corefcn/fft2.cc	Wed May 25 16:51:16 2016 -0400
@@ -57,10 +57,10 @@
   if (nargin > 1)
     {
       double dval = args(1).double_value ();
-      if (xisnan (dval))
+      if (octave::math::isnan (dval))
         error ("%s: number of rows (N) cannot be NaN", fcn);
 
-      n_rows = NINTbig (dval);
+      n_rows = octave::math::nint_big (dval);
       if (n_rows < 0)
         error ("%s: number of rows (N) must be greater than zero", fcn);
     }
@@ -69,10 +69,10 @@
   if (nargin > 2)
     {
       double dval = args(2).double_value ();
-      if (xisnan (dval))
+      if (octave::math::isnan (dval))
         error ("%s: number of columns (M) cannot be NaN", fcn);
 
-      n_cols = NINTbig (dval);
+      n_cols = octave::math::nint_big (dval);
       if (n_cols < 0)
         error ("%s: number of columns (M) must be greater than zero", fcn);
     }
--- a/libinterp/corefcn/fftn.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/corefcn/fftn.cc	Wed May 25 16:51:16 2016 -0400
@@ -68,12 +68,12 @@
 
       for (int i = 0; i < dims.ndims (); i++)
         {
-          if (xisnan (val(i,0)))
+          if (octave::math::isnan (val(i,0)))
             error ("%s: SIZE has invalid NaN entries", fcn);
-          else if (NINTbig (val(i,0)) < 0)
+          else if (octave::math::nint_big (val(i,0)) < 0)
             error ("%s: all dimensions in SIZE must be greater than zero", fcn);
           else
-            dims(i) = NINTbig(val(i,0));
+            dims(i) = octave::math::nint_big(val(i,0));
         }
     }
 
--- a/libinterp/corefcn/find.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/corefcn/find.cc	Wed May 25 16:51:16 2016 -0400
@@ -394,9 +394,9 @@
     {
       double val = args(1).xscalar_value ("find: N must be an integer");
 
-      if (val < 0 || (! xisinf (val) && val != xround (val)))
+      if (val < 0 || (! octave::math::isinf (val) && val != octave::math::round (val)))
         error ("find: N must be a non-negative integer");
-      else if (! xisinf (val))
+      else if (! octave::math::isinf (val))
         n_to_find = val;
     }
 
--- a/libinterp/corefcn/ft-text-renderer.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/corefcn/ft-text-renderer.cc	Wed May 25 16:51:16 2016 -0400
@@ -605,7 +605,7 @@
             {
               bbox(1) -= (*it)(3);
               bbox(3) += (*it)(3);
-              bbox(2) = xmax (bbox(2), (*it)(2));
+              bbox(2) = octave::math::max (bbox(2), (*it)(2));
             }
         }
       break;
@@ -806,7 +806,7 @@
                   // glyph.  Then extend the line bounding box if necessary.
 
                   xoffset += (face->glyph->advance.x >> 6);
-                  bb(2) = xmax (bb(2), xoffset);
+                  bb(2) = octave::math::max (bb(2), xoffset);
                 }
               break;
             }
@@ -1073,7 +1073,7 @@
     {
       xoffset = saved_xoffset;
       (*it)->accept (*this);
-      max_xoffset = xmax (xoffset, max_xoffset);
+      max_xoffset = octave::math::max (xoffset, max_xoffset);
     }
 
   xoffset = max_xoffset;
--- a/libinterp/corefcn/gcd.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/corefcn/gcd.cc	Wed May 25 16:51:16 2016 -0400
@@ -39,7 +39,7 @@
 static double
 simple_gcd (double a, double b)
 {
-  if (! xisinteger (a) || ! xisinteger (b))
+  if (! octave::math::isinteger (a) || ! octave::math::isinteger (b))
     error ("gcd: all values must be integers");
 
   double aa = fabs (a);
@@ -75,8 +75,8 @@
 static std::complex<FP>
 simple_gcd (const std::complex<FP>& a, const std::complex<FP>& b)
 {
-  if (! xisinteger (a.real ()) || ! xisinteger (a.imag ())
-      || ! xisinteger (b.real ()) || ! xisinteger (b.imag ()))
+  if (! octave::math::isinteger (a.real ()) || ! octave::math::isinteger (a.imag ())
+      || ! octave::math::isinteger (b.real ()) || ! octave::math::isinteger (b.imag ()))
     error ("gcd: all complex parts must be integers");
 
   std::complex<FP> aa = a;
@@ -116,7 +116,7 @@
 static double
 extended_gcd (double a, double b, double& x, double& y)
 {
-  if (! xisinteger (a) || ! xisinteger (b))
+  if (! octave::math::isinteger (a) || ! octave::math::isinteger (b))
     error ("gcd: all values must be integers");
 
   double aa = fabs (a);
@@ -154,8 +154,8 @@
 extended_gcd (const std::complex<FP>& a, const std::complex<FP>& b,
               std::complex<FP>& x, std::complex<FP>& y)
 {
-  if (! xisinteger (a.real ()) || ! xisinteger (a.imag ())
-      || ! xisinteger (b.real ()) || ! xisinteger (b.imag ()))
+  if (! octave::math::isinteger (a.real ()) || ! octave::math::isinteger (a.imag ())
+      || ! octave::math::isinteger (b.real ()) || ! octave::math::isinteger (b.imag ()))
     error ("gcd: all complex parts must be integers");
 
   std::complex<FP> aa = a;
--- a/libinterp/corefcn/getgrent.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/corefcn/getgrent.cc	Wed May 25 16:51:16 2016 -0400
@@ -97,7 +97,7 @@
 
   double dval = args(0).double_value ();
 
-  if (D_NINT (dval) != dval)
+  if (octave::math::x_nint (dval) != dval)
     error ("getgrgid: GID must be an integer");
 
   gid_t gid = static_cast<gid_t> (dval);
--- a/libinterp/corefcn/getpwent.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/corefcn/getpwent.cc	Wed May 25 16:51:16 2016 -0400
@@ -101,7 +101,7 @@
 
   double dval = args(0).double_value ();
 
-  if (D_NINT (dval) != dval)
+  if (octave::math::x_nint (dval) != dval)
     error ("getpwuid: UID must be an integer");
 
   uid_t uid = static_cast<uid_t> (dval);
--- a/libinterp/corefcn/gl-render.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/corefcn/gl-render.cc	Wed May 25 16:51:16 2016 -0400
@@ -1262,7 +1262,7 @@
       string_vector xticklabels = props.get_xticklabel ().string_vector_value ();
       int wmax = 0;
       int hmax = 0;
-      bool tick_along_z = nearhoriz || xisinf (fy);
+      bool tick_along_z = nearhoriz || octave::math::isinf (fy);
       bool mirror = props.is_box () && xstate != AXE_ANY_DIR;
 
       set_color (props.get_xcolor_rgb ());
@@ -1278,14 +1278,14 @@
         {
           render_tickmarks (xticks, x_min, x_max, ypTick, ypTick,
                             zpTick, zpTickN, 0., 0.,
-                            signum (zpTick-zpTickN)*fz*xticklen,
+                            octave::math::signum (zpTick-zpTickN)*fz*xticklen,
                             0, mirror);
         }
       else
         {
           render_tickmarks (xticks, x_min, x_max, ypTick, ypTickN,
                             zpTick, zpTick, 0.,
-                            signum (ypTick-ypTickN)*fy*xticklen,
+                            octave::math::signum (ypTick-ypTickN)*fy*xticklen,
                             0., 0, mirror);
         }
 
@@ -1297,11 +1297,11 @@
 
           if (tick_along_z)
             render_ticktexts (xticks, xticklabels, x_min, x_max, ypTick,
-                              zpTick+signum (zpTick-zpTickN)*fz*xtickoffset,
+                              zpTick+octave::math::signum (zpTick-zpTickN)*fz*xtickoffset,
                               0, halign, valign, wmax, hmax);
           else
             render_ticktexts (xticks, xticklabels, x_min, x_max,
-                              ypTick+signum (ypTick-ypTickN)*fy*xtickoffset,
+                              ypTick+octave::math::signum (ypTick-ypTickN)*fy*xtickoffset,
                               zpTick, 0, halign, valign, wmax, hmax);
         }
 
@@ -1317,12 +1317,12 @@
           if (tick_along_z)
             render_tickmarks (xmticks, x_min, x_max, ypTick, ypTick,
                               zpTick, zpTickN, 0., 0.,
-                              signum (zpTick-zpTickN)*fz*xticklen/2,
+                              octave::math::signum (zpTick-zpTickN)*fz*xticklen/2,
                               0, mirror);
           else
             render_tickmarks (xmticks, x_min, x_max, ypTick, ypTickN,
                               zpTick, zpTick, 0.,
-                              signum (ypTick-ypTickN)*fy*xticklen/2,
+                              octave::math::signum (ypTick-ypTickN)*fy*xticklen/2,
                               0., 0, mirror);
         }
 
@@ -1372,7 +1372,7 @@
       string_vector yticklabels = props.get_yticklabel ().string_vector_value ();
       int wmax = 0;
       int hmax = 0;
-      bool tick_along_z = nearhoriz || xisinf (fx);
+      bool tick_along_z = nearhoriz || octave::math::isinf (fx);
       bool mirror = props.is_box () && ystate != AXE_ANY_DIR
                     && (! props.has_property ("__plotyy_axes__"));
 
@@ -1388,12 +1388,12 @@
       if (tick_along_z)
         render_tickmarks (yticks, y_min, y_max, xpTick, xpTick,
                           zpTick, zpTickN, 0., 0.,
-                          signum (zpTick-zpTickN)*fz*yticklen,
+                          octave::math::signum (zpTick-zpTickN)*fz*yticklen,
                           1, mirror);
       else
         render_tickmarks (yticks, y_min, y_max, xpTick, xpTickN,
                           zpTick, zpTick,
-                          signum (xPlaneN-xPlane)*fx*yticklen,
+                          octave::math::signum (xPlaneN-xPlane)*fx*yticklen,
                           0., 0., 1, mirror);
 
       // tick texts
@@ -1405,11 +1405,11 @@
 
           if (tick_along_z)
             render_ticktexts (yticks, yticklabels, y_min, y_max, xpTick,
-                              zpTick+signum (zpTick-zpTickN)*fz*ytickoffset,
+                              zpTick+octave::math::signum (zpTick-zpTickN)*fz*ytickoffset,
                               1, halign, valign, wmax, hmax);
           else
             render_ticktexts (yticks, yticklabels, y_min, y_max,
-                              xpTick+signum (xpTick-xpTickN)*fx*ytickoffset,
+                              xpTick+octave::math::signum (xpTick-xpTickN)*fx*ytickoffset,
                               zpTick, 1, halign, valign, wmax, hmax);
         }
 
@@ -1425,12 +1425,12 @@
           if (tick_along_z)
             render_tickmarks (ymticks, y_min, y_max, xpTick, xpTick,
                               zpTick, zpTickN, 0., 0.,
-                              signum (zpTick-zpTickN)*fz*yticklen/2,
+                              octave::math::signum (zpTick-zpTickN)*fz*yticklen/2,
                               1, mirror);
           else
             render_tickmarks (ymticks, y_min, y_max, xpTick, xpTickN,
                               zpTick, zpTick,
-                              signum (xpTick-xpTickN)*fx*yticklen/2,
+                              octave::math::signum (xpTick-xpTickN)*fx*yticklen/2,
                               0., 0., 1, mirror);
         }
 
@@ -1485,28 +1485,28 @@
       // tick marks
       if (xySym)
         {
-          if (xisinf (fy))
+          if (octave::math::isinf (fy))
             render_tickmarks (zticks, z_min, z_max, xPlaneN, xPlane,
                               yPlane, yPlane,
-                              signum (xPlaneN-xPlane)*fx*zticklen,
+                              octave::math::signum (xPlaneN-xPlane)*fx*zticklen,
                               0., 0., 2, mirror);
           else
             render_tickmarks (zticks, z_min, z_max, xPlaneN, xPlaneN,
                               yPlane, yPlane, 0.,
-                              signum (yPlane-yPlaneN)*fy*zticklen,
+                              octave::math::signum (yPlane-yPlaneN)*fy*zticklen,
                               0., 2, false);
         }
       else
         {
-          if (xisinf (fx))
+          if (octave::math::isinf (fx))
             render_tickmarks (zticks, z_min, z_max, xPlaneN, xPlane,
                               yPlaneN, yPlane, 0.,
-                              signum (yPlaneN-yPlane)*fy*zticklen,
+                              octave::math::signum (yPlaneN-yPlane)*fy*zticklen,
                               0., 2, mirror);
           else
             render_tickmarks (zticks, z_min, z_max, xPlane, xPlane,
                               yPlaneN, yPlane,
-                              signum (xPlane-xPlaneN)*fx*zticklen,
+                              octave::math::signum (xPlane-xPlaneN)*fx*zticklen,
                               0., 0., 2, false);
         }
 
@@ -1518,24 +1518,24 @@
 
           if (xySym)
             {
-              if (xisinf (fy))
+              if (octave::math::isinf (fy))
                 render_ticktexts (zticks, zticklabels, z_min, z_max,
-                                  xPlaneN+signum (xPlaneN-xPlane)*fx*ztickoffset,
+                                  xPlaneN+octave::math::signum (xPlaneN-xPlane)*fx*ztickoffset,
                                   yPlane, 2, halign, valign, wmax, hmax);
               else
                 render_ticktexts (zticks, zticklabels, z_min, z_max, xPlaneN,
-                                  yPlane+signum (yPlane-yPlaneN)*fy*ztickoffset,
+                                  yPlane+octave::math::signum (yPlane-yPlaneN)*fy*ztickoffset,
                                   2, halign, valign, wmax, hmax);
             }
           else
             {
-              if (xisinf (fx))
+              if (octave::math::isinf (fx))
                 render_ticktexts (zticks, zticklabels, z_min, z_max, xPlane,
-                                  yPlaneN+signum (yPlaneN-yPlane)*fy*ztickoffset,
+                                  yPlaneN+octave::math::signum (yPlaneN-yPlane)*fy*ztickoffset,
                                   2, halign, valign, wmax, hmax);
               else
                 render_ticktexts (zticks, zticklabels, z_min, z_max,
-                                  xPlane+signum (xPlane-xPlaneN)*fx*ztickoffset,
+                                  xPlane+octave::math::signum (xPlane-xPlaneN)*fx*ztickoffset,
                                   yPlaneN, 2, halign, valign, wmax, hmax);
             }
         }
@@ -1550,28 +1550,28 @@
         {
           if (xySym)
             {
-              if (xisinf (fy))
+              if (octave::math::isinf (fy))
                 render_tickmarks (zmticks, z_min, z_max, xPlaneN, xPlane,
                                   yPlane, yPlane,
-                                  signum (xPlaneN-xPlane)*fx*zticklen/2,
+                                  octave::math::signum (xPlaneN-xPlane)*fx*zticklen/2,
                                   0., 0., 2, mirror);
               else
                 render_tickmarks (zmticks, z_min, z_max, xPlaneN, xPlaneN,
                                   yPlane, yPlane, 0.,
-                                  signum (yPlane-yPlaneN)*fy*zticklen/2,
+                                  octave::math::signum (yPlane-yPlaneN)*fy*zticklen/2,
                                   0., 2, false);
             }
           else
             {
-              if (xisinf (fx))
+              if (octave::math::isinf (fx))
                 render_tickmarks (zmticks, z_min, z_max, xPlane, xPlane,
                                   yPlaneN, yPlane, 0.,
-                                  signum (yPlaneN-yPlane)*fy*zticklen/2,
+                                  octave::math::signum (yPlaneN-yPlane)*fy*zticklen/2,
                                   0., 2, mirror);
               else
                 render_tickmarks (zmticks, z_min, z_max, xPlane, xPlane,
                                   yPlaneN, yPlaneN,
-                                  signum (xPlane-xPlaneN)*fx*zticklen/2,
+                                  octave::math::signum (xPlane-xPlaneN)*fx*zticklen/2,
                                   0., 0., 2, false);
             }
         }
@@ -2005,14 +2005,14 @@
                   if (fc_mode == FLAT)
                     {
                       // "flat" only needs color at lower-left vertex
-                      if (! xfinite (c(j-1,i-1)))
+                      if (! octave::math::finite (c(j-1,i-1)))
                         continue;
                     }
                   else if (fc_mode == INTERP)
                     {
                       // "interp" needs valid color at all 4 vertices
-                      if (! (xfinite (c(j-1, i-1)) && xfinite (c(j, i-1))
-                             && xfinite (c(j-1, i)) && xfinite (c(j, i))))
+                      if (! (octave::math::finite (c(j-1, i-1)) && octave::math::finite (c(j, i-1))
+                             && octave::math::finite (c(j-1, i)) && octave::math::finite (c(j, i))))
                         continue;
                     }
 
@@ -2210,13 +2210,13 @@
                       if (ec_mode == FLAT)
                         {
                           // "flat" only needs color at lower-left vertex
-                          if (! xfinite (c(j-1,i)))
+                          if (! octave::math::finite (c(j-1,i)))
                             continue;
                         }
                       else if (ec_mode == INTERP)
                         {
                           // "interp" needs valid color at both vertices
-                          if (! (xfinite (c(j-1, i)) && xfinite (c(j, i))))
+                          if (! (octave::math::finite (c(j-1, i)) && octave::math::finite (c(j, i))))
                             continue;
                         }
 
@@ -2307,13 +2307,13 @@
                       if (ec_mode == FLAT)
                         {
                           // "flat" only needs color at lower-left vertex
-                          if (! xfinite (c(j,i-1)))
+                          if (! octave::math::finite (c(j,i-1)))
                             continue;
                         }
                       else if (ec_mode == INTERP)
                         {
                           // "interp" needs valid color at both vertices
-                          if (! (xfinite (c(j, i-1)) && xfinite (c(j, i))))
+                          if (! (octave::math::finite (c(j, i-1)) && octave::math::finite (c(j, i))))
                             continue;
                         }
 
@@ -2445,7 +2445,7 @@
               if ((do_edge && mecolor.is_empty ())
                   || (do_face && mfcolor.is_empty ()))
                 {
-                  if (! xfinite (c(j,i)))
+                  if (! octave::math::finite (c(j,i)))
                     continue;  // Skip NaNs in color data
 
                   for (int k = 0; k < 3; k++)
@@ -2545,7 +2545,7 @@
       bool fclip = false;
       int count = 0;
 
-      for (int j = 0; j < fcmax && ! xisnan (f(i,j)); j++, count++)
+      for (int j = 0; j < fcmax && ! octave::math::isnan (f(i,j)); j++, count++)
         fclip = (fclip || clip(int (f(i,j) - 1)));
 
       clip_f(i) = fclip;
@@ -2993,7 +2993,7 @@
   const ColumnVector p0 = xform.transform (x(0), y(0), 0);
   const ColumnVector p1 = xform.transform (x(1), y(1), 0);
 
-  if (xisnan (p0(0)) || xisnan (p0(1)) || xisnan (p1(0)) || xisnan (p1(1)))
+  if (octave::math::isnan (p0(0)) || octave::math::isnan (p0(1)) || octave::math::isnan (p1(0)) || octave::math::isnan (p1(1)))
     {
       warning ("opengl_renderer: image X,Y data too large to draw");
       return;
--- a/libinterp/corefcn/gl-render.h	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/corefcn/gl-render.h	Wed May 25 16:51:16 2016 -0400
@@ -138,8 +138,8 @@
 
   bool is_nan_or_inf (double x, double y, double z) const
   {
-    return (xisnan (x) || xisnan (y) || xisnan (z)
-            || xisinf (x) || xisinf (y) || xisinf (z));
+    return (octave::math::isnan (x) || octave::math::isnan (y) || octave::math::isnan (z)
+            || octave::math::isinf (x) || octave::math::isinf (y) || octave::math::isinf (z));
   }
 
   octave_uint8 clip_code (double x, double y, double z) const
--- a/libinterp/corefcn/graphics.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/corefcn/graphics.cc	Wed May 25 16:51:16 2016 -0400
@@ -845,11 +845,11 @@
                  octave_idx_type nc, octave_idx_type i, double *av)
 {
   if (is_scaled)
-    x = xround ((nc - 1) * (x - clim_0) / (clim_1 - clim_0));
+    x = octave::math::round ((nc - 1) * (x - clim_0) / (clim_1 - clim_0));
   else if (is_real)
-    x = xround (x - 1);
-
-  if (xisnan (x))
+    x = octave::math::round (x - 1);
+
+  if (octave::math::isnan (x))
     {
       av[i]       = x;
       av[i+lda]   = x;
@@ -985,7 +985,7 @@
       double e = double (data[i]);
 
       // Don't need to test for NaN here as NaN>x and NaN<x is always false
-      if (! xisinf (e))
+      if (! octave::math::isinf (e))
         {
           if (e < emin)
             emin = e;
@@ -1560,7 +1560,7 @@
 
   graphics_handle gh = gh_manager::lookup (dv);
 
-  if (! (xisnan (gh.value ()) || gh.ok ()))
+  if (! (octave::math::isnan (gh.value ()) || gh.ok ()))
     error ("set: invalid graphics handle (= %g) for property \"%s\"",
            dv, get_name ().c_str ());
 
@@ -3395,7 +3395,7 @@
 {
   graphics_handle val (v);
 
-  if (xisnan (val.value ()))
+  if (octave::math::isnan (val.value ()))
     {
       if (! cbo_stack.empty ())
         {
@@ -3422,7 +3422,7 @@
 {
   graphics_handle val (v);
 
-  if (xisnan (val.value ()) || is_handle (val))
+  if (octave::math::isnan (val.value ()) || is_handle (val))
     {
       currentfigure = val;
 
@@ -3582,7 +3582,7 @@
 {
   graphics_handle hax (val);
 
-  if (xisnan (hax.value ()) || is_handle (hax))
+  if (octave::math::isnan (hax.value ()) || is_handle (hax))
     currentaxes = hax;
   else
     err_set_invalid ("currentaxes");
@@ -5222,7 +5222,7 @@
       double d = 5 * sqrt (pb(0)*pb(0) + pb(1)*pb(1) + pb(2)*pb(2));
 
       if (el == 90 || el == -90)
-        c_eye(2) = d*signum (el);
+        c_eye(2) = d*octave::math::signum (el);
       else
         {
           az *= M_PI/180.0;
@@ -5249,9 +5249,9 @@
       if (el == 90 || el == -90)
         {
           c_upv(0) =
-            -signum (el) *sin (az*M_PI/180.0)*(xlimits(1)-xlimits(0))/pb(0);
+            -octave::math::signum (el) *sin (az*M_PI/180.0)*(xlimits(1)-xlimits(0))/pb(0);
           c_upv(1) =
-            signum (el) * cos (az*M_PI/180.0)*(ylimits(1)-ylimits(0))/pb(1);
+            octave::math::signum (el) * cos (az*M_PI/180.0)*(ylimits(1)-ylimits(0))/pb(1);
         }
       else
         c_upv(2) = 1;
@@ -5424,8 +5424,8 @@
 
   p1 = xform.transform (x_min, (y_min+y_max)/2, (z_min+z_max)/2, false);
   p2 = xform.transform (x_max, (y_min+y_max)/2, (z_min+z_max)/2, false);
-  dir(0) = xround (p2(0) - p1(0));
-  dir(1) = xround (p2(1) - p1(1));
+  dir(0) = octave::math::round (p2(0) - p1(0));
+  dir(1) = octave::math::round (p2(1) - p1(1));
   dir(2) = (p2(2) - p1(2));
   if (dir(0) == 0 && dir(1) == 0)
     xstate = AXE_DEPTH_DIR;
@@ -5452,8 +5452,8 @@
 
   p1 = xform.transform ((x_min + x_max)/2, y_min, (z_min + z_max)/2, false);
   p2 = xform.transform ((x_min + x_max)/2, y_max, (z_min + z_max)/2, false);
-  dir(0) = xround (p2(0) - p1(0));
-  dir(1) = xround (p2(1) - p1(1));
+  dir(0) = octave::math::round (p2(0) - p1(0));
+  dir(1) = octave::math::round (p2(1) - p1(1));
   dir(2) = (p2(2) - p1(2));
   if (dir(0) == 0 && dir(1) == 0)
     ystate = AXE_DEPTH_DIR;
@@ -5480,8 +5480,8 @@
 
   p1 = xform.transform ((x_min + x_max)/2, (y_min + y_max)/2, z_min, false);
   p2 = xform.transform ((x_min + x_max)/2, (y_min + y_max)/2, z_max, false);
-  dir(0) = xround (p2(0) - p1(0));
-  dir(1) = xround (p2(1) - p1(1));
+  dir(0) = octave::math::round (p2(0) - p1(0));
+  dir(1) = octave::math::round (p2(1) - p1(1));
   dir(2) = (p2(2) - p1(2));
   if (dir(0) == 0 && dir(1) == 0)
     zstate = AXE_DEPTH_DIR;
@@ -5691,11 +5691,11 @@
       ColumnVector p =
         graphics_xform::xform_vector ((xpTickN + xpTick)/2, ypTick, zpTick);
 
-      bool tick_along_z = nearhoriz || xisinf (fy);
+      bool tick_along_z = nearhoriz || octave::math::isinf (fy);
       if (tick_along_z)
-        p(2) += (signum (zpTick - zpTickN) * fz * xtickoffset);
+        p(2) += (octave::math::signum (zpTick - zpTickN) * fz * xtickoffset);
       else
-        p(1) += (signum (ypTick - ypTickN) * fy * xtickoffset);
+        p(1) += (octave::math::signum (ypTick - ypTickN) * fy * xtickoffset);
 
       p = xform.transform (p(0), p(1), p(2), false);
 
@@ -5801,11 +5801,11 @@
       ColumnVector p =
         graphics_xform::xform_vector (xpTick, (ypTickN + ypTick)/2, zpTick);
 
-      bool tick_along_z = nearhoriz || xisinf (fx);
+      bool tick_along_z = nearhoriz || octave::math::isinf (fx);
       if (tick_along_z)
-        p(2) += (signum (zpTick - zpTickN) * fz * ytickoffset);
+        p(2) += (octave::math::signum (zpTick - zpTickN) * fz * ytickoffset);
       else
-        p(0) += (signum (xpTick - xpTickN) * fx * ytickoffset);
+        p(0) += (octave::math::signum (xpTick - xpTickN) * fx * ytickoffset);
 
       p = xform.transform (p(0), p(1), p(2), false);
 
@@ -5907,19 +5907,19 @@
         {
           p = graphics_xform::xform_vector (xPlaneN, yPlane,
                                             (zpTickN + zpTick)/2);
-          if (xisinf (fy))
-            p(0) += (signum (xPlaneN - xPlane) * fx * ztickoffset);
+          if (octave::math::isinf (fy))
+            p(0) += (octave::math::signum (xPlaneN - xPlane) * fx * ztickoffset);
           else
-            p(1) += (signum (yPlane - yPlaneN) * fy * ztickoffset);
+            p(1) += (octave::math::signum (yPlane - yPlaneN) * fy * ztickoffset);
         }
       else
         {
           p = graphics_xform::xform_vector (xPlane, yPlaneN,
                                             (zpTickN + zpTick)/2);
-          if (xisinf (fx))
-            p(1) += (signum (yPlaneN - yPlane) * fy * ztickoffset);
+          if (octave::math::isinf (fx))
+            p(1) += (octave::math::signum (yPlaneN - yPlane) * fy * ztickoffset);
           else
-            p(0) += (signum (xPlane - xPlaneN) * fx * ztickoffset);
+            p(0) += (octave::math::signum (xPlane - xPlaneN) * fx * ztickoffset);
         }
 
       p = xform.transform (p(0), p(1), p(2), false);
@@ -6042,7 +6042,7 @@
   double yval = ylength / scalefactors(1);
   double zval = zlength / scalefactors(2);
 
-  double minval = xmin (xmin (xval, yval), zval);
+  double minval = octave::math::min (octave::math::min (xval, yval), zval);
 
   aspectratios(0) = xval / minval;
   aspectratios(1) = yval / minval;
@@ -6060,15 +6060,15 @@
       double min_pos = octave::numeric_limits<double>::Inf ();
       double max_neg = -octave::numeric_limits<double>::Inf ();
       get_children_limits (minval, maxval, min_pos, max_neg, kids, limit_type);
-      if (xfinite (minval) && xfinite (maxval))
+      if (octave::math::finite (minval) && octave::math::finite (maxval))
         {
           limits(0) = minval;
           limits(1) = maxval;
-          s = xmax (s, (maxval - minval) / (pbfactor * dafactor));
+          s = octave::math::max (s, (maxval - minval) / (pbfactor * dafactor));
         }
     }
   else
-    s = xmax (s, (limits(1) - limits(0)) / (pbfactor * dafactor));
+    s = octave::math::max (s, (limits(1) - limits(0)) / (pbfactor * dafactor));
 }
 
 static std::set<double> updating_aspectratios;
@@ -6147,8 +6147,8 @@
           dx = pba(0) * da(0);
           dy = pba(1) * da(1);
           dz = pba(2) * da(2);
-          if (xisinf (s))
-            s = 1 / xmin (xmin (dx, dy), dz);
+          if (octave::math::isinf (s))
+            s = 1 / octave::math::min (octave::math::min (dx, dy), dz);
 
           if (xlimmode_is ("auto"))
             {
@@ -6592,16 +6592,16 @@
                   const array_property& data)
 {
   double val = data.min_val ();
-  if (xfinite (val) && val < min_val)
+  if (octave::math::finite (val) && val < min_val)
     min_val = val;
   val = data.max_val ();
-  if (xfinite (val) && val > max_val)
+  if (octave::math::finite (val) && val > max_val)
     max_val = val;
   val = data.min_pos ();
-  if (xfinite (val) && val > 0 && val < min_pos)
+  if (octave::math::finite (val) && val > 0 && val < min_pos)
     min_pos = val;
   val = data.max_neg ();
-  if (xfinite (val) && val < 0 && val > max_neg)
+  if (octave::math::finite (val) && val < 0 && val > max_neg)
     max_neg = val;
 }
 */
@@ -6620,19 +6620,19 @@
           double val;
 
           val = m(0);
-          if (xfinite (val) && val < min_val)
+          if (octave::math::finite (val) && val < min_val)
             min_val = val;
 
           val = m(1);
-          if (xfinite (val) && val > max_val)
+          if (octave::math::finite (val) && val > max_val)
             max_val = val;
 
           val = m(2);
-          if (xfinite (val) && val > 0 && val < min_pos)
+          if (octave::math::finite (val) && val > 0 && val < min_pos)
             min_pos = val;
 
           val = m(3);
-          if (xfinite (val) && val < 0 && val > max_neg)
+          if (octave::math::finite (val) && val < 0 && val > max_neg)
             max_neg = val;
         }
     }
@@ -6704,16 +6704,16 @@
   double min_val = xmin;
   double max_val = xmax;
 
-  if (xisinf (min_val) && min_val > 0 && xisinf (max_val) && max_val < 0)
+  if (octave::math::isinf (min_val) && min_val > 0 && octave::math::isinf (max_val) && max_val < 0)
     {
       retval = default_lim (logscale);
       return retval;
     }
-  else if (! (xisinf (min_val) || xisinf (max_val)))
+  else if (! (octave::math::isinf (min_val) || octave::math::isinf (max_val)))
     {
       if (logscale)
         {
-          if (xisinf (min_pos) && xisinf (max_neg))
+          if (octave::math::isinf (min_pos) && octave::math::isinf (max_neg))
             {
               // FIXME: max_neg is needed for "loglog ([0 -Inf])"
               //        This is the *only* place where max_neg is needed.
@@ -6827,7 +6827,7 @@
 
   if (is_logscale)
     {
-      if (! (xisinf (hi) || xisinf (lo)))
+      if (! (octave::math::isinf (hi) || octave::math::isinf (lo)))
         tick_sep = 1;  // Tick is every order of magnitude (bug #39449)
       else
         tick_sep = 0;
@@ -7128,16 +7128,16 @@
   if (limits.numel () == 4) \
     { \
       val = limits(0); \
-      if (xfinite (val)) \
+      if (octave::math::finite (val)) \
         min_val = val; \
       val = limits(1); \
-      if (xfinite (val)) \
+      if (octave::math::finite (val)) \
         max_val = val; \
       val = limits(2); \
-      if (xfinite (val)) \
+      if (octave::math::finite (val)) \
         min_pos = val; \
       val = limits(3); \
-      if (xfinite (val)) \
+      if (octave::math::finite (val)) \
         max_neg = val; \
     } \
   else \
@@ -8209,7 +8209,7 @@
           bool turn_valid = false;
           for (octave_idx_type ii = 0; ii < idx.rows (); ii++)
             {
-              if (xisnan (idx(ii,jj)) || turn_valid)
+              if (octave::math::isnan (idx(ii,jj)) || turn_valid)
                 {
                   idx(ii,jj) = valid_vert;
                   turn_valid = true;
@@ -8474,16 +8474,16 @@
   if (limits.numel () == 4)
     {
       val = limits(0);
-      if (xfinite (val))
+      if (octave::math::finite (val))
         min_val = val;
       val = limits(1);
-      if (xfinite (val))
+      if (octave::math::finite (val))
         max_val = val;
       val = limits(2);
-      if (xfinite (val))
+      if (octave::math::finite (val))
         min_pos = val;
       val = limits(3);
-      if (xfinite (val))
+      if (octave::math::finite (val))
         max_neg = val;
     }
   else
@@ -10109,7 +10109,7 @@
         }
     }
 
-  if (xisnan (val))
+  if (octave::math::isnan (val))
     val = args(0).xdouble_value ("__go_%s__: invalid parent", go_name.c_str ());
 
   graphics_handle parent = gh_manager::lookup (val);
@@ -10175,7 +10175,7 @@
 
       graphics_handle h = octave::numeric_limits<double>::NaN ();
 
-      if (xisnan (val))
+      if (octave::math::isnan (val))
         {
           caseless_str pname ("integerhandle");
 
@@ -10210,7 +10210,7 @@
               go.get_properties ().init_integerhandle ("off");
             }
         }
-      else if (val > 0 && D_NINT (val) == val)
+      else if (val > 0 && octave::math::x_nint (val) == val)
         h = gh_manager::make_figure_handle (val, false);
 
       if (! h.ok ())
--- a/libinterp/corefcn/graphics.in.h	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/corefcn/graphics.in.h	Wed May 25 16:51:16 2016 -0400
@@ -6188,7 +6188,7 @@
 
   graphics_handle do_lookup (double val)
   {
-    iterator p = (xisnan (val) ? handle_map.end () : handle_map.find (val));
+    iterator p = (octave::math::isnan (val) ? handle_map.end () : handle_map.find (val));
 
     return (p != handle_map.end ()) ? p->first : graphics_handle ();
   }
--- a/libinterp/corefcn/jit-typeinfo.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/corefcn/jit-typeinfo.cc	Wed May 25 16:51:16 2016 -0400
@@ -395,7 +395,7 @@
 static inline int
 xisint (double x)
 {
-  return (D_NINT (x) == x
+  return (octave::math::x_nint (x) == x
           && ((x >= 0 && x < std::numeric_limits<int>::max ())
               || (x <= 0 && x > std::numeric_limits<int>::min ())));
 }
--- a/libinterp/corefcn/ls-mat5.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/corefcn/ls-mat5.cc	Wed May 25 16:51:16 2016 -0400
@@ -1891,7 +1891,7 @@
             {
               double tmp = val[i];
 
-              if (xfinite (tmp)
+              if (octave::math::finite (tmp)
                   && fabs (tmp) > std::numeric_limits<float>::max ())
                 {
                   too_large_for_float = true;
@@ -1921,7 +1921,7 @@
       //     if (val < min_val)
       //       min_val = val;
       //
-      //     if (D_NINT (val) != val)
+      //     if (octave::math::x_nint (val) != val)
       //       {
       //         all_integers = false;
       //         break;
@@ -1976,7 +1976,7 @@
       //     if (val < min_val)
       //       min_val = val;
       //
-      //     if (D_NINT (val) != val)
+      //     if (octave::math::x_nint (val) != val)
       //       {
       //         all_integers = false;
       //         break;
--- a/libinterp/corefcn/mgorth.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/corefcn/mgorth.cc	Wed May 25 16:51:16 2016 -0400
@@ -44,7 +44,7 @@
     }
 
   h(Vc) = xnorm (x);
-  if (real (h(Vc)) > 0)
+  if (octave::math::real (h(Vc)) > 0)
     x /= h(Vc);
 }
 
--- a/libinterp/corefcn/oct-handle.h	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/corefcn/oct-handle.h	Wed May 25 16:51:16 2016 -0400
@@ -106,7 +106,7 @@
     return old_value;
   }
 
-  bool ok (void) const { return ! xisnan (val); }
+  bool ok (void) const { return ! octave::math::isnan (val); }
 
 private:
   double val;
--- a/libinterp/corefcn/oct-stream.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/corefcn/oct-stream.cc	Wed May 25 16:51:16 2016 -0400
@@ -97,7 +97,7 @@
     {
       if (! lo_ieee_isnan (dval))
         {
-          int ival = NINT (dval);
+          int ival = octave::math::nint (dval);
 
           if (ival == dval)
             retval = ival;
@@ -119,7 +119,7 @@
   if (lo_ieee_isnan (d))
     ::error ("%s: NaN is invalid as size specification", who.c_str ());
 
-  if (xisinf (d))
+  if (octave::math::isinf (d))
     retval = -1;
   else
     {
@@ -127,7 +127,7 @@
         ::error ("%s: negative value invalid as size specification",
                  who.c_str ());
 
-      retval = NINT (d);
+      retval = octave::math::nint (d);
     }
 
   return retval;
@@ -159,7 +159,7 @@
     {
       dnr = size(0);
 
-      if (xisinf (dnr))
+      if (octave::math::isinf (dnr))
         ::error ("%s: invalid size specification", who.c_str ());
 
       dnc = size(1);
@@ -2991,7 +2991,7 @@
 
       // check for "treat as empty" string
       if (treat_as_empty.numel ()
-          && (is.fail () || octave_is_NaN_or_NA (Complex (re))
+          && (is.fail () || octave::math::is_NaN_or_NA (Complex (re))
               || re == octave::numeric_limits<double>::Inf ()))
         {
 
@@ -5365,7 +5365,7 @@
                     {
                       double dval = val(idx);
 
-                      if (D_NINT (dval) != dval || dval < 0 || dval > 255)
+                      if (octave::math::x_nint (dval) != dval || dval < 0 || dval > 255)
                         break;
                     }
 
@@ -5392,7 +5392,7 @@
                 {
                   double dval = retval.double_value ();
 
-                  if (D_NINT (dval) == dval && dval >= 0 && dval < 256)
+                  if (octave::math::x_nint (dval) == dval && dval >= 0 && dval < 256)
                     retval = static_cast<char> (dval);
                 }
             }
@@ -5437,8 +5437,8 @@
 
   double dval = val.double_value (true);
 
-  if (D_NINT (dval) == dval)
-    retval = NINT (dval);
+  if (octave::math::x_nint (dval) == dval)
+    retval = octave::math::nint (dval);
   else
     curr_state = conversion_error;
 
@@ -5532,7 +5532,7 @@
     {
       double dval = val.double_value (true);
 
-      if (dval == xround (dval) && dval <= limit)
+      if (dval == octave::math::round (dval) && dval <= limit)
         return true;
     }
 
@@ -5559,7 +5559,7 @@
 
       uint64_t limit = std::numeric_limits<uint64_t>::max ();
 
-      if (dval == xround (dval) && dval >= 0 && dval <= limit)
+      if (dval == octave::math::round (dval) && dval >= 0 && dval <= limit)
         return true;
     }
 
@@ -6019,7 +6019,7 @@
 
   if (tc_count.is_defined ())
     {
-      if (tc_count.is_scalar_type () && xisinf (tc_count.scalar_value ()))
+      if (tc_count.is_scalar_type () && octave::math::isinf (tc_count.scalar_value ()))
         count = -1;
       else
         {
--- a/libinterp/corefcn/pr-output.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/corefcn/pr-output.cc	Wed May 25 16:51:16 2016 -0400
@@ -354,24 +354,24 @@
   if (len <= 0)
     len = 10;
 
-  if (xisinf (val))
+  if (octave::math::isinf (val))
     s = "1/0";
-  else if (xisnan (val))
+  else if (octave::math::isnan (val))
     s = "0/0";
   else if (val < std::numeric_limits<int>::min ()
            || val > std::numeric_limits<int>::max ()
-           || D_NINT (val) == val)
+           || octave::math::x_nint (val) == val)
     {
       std::ostringstream buf;
       buf.flags (std::ios::fixed);
-      buf << std::setprecision (0) << xround (val);
+      buf << std::setprecision (0) << octave::math::round (val);
       s = buf.str ();
     }
   else
     {
       double lastn = 1.;
       double lastd = 0.;
-      double n = xround (val);
+      double n = octave::math::round (val);
       double d = 1.;
       double frac = val - n;
       int m = 0;
@@ -384,7 +384,7 @@
       while (1)
         {
           double flip = 1. / frac;
-          double step = xround (flip);
+          double step = octave::math::round (flip);
           double nextn = n;
           double nextd = d;
 
@@ -510,7 +510,7 @@
     for (octave_idx_type i = 0; i < nr; i++)
       {
         double val = m(i,j);
-        if (! xfinite (val))
+        if (! octave::math::finite (val))
           continue;
 
         all_inf_or_nan = false;
@@ -539,7 +539,7 @@
     for (octave_idx_type i = 0; i < nr; i++)
       {
         double val = m(i,j);
-        if (! xfinite (val))
+        if (! octave::math::finite (val))
           continue;
 
         all_inf_or_nan = false;
@@ -660,9 +660,9 @@
   if (free_format)
     return;
 
-  bool inf_or_nan = (xisinf (d) || xisnan (d));
-
-  bool int_only = (! inf_or_nan && D_NINT (d) == d);
+  bool inf_or_nan = (octave::math::isinf (d) || octave::math::isnan (d));
+
+  bool int_only = (! inf_or_nan && octave::math::x_nint (d) == d);
 
   double d_abs = d < 0.0 ? -d : d;
 
@@ -1004,16 +1004,16 @@
   double rp = c.real ();
   double ip = c.imag ();
 
-  bool inf_or_nan = (xisinf (c) || xisnan (c));
-
-  bool int_only = (D_NINT (rp) == rp && D_NINT (ip) == ip);
+  bool inf_or_nan = (octave::math::isinf (c) || octave::math::isnan (c));
+
+  bool int_only = (octave::math::x_nint (rp) == rp && octave::math::x_nint (ip) == ip);
 
   double r_abs = rp < 0.0 ? -rp : rp;
   double i_abs = ip < 0.0 ? -ip : ip;
 
-  int r_x = (! xfinite (rp) || r_abs == 0.0) ? 0 : num_digits (r_abs);
-
-  int i_x = (! xfinite (ip) || i_abs == 0.0) ? 0 : num_digits (i_abs);
+  int r_x = (! octave::math::finite (rp) || r_abs == 0.0) ? 0 : num_digits (r_abs);
+
+  int i_x = (! octave::math::finite (ip) || i_abs == 0.0) ? 0 : num_digits (i_abs);
 
   int x_max, x_min;
 
@@ -1522,7 +1522,7 @@
                 }
             }
         }
-      else if (octave_is_NA (d))
+      else if (octave::math::is_NA (d))
         {
           octave_preserve_stream_state stream_state (os);
 
@@ -1533,7 +1533,7 @@
         }
       else if (rat_format)
         os << pr_rational_float (*fmt, d);
-      else if (xisinf (d))
+      else if (octave::math::isinf (d))
         {
           octave_preserve_stream_state stream_state (os);
 
@@ -1548,7 +1548,7 @@
           else
             os << s;
         }
-      else if (xisnan (d))
+      else if (octave::math::isnan (d))
         {
           octave_preserve_stream_state stream_state (os);
 
--- a/libinterp/corefcn/quad.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/corefcn/quad.cc	Wed May 25 16:51:16 2016 -0400
@@ -219,18 +219,18 @@
       FloatIndefQuad::IntegralType indef_type
         = FloatIndefQuad::doubly_infinite;
       float bound = 0.0;
-      if (xisinf (a) && xisinf (b))
+      if (octave::math::isinf (a) && octave::math::isinf (b))
         {
           indefinite = 1;
           indef_type = FloatIndefQuad::doubly_infinite;
         }
-      else if (xisinf (a))
+      else if (octave::math::isinf (a))
         {
           indefinite = 1;
           bound = b;
           indef_type = FloatIndefQuad::neg_inf_to_bound;
         }
-      else if (xisinf (b))
+      else if (octave::math::isinf (b))
         {
           indefinite = 1;
           bound = a;
@@ -312,18 +312,18 @@
       int indefinite = 0;
       IndefQuad::IntegralType indef_type = IndefQuad::doubly_infinite;
       double bound = 0.0;
-      if (xisinf (a) && xisinf (b))
+      if (octave::math::isinf (a) && octave::math::isinf (b))
         {
           indefinite = 1;
           indef_type = IndefQuad::doubly_infinite;
         }
-      else if (xisinf (a))
+      else if (octave::math::isinf (a))
         {
           indefinite = 1;
           bound = b;
           indef_type = IndefQuad::neg_inf_to_bound;
         }
-      else if (xisinf (b))
+      else if (octave::math::isinf (b))
         {
           indefinite = 1;
           bound = a;
--- a/libinterp/corefcn/quadcc.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/corefcn/quadcc.cc	Wed May 25 16:51:16 2016 -0400
@@ -1639,11 +1639,11 @@
     }
 
   // If a or b are +/-Inf, transform the integral.
-  if (xisinf (a) || xisinf (b))
+  if (octave::math::isinf (a) || octave::math::isinf (b))
     {
       wrap = true;
       for (i = 0; i < nivals + 1; i++)
-        if (xisinf (iivals[i]))
+        if (octave::math::isinf (iivals[i]))
           iivals[i] = gnulib::copysign (1.0, iivals[i]);
         else
           iivals[i] = 2.0 * atan (iivals[i]) / M_PI;
@@ -1692,7 +1692,7 @@
               iv->fx[i] *= (1.0 + xw * xw) * M_PI / 2;
             }
           neval++;
-          if (! xfinite (iv->fx[i]))
+          if (! octave::math::finite (iv->fx[i]))
             {
               nans[nnans++] = i;
               iv->fx[i] = 0.0;
@@ -1808,7 +1808,7 @@
           nnans = 0;
           for (i = 0; i <= 32; i += skip[d])
             {
-              if (! xfinite (iv->fx[i]))
+              if (! octave::math::finite (iv->fx[i]))
                 {
                   nans[nnans++] = i;
                   iv->fx[i] = 0.0;
@@ -1945,7 +1945,7 @@
           nnans = 0;
           for (i = 0; i <= 32; i += skip[0])
             {
-              if (! xfinite (ivl->fx[i]))
+              if (! octave::math::finite (ivl->fx[i]))
                 {
                   nans[nnans++] = i;
                   ivl->fx[i] = 0.0;
@@ -2036,7 +2036,7 @@
           nnans = 0;
           for (i = 0; i <= 32; i += skip[0])
             {
-              if (! xfinite (ivr->fx[i]))
+              if (! octave::math::finite (ivr->fx[i]))
                 {
                   nans[nnans++] = i;
                   ivr->fx[i] = 0.0;
--- a/libinterp/corefcn/rand.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/corefcn/rand.cc	Wed May 25 16:51:16 2016 -0400
@@ -148,13 +148,13 @@
           {
             double dval = tmp.double_value ();
 
-            if (xisnan (dval))
+            if (octave::math::isnan (dval))
               error ("%s: NaN is invalid matrix dimension", fcn);
 
             dims.resize (2);
 
-            dims(0) = NINTbig (tmp.double_value ());
-            dims(1) = NINTbig (tmp.double_value ());
+            dims(0) = octave::math::nint_big (tmp.double_value ());
+            dims(1) = octave::math::nint_big (tmp.double_value ());
 
             goto gen_matrix;
           }
@@ -169,8 +169,8 @@
 
             dims.resize (n);
 
-            octave_idx_type base = NINTbig (r.base ());
-            octave_idx_type incr = NINTbig (r.inc ());
+            octave_idx_type base = octave::math::nint_big (r.base ());
+            octave_idx_type incr = octave::math::nint_big (r.inc ());
 
             for (octave_idx_type i = 0; i < n; i++)
               {
--- a/libinterp/corefcn/sparse-xpow.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/corefcn/sparse-xpow.cc	Wed May 25 16:51:16 2016 -0400
@@ -46,7 +46,7 @@
 static inline int
 xisint (double x)
 {
-  return (D_NINT (x) == x
+  return (octave::math::x_nint (x) == x
           && ((x >= 0 && x < std::numeric_limits<int>::max ())
               || (x <= 0 && x > std::numeric_limits<int>::min ())));
 }
--- a/libinterp/corefcn/spparms.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/corefcn/spparms.cc	Wed May 25 16:51:16 2016 -0400
@@ -145,7 +145,7 @@
           else
             {
               double val = octave_sparse_params::get_key (str);
-              if (xisnan (val))
+              if (octave::math::isnan (val))
                 error ("spparms: KEY not recognized");
 
               retval = ovl (val);
--- a/libinterp/corefcn/sysdep.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/corefcn/sysdep.cc	Wed May 25 16:51:16 2016 -0400
@@ -795,13 +795,13 @@
     {
       double dval = args(0).double_value ();
 
-      if (xisnan (dval))
+      if (octave::math::isnan (dval))
         warning ("pause: NaN is an invalid delay");
       else
         {
           Fdrawnow ();
 
-          if (xisinf (dval))
+          if (octave::math::isinf (dval))
             {
               flush_octave_stdout ();
               octave_kbhit ();
--- a/libinterp/corefcn/urlwrite.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/corefcn/urlwrite.cc	Wed May 25 16:51:16 2016 -0400
@@ -164,7 +164,7 @@
 
   curl_handle do_lookup (double val)
   {
-    iterator p = (xisnan (val) ? handle_map.end () : handle_map.find (val));
+    iterator p = (octave::math::isnan (val) ? handle_map.end () : handle_map.find (val));
 
     return (p != handle_map.end ()) ? p->first : curl_handle ();
   }
--- a/libinterp/corefcn/utils.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/corefcn/utils.cc	Wed May 25 16:51:16 2016 -0400
@@ -1165,8 +1165,8 @@
         error ("%s (A): use %s (size (A)) instead", warn_for, warn_for);
 
       Array<double> v = a.vector_value ();
-      nr = static_cast<octave_idx_type> (fix (v(0)));
-      nc = static_cast<octave_idx_type> (fix (v(1)));
+      nr = static_cast<octave_idx_type> (octave::math::fix (v(0)));
+      nc = static_cast<octave_idx_type> (octave::math::fix (v(1)));
     }
 
   check_dimensions (nr, nc, warn_for);
--- a/libinterp/corefcn/xpow.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/corefcn/xpow.cc	Wed May 25 16:51:16 2016 -0400
@@ -70,7 +70,7 @@
 static inline int
 xisint (double x)
 {
-  return (D_NINT (x) == x
+  return (octave::math::x_nint (x) == x
           && ((x >= 0 && x < std::numeric_limits<int>::max ())
               || (x <= 0 && x > std::numeric_limits<int>::min ())));
 }
@@ -1478,7 +1478,7 @@
 static inline int
 xisint (float x)
 {
-  return (D_NINT (x) == x
+  return (octave::math::x_nint (x) == x
           && ((x >= 0 && x < std::numeric_limits<int>::max ())
               || (x <= 0 && x > std::numeric_limits<int>::min ())));
 }
--- a/libinterp/dldfcn/__glpk__.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/dldfcn/__glpk__.cc	Wed May 25 16:51:16 2016 -0400
@@ -419,7 +419,7 @@
   Array<int> freeLB (dim_vector (mrowsc, 1));
   for (int i = 0; i < mrowsc; i++)
     {
-      if (xisinf (lb[i]))
+      if (octave::math::isinf (lb[i]))
         {
           freeLB(i) = 1;
           lb[i] = -octave::numeric_limits<double>::Inf ();
@@ -440,7 +440,7 @@
   Array<int> freeUB (dim_vector (mrowsc, 1));
   for (int i = 0; i < mrowsc; i++)
     {
-      if (xisinf (ub[i]))
+      if (octave::math::isinf (ub[i]))
         {
           freeUB(i) = 1;
           ub[i] = octave::numeric_limits<double>::Inf ();
--- a/libinterp/dldfcn/audioread.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/dldfcn/audioread.cc	Wed May 25 16:51:16 2016 -0400
@@ -109,11 +109,11 @@
       if (range.numel () != 2)
         error ("audioread: invalid specification for range of frames");
 
-      double dstart = xisinf (range(0)) ? info.frames : range(0);
-      double dend = xisinf (range(1)) ? info.frames : range(1);
+      double dstart = octave::math::isinf (range(0)) ? info.frames : range(0);
+      double dend = octave::math::isinf (range(1)) ? info.frames : range(1);
 
       if (dstart < 1 || dstart > dend || dend > info.frames
-          || D_NINT (dstart) != dstart || D_NINT (dend) != dend)
+          || octave::math::x_nint (dstart) != dstart || octave::math::x_nint (dend) != dend)
         error ("audioread: invalid specification for range of frames");
 
       start = dstart - 1;
--- a/libinterp/octave-value/ov-base-scalar.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/octave-value/ov-base-scalar.cc	Wed May 25 16:51:16 2016 -0400
@@ -139,7 +139,7 @@
 bool
 octave_base_scalar<ST>::is_true (void) const
 {
-  if (xisnan (scalar))
+  if (octave::math::isnan (scalar))
     err_nan_to_logical_conversion ();
 
   return (scalar != ST ());
--- a/libinterp/octave-value/ov-base.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/octave-value/ov-base.cc	Wed May 25 16:51:16 2016 -0400
@@ -451,14 +451,14 @@
         err_wrong_type_arg (e, "octave_base_value::" #F "_value ()", type_name ()); \
       } \
  \
-    if (require_int && D_NINT (d) != d) \
+    if (require_int && octave::math::x_nint (d) != d) \
       error_with_cfn ("conversion of %g to " #T " value failed", d); \
     else if (d < std::numeric_limits<T>::min ()) \
       retval = std::numeric_limits<T>::min (); \
     else if (d > std::numeric_limits<T>::max ()) \
       retval = std::numeric_limits<T>::max (); \
     else \
-      retval = static_cast<T> (::fix (d)); \
+      retval = static_cast<T> (octave::math::fix (d)); \
  \
     return retval; \
   }
@@ -489,10 +489,10 @@
       err_wrong_type_arg (e, "octave_base_value::nint_value ()", type_name ());
     }
 
-  if (xisnan (d))
+  if (octave::math::isnan (d))
     error ("conversion of NaN to integer value failed");
 
-  return static_cast<int> (::fix (d));
+  return static_cast<int> (octave::math::fix (d));
 }
 
 double
--- a/libinterp/octave-value/ov-complex.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/octave-value/ov-complex.cc	Wed May 25 16:51:16 2016 -0400
@@ -482,45 +482,45 @@
       return octave_value (FCN (scalar))
 
       SCALAR_MAPPER (abs, std::abs);
-      SCALAR_MAPPER (acos, ::acos);
+      SCALAR_MAPPER (acos, octave::math::acos);
       SCALAR_MAPPER (acosh, xacosh);
       SCALAR_MAPPER (angle, std::arg);
       SCALAR_MAPPER (arg, std::arg);
-      SCALAR_MAPPER (asin, ::asin);
+      SCALAR_MAPPER (asin, octave::math::asin);
       SCALAR_MAPPER (asinh, xasinh);
-      SCALAR_MAPPER (atan, ::atan);
+      SCALAR_MAPPER (atan, octave::math::atan);
       SCALAR_MAPPER (atanh, xatanh);
       SCALAR_MAPPER (erf, xerf);
       SCALAR_MAPPER (erfc, xerfc);
       SCALAR_MAPPER (erfcx, ::erfcx);
       SCALAR_MAPPER (erfi, ::erfi);
       SCALAR_MAPPER (dawson, ::dawson);
-      SCALAR_MAPPER (ceil, ::ceil);
+      SCALAR_MAPPER (ceil, octave::math::ceil);
       SCALAR_MAPPER (conj, std::conj);
       SCALAR_MAPPER (cos, std::cos);
       SCALAR_MAPPER (cosh, std::cosh);
       SCALAR_MAPPER (exp, std::exp);
       SCALAR_MAPPER (expm1, xexpm1);
-      SCALAR_MAPPER (fix, ::fix);
-      SCALAR_MAPPER (floor, ::floor);
+      SCALAR_MAPPER (fix, octave::math::fix);
+      SCALAR_MAPPER (floor, octave::math::floor);
       SCALAR_MAPPER (imag, std::imag);
       SCALAR_MAPPER (log, std::log);
-      SCALAR_MAPPER (log2, xlog2);
+      SCALAR_MAPPER (log2, octave::math::log2);
       SCALAR_MAPPER (log10, std::log10);
       SCALAR_MAPPER (log1p, xlog1p);
       SCALAR_MAPPER (real, std::real);
-      SCALAR_MAPPER (round, xround);
-      SCALAR_MAPPER (roundb, xroundb);
-      SCALAR_MAPPER (signum, ::signum);
+      SCALAR_MAPPER (round, octave::math::round);
+      SCALAR_MAPPER (roundb, octave::math::roundb);
+      SCALAR_MAPPER (signum, octave::math::signum);
       SCALAR_MAPPER (sin, std::sin);
       SCALAR_MAPPER (sinh, std::sinh);
       SCALAR_MAPPER (sqrt, std::sqrt);
       SCALAR_MAPPER (tan, std::tan);
       SCALAR_MAPPER (tanh, std::tanh);
-      SCALAR_MAPPER (isfinite, xfinite);
-      SCALAR_MAPPER (isinf, xisinf);
-      SCALAR_MAPPER (isna, octave_is_NA);
-      SCALAR_MAPPER (isnan, xisnan);
+      SCALAR_MAPPER (isfinite, octave::math::finite);
+      SCALAR_MAPPER (isinf, octave::math::isinf);
+      SCALAR_MAPPER (isna, octave::math::is_NA);
+      SCALAR_MAPPER (isnan, octave::math::isnan);
 
     default:
       return octave_base_value::map (umap);
--- a/libinterp/octave-value/ov-complex.h	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/octave-value/ov-complex.h	Wed May 25 16:51:16 2016 -0400
@@ -140,7 +140,7 @@
 
   bool bool_value (bool warn = false) const
   {
-    if (xisnan (scalar))
+    if (octave::math::isnan (scalar))
       err_nan_to_logical_conversion ();
     if (warn && scalar != 0.0 && scalar != 1.0)
       warn_logical_conversion ();
@@ -150,7 +150,7 @@
 
   boolNDArray bool_array_value (bool warn = false) const
   {
-    if (xisnan (scalar))
+    if (octave::math::isnan (scalar))
       err_nan_to_logical_conversion ();
     if (warn && scalar != 0.0 && scalar != 1.0)
       warn_logical_conversion ();
--- a/libinterp/octave-value/ov-cx-mat.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/octave-value/ov-cx-mat.cc	Wed May 25 16:51:16 2016 -0400
@@ -765,39 +765,39 @@
     case umap_ ## UMAP: \
       return octave_value (matrix.map<TYPE> (FCN))
 
-      ARRAY_MAPPER (acos, Complex, ::acos);
+      ARRAY_MAPPER (acos, Complex, octave::math::acos);
       ARRAY_MAPPER (acosh, Complex, xacosh);
       ARRAY_MAPPER (angle, double, std::arg);
       ARRAY_MAPPER (arg, double, std::arg);
-      ARRAY_MAPPER (asin, Complex, ::asin);
+      ARRAY_MAPPER (asin, Complex, octave::math::asin);
       ARRAY_MAPPER (asinh, Complex, xasinh);
-      ARRAY_MAPPER (atan, Complex, ::atan);
+      ARRAY_MAPPER (atan, Complex, octave::math::atan);
       ARRAY_MAPPER (atanh, Complex, xatanh);
       ARRAY_MAPPER (erf, Complex, xerf);
       ARRAY_MAPPER (erfc, Complex, xerfc);
       ARRAY_MAPPER (erfcx, Complex, ::erfcx);
       ARRAY_MAPPER (erfi, Complex, ::erfi);
       ARRAY_MAPPER (dawson, Complex, ::dawson);
-      ARRAY_MAPPER (ceil, Complex, ::ceil);
+      ARRAY_MAPPER (ceil, Complex, octave::math::ceil);
       ARRAY_MAPPER (cos, Complex, std::cos);
       ARRAY_MAPPER (cosh, Complex, std::cosh);
       ARRAY_MAPPER (exp, Complex, std::exp);
       ARRAY_MAPPER (expm1, Complex, xexpm1);
-      ARRAY_MAPPER (fix, Complex, ::fix);
-      ARRAY_MAPPER (floor, Complex, ::floor);
+      ARRAY_MAPPER (fix, Complex, octave::math::fix);
+      ARRAY_MAPPER (floor, Complex, octave::math::floor);
       ARRAY_MAPPER (log, Complex, std::log);
-      ARRAY_MAPPER (log2, Complex, xlog2);
+      ARRAY_MAPPER (log2, Complex, octave::math::log2);
       ARRAY_MAPPER (log10, Complex, std::log10);
       ARRAY_MAPPER (log1p, Complex, xlog1p);
-      ARRAY_MAPPER (round, Complex, xround);
-      ARRAY_MAPPER (roundb, Complex, xroundb);
-      ARRAY_MAPPER (signum, Complex, ::signum);
+      ARRAY_MAPPER (round, Complex, octave::math::round);
+      ARRAY_MAPPER (roundb, Complex, octave::math::roundb);
+      ARRAY_MAPPER (signum, Complex, octave::math::signum);
       ARRAY_MAPPER (sin, Complex, std::sin);
       ARRAY_MAPPER (sinh, Complex, std::sinh);
       ARRAY_MAPPER (sqrt, Complex, std::sqrt);
       ARRAY_MAPPER (tan, Complex, std::tan);
       ARRAY_MAPPER (tanh, Complex, std::tanh);
-      ARRAY_MAPPER (isna, bool, octave_is_NA);
+      ARRAY_MAPPER (isna, bool, octave::math::is_NA);
 
     default:
       return octave_base_value::map (umap);
--- a/libinterp/octave-value/ov-cx-sparse.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/octave-value/ov-cx-sparse.cc	Wed May 25 16:51:16 2016 -0400
@@ -918,43 +918,43 @@
     case umap_ ## UMAP: \
       return octave_value (matrix.map<TYPE> (FCN))
 
-      ARRAY_MAPPER (acos, Complex, ::acos);
+      ARRAY_MAPPER (acos, Complex, octave::math::acos);
       ARRAY_MAPPER (acosh, Complex, xacosh);
       ARRAY_MAPPER (angle, double, std::arg);
       ARRAY_MAPPER (arg, double, std::arg);
-      ARRAY_MAPPER (asin, Complex, ::asin);
+      ARRAY_MAPPER (asin, Complex, octave::math::asin);
       ARRAY_MAPPER (asinh, Complex, xasinh);
-      ARRAY_MAPPER (atan, Complex, ::atan);
+      ARRAY_MAPPER (atan, Complex, octave::math::atan);
       ARRAY_MAPPER (atanh, Complex, xatanh);
       ARRAY_MAPPER (erf, Complex, xerf);
       ARRAY_MAPPER (erfc, Complex, xerfc);
       ARRAY_MAPPER (erfcx, Complex, ::erfcx);
       ARRAY_MAPPER (erfi, Complex, ::erfi);
       ARRAY_MAPPER (dawson, Complex, ::dawson);
-      ARRAY_MAPPER (ceil, Complex, ::ceil);
+      ARRAY_MAPPER (ceil, Complex, octave::math::ceil);
       ARRAY_MAPPER (conj, Complex, std::conj<double>);
       ARRAY_MAPPER (cos, Complex, std::cos);
       ARRAY_MAPPER (cosh, Complex, std::cosh);
       ARRAY_MAPPER (exp, Complex, std::exp);
       ARRAY_MAPPER (expm1, Complex, xexpm1);
-      ARRAY_MAPPER (fix, Complex, ::fix);
-      ARRAY_MAPPER (floor, Complex, ::floor);
+      ARRAY_MAPPER (fix, Complex, octave::math::fix);
+      ARRAY_MAPPER (floor, Complex, octave::math::floor);
       ARRAY_MAPPER (log, Complex, std::log);
-      ARRAY_MAPPER (log2, Complex, xlog2);
+      ARRAY_MAPPER (log2, Complex, octave::math::log2);
       ARRAY_MAPPER (log10, Complex, std::log10);
       ARRAY_MAPPER (log1p, Complex, xlog1p);
-      ARRAY_MAPPER (round, Complex, xround);
-      ARRAY_MAPPER (roundb, Complex, xroundb);
-      ARRAY_MAPPER (signum, Complex, ::signum);
+      ARRAY_MAPPER (round, Complex, octave::math::round);
+      ARRAY_MAPPER (roundb, Complex, octave::math::roundb);
+      ARRAY_MAPPER (signum, Complex, octave::math::signum);
       ARRAY_MAPPER (sin, Complex, std::sin);
       ARRAY_MAPPER (sinh, Complex, std::sinh);
       ARRAY_MAPPER (sqrt, Complex, std::sqrt);
       ARRAY_MAPPER (tan, Complex, std::tan);
       ARRAY_MAPPER (tanh, Complex, std::tanh);
-      ARRAY_MAPPER (isnan, bool, xisnan);
-      ARRAY_MAPPER (isna, bool, octave_is_NA);
-      ARRAY_MAPPER (isinf, bool, xisinf);
-      ARRAY_MAPPER (isfinite, bool, xfinite);
+      ARRAY_MAPPER (isnan, bool, octave::math::isnan);
+      ARRAY_MAPPER (isna, bool, octave::math::is_NA);
+      ARRAY_MAPPER (isinf, bool, octave::math::isinf);
+      ARRAY_MAPPER (isfinite, bool, octave::math::finite);
 
     default: // Attempt to go via dense matrix.
       return octave_base_sparse<SparseComplexMatrix>::map (umap);
--- a/libinterp/octave-value/ov-float.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/octave-value/ov-float.cc	Wed May 25 16:51:16 2016 -0400
@@ -110,10 +110,10 @@
 {
   octave_value retval;
 
-  if (xisnan (scalar))
+  if (octave::math::isnan (scalar))
     err_nan_to_character_conversion ();
 
-  int ival = NINT (scalar);
+  int ival = octave::math::nint (scalar);
 
   if (ival < 0 || ival > std::numeric_limits<unsigned char>::max ())
     {
@@ -297,14 +297,13 @@
       return octave_value (FCN (scalar))
 
       SCALAR_MAPPER (abs, ::fabsf);
-      SCALAR_MAPPER (acos, rc_acos);
-      SCALAR_MAPPER (acosh, rc_acosh);
-      SCALAR_MAPPER (angle, ::arg);
-      SCALAR_MAPPER (arg, ::arg);
-      SCALAR_MAPPER (asin, rc_asin);
+      SCALAR_MAPPER (acos, octave::math::rc_acos);
+      SCALAR_MAPPER (acosh, octave::math::rc_acosh);
+      SCALAR_MAPPER (angle, octave::math::arg);
+      SCALAR_MAPPER (asin, octave::math::rc_asin);
       SCALAR_MAPPER (asinh, xasinh);
       SCALAR_MAPPER (atan, ::atanf);
-      SCALAR_MAPPER (atanh, rc_atanh);
+      SCALAR_MAPPER (atanh, octave::math::rc_atanh);
       SCALAR_MAPPER (erf, xerf);
       SCALAR_MAPPER (erfinv, ::erfinv);
       SCALAR_MAPPER (erfcinv, ::erfcinv);
@@ -320,25 +319,25 @@
       SCALAR_MAPPER (cosh, ::coshf);
       SCALAR_MAPPER (exp, ::expf);
       SCALAR_MAPPER (expm1, xexpm1);
-      SCALAR_MAPPER (fix, ::fix);
+      SCALAR_MAPPER (fix, octave::math::fix);
       SCALAR_MAPPER (floor, gnulib::floorf);
-      SCALAR_MAPPER (log, rc_log);
-      SCALAR_MAPPER (log2, rc_log2);
-      SCALAR_MAPPER (log10, rc_log10);
+      SCALAR_MAPPER (log, octave::math::rc_log);
+      SCALAR_MAPPER (log2, octave::math::rc_log2);
+      SCALAR_MAPPER (log10, octave::math::rc_log10);
       SCALAR_MAPPER (log1p, rc_log1p);
-      SCALAR_MAPPER (round, xround);
-      SCALAR_MAPPER (roundb, xroundb);
-      SCALAR_MAPPER (signum, ::signum);
+      SCALAR_MAPPER (round, octave::math::round);
+      SCALAR_MAPPER (roundb, octave::math::roundb);
+      SCALAR_MAPPER (signum, octave::math::signum);
       SCALAR_MAPPER (sin, ::sinf);
       SCALAR_MAPPER (sinh, ::sinhf);
-      SCALAR_MAPPER (sqrt, rc_sqrt);
+      SCALAR_MAPPER (sqrt, octave::math::rc_sqrt);
       SCALAR_MAPPER (tan, ::tanf);
       SCALAR_MAPPER (tanh, ::tanhf);
-      SCALAR_MAPPER (isfinite, xfinite);
-      SCALAR_MAPPER (isinf, xisinf);
-      SCALAR_MAPPER (isna, octave_is_NA);
-      SCALAR_MAPPER (isnan, xisnan);
-      SCALAR_MAPPER (xsignbit, xsignbit);
+      SCALAR_MAPPER (isfinite, octave::math::finite);
+      SCALAR_MAPPER (isinf, octave::math::isinf);
+      SCALAR_MAPPER (isna, octave::math::is_NA);
+      SCALAR_MAPPER (isnan, octave::math::isnan);
+      SCALAR_MAPPER (xsignbit, octave::math::signbit);
 
     // Special cases for Matlab compatibility.
     case umap_xtolower:
--- a/libinterp/octave-value/ov-float.h	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/octave-value/ov-float.h	Wed May 25 16:51:16 2016 -0400
@@ -198,7 +198,7 @@
 
   bool bool_value (bool warn = false) const
   {
-    if (xisnan (scalar))
+    if (octave::math::isnan (scalar))
       err_nan_to_logical_conversion ();
     if (warn && scalar != 0 && scalar != 1)
       warn_logical_conversion ();
@@ -208,7 +208,7 @@
 
   boolNDArray bool_array_value (bool warn = false) const
   {
-    if (xisnan (scalar))
+    if (octave::math::isnan (scalar))
       err_nan_to_logical_conversion ();
     if (warn && scalar != 0 && scalar != 1)
       warn_logical_conversion ();
--- a/libinterp/octave-value/ov-flt-complex.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/octave-value/ov-flt-complex.cc	Wed May 25 16:51:16 2016 -0400
@@ -432,45 +432,45 @@
       return octave_value (FCN (scalar))
 
       SCALAR_MAPPER (abs, std::abs);
-      SCALAR_MAPPER (acos, ::acos);
+      SCALAR_MAPPER (acos, octave::math::acos);
       SCALAR_MAPPER (acosh, xacosh);
       SCALAR_MAPPER (angle, std::arg);
       SCALAR_MAPPER (arg, std::arg);
-      SCALAR_MAPPER (asin, ::asin);
+      SCALAR_MAPPER (asin, octave::math::asin);
       SCALAR_MAPPER (asinh, xasinh);
-      SCALAR_MAPPER (atan, ::atan);
+      SCALAR_MAPPER (atan, octave::math::atan);
       SCALAR_MAPPER (atanh, xatanh);
       SCALAR_MAPPER (erf, xerf);
       SCALAR_MAPPER (erfc, xerfc);
       SCALAR_MAPPER (erfcx, ::erfcx);
       SCALAR_MAPPER (erfi, ::erfi);
       SCALAR_MAPPER (dawson, ::dawson);
-      SCALAR_MAPPER (ceil, ::ceil);
+      SCALAR_MAPPER (ceil, octave::math::ceil);
       SCALAR_MAPPER (conj, std::conj);
       SCALAR_MAPPER (cos, std::cos);
       SCALAR_MAPPER (cosh, std::cosh);
       SCALAR_MAPPER (exp, std::exp);
       SCALAR_MAPPER (expm1, xexpm1);
-      SCALAR_MAPPER (fix, ::fix);
-      SCALAR_MAPPER (floor, ::floor);
+      SCALAR_MAPPER (fix, octave::math::fix);
+      SCALAR_MAPPER (floor, octave::math::floor);
       SCALAR_MAPPER (imag, std::imag);
       SCALAR_MAPPER (log, std::log);
-      SCALAR_MAPPER (log2, xlog2);
+      SCALAR_MAPPER (log2, octave::math::log2);
       SCALAR_MAPPER (log10, std::log10);
       SCALAR_MAPPER (log1p, xlog1p);
       SCALAR_MAPPER (real, std::real);
-      SCALAR_MAPPER (round, xround);
-      SCALAR_MAPPER (roundb, xroundb);
-      SCALAR_MAPPER (signum, ::signum);
+      SCALAR_MAPPER (round, octave::math::round);
+      SCALAR_MAPPER (roundb, octave::math::roundb);
+      SCALAR_MAPPER (signum, octave::math::signum);
       SCALAR_MAPPER (sin, std::sin);
       SCALAR_MAPPER (sinh, std::sinh);
       SCALAR_MAPPER (sqrt, std::sqrt);
       SCALAR_MAPPER (tan, std::tan);
       SCALAR_MAPPER (tanh, std::tanh);
-      SCALAR_MAPPER (isfinite, xfinite);
-      SCALAR_MAPPER (isinf, xisinf);
-      SCALAR_MAPPER (isna, octave_is_NA);
-      SCALAR_MAPPER (isnan, xisnan);
+      SCALAR_MAPPER (isfinite, octave::math::finite);
+      SCALAR_MAPPER (isinf, octave::math::isinf);
+      SCALAR_MAPPER (isna, octave::math::is_NA);
+      SCALAR_MAPPER (isnan, octave::math::isnan);
 
     default:
       return octave_base_value::map (umap);
--- a/libinterp/octave-value/ov-flt-complex.h	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/octave-value/ov-flt-complex.h	Wed May 25 16:51:16 2016 -0400
@@ -136,7 +136,7 @@
 
   bool bool_value (bool warn = false) const
   {
-    if (xisnan (scalar))
+    if (octave::math::isnan (scalar))
       err_nan_to_logical_conversion ();
     if (warn && scalar != 0.0f && scalar != 1.0f)
       warn_logical_conversion ();
@@ -146,7 +146,7 @@
 
   boolNDArray bool_array_value (bool warn = false) const
   {
-    if (xisnan (scalar))
+    if (octave::math::isnan (scalar))
       err_nan_to_logical_conversion ();
     if (warn && scalar != 0.0f && scalar != 1.0f)
       warn_logical_conversion ();
--- a/libinterp/octave-value/ov-flt-cx-mat.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/octave-value/ov-flt-cx-mat.cc	Wed May 25 16:51:16 2016 -0400
@@ -715,39 +715,39 @@
     case umap_ ## UMAP: \
       return octave_value (matrix.map<TYPE> (FCN))
 
-      ARRAY_MAPPER (acos, FloatComplex, ::acos);
+      ARRAY_MAPPER (acos, FloatComplex, octave::math::acos);
       ARRAY_MAPPER (acosh, FloatComplex, xacosh);
       ARRAY_MAPPER (angle, float, std::arg);
       ARRAY_MAPPER (arg, float, std::arg);
-      ARRAY_MAPPER (asin, FloatComplex, ::asin);
+      ARRAY_MAPPER (asin, FloatComplex, octave::math::asin);
       ARRAY_MAPPER (asinh, FloatComplex, xasinh);
-      ARRAY_MAPPER (atan, FloatComplex, ::atan);
+      ARRAY_MAPPER (atan, FloatComplex, octave::math::atan);
       ARRAY_MAPPER (atanh, FloatComplex, xatanh);
       ARRAY_MAPPER (erf, FloatComplex, xerf);
       ARRAY_MAPPER (erfc, FloatComplex, xerfc);
       ARRAY_MAPPER (erfcx, FloatComplex, ::erfcx);
       ARRAY_MAPPER (erfi, FloatComplex, ::erfi);
       ARRAY_MAPPER (dawson, FloatComplex, ::dawson);
-      ARRAY_MAPPER (ceil, FloatComplex, ::ceil);
+      ARRAY_MAPPER (ceil, FloatComplex, octave::math::ceil);
       ARRAY_MAPPER (cos, FloatComplex, std::cos);
       ARRAY_MAPPER (cosh, FloatComplex, std::cosh);
       ARRAY_MAPPER (exp, FloatComplex, std::exp);
       ARRAY_MAPPER (expm1, FloatComplex, xexpm1);
-      ARRAY_MAPPER (fix, FloatComplex, ::fix);
-      ARRAY_MAPPER (floor, FloatComplex, ::floor);
+      ARRAY_MAPPER (fix, FloatComplex, octave::math::fix);
+      ARRAY_MAPPER (floor, FloatComplex, octave::math::floor);
       ARRAY_MAPPER (log, FloatComplex, std::log);
-      ARRAY_MAPPER (log2, FloatComplex, xlog2);
+      ARRAY_MAPPER (log2, FloatComplex, octave::math::log2);
       ARRAY_MAPPER (log10, FloatComplex, std::log10);
       ARRAY_MAPPER (log1p, FloatComplex, xlog1p);
-      ARRAY_MAPPER (round, FloatComplex, xround);
-      ARRAY_MAPPER (roundb, FloatComplex, xroundb);
-      ARRAY_MAPPER (signum, FloatComplex, ::signum);
+      ARRAY_MAPPER (round, FloatComplex, octave::math::round);
+      ARRAY_MAPPER (roundb, FloatComplex, octave::math::roundb);
+      ARRAY_MAPPER (signum, FloatComplex, octave::math::signum);
       ARRAY_MAPPER (sin, FloatComplex, std::sin);
       ARRAY_MAPPER (sinh, FloatComplex, std::sinh);
       ARRAY_MAPPER (sqrt, FloatComplex, std::sqrt);
       ARRAY_MAPPER (tan, FloatComplex, std::tan);
       ARRAY_MAPPER (tanh, FloatComplex, std::tanh);
-      ARRAY_MAPPER (isna, bool, octave_is_NA);
+      ARRAY_MAPPER (isna, bool, octave::math::is_NA);
 
     default:
       return octave_base_value::map (umap);
--- a/libinterp/octave-value/ov-flt-re-diag.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/octave-value/ov-flt-re-diag.cc	Wed May 25 16:51:16 2016 -0400
@@ -103,7 +103,7 @@
     case umap_sqrt:
       {
         FloatComplexColumnVector tmp = matrix.extract_diag ().map<FloatComplex>
-                                       (rc_sqrt);
+                                       (octave::math::rc_sqrt);
         FloatComplexDiagMatrix retval (tmp);
         retval.resize (matrix.rows (), matrix.columns ());
         return retval;
--- a/libinterp/octave-value/ov-flt-re-mat.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/octave-value/ov-flt-re-mat.cc	Wed May 25 16:51:16 2016 -0400
@@ -281,10 +281,10 @@
 
       float d = matrix(i);
 
-      if (xisnan (d))
+      if (octave::math::isnan (d))
         err_nan_to_character_conversion ();
 
-      int ival = NINT (d);
+      int ival = octave::math::nint (d);
 
       if (ival < 0 || ival > std::numeric_limits<unsigned char>::max ())
         {
@@ -743,14 +743,14 @@
     case umap_ ## UMAP: \
       return do_rc_map (matrix, FCN)
 
-      RC_ARRAY_MAPPER (acos, FloatComplex, rc_acos);
-      RC_ARRAY_MAPPER (acosh, FloatComplex, rc_acosh);
-      ARRAY_MAPPER (angle, float, ::arg);
-      ARRAY_MAPPER (arg, float, ::arg);
-      RC_ARRAY_MAPPER (asin, FloatComplex, rc_asin);
+      RC_ARRAY_MAPPER (acos, FloatComplex, octave::math::rc_acos);
+      RC_ARRAY_MAPPER (acosh, FloatComplex, octave::math::rc_acosh);
+      ARRAY_MAPPER (angle, float, octave::math::arg);
+      ARRAY_MAPPER (arg, float,octave::math ::arg);
+      RC_ARRAY_MAPPER (asin, FloatComplex, octave::math::rc_asin);
       ARRAY_MAPPER (asinh, float, xasinh);
       ARRAY_MAPPER (atan, float, ::atanf);
-      RC_ARRAY_MAPPER (atanh, FloatComplex, rc_atanh);
+      RC_ARRAY_MAPPER (atanh, FloatComplex, octave::math::rc_atanh);
       ARRAY_MAPPER (erf, float, xerf);
       ARRAY_MAPPER (erfinv, float, ::erfinv);
       ARRAY_MAPPER (erfcinv, float, ::erfcinv);
@@ -766,22 +766,22 @@
       ARRAY_MAPPER (cosh, float, ::coshf);
       ARRAY_MAPPER (exp, float, ::expf);
       ARRAY_MAPPER (expm1, float, xexpm1);
-      ARRAY_MAPPER (fix, float, ::fix);
+      ARRAY_MAPPER (fix, float, octave::math::fix);
       ARRAY_MAPPER (floor, float, ::floorf);
-      RC_ARRAY_MAPPER (log, FloatComplex, rc_log);
-      RC_ARRAY_MAPPER (log2, FloatComplex, rc_log2);
-      RC_ARRAY_MAPPER (log10, FloatComplex, rc_log10);
+      RC_ARRAY_MAPPER (log, FloatComplex, octave::math::rc_log);
+      RC_ARRAY_MAPPER (log2, FloatComplex, octave::math::rc_log2);
+      RC_ARRAY_MAPPER (log10, FloatComplex, octave::math::rc_log10);
       RC_ARRAY_MAPPER (log1p, FloatComplex, rc_log1p);
-      ARRAY_MAPPER (round, float, xround);
-      ARRAY_MAPPER (roundb, float, xroundb);
-      ARRAY_MAPPER (signum, float, ::signum);
+      ARRAY_MAPPER (round, float, octave::math::round);
+      ARRAY_MAPPER (roundb, float, octave::math::roundb);
+      ARRAY_MAPPER (signum, float, octave::math::signum);
       ARRAY_MAPPER (sin, float, ::sinf);
       ARRAY_MAPPER (sinh, float, ::sinhf);
-      RC_ARRAY_MAPPER (sqrt, FloatComplex, rc_sqrt);
+      RC_ARRAY_MAPPER (sqrt, FloatComplex, octave::math::rc_sqrt);
       ARRAY_MAPPER (tan, float, ::tanf);
       ARRAY_MAPPER (tanh, float, ::tanhf);
-      ARRAY_MAPPER (isna, bool, octave_is_NA);
-      ARRAY_MAPPER (xsignbit, float, xsignbit);
+      ARRAY_MAPPER (isna, bool, octave::math::is_NA);
+      ARRAY_MAPPER (xsignbit, float, octave::math::signbit);
 
     // Special cases for Matlab compatibility.
     case umap_xtolower:
--- a/libinterp/octave-value/ov-re-diag.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/octave-value/ov-re-diag.cc	Wed May 25 16:51:16 2016 -0400
@@ -171,7 +171,7 @@
       return DiagMatrix (matrix.rows (), matrix.cols (), 0.0);
     case umap_sqrt:
       {
-        ComplexColumnVector tmp = matrix.extract_diag ().map<Complex> (rc_sqrt);
+        ComplexColumnVector tmp = matrix.extract_diag ().map<Complex> (octave::math::rc_sqrt);
         ComplexDiagMatrix retval (tmp);
         retval.resize (matrix.rows (), matrix.columns ());
         return retval;
--- a/libinterp/octave-value/ov-re-mat.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/octave-value/ov-re-mat.cc	Wed May 25 16:51:16 2016 -0400
@@ -383,10 +383,10 @@
 
       double d = matrix(i);
 
-      if (xisnan (d))
+      if (octave::math::isnan (d))
         err_nan_to_character_conversion ();
 
-      int ival = NINT (d);
+      int ival = octave::math::nint (d);
 
       if (ival < 0 || ival > std::numeric_limits<unsigned char>::max ())
         {
@@ -868,14 +868,14 @@
     case umap_ ## UMAP: \
       return do_rc_map (matrix, FCN)
 
-      RC_ARRAY_MAPPER (acos, Complex, rc_acos);
-      RC_ARRAY_MAPPER (acosh, Complex, rc_acosh);
-      ARRAY_MAPPER (angle, double, ::arg);
-      ARRAY_MAPPER (arg, double, ::arg);
-      RC_ARRAY_MAPPER (asin, Complex, rc_asin);
+      RC_ARRAY_MAPPER (acos, Complex, octave::math::rc_acos);
+      RC_ARRAY_MAPPER (acosh, Complex, octave::math::rc_acosh);
+      ARRAY_MAPPER (angle, double, octave::math::arg);
+      ARRAY_MAPPER (arg, double,octave::math ::arg);
+      RC_ARRAY_MAPPER (asin, Complex, octave::math::rc_asin);
       ARRAY_MAPPER (asinh, double, xasinh);
       ARRAY_MAPPER (atan, double, ::atan);
-      RC_ARRAY_MAPPER (atanh, Complex, rc_atanh);
+      RC_ARRAY_MAPPER (atanh, Complex, octave::math::rc_atanh);
       ARRAY_MAPPER (erf, double, xerf);
       ARRAY_MAPPER (erfinv, double, ::erfinv);
       ARRAY_MAPPER (erfcinv, double, ::erfcinv);
@@ -891,22 +891,22 @@
       ARRAY_MAPPER (cosh, double, ::cosh);
       ARRAY_MAPPER (exp, double, ::exp);
       ARRAY_MAPPER (expm1, double, xexpm1);
-      ARRAY_MAPPER (fix, double, ::fix);
+      ARRAY_MAPPER (fix, double, octave::math::fix);
       ARRAY_MAPPER (floor, double, ::floor);
-      RC_ARRAY_MAPPER (log, Complex, rc_log);
-      RC_ARRAY_MAPPER (log2, Complex, rc_log2);
-      RC_ARRAY_MAPPER (log10, Complex, rc_log10);
+      RC_ARRAY_MAPPER (log, Complex, octave::math::rc_log);
+      RC_ARRAY_MAPPER (log2, Complex, octave::math::rc_log2);
+      RC_ARRAY_MAPPER (log10, Complex, octave::math::rc_log10);
       RC_ARRAY_MAPPER (log1p, Complex, rc_log1p);
-      ARRAY_MAPPER (round, double, xround);
-      ARRAY_MAPPER (roundb, double, xroundb);
-      ARRAY_MAPPER (signum, double, ::signum);
+      ARRAY_MAPPER (round, double, octave::math::round);
+      ARRAY_MAPPER (roundb, double, octave::math::roundb);
+      ARRAY_MAPPER (signum, double, octave::math::signum);
       ARRAY_MAPPER (sin, double, ::sin);
       ARRAY_MAPPER (sinh, double, ::sinh);
-      RC_ARRAY_MAPPER (sqrt, Complex, rc_sqrt);
+      RC_ARRAY_MAPPER (sqrt, Complex, octave::math::rc_sqrt);
       ARRAY_MAPPER (tan, double, ::tan);
       ARRAY_MAPPER (tanh, double, ::tanh);
-      ARRAY_MAPPER (isna, bool, octave_is_NA);
-      ARRAY_MAPPER (xsignbit, double, xsignbit);
+      ARRAY_MAPPER (isna, bool, octave::math::is_NA);
+      ARRAY_MAPPER (xsignbit, double, octave::math::signbit);
 
     // Special cases for Matlab compatibility.
     case umap_xtolower:
--- a/libinterp/octave-value/ov-re-sparse.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/octave-value/ov-re-sparse.cc	Wed May 25 16:51:16 2016 -0400
@@ -219,10 +219,10 @@
 
             double d = matrix.data (i);
 
-            if (xisnan (d))
+            if (octave::math::isnan (d))
               err_nan_to_character_conversion ();
 
-            int ival = NINT (d);
+            int ival = octave::math::nint (d);
 
             if (ival < 0 || ival > std::numeric_limits<unsigned char>::max ())
               {
@@ -907,14 +907,14 @@
     case umap_ ## UMAP: \
       return octave_value (matrix.map<TYPE> (FCN))
 
-      ARRAY_MAPPER (acos, Complex, rc_acos);
-      ARRAY_MAPPER (acosh, Complex, rc_acosh);
-      ARRAY_MAPPER (angle, double, ::arg);
-      ARRAY_MAPPER (arg, double, ::arg);
-      ARRAY_MAPPER (asin, Complex, rc_asin);
+      ARRAY_MAPPER (acos, Complex, octave::math::rc_acos);
+      ARRAY_MAPPER (acosh, Complex, octave::math::rc_acosh);
+      ARRAY_MAPPER (angle, double, octave::math::arg);
+      ARRAY_MAPPER (arg, double,octave::math ::arg);
+      ARRAY_MAPPER (asin, Complex, octave::math::rc_asin);
       ARRAY_MAPPER (asinh, double, xasinh);
       ARRAY_MAPPER (atan, double, ::atan);
-      ARRAY_MAPPER (atanh, Complex, rc_atanh);
+      ARRAY_MAPPER (atanh, Complex, octave::math::rc_atanh);
       ARRAY_MAPPER (erf, double, xerf);
       ARRAY_MAPPER (erfinv, double, ::erfinv);
       ARRAY_MAPPER (erfcinv, double, ::erfcinv);
@@ -930,24 +930,24 @@
       ARRAY_MAPPER (cosh, double, ::cosh);
       ARRAY_MAPPER (exp, double, ::exp);
       ARRAY_MAPPER (expm1, double, xexpm1);
-      ARRAY_MAPPER (fix, double, ::fix);
+      ARRAY_MAPPER (fix, double, octave::math::fix);
       ARRAY_MAPPER (floor, double, ::floor);
-      ARRAY_MAPPER (log, Complex, rc_log);
-      ARRAY_MAPPER (log2, Complex, rc_log2);
-      ARRAY_MAPPER (log10, Complex, rc_log10);
+      ARRAY_MAPPER (log, Complex, octave::math::rc_log);
+      ARRAY_MAPPER (log2, Complex, octave::math::rc_log2);
+      ARRAY_MAPPER (log10, Complex, octave::math::rc_log10);
       ARRAY_MAPPER (log1p, Complex, rc_log1p);
-      ARRAY_MAPPER (round, double, xround);
-      ARRAY_MAPPER (roundb, double, xroundb);
-      ARRAY_MAPPER (signum, double, ::signum);
+      ARRAY_MAPPER (round, double, octave::math::round);
+      ARRAY_MAPPER (roundb, double, octave::math::roundb);
+      ARRAY_MAPPER (signum, double, octave::math::signum);
       ARRAY_MAPPER (sin, double, ::sin);
       ARRAY_MAPPER (sinh, double, ::sinh);
-      ARRAY_MAPPER (sqrt, Complex, rc_sqrt);
+      ARRAY_MAPPER (sqrt, Complex, octave::math::rc_sqrt);
       ARRAY_MAPPER (tan, double, ::tan);
       ARRAY_MAPPER (tanh, double, ::tanh);
-      ARRAY_MAPPER (isnan, bool, xisnan);
-      ARRAY_MAPPER (isna, bool, octave_is_NA);
-      ARRAY_MAPPER (isinf, bool, xisinf);
-      ARRAY_MAPPER (isfinite, bool, xfinite);
+      ARRAY_MAPPER (isnan, bool, octave::math::isnan);
+      ARRAY_MAPPER (isna, bool, octave::math::is_NA);
+      ARRAY_MAPPER (isinf, bool, octave::math::isinf);
+      ARRAY_MAPPER (isfinite, bool, octave::math::finite);
 
     default: // Attempt to go via dense matrix.
       return octave_base_sparse<SparseMatrix>::map (umap);
--- a/libinterp/octave-value/ov-scalar.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/octave-value/ov-scalar.cc	Wed May 25 16:51:16 2016 -0400
@@ -131,10 +131,10 @@
 {
   octave_value retval;
 
-  if (xisnan (scalar))
+  if (octave::math::isnan (scalar))
     err_nan_to_character_conversion ();
 
-  int ival = NINT (scalar);
+  int ival = octave::math::nint (scalar);
 
   if (ival < 0 || ival > std::numeric_limits<unsigned char>::max ())
     {
@@ -320,14 +320,14 @@
       return octave_value (FCN (scalar))
 
       SCALAR_MAPPER (abs, ::fabs);
-      SCALAR_MAPPER (acos, rc_acos);
-      SCALAR_MAPPER (acosh, rc_acosh);
-      SCALAR_MAPPER (angle, ::arg);
-      SCALAR_MAPPER (arg, ::arg);
-      SCALAR_MAPPER (asin, rc_asin);
+      SCALAR_MAPPER (acos, octave::math::rc_acos);
+      SCALAR_MAPPER (acosh, octave::math::rc_acosh);
+      SCALAR_MAPPER (angle, octave::math::arg);
+      SCALAR_MAPPER (arg,octave::math ::arg);
+      SCALAR_MAPPER (asin, octave::math::rc_asin);
       SCALAR_MAPPER (asinh, xasinh);
       SCALAR_MAPPER (atan, ::atan);
-      SCALAR_MAPPER (atanh, rc_atanh);
+      SCALAR_MAPPER (atanh, octave::math::rc_atanh);
       SCALAR_MAPPER (erf, xerf);
       SCALAR_MAPPER (erfinv, ::erfinv);
       SCALAR_MAPPER (erfcinv, ::erfcinv);
@@ -343,25 +343,25 @@
       SCALAR_MAPPER (cosh, ::cosh);
       SCALAR_MAPPER (exp, ::exp);
       SCALAR_MAPPER (expm1, xexpm1);
-      SCALAR_MAPPER (fix, ::fix);
+      SCALAR_MAPPER (fix, octave::math::fix);
       SCALAR_MAPPER (floor, gnulib::floor);
-      SCALAR_MAPPER (log, rc_log);
-      SCALAR_MAPPER (log2, rc_log2);
-      SCALAR_MAPPER (log10, rc_log10);
+      SCALAR_MAPPER (log, octave::math::rc_log);
+      SCALAR_MAPPER (log2, octave::math::rc_log2);
+      SCALAR_MAPPER (log10, octave::math::rc_log10);
       SCALAR_MAPPER (log1p, rc_log1p);
-      SCALAR_MAPPER (round, xround);
-      SCALAR_MAPPER (roundb, xroundb);
-      SCALAR_MAPPER (signum, ::signum);
+      SCALAR_MAPPER (round, octave::math::round);
+      SCALAR_MAPPER (roundb, octave::math::roundb);
+      SCALAR_MAPPER (signum, octave::math::signum);
       SCALAR_MAPPER (sin, ::sin);
       SCALAR_MAPPER (sinh, ::sinh);
-      SCALAR_MAPPER (sqrt, rc_sqrt);
+      SCALAR_MAPPER (sqrt, octave::math::rc_sqrt);
       SCALAR_MAPPER (tan, ::tan);
       SCALAR_MAPPER (tanh, ::tanh);
-      SCALAR_MAPPER (isfinite, xfinite);
-      SCALAR_MAPPER (isinf, xisinf);
-      SCALAR_MAPPER (isna, octave_is_NA);
-      SCALAR_MAPPER (isnan, xisnan);
-      SCALAR_MAPPER (xsignbit, xsignbit);
+      SCALAR_MAPPER (isfinite, octave::math::finite);
+      SCALAR_MAPPER (isinf, octave::math::isinf);
+      SCALAR_MAPPER (isna, octave::math::is_NA);
+      SCALAR_MAPPER (isnan, octave::math::isnan);
+      SCALAR_MAPPER (xsignbit, octave::math::signbit);
 
     // Special cases for Matlab compatibility.
     case umap_xtolower:
--- a/libinterp/octave-value/ov-scalar.h	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/octave-value/ov-scalar.h	Wed May 25 16:51:16 2016 -0400
@@ -197,7 +197,7 @@
 
   bool bool_value (bool warn = false) const
   {
-    if (xisnan (scalar))
+    if (octave::math::isnan (scalar))
       err_nan_to_logical_conversion ();
     if (warn && scalar != 0 && scalar != 1)
       warn_logical_conversion ();
@@ -207,7 +207,7 @@
 
   boolNDArray bool_array_value (bool warn = false) const
   {
-    if (xisnan (scalar))
+    if (octave::math::isnan (scalar))
       err_nan_to_logical_conversion ();
     if (warn && scalar != 0 && scalar != 1)
       warn_logical_conversion ();
--- a/libinterp/octave-value/ov-usr-fcn.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/octave-value/ov-usr-fcn.cc	Wed May 25 16:51:16 2016 -0400
@@ -1019,7 +1019,7 @@
 
 static bool isargout1 (int nargout, const Matrix& ignored, double k)
 {
-  if (k != xround (k) || k <= 0)
+  if (k != octave::math::round (k) || k <= 0)
     error ("isargout: K must be a positive integer");
 
   return (k == 1 || k <= nargout) && ! val_in_table (ignored, k);
--- a/libinterp/operators/op-cs-cs.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/operators/op-cs-cs.cc	Wed May 25 16:51:16 2016 -0400
@@ -44,7 +44,7 @@
 {
   const octave_complex& v = dynamic_cast<const octave_complex&> (a);
   Complex x = v.complex_value ();
-  if (xisnan (x))
+  if (octave::math::isnan (x))
     err_nan_to_logical_conversion ();
 
   return octave_value (x == 0.0);
--- a/libinterp/operators/op-fcs-fcs.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/operators/op-fcs-fcs.cc	Wed May 25 16:51:16 2016 -0400
@@ -42,7 +42,7 @@
 {
   const octave_float_complex& v = dynamic_cast<const octave_float_complex&> (a);
   FloatComplex x = v.float_complex_value ();
-  if (xisnan (x))
+  if (octave::math::isnan (x))
     err_nan_to_logical_conversion ();
 
   return octave_value (x == 0.0f);
--- a/libinterp/operators/op-fs-fs.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/operators/op-fs-fs.cc	Wed May 25 16:51:16 2016 -0400
@@ -44,7 +44,7 @@
 {
   const octave_float_scalar& v = dynamic_cast<const octave_float_scalar&> (a);
   float x = v.float_value ();
-  if (xisnan (x))
+  if (octave::math::isnan (x))
     err_nan_to_logical_conversion ();
 
   return octave_value (x == 0.0f);
--- a/libinterp/operators/op-s-s.cc	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/operators/op-s-s.cc	Wed May 25 16:51:16 2016 -0400
@@ -45,7 +45,7 @@
 {
   const octave_scalar& v = dynamic_cast<const octave_scalar&> (a);
   double x = v.scalar_value ();
-  if (xisnan (x))
+  if (octave::math::isnan (x))
     err_nan_to_logical_conversion ();
 
   return octave_value (x == 0.0);
--- a/libinterp/operators/ops.h	Fri May 27 10:20:48 2016 -0400
+++ b/libinterp/operators/ops.h	Wed May 25 16:51:16 2016 -0400
@@ -314,7 +314,7 @@
     const CONCAT2 (octave_, t1)& v1 = dynamic_cast<const CONCAT2 (octave_, t1)&> (a1); \
     const CONCAT2 (octave_, t2)& v2 = dynamic_cast<const CONCAT2 (octave_, t2)&> (a2); \
  \
-    if (xisnan (v1.CONCAT2 (t1, _value) ()) || xisnan (v2.CONCAT2 (t2, _value) ())) \
+    if (octave::math::isnan (v1.CONCAT2 (t1, _value) ()) || octave::math::isnan (v2.CONCAT2 (t2, _value) ())) \
       err_nan_to_logical_conversion (); \
  \
     return octave_value \
--- a/liboctave/array/Array-C.cc	Fri May 27 10:20:48 2016 -0400
+++ b/liboctave/array/Array-C.cc	Wed May 25 16:51:16 2016 -0400
@@ -44,7 +44,7 @@
 inline bool
 sort_isnan<Complex> (const Complex& x)
 {
-  return xisnan (x);
+  return octave::math::isnan (x);
 }
 
 // Sort Criteria: 1) isnan, 2) magnitude of z, 3) phase of z in range (-pi, pi]
@@ -52,13 +52,13 @@
 static bool
 nan_ascending_compare (const Complex& x, const Complex& y)
 {
-  return xisnan (y) ? ! xisnan (x) : x < y;
+  return octave::math::isnan (y) ? ! octave::math::isnan (x) : x < y;
 }
 
 static bool
 nan_descending_compare (const Complex& x, const Complex& y)
 {
-  return xisnan (x) ? ! xisnan (y) : x > y;
+  return octave::math::isnan (x) ? ! octave::math::isnan (y) : x > y;
 }
 
 Array<Complex>::compare_fcn_type
@@ -69,7 +69,7 @@
   if (allow_chk)
     {
       octave_idx_type k = 0;
-      for (; k < a.numel () && ! xisnan (a(k)); k++) ;
+      for (; k < a.numel () && ! octave::math::isnan (a(k)); k++) ;
       if (k == a.numel ())
         {
           if (mode == ASCENDING)
--- a/liboctave/array/Array-d.cc	Fri May 27 10:20:48 2016 -0400
+++ b/liboctave/array/Array-d.cc	Wed May 25 16:51:16 2016 -0400
@@ -46,19 +46,19 @@
 inline bool
 sort_isnan<double> (double x)
 {
-  return xisnan (x);
+  return octave::math::isnan (x);
 }
 
 static bool
 nan_ascending_compare (double x, double y)
 {
-  return xisnan (y) ? ! xisnan (x) : x < y;
+  return octave::math::isnan (y) ? ! octave::math::isnan (x) : x < y;
 }
 
 static bool
 nan_descending_compare (double x, double y)
 {
-  return xisnan (x) ? ! xisnan (y) : x > y;
+  return octave::math::isnan (x) ? ! octave::math::isnan (y) : x > y;
 }
 
 Array<double>::compare_fcn_type
@@ -69,7 +69,7 @@
   if (allow_chk)
     {
       octave_idx_type k = 0;
-      for (; k < a.numel () && ! xisnan (a(k)); k++) ;
+      for (; k < a.numel () && ! octave::math::isnan (a(k)); k++) ;
       if (k == a.numel ())
         {
           if (mode == ASCENDING)
@@ -107,7 +107,7 @@
   if (! mode)
     {
       // Auto-detect mode.
-      if (el[n-1] < el[0] || xisnan (el[0]))
+      if (el[n-1] < el[0] || octave::math::isnan (el[0]))
         mode = DESCENDING;
       else
         mode = ASCENDING;
@@ -120,7 +120,7 @@
       // Sort out NaNs.
       do
         r = el[j++];
-      while (xisnan (r) && j < n);
+      while (octave::math::isnan (r) && j < n);
 
       // Orient the test so that NaN will not pass through.
       for (; j < n; j++)
@@ -138,7 +138,7 @@
   else if (mode == ASCENDING)
     {
       // Sort out NaNs.
-      while (n > 0 && xisnan (el[n-1]))
+      while (n > 0 && octave::math::isnan (el[n-1]))
         n--;
 
       if (n > 0)
--- a/liboctave/array/Array-f.cc	Fri May 27 10:20:48 2016 -0400
+++ b/liboctave/array/Array-f.cc	Wed May 25 16:51:16 2016 -0400
@@ -46,19 +46,19 @@
 inline bool
 sort_isnan<float> (float x)
 {
-  return xisnan (x);
+  return octave::math::isnan (x);
 }
 
 static bool
 nan_ascending_compare (float x, float y)
 {
-  return xisnan (y) ? ! xisnan (x) : x < y;
+  return octave::math::isnan (y) ? ! octave::math::isnan (x) : x < y;
 }
 
 static bool
 nan_descending_compare (float x, float y)
 {
-  return xisnan (x) ? ! xisnan (y) : x > y;
+  return octave::math::isnan (x) ? ! octave::math::isnan (y) : x > y;
 }
 
 Array<float>::compare_fcn_type
@@ -69,7 +69,7 @@
   if (allow_chk)
     {
       octave_idx_type k = 0;
-      for (; k < a.numel () && ! xisnan (a(k)); k++) ;
+      for (; k < a.numel () && ! octave::math::isnan (a(k)); k++) ;
       if (k == a.numel ())
         {
           if (mode == ASCENDING)
@@ -107,7 +107,7 @@
   if (! mode)
     {
       // Auto-detect mode.
-      if (el[n-1] < el[0] || xisnan (el[0]))
+      if (el[n-1] < el[0] || octave::math::isnan (el[0]))
         mode = DESCENDING;
       else
         mode = ASCENDING;
@@ -120,7 +120,7 @@
       // Sort out NaNs.
       do
         r = el[j++];
-      while (xisnan (r) && j < n);
+      while (octave::math::isnan (r) && j < n);
 
       // Orient the test so that NaN will not pass through.
       for (; j < n; j++)
@@ -138,7 +138,7 @@
   else if (mode == ASCENDING)
     {
       // Sort out NaNs.
-      while (n > 0 && xisnan (el[n-1]))
+      while (n > 0 && octave::math::isnan (el[n-1]))
         n--;
 
       if (n > 0)
--- a/liboctave/array/Array-fC.cc	Fri May 27 10:20:48 2016 -0400
+++ b/liboctave/array/Array-fC.cc	Wed May 25 16:51:16 2016 -0400
@@ -44,7 +44,7 @@
 inline bool
 sort_isnan<FloatComplex> (const FloatComplex& x)
 {
-  return xisnan (x);
+  return octave::math::isnan (x);
 }
 
 // Sort Criteria: 1) isnan, 2) magnitude of z, 3) phase of z in range (-pi, pi]
@@ -52,13 +52,13 @@
 static bool
 nan_ascending_compare (const FloatComplex& x, const FloatComplex& y)
 {
-  return xisnan (y) ? ! xisnan (x) : x < y;
+  return octave::math::isnan (y) ? ! octave::math::isnan (x) : x < y;
 }
 
 static bool
 nan_descending_compare (const FloatComplex& x, const FloatComplex& y)
 {
-  return xisnan (x) ? ! xisnan (y) : x > y;
+  return octave::math::isnan (x) ? ! octave::math::isnan (y) : x > y;
 }
 
 Array<FloatComplex>::compare_fcn_type
@@ -69,7 +69,7 @@
   if (allow_chk)
     {
       octave_idx_type k = 0;
-      for (; k < a.numel () && ! xisnan (a(k)); k++) ;
+      for (; k < a.numel () && ! octave::math::isnan (a(k)); k++) ;
       if (k == a.numel ())
         {
           if (mode == ASCENDING)
--- a/liboctave/array/Array.cc	Fri May 27 10:20:48 2016 -0400
+++ b/liboctave/array/Array.cc	Wed May 25 16:51:16 2016 -0400
@@ -2209,7 +2209,7 @@
   sortmode vmode = UNSORTED;
 
   // Attempt the O(M+N) algorithm if M is large enough.
-  if (nval > ratio * n / xlog2 (n + 1.0))
+  if (nval > ratio * n / octave::math::log2 (n + 1.0))
     {
       vmode = values.is_sorted ();
       // The table must not contain a NaN.
--- a/liboctave/array/CMatrix.cc	Fri May 27 10:20:48 2016 -0400
+++ b/liboctave/array/CMatrix.cc	Wed May 25 16:51:16 2016 -0400
@@ -1049,7 +1049,7 @@
   anorm = retval.abs ().sum ().row (static_cast<octave_idx_type>(0)).max ();
 
   // Work around bug #45577, LAPACK crashes Octave if norm is NaN
-  if (xisnan (anorm))
+  if (octave::math::isnan (anorm))
     info = -1;
   else
     F77_XFCN (zgetrf, ZGETRF, (nc, nc, tmp_data, nr, pipvt, info));
@@ -1617,7 +1617,7 @@
       anorm = xnorm (*this, 1);
 
       // Work around bug #45577, LAPACK crashes Octave if norm is NaN
-      if (xisnan (anorm))
+      if (octave::math::isnan (anorm))
         info = -1;
       else
         F77_XFCN (zgetrf, ZGETRF, (nr, nr, tmp_data, nr, pipvt, info));
@@ -1812,7 +1812,7 @@
               double *prz = rz.fortran_vec ();
 
               // Work around bug #45577, LAPACK crashes Octave if norm is NaN
-              if (xisnan (anorm))
+              if (octave::math::isnan (anorm))
                 info = -1;
               else
                 F77_XFCN (zgetrf, ZGETRF, (nr, nr, tmp_data, nr, pipvt, info));
@@ -1917,7 +1917,7 @@
 
           volatile double rcond_plus_one = rcon + 1.0;
 
-          if (rcond_plus_one == 1.0 || xisnan (rcon))
+          if (rcond_plus_one == 1.0 || octave::math::isnan (rcon))
             {
               info = -2;
 
@@ -2007,7 +2007,7 @@
 
           volatile double rcond_plus_one = rcon + 1.0;
 
-          if (rcond_plus_one == 1.0 || xisnan (rcon))
+          if (rcond_plus_one == 1.0 || octave::math::isnan (rcon))
             {
               info = -2;
 
@@ -2089,7 +2089,7 @@
 
                   volatile double rcond_plus_one = rcon + 1.0;
 
-                  if (rcond_plus_one == 1.0 || xisnan (rcon))
+                  if (rcond_plus_one == 1.0 || octave::math::isnan (rcon))
                     {
                       info = -2;
 
@@ -2141,7 +2141,7 @@
                     .max ();
 
           // Work around bug #45577, LAPACK crashes Octave if norm is NaN
-          if (xisnan (anorm))
+          if (octave::math::isnan (anorm))
             info = -2;
           else
             F77_XFCN (zgetrf, ZGETRF, (nr, nr, tmp_data, nr, pipvt, info));
@@ -2176,7 +2176,7 @@
 
                   volatile double rcond_plus_one = rcon + 1.0;
 
-                  if (rcond_plus_one == 1.0 || xisnan (rcon))
+                  if (rcond_plus_one == 1.0 || octave::math::isnan (rcon))
                     {
                       info = -2;
 
@@ -2617,7 +2617,7 @@
       // call.
       double dminmn = static_cast<double> (minmn);
       double dsmlsizp1 = static_cast<double> (smlsiz+1);
-      double tmp = xlog2 (dminmn / dsmlsizp1);
+      double tmp = octave::math::log2 (dminmn / dsmlsizp1);
 
       octave_idx_type nlvl = static_cast<octave_idx_type> (tmp) + 1;
       if (nlvl < 0)
@@ -2807,7 +2807,7 @@
       // call.
       double dminmn = static_cast<double> (minmn);
       double dsmlsizp1 = static_cast<double> (smlsiz+1);
-      double tmp = xlog2 (dminmn / dsmlsizp1);
+      double tmp = octave::math::log2 (dminmn / dsmlsizp1);
 
       octave_idx_type nlvl = static_cast<octave_idx_type> (tmp) + 1;
       if (nlvl < 0)
@@ -3153,7 +3153,7 @@
             {
               tmp_min = elem (i, idx_j);
 
-              if (! xisnan (tmp_min))
+              if (! octave::math::isnan (tmp_min))
                 {
                   abs_min = real_only ? std::real (tmp_min)
                                       : std::abs (tmp_min);
@@ -3165,7 +3165,7 @@
             {
               Complex tmp = elem (i, j);
 
-              if (xisnan (tmp))
+              if (octave::math::isnan (tmp))
                 continue;
 
               double abs_tmp = real_only ? std::real (tmp) : std::abs (tmp);
@@ -3178,7 +3178,7 @@
                 }
             }
 
-          if (xisnan (tmp_min))
+          if (octave::math::isnan (tmp_min))
             {
               result.elem (i) = Complex_NaN_result;
               idx_arg.elem (i) = 0;
@@ -3228,7 +3228,7 @@
             {
               tmp_max = elem (i, idx_j);
 
-              if (! xisnan (tmp_max))
+              if (! octave::math::isnan (tmp_max))
                 {
                   abs_max = real_only ? std::real (tmp_max)
                                       : std::abs (tmp_max);
@@ -3240,7 +3240,7 @@
             {
               Complex tmp = elem (i, j);
 
-              if (xisnan (tmp))
+              if (octave::math::isnan (tmp))
                 continue;
 
               double abs_tmp = real_only ? std::real (tmp) : std::abs (tmp);
@@ -3253,7 +3253,7 @@
                 }
             }
 
-          if (xisnan (tmp_max))
+          if (octave::math::isnan (tmp_max))
             {
               result.elem (i) = Complex_NaN_result;
               idx_arg.elem (i) = 0;
@@ -3303,7 +3303,7 @@
             {
               tmp_min = elem (idx_i, j);
 
-              if (! xisnan (tmp_min))
+              if (! octave::math::isnan (tmp_min))
                 {
                   abs_min = real_only ? std::real (tmp_min)
                                       : std::abs (tmp_min);
@@ -3315,7 +3315,7 @@
             {
               Complex tmp = elem (i, j);
 
-              if (xisnan (tmp))
+              if (octave::math::isnan (tmp))
                 continue;
 
               double abs_tmp = real_only ? std::real (tmp) : std::abs (tmp);
@@ -3328,7 +3328,7 @@
                 }
             }
 
-          if (xisnan (tmp_min))
+          if (octave::math::isnan (tmp_min))
             {
               result.elem (j) = Complex_NaN_result;
               idx_arg.elem (j) = 0;
@@ -3378,7 +3378,7 @@
             {
               tmp_max = elem (idx_i, j);
 
-              if (! xisnan (tmp_max))
+              if (! octave::math::isnan (tmp_max))
                 {
                   abs_max = real_only ? std::real (tmp_max)
                                       : std::abs (tmp_max);
@@ -3390,7 +3390,7 @@
             {
               Complex tmp = elem (i, j);
 
-              if (xisnan (tmp))
+              if (octave::math::isnan (tmp))
                 continue;
 
               double abs_tmp = real_only ? std::real (tmp) : std::abs (tmp);
@@ -3403,7 +3403,7 @@
                 }
             }
 
-          if (xisnan (tmp_max))
+          if (octave::math::isnan (tmp_max))
             {
               result.elem (j) = Complex_NaN_result;
               idx_arg.elem (j) = 0;
@@ -3720,7 +3720,7 @@
     for (octave_idx_type i = 0; i < nr; i++)
       {
         octave_quit ();
-        result(i, j) = xmin (c, m(i, j));
+        result(i, j) = octave::math::min (c, m(i, j));
       }
 
   return result;
@@ -3740,7 +3740,7 @@
     for (octave_idx_type i = 0; i < nr; i++)
       {
         octave_quit ();
-        result(i, j) = xmin (m(i, j), c);
+        result(i, j) = octave::math::min (m(i, j), c);
       }
 
   return result;
@@ -3776,14 +3776,14 @@
       if (columns_are_real_only)
         {
           for (octave_idx_type i = 0; i < nr; i++)
-            result(i, j) = xmin (std::real (a(i, j)), std::real (b(i, j)));
+            result(i, j) = octave::math::min (std::real (a(i, j)), std::real (b(i, j)));
         }
       else
         {
           for (octave_idx_type i = 0; i < nr; i++)
             {
               octave_quit ();
-              result(i, j) = xmin (a(i, j), b(i, j));
+              result(i, j) = octave::math::min (a(i, j), b(i, j));
             }
         }
     }
@@ -3805,7 +3805,7 @@
     for (octave_idx_type i = 0; i < nr; i++)
       {
         octave_quit ();
-        result(i, j) = xmax (c, m(i, j));
+        result(i, j) = octave::math::max (c, m(i, j));
       }
 
   return result;
@@ -3825,7 +3825,7 @@
     for (octave_idx_type i = 0; i < nr; i++)
       {
         octave_quit ();
-        result(i, j) = xmax (m(i, j), c);
+        result(i, j) = octave::math::max (m(i, j), c);
       }
 
   return result;
@@ -3863,7 +3863,7 @@
           for (octave_idx_type i = 0; i < nr; i++)
             {
               octave_quit ();
-              result(i, j) = xmax (std::real (a(i, j)), std::real (b(i, j)));
+              result(i, j) = octave::math::max (std::real (a(i, j)), std::real (b(i, j)));
             }
         }
       else
@@ -3871,7 +3871,7 @@
           for (octave_idx_type i = 0; i < nr; i++)
             {
               octave_quit ();
-              result(i, j) = xmax (a(i, j), b(i, j));
+              result(i, j) = octave::math::max (a(i, j), b(i, j));
             }
         }
     }
--- a/liboctave/array/CNDArray.cc	Fri May 27 10:20:48 2016 -0400
+++ b/liboctave/array/CNDArray.cc	Wed May 25 16:51:16 2016 -0400
@@ -574,7 +574,7 @@
       if (i_val < min_val)
         min_val = i_val;
 
-      if (D_NINT (r_val) != r_val || D_NINT (i_val) != i_val)
+      if (octave::math::x_nint (r_val) != r_val || octave::math::x_nint (i_val) != i_val)
         return false;
     }
 
@@ -728,19 +728,19 @@
 boolNDArray
 ComplexNDArray::isnan (void) const
 {
-  return do_mx_unary_map<bool, Complex, xisnan> (*this);
+  return do_mx_unary_map<bool, Complex, octave::math::isnan> (*this);
 }
 
 boolNDArray
 ComplexNDArray::isinf (void) const
 {
-  return do_mx_unary_map<bool, Complex, xisinf> (*this);
+  return do_mx_unary_map<bool, Complex, octave::math::isinf> (*this);
 }
 
 boolNDArray
 ComplexNDArray::isfinite (void) const
 {
-  return do_mx_unary_map<bool, Complex, xfinite> (*this);
+  return do_mx_unary_map<bool, Complex, octave::math::finite> (*this);
 }
 
 ComplexNDArray
--- a/liboctave/array/CSparse.cc	Fri May 27 10:20:48 2016 -0400
+++ b/liboctave/array/CSparse.cc	Wed May 25 16:51:16 2016 -0400
@@ -310,12 +310,12 @@
             {
               Complex tmp = data (i);
 
-              if (xisnan (tmp))
+              if (octave::math::isnan (tmp))
                 continue;
 
               double abs_tmp = std::abs (tmp);
 
-              if (xisnan (abs_max) || abs_tmp > abs_max)
+              if (octave::math::isnan (abs_max) || abs_tmp > abs_max)
                 {
                   idx_j = ridx (i);
                   tmp_max = tmp;
@@ -323,7 +323,7 @@
                 }
             }
 
-          idx_arg.elem (j) = xisnan (tmp_max) ? 0 : idx_j;
+          idx_arg.elem (j) = octave::math::isnan (tmp_max) ? 0 : idx_j;
           if (abs_max != 0.)
             nel++;
         }
@@ -372,7 +372,7 @@
               octave_idx_type ix = idx_arg.elem (ir);
               Complex tmp = data (i);
 
-              if (xisnan (tmp))
+              if (octave::math::isnan (tmp))
                 continue;
               else if (ix == -1 || std::abs (tmp) > std::abs (elem (ir, ix)))
                 idx_arg.elem (ir) = j;
@@ -467,12 +467,12 @@
             {
               Complex tmp = data (i);
 
-              if (xisnan (tmp))
+              if (octave::math::isnan (tmp))
                 continue;
 
               double abs_tmp = std::abs (tmp);
 
-              if (xisnan (abs_min) || abs_tmp < abs_min)
+              if (octave::math::isnan (abs_min) || abs_tmp < abs_min)
                 {
                   idx_j = ridx (i);
                   tmp_min = tmp;
@@ -480,7 +480,7 @@
                 }
             }
 
-          idx_arg.elem (j) = xisnan (tmp_min) ? 0 : idx_j;
+          idx_arg.elem (j) = octave::math::isnan (tmp_min) ? 0 : idx_j;
           if (abs_min != 0.)
             nel++;
         }
@@ -529,7 +529,7 @@
               octave_idx_type ix = idx_arg.elem (ir);
               Complex tmp = data (i);
 
-              if (xisnan (tmp))
+              if (octave::math::isnan (tmp))
                 continue;
               else if (ix == -1 || std::abs (tmp) < std::abs (elem (ir, ix)))
                 idx_arg.elem (ir) = j;
@@ -1161,11 +1161,11 @@
       UMFPACK_ZNAME (defaults) (control);
 
       double tmp = octave_sparse_params::get_key ("spumoni");
-      if (! xisnan (tmp))
+      if (! octave::math::isnan (tmp))
         Control (UMFPACK_PRL) = tmp;
 
       tmp = octave_sparse_params::get_key ("piv_tol");
-      if (! xisnan (tmp))
+      if (! octave::math::isnan (tmp))
         {
           Control (UMFPACK_SYM_PIVOT_TOLERANCE) = tmp;
           Control (UMFPACK_PIVOT_TOLERANCE) = tmp;
@@ -1173,7 +1173,7 @@
 
       // Set whether we are allowed to modify Q or not
       tmp = octave_sparse_params::get_key ("autoamd");
-      if (! xisnan (tmp))
+      if (! octave::math::isnan (tmp))
         Control (UMFPACK_FIXQ) = tmp;
 
       // Turn-off UMFPACK scaling for LU
@@ -1779,7 +1779,7 @@
 
       volatile double rcond_plus_one = rcond + 1.0;
 
-      if (rcond_plus_one == 1.0 || xisnan (rcond))
+      if (rcond_plus_one == 1.0 || octave::math::isnan (rcond))
         {
           err = -2;
 
@@ -2061,7 +2061,7 @@
 
       volatile double rcond_plus_one = rcond + 1.0;
 
-      if (rcond_plus_one == 1.0 || xisnan (rcond))
+      if (rcond_plus_one == 1.0 || octave::math::isnan (rcond))
         {
           err = -2;
 
@@ -2290,7 +2290,7 @@
 
       volatile double rcond_plus_one = rcond + 1.0;
 
-      if (rcond_plus_one == 1.0 || xisnan (rcond))
+      if (rcond_plus_one == 1.0 || octave::math::isnan (rcond))
         {
           err = -2;
 
@@ -2572,7 +2572,7 @@
 
       volatile double rcond_plus_one = rcond + 1.0;
 
-      if (rcond_plus_one == 1.0 || xisnan (rcond))
+      if (rcond_plus_one == 1.0 || octave::math::isnan (rcond))
         {
           err = -2;
 
@@ -2821,7 +2821,7 @@
 
       volatile double rcond_plus_one = rcond + 1.0;
 
-      if (rcond_plus_one == 1.0 || xisnan (rcond))
+      if (rcond_plus_one == 1.0 || octave::math::isnan (rcond))
         {
           err = -2;
 
@@ -3122,7 +3122,7 @@
 
       volatile double rcond_plus_one = rcond + 1.0;
 
-      if (rcond_plus_one == 1.0 || xisnan (rcond))
+      if (rcond_plus_one == 1.0 || octave::math::isnan (rcond))
         {
           err = -2;
 
@@ -3375,7 +3375,7 @@
 
       volatile double rcond_plus_one = rcond + 1.0;
 
-      if (rcond_plus_one == 1.0 || xisnan (rcond))
+      if (rcond_plus_one == 1.0 || octave::math::isnan (rcond))
         {
           err = -2;
 
@@ -3675,7 +3675,7 @@
 
       volatile double rcond_plus_one = rcond + 1.0;
 
-      if (rcond_plus_one == 1.0 || xisnan (rcond))
+      if (rcond_plus_one == 1.0 || octave::math::isnan (rcond))
         {
           err = -2;
 
@@ -4389,7 +4389,7 @@
 
                   volatile double rcond_plus_one = rcond + 1.0;
 
-                  if (rcond_plus_one == 1.0 || xisnan (rcond))
+                  if (rcond_plus_one == 1.0 || octave::math::isnan (rcond))
                     {
                       err = -2;
 
@@ -4508,7 +4508,7 @@
 
                   volatile double rcond_plus_one = rcond + 1.0;
 
-                  if (rcond_plus_one == 1.0 || xisnan (rcond))
+                  if (rcond_plus_one == 1.0 || octave::math::isnan (rcond))
                     {
                       err = -2;
 
@@ -4633,7 +4633,7 @@
 
                   volatile double rcond_plus_one = rcond + 1.0;
 
-                  if (rcond_plus_one == 1.0 || xisnan (rcond))
+                  if (rcond_plus_one == 1.0 || octave::math::isnan (rcond))
                     {
                       err = -2;
 
@@ -4785,7 +4785,7 @@
 
                   volatile double rcond_plus_one = rcond + 1.0;
 
-                  if (rcond_plus_one == 1.0 || xisnan (rcond))
+                  if (rcond_plus_one == 1.0 || octave::math::isnan (rcond))
                     {
                       err = -2;
 
@@ -4949,7 +4949,7 @@
 
                   volatile double rcond_plus_one = rcond + 1.0;
 
-                  if (rcond_plus_one == 1.0 || xisnan (rcond))
+                  if (rcond_plus_one == 1.0 || octave::math::isnan (rcond))
                     {
                       err = -2;
 
@@ -5066,7 +5066,7 @@
 
                   volatile double rcond_plus_one = rcond + 1.0;
 
-                  if (rcond_plus_one == 1.0 || xisnan (rcond))
+                  if (rcond_plus_one == 1.0 || octave::math::isnan (rcond))
                     {
                       err = -2;
 
@@ -5193,7 +5193,7 @@
 
                   volatile double rcond_plus_one = rcond + 1.0;
 
-                  if (rcond_plus_one == 1.0 || xisnan (rcond))
+                  if (rcond_plus_one == 1.0 || octave::math::isnan (rcond))
                     {
                       err = -2;
 
@@ -5350,7 +5350,7 @@
 
                   volatile double rcond_plus_one = rcond + 1.0;
 
-                  if (rcond_plus_one == 1.0 || xisnan (rcond))
+                  if (rcond_plus_one == 1.0 || octave::math::isnan (rcond))
                     {
                       err = -2;
 
@@ -5445,10 +5445,10 @@
   UMFPACK_ZNAME (defaults) (control);
 
   double tmp = octave_sparse_params::get_key ("spumoni");
-  if (! xisnan (tmp))
+  if (! octave::math::isnan (tmp))
     Control (UMFPACK_PRL) = tmp;
   tmp = octave_sparse_params::get_key ("piv_tol");
-  if (! xisnan (tmp))
+  if (! octave::math::isnan (tmp))
     {
       Control (UMFPACK_SYM_PIVOT_TOLERANCE) = tmp;
       Control (UMFPACK_PIVOT_TOLERANCE) = tmp;
@@ -5456,7 +5456,7 @@
 
   // Set whether we are allowed to modify Q or not
   tmp = octave_sparse_params::get_key ("autoamd");
-  if (! xisnan (tmp))
+  if (! octave::math::isnan (tmp))
     Control (UMFPACK_FIXQ) = tmp;
 
   UMFPACK_ZNAME (report_control) (control);
@@ -5506,7 +5506,7 @@
       volatile double rcond_plus_one = rcond + 1.0;
 
       if (status == UMFPACK_WARNING_singular_matrix
-          || rcond_plus_one == 1.0 || xisnan (rcond))
+          || rcond_plus_one == 1.0 || octave::math::isnan (rcond))
         {
           UMFPACK_ZNAME (report_numeric) (Numeric, control);
 
@@ -5665,7 +5665,7 @@
             {
               volatile double rcond_plus_one = rcond + 1.0;
 
-              if (rcond_plus_one == 1.0 || xisnan (rcond))
+              if (rcond_plus_one == 1.0 || octave::math::isnan (rcond))
                 {
                   err = -2;
 
@@ -5925,7 +5925,7 @@
             {
               volatile double rcond_plus_one = rcond + 1.0;
 
-              if (rcond_plus_one == 1.0 || xisnan (rcond))
+              if (rcond_plus_one == 1.0 || octave::math::isnan (rcond))
                 {
                   err = -2;
 
@@ -6213,7 +6213,7 @@
             {
               volatile double rcond_plus_one = rcond + 1.0;
 
-              if (rcond_plus_one == 1.0 || xisnan (rcond))
+              if (rcond_plus_one == 1.0 || octave::math::isnan (rcond))
                 {
                   err = -2;
 
@@ -6452,7 +6452,7 @@
             {
               volatile double rcond_plus_one = rcond + 1.0;
 
-              if (rcond_plus_one == 1.0 || xisnan (rcond))
+              if (rcond_plus_one == 1.0 || octave::math::isnan (rcond))
                 {
                   err = -2;
 
@@ -6586,7 +6586,7 @@
               volatile double rcond_plus_one = rcond + 1.0;
 
               if (status == UMFPACK_WARNING_singular_matrix
-                  || rcond_plus_one == 1.0 || xisnan (rcond))
+                  || rcond_plus_one == 1.0 || octave::math::isnan (rcond))
                 {
                   err = -2;
 
@@ -7199,7 +7199,7 @@
   for (octave_idx_type i = 0; i < nel; i++)
     {
       Complex val = data (i);
-      if (xisnan (val))
+      if (octave::math::isnan (val))
         return true;
     }
 
@@ -7214,7 +7214,7 @@
   for (octave_idx_type i = 0; i < nel; i++)
     {
       Complex val = data (i);
-      if (xisinf (val) || xisnan (val))
+      if (octave::math::isinf (val) || octave::math::isnan (val))
         return true;
     }
 
@@ -7263,7 +7263,7 @@
       if (i_val < min_val)
         min_val = i_val;
 
-      if (D_NINT (r_val) != r_val || D_NINT (i_val) != i_val)
+      if (octave::math::x_nint (r_val) != r_val || octave::math::x_nint (i_val) != i_val)
         return false;
     }
 
@@ -7604,7 +7604,7 @@
 
       for (octave_idx_type j = 0; j < nc; j++)
         for (octave_idx_type i = m.cidx (j); i < m.cidx (j+1); i++)
-          result.data (i) = xmin (c, m.data (i));
+          result.data (i) = octave::math::min (c, m.data (i));
     }
 
   return result;
@@ -7647,7 +7647,7 @@
               octave_quit ();
               if ((! jb_lt_max) || (ja_lt_max && (a.ridx (ja) < b.ridx (jb))))
                 {
-                  Complex tmp = xmin (a.data (ja), 0.);
+                  Complex tmp = octave::math::min (a.data (ja), 0.);
                   if (tmp != 0.)
                     {
                       r.ridx (jx) = a.ridx (ja);
@@ -7660,7 +7660,7 @@
               else if ((! ja_lt_max)
                        || (jb_lt_max && (b.ridx (jb) < a.ridx (ja))))
                 {
-                  Complex tmp = xmin (0., b.data (jb));
+                  Complex tmp = octave::math::min (0., b.data (jb));
                   if (tmp != 0.)
                     {
                       r.ridx (jx) = b.ridx (jb);
@@ -7672,7 +7672,7 @@
                 }
               else
                 {
-                  Complex tmp = xmin (a.data (ja), b.data (jb));
+                  Complex tmp = octave::math::min (a.data (ja), b.data (jb));
                   if (tmp != 0.)
                     {
                       r.data (jx) = tmp;
@@ -7714,12 +7714,12 @@
   EMPTY_RETURN_CHECK (SparseComplexMatrix);
 
   // Count the number of nonzero elements
-  if (xmax (c, 0.) != 0.)
+  if (octave::math::max (c, 0.) != 0.)
     {
       result = SparseComplexMatrix (nr, nc, c);
       for (octave_idx_type j = 0; j < nc; j++)
         for (octave_idx_type i = m.cidx (j); i < m.cidx (j+1); i++)
-          result.xdata (m.ridx (i) + j * nr) = xmax (c, m.data (i));
+          result.xdata (m.ridx (i) + j * nr) = octave::math::max (c, m.data (i));
     }
   else
     result = SparseComplexMatrix (m);
@@ -7764,7 +7764,7 @@
               octave_quit ();
               if ((! jb_lt_max) || (ja_lt_max && (a.ridx (ja) < b.ridx (jb))))
                 {
-                  Complex tmp = xmax (a.data (ja), 0.);
+                  Complex tmp = octave::math::max (a.data (ja), 0.);
                   if (tmp != 0.)
                     {
                       r.ridx (jx) = a.ridx (ja);
@@ -7777,7 +7777,7 @@
               else if ((! ja_lt_max)
                        || (jb_lt_max && (b.ridx (jb) < a.ridx (ja))))
                 {
-                  Complex tmp = xmax (0., b.data (jb));
+                  Complex tmp = octave::math::max (0., b.data (jb));
                   if (tmp != 0.)
                     {
                       r.ridx (jx) = b.ridx (jb);
@@ -7789,7 +7789,7 @@
                 }
               else
                 {
-                  Complex tmp = xmax (a.data (ja), b.data (jb));
+                  Complex tmp = octave::math::max (a.data (ja), b.data (jb));
                   if (tmp != 0.)
                     {
                       r.data (jx) = tmp;
--- a/liboctave/array/Range.cc	Fri May 27 10:20:48 2016 -0400
+++ b/liboctave/array/Range.cc	Wed May 25 16:51:16 2016 -0400
@@ -43,9 +43,9 @@
   // will also be an integer, even if the limit is not.  If there is one
   // or fewer elements only the base needs to be an integer
 
-  return (! (xisnan (rng_base) || xisnan (rng_inc))
-          && (NINTbig (rng_base) == rng_base || rng_numel < 1)
-          && (NINTbig (rng_inc) == rng_inc || rng_numel <= 1));
+  return (! (octave::math::isnan (rng_base) || octave::math::isnan (rng_inc))
+          && (octave::math::nint_big (rng_base) == rng_base || rng_numel < 1)
+          && (octave::math::nint_big (rng_inc) == rng_inc || rng_numel <= 1));
 }
 
 Matrix
--- a/liboctave/array/Range.h	Fri May 27 10:20:48 2016 -0400
+++ b/liboctave/array/Range.h	Wed May 25 16:51:16 2016 -0400
@@ -62,7 +62,7 @@
     : rng_base (b), rng_limit (b + (n-1) * i), rng_inc (i),
       rng_numel (n), cache ()
   {
-    if (! xfinite (b) || ! xfinite (i) || ! xfinite (rng_limit))
+    if (! octave::math::finite (b) || ! octave::math::finite (i) || ! octave::math::finite (rng_limit))
       rng_numel = -2;
     else
       {
@@ -155,7 +155,7 @@
     : rng_base (b), rng_limit (l), rng_inc (i),
       rng_numel (n), cache ()
   {
-    if (! xfinite (b) || ! xfinite (i) || ! xfinite (l))
+    if (! octave::math::finite (b) || ! octave::math::finite (i) || ! octave::math::finite (l))
       rng_numel = -2;
   }
 };
--- a/liboctave/array/Sparse-C.cc	Fri May 27 10:20:48 2016 -0400
+++ b/liboctave/array/Sparse-C.cc	Wed May 25 16:51:16 2016 -0400
@@ -37,7 +37,7 @@
 static double
 xabs (const Complex& x)
 {
-  return ((xisinf (x.real ()) || xisinf (x.imag ()))
+  return ((octave::math::isinf (x.real ()) || octave::math::isinf (x.imag ()))
           ? octave::numeric_limits<double>::Inf () : abs (x));
 }
 
@@ -46,7 +46,7 @@
 bool
 sparse_ascending_compare<Complex> (const Complex& a, const Complex& b)
 {
-  return (xisnan (b) || (xabs (a) < xabs (b))
+  return (octave::math::isnan (b) || (xabs (a) < xabs (b))
           || ((xabs (a) == xabs (b)) && (arg (a) < arg (b))));
 }
 
@@ -54,7 +54,7 @@
 bool
 sparse_descending_compare<Complex> (const Complex& a, const Complex& b)
 {
-  return (xisnan (a) || (xabs (a) > xabs (b))
+  return (octave::math::isnan (a) || (xabs (a) > xabs (b))
           || ((xabs (a) == xabs (b)) && (arg (a) > arg (b))));
 }
 
--- a/liboctave/array/Sparse-d.cc	Fri May 27 10:20:48 2016 -0400
+++ b/liboctave/array/Sparse-d.cc	Wed May 25 16:51:16 2016 -0400
@@ -35,14 +35,14 @@
 bool
 sparse_ascending_compare<double> (double a, double b)
 {
-  return (xisnan (b) || (a < b));
+  return (octave::math::isnan (b) || (a < b));
 }
 
 template <>
 bool
 sparse_descending_compare<double> (double a, double b)
 {
-  return (xisnan (a) || (a > b));
+  return (octave::math::isnan (a) || (a > b));
 }
 
 INSTANTIATE_SPARSE (double, OCTAVE_API);
--- a/liboctave/array/chNDArray.cc	Fri May 27 10:20:48 2016 -0400
+++ b/liboctave/array/chNDArray.cc	Wed May 25 16:51:16 2016 -0400
@@ -119,11 +119,11 @@
     {
       double d = rb.elem (i);
 
-      if (xisnan (d))
+      if (octave::math::isnan (d))
         (*current_liboctave_error_handler)
           ("invalid conversion from NaN to character");
 
-      octave_idx_type ival = NINTbig (d);
+      octave_idx_type ival = octave::math::nint_big (d);
 
       if (ival < 0 || ival > std::numeric_limits<unsigned char>::max ())
         // FIXME: is there something better to do? Should we warn the user?
--- a/liboctave/array/dMatrix.cc	Fri May 27 10:20:48 2016 -0400
+++ b/liboctave/array/dMatrix.cc	Wed May 25 16:51:16 2016 -0400
@@ -1587,7 +1587,7 @@
 
           volatile double rcond_plus_one = rcon + 1.0;
 
-          if (rcond_plus_one == 1.0 || xisnan (rcon))
+          if (rcond_plus_one == 1.0 || octave::math::isnan (rcon))
             {
               info = -2;
 
@@ -1676,7 +1676,7 @@
 
           volatile double rcond_plus_one = rcon + 1.0;
 
-          if (rcond_plus_one == 1.0 || xisnan (rcon))
+          if (rcond_plus_one == 1.0 || octave::math::isnan (rcon))
             {
               info = -2;
 
@@ -1756,7 +1756,7 @@
 
                   volatile double rcond_plus_one = rcon + 1.0;
 
-                  if (rcond_plus_one == 1.0 || xisnan (rcon))
+                  if (rcond_plus_one == 1.0 || octave::math::isnan (rcon))
                     {
                       info = -2;
 
@@ -1837,7 +1837,7 @@
 
                   volatile double rcond_plus_one = rcon + 1.0;
 
-                  if (rcond_plus_one == 1.0 || xisnan (rcon))
+                  if (rcond_plus_one == 1.0 || octave::math::isnan (rcon))
                     {
                       info = -2;
 
@@ -2267,7 +2267,7 @@
       // of LAPACK does not return it on a query call.
       double dminmn = static_cast<double> (minmn);
       double dsmlsizp1 = static_cast<double> (smlsiz+1);
-      double tmp = xlog2 (dminmn / dsmlsizp1);
+      double tmp = octave::math::log2 (dminmn / dsmlsizp1);
 
       octave_idx_type nlvl = static_cast<octave_idx_type> (tmp) + 1;
       if (nlvl < 0)
@@ -2456,7 +2456,7 @@
       // of LAPACK does not return it on a query call.
       double dminmn = static_cast<double> (minmn);
       double dsmlsizp1 = static_cast<double> (smlsiz+1);
-      double tmp = xlog2 (dminmn / dsmlsizp1);
+      double tmp = octave::math::log2 (dminmn / dsmlsizp1);
 
       octave_idx_type nlvl = static_cast<octave_idx_type> (tmp) + 1;
       if (nlvl < 0)
@@ -2699,7 +2699,7 @@
             {
               tmp_min = elem (i, idx_j);
 
-              if (! xisnan (tmp_min))
+              if (! octave::math::isnan (tmp_min))
                 break;
             }
 
@@ -2707,7 +2707,7 @@
             {
               double tmp = elem (i, j);
 
-              if (xisnan (tmp))
+              if (octave::math::isnan (tmp))
                 continue;
               else if (tmp < tmp_min)
                 {
@@ -2717,7 +2717,7 @@
             }
 
           result.elem (i) = tmp_min;
-          idx_arg.elem (i) = xisnan (tmp_min) ? 0 : idx_j;
+          idx_arg.elem (i) = octave::math::isnan (tmp_min) ? 0 : idx_j;
         }
     }
 
@@ -2754,7 +2754,7 @@
             {
               tmp_max = elem (i, idx_j);
 
-              if (! xisnan (tmp_max))
+              if (! octave::math::isnan (tmp_max))
                 break;
             }
 
@@ -2762,7 +2762,7 @@
             {
               double tmp = elem (i, j);
 
-              if (xisnan (tmp))
+              if (octave::math::isnan (tmp))
                 continue;
               else if (tmp > tmp_max)
                 {
@@ -2772,7 +2772,7 @@
             }
 
           result.elem (i) = tmp_max;
-          idx_arg.elem (i) = xisnan (tmp_max) ? 0 : idx_j;
+          idx_arg.elem (i) = octave::math::isnan (tmp_max) ? 0 : idx_j;
         }
     }
 
@@ -2809,7 +2809,7 @@
             {
               tmp_min = elem (idx_i, j);
 
-              if (! xisnan (tmp_min))
+              if (! octave::math::isnan (tmp_min))
                 break;
             }
 
@@ -2817,7 +2817,7 @@
             {
               double tmp = elem (i, j);
 
-              if (xisnan (tmp))
+              if (octave::math::isnan (tmp))
                 continue;
               else if (tmp < tmp_min)
                 {
@@ -2827,7 +2827,7 @@
             }
 
           result.elem (j) = tmp_min;
-          idx_arg.elem (j) = xisnan (tmp_min) ? 0 : idx_i;
+          idx_arg.elem (j) = octave::math::isnan (tmp_min) ? 0 : idx_i;
         }
     }
 
@@ -2864,7 +2864,7 @@
             {
               tmp_max = elem (idx_i, j);
 
-              if (! xisnan (tmp_max))
+              if (! octave::math::isnan (tmp_max))
                 break;
             }
 
@@ -2872,7 +2872,7 @@
             {
               double tmp = elem (i, j);
 
-              if (xisnan (tmp))
+              if (octave::math::isnan (tmp))
                 continue;
               else if (tmp > tmp_max)
                 {
@@ -2882,7 +2882,7 @@
             }
 
           result.elem (j) = tmp_max;
-          idx_arg.elem (j) = xisnan (tmp_max) ? 0 : idx_i;
+          idx_arg.elem (j) = octave::math::isnan (tmp_max) ? 0 : idx_i;
         }
     }
 
@@ -3139,7 +3139,7 @@
     for (octave_idx_type i = 0; i < nr; i++)
       {
         octave_quit ();
-        result(i, j) = xmin (d, m(i, j));
+        result(i, j) = octave::math::min (d, m(i, j));
       }
 
   return result;
@@ -3159,7 +3159,7 @@
     for (octave_idx_type i = 0; i < nr; i++)
       {
         octave_quit ();
-        result(i, j) = xmin (m(i, j), d);
+        result(i, j) = octave::math::min (m(i, j), d);
       }
 
   return result;
@@ -3183,7 +3183,7 @@
     for (octave_idx_type i = 0; i < nr; i++)
       {
         octave_quit ();
-        result(i, j) = xmin (a(i, j), b(i, j));
+        result(i, j) = octave::math::min (a(i, j), b(i, j));
       }
 
   return result;
@@ -3203,7 +3203,7 @@
     for (octave_idx_type i = 0; i < nr; i++)
       {
         octave_quit ();
-        result(i, j) = xmax (d, m(i, j));
+        result(i, j) = octave::math::max (d, m(i, j));
       }
 
   return result;
@@ -3223,7 +3223,7 @@
     for (octave_idx_type i = 0; i < nr; i++)
       {
         octave_quit ();
-        result(i, j) = xmax (m(i, j), d);
+        result(i, j) = octave::math::max (m(i, j), d);
       }
 
   return result;
@@ -3247,7 +3247,7 @@
     for (octave_idx_type i = 0; i < nr; i++)
       {
         octave_quit ();
-        result(i, j) = xmax (a(i, j), b(i, j));
+        result(i, j) = octave::math::max (a(i, j), b(i, j));
       }
 
   return result;
--- a/liboctave/array/dNDArray.cc	Fri May 27 10:20:48 2016 -0400
+++ b/liboctave/array/dNDArray.cc	Wed May 25 16:51:16 2016 -0400
@@ -549,14 +549,14 @@
 bool
 NDArray::any_element_is_negative (bool neg_zero) const
 {
-  return (neg_zero ? test_all (xnegative_sign)
+  return (neg_zero ? test_all (octave::math::negative_sign)
           : do_mx_check<double> (*this, mx_inline_any_negative));
 }
 
 bool
 NDArray::any_element_is_positive (bool neg_zero) const
 {
-  return (neg_zero ? test_all (xpositive_sign)
+  return (neg_zero ? test_all (octave::math::positive_sign)
           : do_mx_check<double> (*this, mx_inline_any_positive));
 }
 
@@ -616,7 +616,7 @@
       if (val < min_val)
         min_val = val;
 
-      if (! xisinteger (val))
+      if (! octave::math::isinteger (val))
         return false;
     }
 
@@ -626,7 +626,7 @@
 bool
 NDArray::all_integers (void) const
 {
-  return test_all (xisinteger);
+  return test_all (octave::math::isinteger);
 }
 
 bool
@@ -766,11 +766,11 @@
     {
       double d = elem (i);
 
-      if (xisnan (d))
+      if (octave::math::isnan (d))
         (*current_liboctave_error_handler)
           ("invalid conversion from NaN to character");
 
-      octave_idx_type ival = NINTbig (d);
+      octave_idx_type ival = octave::math::nint_big (d);
 
       if (ival < 0 || ival > std::numeric_limits<unsigned char>::max ())
         // FIXME: is there something better to do? Should we warn the user?
@@ -821,19 +821,19 @@
 boolNDArray
 NDArray::isnan (void) const
 {
-  return do_mx_unary_map<bool, double, xisnan> (*this);
+  return do_mx_unary_map<bool, double, octave::math::isnan> (*this);
 }
 
 boolNDArray
 NDArray::isinf (void) const
 {
-  return do_mx_unary_map<bool, double, xisinf> (*this);
+  return do_mx_unary_map<bool, double, octave::math::isinf> (*this);
 }
 
 boolNDArray
 NDArray::isfinite (void) const
 {
-  return do_mx_unary_map<bool, double, xfinite> (*this);
+  return do_mx_unary_map<bool, double, octave::math::finite> (*this);
 }
 
 void
--- a/liboctave/array/dSparse.cc	Fri May 27 10:20:48 2016 -0400
+++ b/liboctave/array/dSparse.cc	Wed May 25 16:51:16 2016 -0400
@@ -319,9 +319,9 @@
             {
               double tmp = data (i);
 
-              if (xisnan (tmp))
+              if (octave::math::isnan (tmp))
                 continue;
-              else if (xisnan (tmp_max) || tmp > tmp_max)
+              else if (octave::math::isnan (tmp_max) || tmp > tmp_max)
                 {
                   idx_j = ridx (i);
                   tmp_max = tmp;
@@ -329,7 +329,7 @@
 
             }
 
-          idx_arg.elem (j) = xisnan (tmp_max) ? 0 : idx_j;
+          idx_arg.elem (j) = octave::math::isnan (tmp_max) ? 0 : idx_j;
           if (tmp_max != 0.)
             nel++;
         }
@@ -379,7 +379,7 @@
               octave_idx_type ix = idx_arg.elem (ir);
               double tmp = data (i);
 
-              if (xisnan (tmp))
+              if (octave::math::isnan (tmp))
                 continue;
               else if (ix == -1 || tmp > elem (ir, ix))
                 idx_arg.elem (ir) = j;
@@ -470,9 +470,9 @@
             {
               double tmp = data (i);
 
-              if (xisnan (tmp))
+              if (octave::math::isnan (tmp))
                 continue;
-              else if (xisnan (tmp_min) || tmp < tmp_min)
+              else if (octave::math::isnan (tmp_min) || tmp < tmp_min)
                 {
                   idx_j = ridx (i);
                   tmp_min = tmp;
@@ -480,7 +480,7 @@
 
             }
 
-          idx_arg.elem (j) = xisnan (tmp_min) ? 0 : idx_j;
+          idx_arg.elem (j) = octave::math::isnan (tmp_min) ? 0 : idx_j;
           if (tmp_min != 0.)
             nel++;
         }
@@ -530,7 +530,7 @@
               octave_idx_type ix = idx_arg.elem (ir);
               double tmp = data (i);
 
-              if (xisnan (tmp))
+              if (octave::math::isnan (tmp))
                 continue;
               else if (ix == -1 || tmp < elem (ir, ix))
                 idx_arg.elem (ir) = j;
@@ -1247,11 +1247,11 @@
       UMFPACK_DNAME (defaults) (control);
 
       double tmp = octave_sparse_params::get_key ("spumoni");
-      if (! xisnan (tmp))
+      if (! octave::math::isnan (tmp))
         Control (UMFPACK_PRL) = tmp;
 
       tmp = octave_sparse_params::get_key ("piv_tol");
-      if (! xisnan (tmp))
+      if (! octave::math::isnan (tmp))
         {
           Control (UMFPACK_SYM_PIVOT_TOLERANCE) = tmp;
           Control (UMFPACK_PIVOT_TOLERANCE) = tmp;
@@ -1259,7 +1259,7 @@
 
       // Set whether we are allowed to modify Q or not
       tmp = octave_sparse_params::get_key ("autoamd");
-      if (! xisnan (tmp))
+      if (! octave::math::isnan (tmp))
         Control (UMFPACK_FIXQ) = tmp;
 
       // Turn-off UMFPACK scaling for LU
@@ -1857,7 +1857,7 @@
 
       volatile double rcond_plus_one = rcond + 1.0;
 
-      if (rcond_plus_one == 1.0 || xisnan (rcond))
+      if (rcond_plus_one == 1.0 || octave::math::isnan (rcond))
         {
           err = -2;
 
@@ -2139,7 +2139,7 @@
 
       volatile double rcond_plus_one = rcond + 1.0;
 
-      if (rcond_plus_one == 1.0 || xisnan (rcond))
+      if (rcond_plus_one == 1.0 || octave::math::isnan (rcond))
         {
           err = -2;
 
@@ -2370,7 +2370,7 @@
 
       volatile double rcond_plus_one = rcond + 1.0;
 
-      if (rcond_plus_one == 1.0 || xisnan (rcond))
+      if (rcond_plus_one == 1.0 || octave::math::isnan (rcond))
         {
           err = -2;
 
@@ -2654,7 +2654,7 @@
 
       volatile double rcond_plus_one = rcond + 1.0;
 
-      if (rcond_plus_one == 1.0 || xisnan (rcond))
+      if (rcond_plus_one == 1.0 || octave::math::isnan (rcond))
         {
           err = -2;
 
@@ -2907,7 +2907,7 @@
 
       volatile double rcond_plus_one = rcond + 1.0;
 
-      if (rcond_plus_one == 1.0 || xisnan (rcond))
+      if (rcond_plus_one == 1.0 || octave::math::isnan (rcond))
         {
           err = -2;
 
@@ -3207,7 +3207,7 @@
 
       volatile double rcond_plus_one = rcond + 1.0;
 
-      if (rcond_plus_one == 1.0 || xisnan (rcond))
+      if (rcond_plus_one == 1.0 || octave::math::isnan (rcond))
         {
           err = -2;
 
@@ -3461,7 +3461,7 @@
 
       volatile double rcond_plus_one = rcond + 1.0;
 
-      if (rcond_plus_one == 1.0 || xisnan (rcond))
+      if (rcond_plus_one == 1.0 || octave::math::isnan (rcond))
         {
           err = -2;
 
@@ -3763,7 +3763,7 @@
 
       volatile double rcond_plus_one = rcond + 1.0;
 
-      if (rcond_plus_one == 1.0 || xisnan (rcond))
+      if (rcond_plus_one == 1.0 || octave::math::isnan (rcond))
         {
           err = -2;
 
@@ -4496,7 +4496,7 @@
 
                   volatile double rcond_plus_one = rcond + 1.0;
 
-                  if (rcond_plus_one == 1.0 || xisnan (rcond))
+                  if (rcond_plus_one == 1.0 || octave::math::isnan (rcond))
                     {
                       err = -2;
 
@@ -4615,7 +4615,7 @@
 
                   volatile double rcond_plus_one = rcond + 1.0;
 
-                  if (rcond_plus_one == 1.0 || xisnan (rcond))
+                  if (rcond_plus_one == 1.0 || octave::math::isnan (rcond))
                     {
                       err = -2;
 
@@ -4740,7 +4740,7 @@
 
                   volatile double rcond_plus_one = rcond + 1.0;
 
-                  if (rcond_plus_one == 1.0 || xisnan (rcond))
+                  if (rcond_plus_one == 1.0 || octave::math::isnan (rcond))
                     {
                       err = -2;
 
@@ -4892,7 +4892,7 @@
 
                   volatile double rcond_plus_one = rcond + 1.0;
 
-                  if (rcond_plus_one == 1.0 || xisnan (rcond))
+                  if (rcond_plus_one == 1.0 || octave::math::isnan (rcond))
                     {
                       err = -2;
 
@@ -5056,7 +5056,7 @@
 
                   volatile double rcond_plus_one = rcond + 1.0;
 
-                  if (rcond_plus_one == 1.0 || xisnan (rcond))
+                  if (rcond_plus_one == 1.0 || octave::math::isnan (rcond))
                     {
                       err = -2;
 
@@ -5205,7 +5205,7 @@
 
                   volatile double rcond_plus_one = rcond + 1.0;
 
-                  if (rcond_plus_one == 1.0 || xisnan (rcond))
+                  if (rcond_plus_one == 1.0 || octave::math::isnan (rcond))
                     {
                       err = -2;
 
@@ -5353,7 +5353,7 @@
 
                   volatile double rcond_plus_one = rcond + 1.0;
 
-                  if (rcond_plus_one == 1.0 || xisnan (rcond))
+                  if (rcond_plus_one == 1.0 || octave::math::isnan (rcond))
                     {
                       err = -2;
 
@@ -5532,7 +5532,7 @@
 
                   volatile double rcond_plus_one = rcond + 1.0;
 
-                  if (rcond_plus_one == 1.0 || xisnan (rcond))
+                  if (rcond_plus_one == 1.0 || octave::math::isnan (rcond))
                     {
                       err = -2;
 
@@ -5640,10 +5640,10 @@
   UMFPACK_DNAME (defaults) (control);
 
   double tmp = octave_sparse_params::get_key ("spumoni");
-  if (! xisnan (tmp))
+  if (! octave::math::isnan (tmp))
     Control (UMFPACK_PRL) = tmp;
   tmp = octave_sparse_params::get_key ("piv_tol");
-  if (! xisnan (tmp))
+  if (! octave::math::isnan (tmp))
     {
       Control (UMFPACK_SYM_PIVOT_TOLERANCE) = tmp;
       Control (UMFPACK_PIVOT_TOLERANCE) = tmp;
@@ -5651,7 +5651,7 @@
 
   // Set whether we are allowed to modify Q or not
   tmp = octave_sparse_params::get_key ("autoamd");
-  if (! xisnan (tmp))
+  if (! octave::math::isnan (tmp))
     Control (UMFPACK_FIXQ) = tmp;
 
   UMFPACK_DNAME (report_control) (control);
@@ -5697,7 +5697,7 @@
       volatile double rcond_plus_one = rcond + 1.0;
 
       if (status == UMFPACK_WARNING_singular_matrix
-          || rcond_plus_one == 1.0 || xisnan (rcond))
+          || rcond_plus_one == 1.0 || octave::math::isnan (rcond))
         {
           UMFPACK_DNAME (report_numeric) (Numeric, control);
 
@@ -5858,7 +5858,7 @@
             {
               volatile double rcond_plus_one = rcond + 1.0;
 
-              if (rcond_plus_one == 1.0 || xisnan (rcond))
+              if (rcond_plus_one == 1.0 || octave::math::isnan (rcond))
                 {
                   err = -2;
 
@@ -6091,7 +6091,7 @@
             {
               volatile double rcond_plus_one = rcond + 1.0;
 
-              if (rcond_plus_one == 1.0 || xisnan (rcond))
+              if (rcond_plus_one == 1.0 || octave::math::isnan (rcond))
                 {
                   err = -2;
 
@@ -6350,7 +6350,7 @@
             {
               volatile double rcond_plus_one = rcond + 1.0;
 
-              if (rcond_plus_one == 1.0 || xisnan (rcond))
+              if (rcond_plus_one == 1.0 || octave::math::isnan (rcond))
                 {
                   err = -2;
 
@@ -6601,7 +6601,7 @@
             {
               volatile double rcond_plus_one = rcond + 1.0;
 
-              if (rcond_plus_one == 1.0 || xisnan (rcond))
+              if (rcond_plus_one == 1.0 || octave::math::isnan (rcond))
                 {
                   err = -2;
 
@@ -7293,7 +7293,7 @@
   for (octave_idx_type i = 0; i < nel; i++)
     {
       double val = data (i);
-      if (xisnan (val))
+      if (octave::math::isnan (val))
         return true;
     }
 
@@ -7308,7 +7308,7 @@
   for (octave_idx_type i = 0; i < nel; i++)
     {
       double val = data (i);
-      if (xisinf (val) || xisnan (val))
+      if (octave::math::isinf (val) || octave::math::isnan (val))
         return true;
     }
 
@@ -7350,7 +7350,7 @@
   for (octave_idx_type i = 0; i < nel; i++)
     {
       double val = data (i);
-      if (xisnan (val) || D_NINT (val) == val)
+      if (octave::math::isnan (val) || octave::math::x_nint (val) == val)
         continue;
       else
         return false;
@@ -7383,7 +7383,7 @@
       if (val < min_val)
         min_val = val;
 
-      if (D_NINT (val) != val)
+      if (octave::math::x_nint (val) != val)
         return false;
     }
 
@@ -7677,7 +7677,7 @@
       for (octave_idx_type j = 0; j < nc; j++)
         for (octave_idx_type i = m.cidx (j); i < m.cidx (j+1); i++)
           {
-            double tmp = xmin (d, m.data (i));
+            double tmp = octave::math::min (d, m.data (i));
             if (tmp != 0.)
               {
                 octave_idx_type idx = m.ridx (i) + j * nr;
@@ -7691,7 +7691,7 @@
       octave_idx_type nel = 0;
       for (octave_idx_type j = 0; j < nc; j++)
         for (octave_idx_type i = m.cidx (j); i < m.cidx (j+1); i++)
-          if (xmin (d, m.data (i)) != 0.)
+          if (octave::math::min (d, m.data (i)) != 0.)
             nel++;
 
       result = SparseMatrix (nr, nc, nel);
@@ -7702,7 +7702,7 @@
         {
           for (octave_idx_type i = m.cidx (j); i < m.cidx (j+1); i++)
             {
-              double tmp = xmin (d, m.data (i));
+              double tmp = octave::math::min (d, m.data (i));
 
               if (tmp != 0.)
                 {
@@ -7754,7 +7754,7 @@
               octave_quit ();
               if ((! jb_lt_max) || (ja_lt_max && (a.ridx (ja) < b.ridx (jb))))
                 {
-                  double tmp = xmin (a.data (ja), 0.);
+                  double tmp = octave::math::min (a.data (ja), 0.);
                   if (tmp != 0.)
                     {
                       r.ridx (jx) = a.ridx (ja);
@@ -7767,7 +7767,7 @@
               else if ((! ja_lt_max)
                        || (jb_lt_max && (b.ridx (jb) < a.ridx (ja))))
                 {
-                  double tmp = xmin (0., b.data (jb));
+                  double tmp = octave::math::min (0., b.data (jb));
                   if (tmp != 0.)
                     {
                       r.ridx (jx) = b.ridx (jb);
@@ -7779,7 +7779,7 @@
                 }
               else
                 {
-                  double tmp = xmin (a.data (ja), b.data (jb));
+                  double tmp = octave::math::min (a.data (ja), b.data (jb));
                   if (tmp != 0.)
                     {
                       r.data (jx) = tmp;
@@ -7827,7 +7827,7 @@
       for (octave_idx_type j = 0; j < nc; j++)
         for (octave_idx_type i = m.cidx (j); i < m.cidx (j+1); i++)
           {
-            double tmp = xmax (d, m.data (i));
+            double tmp = octave::math::max (d, m.data (i));
 
             if (tmp != 0.)
               {
@@ -7842,7 +7842,7 @@
       octave_idx_type nel = 0;
       for (octave_idx_type j = 0; j < nc; j++)
         for (octave_idx_type i = m.cidx (j); i < m.cidx (j+1); i++)
-          if (xmax (d, m.data (i)) != 0.)
+          if (octave::math::max (d, m.data (i)) != 0.)
             nel++;
 
       result = SparseMatrix (nr, nc, nel);
@@ -7853,7 +7853,7 @@
         {
           for (octave_idx_type i = m.cidx (j); i < m.cidx (j+1); i++)
             {
-              double tmp = xmax (d, m.data (i));
+              double tmp = octave::math::max (d, m.data (i));
               if (tmp != 0.)
                 {
                   result.xdata (ii) = tmp;
@@ -7904,7 +7904,7 @@
               octave_quit ();
               if ((! jb_lt_max) || (ja_lt_max && (a.ridx (ja) < b.ridx (jb))))
                 {
-                  double tmp = xmax (a.data (ja), 0.);
+                  double tmp = octave::math::max (a.data (ja), 0.);
                   if (tmp != 0.)
                     {
                       r.ridx (jx) = a.ridx (ja);
@@ -7917,7 +7917,7 @@
               else if ((! ja_lt_max)
                        || (jb_lt_max && (b.ridx (jb) < a.ridx (ja))))
                 {
-                  double tmp = xmax (0., b.data (jb));
+                  double tmp = octave::math::max (0., b.data (jb));
                   if (tmp != 0.)
                     {
                       r.ridx (jx) = b.ridx (jb);
@@ -7929,7 +7929,7 @@
                 }
               else
                 {
-                  double tmp = xmax (a.data (ja), b.data (jb));
+                  double tmp = octave::math::max (a.data (ja), b.data (jb));
                   if (tmp != 0.)
                     {
                       r.data (jx) = tmp;
--- a/liboctave/array/fCMatrix.cc	Fri May 27 10:20:48 2016 -0400
+++ b/liboctave/array/fCMatrix.cc	Wed May 25 16:51:16 2016 -0400
@@ -1909,7 +1909,7 @@
 
                   volatile float rcond_plus_one = rcon + 1.0;
 
-                  if (rcond_plus_one == 1.0 || xisnan (rcon))
+                  if (rcond_plus_one == 1.0 || octave::math::isnan (rcon))
                     {
                       info = -2;
 
@@ -2003,7 +2003,7 @@
 
                   volatile float rcond_plus_one = rcon + 1.0;
 
-                  if (rcond_plus_one == 1.0 || xisnan (rcon))
+                  if (rcond_plus_one == 1.0 || octave::math::isnan (rcon))
                     {
                       info = -2;
 
@@ -2089,7 +2089,7 @@
 
                   volatile float rcond_plus_one = rcon + 1.0;
 
-                  if (rcond_plus_one == 1.0 || xisnan (rcon))
+                  if (rcond_plus_one == 1.0 || octave::math::isnan (rcon))
                     {
                       info = -2;
 
@@ -2172,7 +2172,7 @@
 
                   volatile float rcond_plus_one = rcon + 1.0;
 
-                  if (rcond_plus_one == 1.0 || xisnan (rcon))
+                  if (rcond_plus_one == 1.0 || octave::math::isnan (rcon))
                     {
                       info = -2;
 
@@ -2624,7 +2624,7 @@
       // call.
       float dminmn = static_cast<float> (minmn);
       float dsmlsizp1 = static_cast<float> (smlsiz+1);
-      float tmp = xlog2 (dminmn / dsmlsizp1);
+      float tmp = octave::math::log2 (dminmn / dsmlsizp1);
 
       octave_idx_type nlvl = static_cast<octave_idx_type> (tmp) + 1;
       if (nlvl < 0)
@@ -2817,7 +2817,7 @@
       // call.
       float dminmn = static_cast<float> (minmn);
       float dsmlsizp1 = static_cast<float> (smlsiz+1);
-      float tmp = xlog2 (dminmn / dsmlsizp1);
+      float tmp = octave::math::log2 (dminmn / dsmlsizp1);
 
       octave_idx_type nlvl = static_cast<octave_idx_type> (tmp) + 1;
       if (nlvl < 0)
@@ -3166,7 +3166,7 @@
             {
               tmp_min = elem (i, idx_j);
 
-              if (! xisnan (tmp_min))
+              if (! octave::math::isnan (tmp_min))
                 {
                   abs_min = real_only ? std::real (tmp_min)
                                       : std::abs (tmp_min);
@@ -3178,7 +3178,7 @@
             {
               FloatComplex tmp = elem (i, j);
 
-              if (xisnan (tmp))
+              if (octave::math::isnan (tmp))
                 continue;
 
               float abs_tmp = real_only ? std::real (tmp) : std::abs (tmp);
@@ -3191,7 +3191,7 @@
                 }
             }
 
-          if (xisnan (tmp_min))
+          if (octave::math::isnan (tmp_min))
             {
               result.elem (i) = FloatComplex_NaN_result;
               idx_arg.elem (i) = 0;
@@ -3241,7 +3241,7 @@
             {
               tmp_max = elem (i, idx_j);
 
-              if (! xisnan (tmp_max))
+              if (! octave::math::isnan (tmp_max))
                 {
                   abs_max = real_only ? std::real (tmp_max)
                                       : std::abs (tmp_max);
@@ -3253,7 +3253,7 @@
             {
               FloatComplex tmp = elem (i, j);
 
-              if (xisnan (tmp))
+              if (octave::math::isnan (tmp))
                 continue;
 
               float abs_tmp = real_only ? std::real (tmp) : std::abs (tmp);
@@ -3266,7 +3266,7 @@
                 }
             }
 
-          if (xisnan (tmp_max))
+          if (octave::math::isnan (tmp_max))
             {
               result.elem (i) = FloatComplex_NaN_result;
               idx_arg.elem (i) = 0;
@@ -3316,7 +3316,7 @@
             {
               tmp_min = elem (idx_i, j);
 
-              if (! xisnan (tmp_min))
+              if (! octave::math::isnan (tmp_min))
                 {
                   abs_min = real_only ? std::real (tmp_min)
                                       : std::abs (tmp_min);
@@ -3328,7 +3328,7 @@
             {
               FloatComplex tmp = elem (i, j);
 
-              if (xisnan (tmp))
+              if (octave::math::isnan (tmp))
                 continue;
 
               float abs_tmp = real_only ? std::real (tmp) : std::abs (tmp);
@@ -3341,7 +3341,7 @@
                 }
             }
 
-          if (xisnan (tmp_min))
+          if (octave::math::isnan (tmp_min))
             {
               result.elem (j) = FloatComplex_NaN_result;
               idx_arg.elem (j) = 0;
@@ -3391,7 +3391,7 @@
             {
               tmp_max = elem (idx_i, j);
 
-              if (! xisnan (tmp_max))
+              if (! octave::math::isnan (tmp_max))
                 {
                   abs_max = real_only ? std::real (tmp_max)
                                       : std::abs (tmp_max);
@@ -3403,7 +3403,7 @@
             {
               FloatComplex tmp = elem (i, j);
 
-              if (xisnan (tmp))
+              if (octave::math::isnan (tmp))
                 continue;
 
               float abs_tmp = real_only ? std::real (tmp) : std::abs (tmp);
@@ -3416,7 +3416,7 @@
                 }
             }
 
-          if (xisnan (tmp_max))
+          if (octave::math::isnan (tmp_max))
             {
               result.elem (j) = FloatComplex_NaN_result;
               idx_arg.elem (j) = 0;
@@ -3736,7 +3736,7 @@
     for (octave_idx_type i = 0; i < nr; i++)
       {
         octave_quit ();
-        result(i, j) = xmin (c, m(i, j));
+        result(i, j) = octave::math::min (c, m(i, j));
       }
 
   return result;
@@ -3756,7 +3756,7 @@
     for (octave_idx_type i = 0; i < nr; i++)
       {
         octave_quit ();
-        result(i, j) = xmin (m(i, j), c);
+        result(i, j) = octave::math::min (m(i, j), c);
       }
 
   return result;
@@ -3792,14 +3792,14 @@
       if (columns_are_real_only)
         {
           for (octave_idx_type i = 0; i < nr; i++)
-            result(i, j) = xmin (std::real (a(i, j)), std::real (b(i, j)));
+            result(i, j) = octave::math::min (std::real (a(i, j)), std::real (b(i, j)));
         }
       else
         {
           for (octave_idx_type i = 0; i < nr; i++)
             {
               octave_quit ();
-              result(i, j) = xmin (a(i, j), b(i, j));
+              result(i, j) = octave::math::min (a(i, j), b(i, j));
             }
         }
     }
@@ -3821,7 +3821,7 @@
     for (octave_idx_type i = 0; i < nr; i++)
       {
         octave_quit ();
-        result(i, j) = xmax (c, m(i, j));
+        result(i, j) = octave::math::max (c, m(i, j));
       }
 
   return result;
@@ -3841,7 +3841,7 @@
     for (octave_idx_type i = 0; i < nr; i++)
       {
         octave_quit ();
-        result(i, j) = xmax (m(i, j), c);
+        result(i, j) = octave::math::max (m(i, j), c);
       }
 
   return result;
@@ -3879,7 +3879,7 @@
           for (octave_idx_type i = 0; i < nr; i++)
             {
               octave_quit ();
-              result(i, j) = xmax (std::real (a(i, j)), std::real (b(i, j)));
+              result(i, j) = octave::math::max (std::real (a(i, j)), std::real (b(i, j)));
             }
         }
       else
@@ -3887,7 +3887,7 @@
           for (octave_idx_type i = 0; i < nr; i++)
             {
               octave_quit ();
-              result(i, j) = xmax (a(i, j), b(i, j));
+              result(i, j) = octave::math::max (a(i, j), b(i, j));
             }
         }
     }
--- a/liboctave/array/fCNDArray.cc	Fri May 27 10:20:48 2016 -0400
+++ b/liboctave/array/fCNDArray.cc	Wed May 25 16:51:16 2016 -0400
@@ -571,7 +571,7 @@
       if (i_val < min_val)
         min_val = i_val;
 
-      if (D_NINT (r_val) != r_val || D_NINT (i_val) != i_val)
+      if (octave::math::x_nint (r_val) != r_val || octave::math::x_nint (i_val) != i_val)
         return false;
     }
 
@@ -737,19 +737,19 @@
 boolNDArray
 FloatComplexNDArray::isnan (void) const
 {
-  return do_mx_unary_map<bool, FloatComplex, xisnan> (*this);
+  return do_mx_unary_map<bool, FloatComplex, octave::math::isnan> (*this);
 }
 
 boolNDArray
 FloatComplexNDArray::isinf (void) const
 {
-  return do_mx_unary_map<bool, FloatComplex, xisinf> (*this);
+  return do_mx_unary_map<bool, FloatComplex, octave::math::isinf> (*this);
 }
 
 boolNDArray
 FloatComplexNDArray::isfinite (void) const
 {
-  return do_mx_unary_map<bool, FloatComplex, xfinite> (*this);
+  return do_mx_unary_map<bool, FloatComplex, octave::math::finite> (*this);
 }
 
 FloatComplexNDArray
--- a/liboctave/array/fMatrix.cc	Fri May 27 10:20:48 2016 -0400
+++ b/liboctave/array/fMatrix.cc	Wed May 25 16:51:16 2016 -0400
@@ -1599,7 +1599,7 @@
 
                   volatile float rcond_plus_one = rcon + 1.0;
 
-                  if (rcond_plus_one == 1.0 || xisnan (rcon))
+                  if (rcond_plus_one == 1.0 || octave::math::isnan (rcon))
                     {
                       info = -2;
 
@@ -1694,7 +1694,7 @@
 
                   volatile float rcond_plus_one = rcon + 1.0;
 
-                  if (rcond_plus_one == 1.0 || xisnan (rcon))
+                  if (rcond_plus_one == 1.0 || octave::math::isnan (rcon))
                     {
                       info = -2;
 
@@ -1779,7 +1779,7 @@
 
                   volatile float rcond_plus_one = rcon + 1.0;
 
-                  if (rcond_plus_one == 1.0 || xisnan (rcon))
+                  if (rcond_plus_one == 1.0 || octave::math::isnan (rcon))
                     {
                       info = -2;
 
@@ -1860,7 +1860,7 @@
 
                   volatile float rcond_plus_one = rcon + 1.0;
 
-                  if (rcond_plus_one == 1.0 || xisnan (rcon))
+                  if (rcond_plus_one == 1.0 || octave::math::isnan (rcon))
                     {
                       info = -2;
 
@@ -2299,7 +2299,7 @@
       // of LAPACK does not return it on a query call.
       float dminmn = static_cast<float> (minmn);
       float dsmlsizp1 = static_cast<float> (smlsiz+1);
-      float tmp = xlog2 (dminmn / dsmlsizp1);
+      float tmp = octave::math::log2 (dminmn / dsmlsizp1);
 
       octave_idx_type nlvl = static_cast<octave_idx_type> (tmp) + 1;
       if (nlvl < 0)
@@ -2488,7 +2488,7 @@
       // of LAPACK does not return it on a query call.
       float dminmn = static_cast<float> (minmn);
       float dsmlsizp1 = static_cast<float> (smlsiz+1);
-      float tmp = xlog2 (dminmn / dsmlsizp1);
+      float tmp = octave::math::log2 (dminmn / dsmlsizp1);
 
       octave_idx_type nlvl = static_cast<octave_idx_type> (tmp) + 1;
       if (nlvl < 0)
@@ -2716,7 +2716,7 @@
             {
               tmp_min = elem (i, idx_j);
 
-              if (! xisnan (tmp_min))
+              if (! octave::math::isnan (tmp_min))
                 break;
             }
 
@@ -2724,7 +2724,7 @@
             {
               float tmp = elem (i, j);
 
-              if (xisnan (tmp))
+              if (octave::math::isnan (tmp))
                 continue;
               else if (tmp < tmp_min)
                 {
@@ -2734,7 +2734,7 @@
             }
 
           result.elem (i) = tmp_min;
-          idx_arg.elem (i) = xisnan (tmp_min) ? 0 : idx_j;
+          idx_arg.elem (i) = octave::math::isnan (tmp_min) ? 0 : idx_j;
         }
     }
 
@@ -2771,7 +2771,7 @@
             {
               tmp_max = elem (i, idx_j);
 
-              if (! xisnan (tmp_max))
+              if (! octave::math::isnan (tmp_max))
                 break;
             }
 
@@ -2779,7 +2779,7 @@
             {
               float tmp = elem (i, j);
 
-              if (xisnan (tmp))
+              if (octave::math::isnan (tmp))
                 continue;
               else if (tmp > tmp_max)
                 {
@@ -2789,7 +2789,7 @@
             }
 
           result.elem (i) = tmp_max;
-          idx_arg.elem (i) = xisnan (tmp_max) ? 0 : idx_j;
+          idx_arg.elem (i) = octave::math::isnan (tmp_max) ? 0 : idx_j;
         }
     }
 
@@ -2826,7 +2826,7 @@
             {
               tmp_min = elem (idx_i, j);
 
-              if (! xisnan (tmp_min))
+              if (! octave::math::isnan (tmp_min))
                 break;
             }
 
@@ -2834,7 +2834,7 @@
             {
               float tmp = elem (i, j);
 
-              if (xisnan (tmp))
+              if (octave::math::isnan (tmp))
                 continue;
               else if (tmp < tmp_min)
                 {
@@ -2844,7 +2844,7 @@
             }
 
           result.elem (j) = tmp_min;
-          idx_arg.elem (j) = xisnan (tmp_min) ? 0 : idx_i;
+          idx_arg.elem (j) = octave::math::isnan (tmp_min) ? 0 : idx_i;
         }
     }
 
@@ -2881,7 +2881,7 @@
             {
               tmp_max = elem (idx_i, j);
 
-              if (! xisnan (tmp_max))
+              if (! octave::math::isnan (tmp_max))
                 break;
             }
 
@@ -2889,7 +2889,7 @@
             {
               float tmp = elem (i, j);
 
-              if (xisnan (tmp))
+              if (octave::math::isnan (tmp))
                 continue;
               else if (tmp > tmp_max)
                 {
@@ -2899,7 +2899,7 @@
             }
 
           result.elem (j) = tmp_max;
-          idx_arg.elem (j) = xisnan (tmp_max) ? 0 : idx_i;
+          idx_arg.elem (j) = octave::math::isnan (tmp_max) ? 0 : idx_i;
         }
     }
 
@@ -3152,7 +3152,7 @@
     for (octave_idx_type i = 0; i < nr; i++)
       {
         octave_quit ();
-        result(i, j) = xmin (d, m(i, j));
+        result(i, j) = octave::math::min (d, m(i, j));
       }
 
   return result;
@@ -3172,7 +3172,7 @@
     for (octave_idx_type i = 0; i < nr; i++)
       {
         octave_quit ();
-        result(i, j) = xmin (m(i, j), d);
+        result(i, j) = octave::math::min (m(i, j), d);
       }
 
   return result;
@@ -3196,7 +3196,7 @@
     for (octave_idx_type i = 0; i < nr; i++)
       {
         octave_quit ();
-        result(i, j) = xmin (a(i, j), b(i, j));
+        result(i, j) = octave::math::min (a(i, j), b(i, j));
       }
 
   return result;
@@ -3216,7 +3216,7 @@
     for (octave_idx_type i = 0; i < nr; i++)
       {
         octave_quit ();
-        result(i, j) = xmax (d, m(i, j));
+        result(i, j) = octave::math::max (d, m(i, j));
       }
 
   return result;
@@ -3236,7 +3236,7 @@
     for (octave_idx_type i = 0; i < nr; i++)
       {
         octave_quit ();
-        result(i, j) = xmax (m(i, j), d);
+        result(i, j) = octave::math::max (m(i, j), d);
       }
 
   return result;
@@ -3260,7 +3260,7 @@
     for (octave_idx_type i = 0; i < nr; i++)
       {
         octave_quit ();
-        result(i, j) = xmax (a(i, j), b(i, j));
+        result(i, j) = octave::math::max (a(i, j), b(i, j));
       }
 
   return result;
--- a/liboctave/array/fNDArray.cc	Fri May 27 10:20:48 2016 -0400
+++ b/liboctave/array/fNDArray.cc	Wed May 25 16:51:16 2016 -0400
@@ -509,14 +509,14 @@
 bool
 FloatNDArray::any_element_is_negative (bool neg_zero) const
 {
-  return (neg_zero ? test_all (xnegative_sign)
+  return (neg_zero ? test_all (octave::math::negative_sign)
           : do_mx_check<float> (*this, mx_inline_any_negative));
 }
 
 bool
 FloatNDArray::any_element_is_positive (bool neg_zero) const
 {
-  return (neg_zero ? test_all (xpositive_sign)
+  return (neg_zero ? test_all (octave::math::positive_sign)
           : do_mx_check<float> (*this, mx_inline_any_positive));
 }
 
@@ -576,7 +576,7 @@
       if (val < min_val)
         min_val = val;
 
-      if (! xisinteger (val))
+      if (! octave::math::isinteger (val))
         return false;
     }
 
@@ -586,7 +586,7 @@
 bool
 FloatNDArray::all_integers (void) const
 {
-  return test_all (xisinteger);
+  return test_all (octave::math::isinteger);
 }
 
 bool
@@ -735,11 +735,11 @@
     {
       float d = elem (i);
 
-      if (xisnan (d))
+      if (octave::math::isnan (d))
         (*current_liboctave_error_handler)
           ("invalid conversion from NaN to character");
 
-      octave_idx_type ival = NINTbig (d);
+      octave_idx_type ival = octave::math::nint_big (d);
 
       if (ival < 0 || ival > std::numeric_limits<unsigned char>::max ())
         // FIXME: is there something better to do?  Should we warn the user?
@@ -792,19 +792,19 @@
 boolNDArray
 FloatNDArray::isnan (void) const
 {
-  return do_mx_unary_map<bool, float, xisnan> (*this);
+  return do_mx_unary_map<bool, float, octave::math::isnan> (*this);
 }
 
 boolNDArray
 FloatNDArray::isinf (void) const
 {
-  return do_mx_unary_map<bool, float, xisinf> (*this);
+  return do_mx_unary_map<bool, float, octave::math::isinf> (*this);
 }
 
 boolNDArray
 FloatNDArray::isfinite (void) const
 {
-  return do_mx_unary_map<bool, float, xfinite> (*this);
+  return do_mx_unary_map<bool, float, octave::math::finite> (*this);
 }
 
 void
--- a/liboctave/array/idx-vector.cc	Fri May 27 10:20:48 2016 -0400
+++ b/liboctave/array/idx-vector.cc	Wed May 25 16:51:16 2016 -0400
@@ -469,7 +469,7 @@
   std::unique_ptr<idx_vector_rep> new_rep (
     new idx_vector_rep (0, len, ext, orig_dims, DIRECT));
 
-  if (ext > len*xlog2 (1.0 + len))
+  if (ext > len*octave::math::log2 (1.0 + len))
     {
       // Use standard sort via octave_sort.
       octave_idx_type *new_data = new octave_idx_type [len];
@@ -542,7 +542,7 @@
   std::unique_ptr<idx_vector_rep> new_rep (
     new idx_vector_rep (0, len, ext, orig_dims, DIRECT));
 
-  if (ext > len*xlog2 (1.0 + len))
+  if (ext > len*octave::math::log2 (1.0 + len))
     {
       // Use standard sort via octave_sort.
       idx.clear (orig_dims);
--- a/liboctave/numeric/CollocWt.cc	Fri May 27 10:20:48 2016 -0400
+++ b/liboctave/numeric/CollocWt.cc	Wed May 25 16:51:16 2016 -0400
@@ -227,7 +227,7 @@
           // Famous last words:  100 iterations should be more than
           // enough in all cases.
 
-          if (++k > 100 || xisnan (z))
+          if (++k > 100 || octave::math::isnan (z))
             return false;
 
           if (std::abs (z) <= 100 * std::numeric_limits<double>::epsilon ())
--- a/liboctave/numeric/DASPK.cc	Fri May 27 10:20:48 2016 -0400
+++ b/liboctave/numeric/DASPK.cc	Wed May 25 16:51:16 2016 -0400
@@ -418,10 +418,10 @@
 
           if (ich.numel () == 6)
             {
-              iwork(31) = NINTbig (ich(0));
-              iwork(32) = NINTbig (ich(1));
-              iwork(33) = NINTbig (ich(2));
-              iwork(34) = NINTbig (ich(3));
+              iwork(31) = octave::math::nint_big (ich(0));
+              iwork(32) = octave::math::nint_big (ich(1));
+              iwork(33) = octave::math::nint_big (ich(2));
+              iwork(34) = octave::math::nint_big (ich(3));
 
               rwork(13) = ich(4);
               rwork(14) = ich(5);
--- a/liboctave/numeric/DET.h	Fri May 27 10:20:48 2016 -0400
+++ b/liboctave/numeric/DET.h	Wed May 25 16:51:16 2016 -0400
@@ -38,18 +38,18 @@
   base_det (T c = 1, int e = 0)
     : c2 (), e2 ()
   {
-    c2 = xlog2 (c, e2);
+    c2 = octave::math::log2 (c, e2);
     e2 += e;
   }
 
   base_det (T c, double e, double b)
     : c2 (), e2 ()
   {
-    e *= xlog2 (b);
+    e *= octave::math::log2 (b);
     e2 = e;
-    c *= xexp2 (e - e2);
+    c *= octave::math::exp2 (e - e2);
     int f;
-    c2 = xlog2 (c, f);
+    c2 = octave::math::log2 (c, f);
     e2 += f;
   }
 
@@ -73,7 +73,7 @@
   void operator *= (T t)
   {
     int e;
-    c2 *= xlog2 (t, e);
+    c2 *= octave::math::log2 (t, e);
     e2 += e;
   }
 
--- a/liboctave/numeric/eigs-base.cc	Fri May 27 10:20:48 2016 -0400
+++ b/liboctave/numeric/eigs-base.cc	Wed May 25 16:51:16 2016 -0400
@@ -450,17 +450,17 @@
           && U.xridx (U.xcidx (j+1)-1) == j)
         d = std::abs (U.xdata (U.xcidx (j+1)-1));
 
-      if (xisnan (minU) || d < minU)
+      if (octave::math::isnan (minU) || d < minU)
         minU = d;
 
-      if (xisnan (maxU) || d > maxU)
+      if (octave::math::isnan (maxU) || d > maxU)
         maxU = d;
     }
 
   double rcond = (minU / maxU);
   volatile double rcond_plus_one = rcond + 1.0;
 
-  if (rcond_plus_one == 1.0 || xisnan (rcond))
+  if (rcond_plus_one == 1.0 || octave::math::isnan (rcond))
     warn_convergence ();
 
   return true;
@@ -522,17 +522,17 @@
   for (octave_idx_type j = 0; j < n; j++)
     {
       double d = std::abs (U.xelem (j,j));
-      if (xisnan (minU) || d < minU)
+      if (octave::math::isnan (minU) || d < minU)
         minU = d;
 
-      if (xisnan (maxU) || d > maxU)
+      if (octave::math::isnan (maxU) || d > maxU)
         maxU = d;
     }
 
   double rcond = (minU / maxU);
   volatile double rcond_plus_one = rcond + 1.0;
 
-  if (rcond_plus_one == 1.0 || xisnan (rcond))
+  if (rcond_plus_one == 1.0 || octave::math::isnan (rcond))
     warn_convergence ();
 
   return true;
@@ -614,17 +614,17 @@
           && U.xridx (U.xcidx (j+1)-1) == j)
         d = std::abs (U.xdata (U.xcidx (j+1)-1));
 
-      if (xisnan (minU) || d < minU)
+      if (octave::math::isnan (minU) || d < minU)
         minU = d;
 
-      if (xisnan (maxU) || d > maxU)
+      if (octave::math::isnan (maxU) || d > maxU)
         maxU = d;
     }
 
   double rcond = (minU / maxU);
   volatile double rcond_plus_one = rcond + 1.0;
 
-  if (rcond_plus_one == 1.0 || xisnan (rcond))
+  if (rcond_plus_one == 1.0 || octave::math::isnan (rcond))
     warn_convergence ();
 
   return true;
@@ -686,17 +686,17 @@
   for (octave_idx_type j = 0; j < n; j++)
     {
       double d = std::abs (U.xelem (j,j));
-      if (xisnan (minU) || d < minU)
+      if (octave::math::isnan (minU) || d < minU)
         minU = d;
 
-      if (xisnan (maxU) || d > maxU)
+      if (octave::math::isnan (maxU) || d > maxU)
         maxU = d;
     }
 
   double rcond = (minU / maxU);
   volatile double rcond_plus_one = rcond + 1.0;
 
-  if (rcond_plus_one == 1.0 || xisnan (rcond))
+  if (rcond_plus_one == 1.0 || octave::math::isnan (rcond))
     warn_convergence ();
 
   return true;
@@ -769,7 +769,7 @@
         {
           octave_idx_type bidx = static_cast<octave_idx_type> (permB(i));
 
-          if (checked(bidx) || bidx < 0 || bidx >= n || D_NINT (bidx) != bidx)
+          if (checked(bidx) || bidx < 0 || bidx >= n || octave::math::x_nint (bidx) != bidx)
             (*current_liboctave_error_handler) ("eigs: permB vector invalid");
         }
     }
@@ -847,7 +847,7 @@
         (*current_liboctave_error_handler)
           ("eigs: unrecoverable exception encountered in dsaupd");
 
-      if (disp > 0 && ! xisnan (workl[iptr (5)-1]))
+      if (disp > 0 && ! octave::math::isnan (workl[iptr (5)-1]))
         {
           if (iter++)
             {
@@ -1042,7 +1042,7 @@
         {
           octave_idx_type bidx = static_cast<octave_idx_type> (permB(i));
 
-          if (checked(bidx) || bidx < 0 || bidx >= n || D_NINT (bidx) != bidx)
+          if (checked(bidx) || bidx < 0 || bidx >= n || octave::math::x_nint (bidx) != bidx)
             (*current_liboctave_error_handler) ("eigs: permB vector invalid");
         }
     }
@@ -1100,7 +1100,7 @@
         (*current_liboctave_error_handler)
           ("eigs: unrecoverable exception encountered in dsaupd");
 
-      if (disp > 0 && ! xisnan (workl[iptr (5)-1]))
+      if (disp > 0 && ! octave::math::isnan (workl[iptr (5)-1]))
         {
           if (iter++)
             {
@@ -1373,7 +1373,7 @@
         (*current_liboctave_error_handler)
           ("eigs: unrecoverable exception encountered in dsaupd");
 
-      if (disp > 0 && ! xisnan (workl[iptr (5)-1]))
+      if (disp > 0 && ! octave::math::isnan (workl[iptr (5)-1]))
         {
           if (iter++)
             {
@@ -1564,7 +1564,7 @@
         {
           octave_idx_type bidx = static_cast<octave_idx_type> (permB(i));
 
-          if (checked(bidx) || bidx < 0 || bidx >= n || D_NINT (bidx) != bidx)
+          if (checked(bidx) || bidx < 0 || bidx >= n || octave::math::x_nint (bidx) != bidx)
             (*current_liboctave_error_handler) ("eigs: permB vector invalid");
         }
     }
@@ -1642,7 +1642,7 @@
         (*current_liboctave_error_handler)
           ("eigs: unrecoverable exception encountered in dnaupd");
 
-      if (disp > 0 && ! xisnan(workl[iptr(5)-1]))
+      if (disp > 0 && ! octave::math::isnan(workl[iptr(5)-1]))
         {
           if (iter++)
             {
@@ -1886,7 +1886,7 @@
         {
           octave_idx_type bidx = static_cast<octave_idx_type> (permB(i));
 
-          if (checked(bidx) || bidx < 0 || bidx >= n || D_NINT (bidx) != bidx)
+          if (checked(bidx) || bidx < 0 || bidx >= n || octave::math::x_nint (bidx) != bidx)
             (*current_liboctave_error_handler) ("eigs: permB vector invalid");
         }
     }
@@ -1944,7 +1944,7 @@
         (*current_liboctave_error_handler)
           ("eigs: unrecoverable exception encountered in dsaupd");
 
-      if (disp > 0 && ! xisnan (workl[iptr (5)-1]))
+      if (disp > 0 && ! octave::math::isnan (workl[iptr (5)-1]))
         {
           if (iter++)
             {
@@ -2272,7 +2272,7 @@
         (*current_liboctave_error_handler)
           ("eigs: unrecoverable exception encountered in dnaupd");
 
-      if (disp > 0 && ! xisnan(workl[iptr(5)-1]))
+      if (disp > 0 && ! octave::math::isnan(workl[iptr(5)-1]))
         {
           if (iter++)
             {
@@ -2513,7 +2513,7 @@
         {
           octave_idx_type bidx = static_cast<octave_idx_type> (permB(i));
 
-          if (checked(bidx) || bidx < 0 || bidx >= n || D_NINT (bidx) != bidx)
+          if (checked(bidx) || bidx < 0 || bidx >= n || octave::math::x_nint (bidx) != bidx)
             (*current_liboctave_error_handler) ("eigs: permB vector invalid");
         }
     }
@@ -2592,7 +2592,7 @@
         (*current_liboctave_error_handler)
           ("eigs: unrecoverable exception encountered in znaupd");
 
-      if (disp > 0 && ! xisnan (workl[iptr (5)-1]))
+      if (disp > 0 && ! octave::math::isnan (workl[iptr (5)-1]))
         {
           if (iter++)
             {
@@ -2789,7 +2789,7 @@
         {
           octave_idx_type bidx = static_cast<octave_idx_type> (permB(i));
 
-          if (checked(bidx) || bidx < 0 || bidx >= n || D_NINT (bidx) != bidx)
+          if (checked(bidx) || bidx < 0 || bidx >= n || octave::math::x_nint (bidx) != bidx)
             (*current_liboctave_error_handler) ("eigs: permB vector invalid");
         }
     }
@@ -2848,7 +2848,7 @@
         (*current_liboctave_error_handler)
           ("eigs: unrecoverable exception encountered in znaupd");
 
-      if (disp > 0 && ! xisnan(workl[iptr(5)-1]))
+      if (disp > 0 && ! octave::math::isnan(workl[iptr(5)-1]))
         {
           if (iter++)
             {
@@ -3133,7 +3133,7 @@
         (*current_liboctave_error_handler)
           ("eigs: unrecoverable exception encountered in znaupd");
 
-      if (disp > 0 && ! xisnan(workl[iptr(5)-1]))
+      if (disp > 0 && ! octave::math::isnan(workl[iptr(5)-1]))
         {
           if (iter++)
             {
--- a/liboctave/numeric/lo-mappers.cc	Fri May 27 10:20:48 2016 -0400
+++ b/liboctave/numeric/lo-mappers.cc	Wed May 25 16:51:16 2016 -0400
@@ -37,616 +37,458 @@
 
 #include "f77-fcn.h"
 
-// double -> double mappers.
-
-// Both xtrunc and xround belong here so we can keep gnulib:: out of
+// Functions that forward to gnulib belong here so we can keep gnulib:: out of
 // lo-mappers.h.
 
-double
-xtrunc (double x)
+namespace octave
 {
-  return gnulib::trunc (x);
-}
+  namespace math
+  {
+    bool
+    is_NA (double x)
+    {
+      return lo_ieee_is_NA (x);
+    }
+
+    bool
+    is_NA (const Complex& x)
+    {
+      return (is_NA (real (x)) || is_NA (imag (x)));
+    }
 
-double
-xcopysign (double x, double y)
-{
-  return gnulib::copysign (x, y);
-}
+    bool
+    is_NA (float x)
+    {
+      return lo_ieee_is_NA (x);
+    }
+
+    bool
+    is_NA (const FloatComplex& x)
+    {
+      return (is_NA (real (x)) || is_NA (imag (x)));
+    }
 
-double xfloor (double x)
-{
-  return gnulib::floor (x);
-}
+    bool
+    is_NaN_or_NA (const Complex& x)
+    {
+      return (isnan (real (x)) || isnan (imag (x)));
+    }
+
+    bool
+    is_NaN_or_NA (const FloatComplex& x)
+    {
+      return (isnan (real (x)) || isnan (imag (x)));
+    }
 
-double
-xround (double x)
-{
-  return gnulib::round (x);
-}
+    Complex
+    acos (const Complex& x)
+    {
+      static Complex i (0, 1);
+
+      Complex tmp;
+
+      if (imag (x) == 0.0)
+        {
+          // If the imaginary part of X is 0, then avoid generating an
+          // imaginary part of -0 for the expression 1-x*x.
+          // This effectively chooses the same phase of the branch cut as Matlab.
+          double xr = real (x);
+          tmp = Complex (1.0 - xr*xr);
+        }
+      else
+        tmp = 1.0 - x*x;
+
+      return -i * log (x + i * sqrt (tmp));
+    }
 
-double
-xroundb (double x)
-{
-  double t = xround (x);
+    FloatComplex
+    acos (const FloatComplex& x)
+    {
+      static FloatComplex i (0, 1);
+
+      FloatComplex tmp;
 
-  if (fabs (x - t) == 0.5)
-    t = 2 * xtrunc (0.5 * t);
+      if (imag (x) == 0.0f)
+        {
+          // If the imaginary part of X is 0, then avoid generating an
+          // imaginary part of -0 for the expression 1-x*x.
+          // This effectively chooses the same phase of the branch cut as Matlab.
+          float xr = real (x);
+          tmp = FloatComplex (1.0f - xr*xr);
+        }
+      else
+        tmp = 1.0f - x*x;
 
-  return t;
-}
+      return -i * log (x + i * sqrt (tmp));
+    }
+
+    Complex
+    asin (const Complex& x)
+    {
+      static Complex i (0, 1);
+
+      Complex tmp;
 
-double
-signum (double x)
-{
-  double tmp = 0.0;
+      if (imag (x) == 0.0)
+        {
+          // If the imaginary part of X is 0, then avoid generating an
+          // imaginary part of -0 for the expression 1-x*x.
+          // This effectively chooses the same phase of the branch cut as Matlab.
+          double xr = real (x);
+          tmp = Complex (1.0 - xr*xr);
+        }
+      else
+        tmp = 1.0 - x*x;
+
+      return -i * log (i*x + sqrt (tmp));
+    }
+
+    FloatComplex
+    asin (const FloatComplex& x)
+    {
+      static FloatComplex i (0, 1);
+
+      FloatComplex tmp;
 
-  if (x < 0.0)
-    tmp = -1.0;
-  else if (x > 0.0)
-    tmp = 1.0;
+      if (imag (x) == 0.0f)
+        {
+          // If the imaginary part of X is 0, then avoid generating an
+          // imaginary part of -0 for the expression 1-x*x.
+          // This effectively chooses the same phase of the branch cut as Matlab.
+          float xr = real (x);
+          tmp = FloatComplex (1.0f - xr*xr);
+        }
+      else
+        tmp = 1.0f - x*x;
+
+      return -i * log (i*x + sqrt (tmp));
+    }
 
-  return xisnan (x) ? octave::numeric_limits<double>::NaN () : tmp;
-}
+    Complex
+    atan (const Complex& x)
+    {
+      static Complex i (0, 1);
+
+      return i * log ((i + x) / (i - x)) / 2.0;
+    }
+
+    FloatComplex
+    atan (const FloatComplex& x)
+    {
+      static FloatComplex i (0, 1);
+
+      return i * log ((i + x) / (i - x)) / 2.0f;
+    }
+
+    double log2 (double x) { return gnulib::log2 (x); }
+    float log2 (float x) { return gnulib::log2f (x); }
 
-double
-xlog2 (double x)
-{
-  return gnulib::log2 (x);
-}
+    Complex
+    log2 (const Complex& x)
+    {
+#if defined (M_LN2)
+      static double ln2 = M_LN2;
+#else
+      static double ln2 = gnulib::log (2.0);
+#endif
+      return std::log (x) / ln2;
+    }
 
-Complex
-xlog2 (const Complex& x)
-{
+    FloatComplex
+    log2 (const FloatComplex& x)
+    {
 #if defined (M_LN2)
-  static double ln2 = M_LN2;
+      static float ln2 = M_LN2;
 #else
-  static double ln2 = gnulib::log (2);
+      static float ln2 = log (2.0f);
 #endif
+      return std::log (x) / ln2;
+    }
 
-  return std::log (x) / ln2;
-}
+    double
+    log2 (double x, int& exp)
+    {
+      return gnulib::frexp (x, &exp);
+    }
+
+    float
+    log2 (float x, int& exp)
+    {
+      return gnulib::frexpf (x, &exp);
+    }
 
-double
-xexp2 (double x)
-{
+    Complex
+    log2 (const Complex& x, int& exp)
+    {
+      double ax = std::abs (x);
+      double lax = log2 (ax, exp);
+      return (ax != lax) ? (x / ax) * lax : x;
+    }
+
+    FloatComplex
+    log2 (const FloatComplex& x, int& exp)
+    {
+      float ax = std::abs (x);
+      float lax = log2 (ax, exp);
+      return (ax != lax) ? (x / ax) * lax : x;
+    }
+
+    double
+    exp2 (double x)
+    {
 #if defined (HAVE_EXP2)
-  return exp2 (x);
+      return ::exp2 (x);
 #else
 #  if defined (M_LN2)
-  static double ln2 = M_LN2;
-#else
-  static double ln2 = gnulib::log (2);
-#endif
-
-  return exp (x * ln2);
-#endif
-}
-
-double
-xlog2 (double x, int& exp)
-{
-  return gnulib::frexp (x, &exp);
-}
-
-Complex
-xlog2 (const Complex& x, int& exp)
-{
-  double ax = std::abs (x);
-  double lax = xlog2 (ax, exp);
-  return (ax != lax) ? (x / ax) * lax : x;
-}
-
-// double -> bool mappers.
-
-bool
-xisnan (double x)
-{
-#if defined (HAVE_CMATH_ISNAN)
-  return std::isnan (x);
-#else
-  return lo_ieee_isnan (x);
-#endif
-}
-
-bool
-xfinite (double x)
-{
-#if defined (HAVE_CMATH_ISFINITE)
-  return std::isfinite (x);
-#else
-  return lo_ieee_finite (x);
-#endif
-}
-
-bool
-xisinf (double x)
-{
-#if defined (HAVE_CMATH_ISINF)
-  return std::isinf (x);
-#else
-  return lo_ieee_isinf (x);
+      static double ln2 = M_LN2;
+#  else
+      static double ln2 = gnulib::log (2.0);
+#  endif
+      return exp (x * ln2);
 #endif
-}
-
-bool
-octave_is_NA (double x)
-{
-  return lo_ieee_is_NA (x);
-}
-
-// (double, double) -> double mappers.
-
-// complex -> complex mappers.
-
-Complex
-acos (const Complex& x)
-{
-  static Complex i (0, 1);
-
-  Complex tmp;
-
-  if (imag (x) == 0.0)
-    {
-      // If the imaginary part of X is 0, then avoid generating an
-      // imaginary part of -0 for the expression 1-x*x.
-      // This effectively chooses the same phase of the branch cut as Matlab.
-      double xr = real (x);
-      tmp = Complex (1.0 - xr*xr);
     }
-  else
-    tmp = 1.0 - x*x;
-
-  return -i * log (x + i * sqrt (tmp));
-}
-
-Complex
-asin (const Complex& x)
-{
-  static Complex i (0, 1);
-
-  Complex tmp;
-
-  if (imag (x) == 0.0)
-    {
-      // If the imaginary part of X is 0, then avoid generating an
-      // imaginary part of -0 for the expression 1-x*x.
-      // This effectively chooses the same phase of the branch cut as Matlab.
-      double xr = real (x);
-      tmp = Complex (1.0 - xr*xr);
-    }
-  else
-    tmp = 1.0 - x*x;
-
-  return -i * log (i*x + sqrt (tmp));
-}
-
-Complex
-atan (const Complex& x)
-{
-  static Complex i (0, 1);
 
-  return i * log ((i + x) / (i - x)) / 2.0;
-}
-
-// complex -> bool mappers.
-
-bool
-octave_is_NA (const Complex& x)
-{
-  return (octave_is_NA (real (x)) || octave_is_NA (imag (x)));
-}
-
-bool
-octave_is_NaN_or_NA (const Complex& x)
-{
-  return (xisnan (real (x)) || xisnan (imag (x)));
-}
-
-// (complex, complex) -> complex mappers.
-
-// FIXME: need to handle NA too?
-
-Complex
-xmin (const Complex& x, const Complex& y)
-{
-  return abs (x) <= abs (y) ? x : (xisnan (x) ? x : y);
-}
-
-Complex
-xmax (const Complex& x, const Complex& y)
-{
-  return abs (x) >= abs (y) ? x : (xisnan (x) ? x : y);
-}
-
-
-// float -> float mappers.
-
-// Both xtrunc and xround belong here so we can keep gnulib:: out of
-// lo-mappers.h.
-
-float
-xtrunc (float x)
-{
-  return gnulib::truncf (x);
-}
-
-float
-xcopysign (float x, float y)
-{
-  return gnulib::copysignf (x, y);
-}
-
-float xfloor (float x)
-{
-  return gnulib::floorf (x);
-}
-
-float
-xround (float x)
-{
-  return gnulib::roundf (x);
-}
-
-float
-xroundb (float x)
-{
-  float t = xround (x);
-
-  if (fabsf (x - t) == 0.5)
-    t = 2 * xtrunc (0.5 * t);
-
-  return t;
-}
-
-float
-signum (float x)
-{
-  float tmp = 0.0;
-
-  if (x < 0.0)
-    tmp = -1.0;
-  else if (x > 0.0)
-    tmp = 1.0;
-
-  return xisnan (x) ? octave::numeric_limits<float>::NaN () : tmp;
-}
-
-float
-xlog2 (float x)
-{
-  return gnulib::log2f (x);
-}
-
-FloatComplex
-xlog2 (const FloatComplex& x)
-{
-#if defined (M_LN2)
-  static float ln2 = M_LN2;
-#else
-  static float ln2 = log (2);
-#endif
-
-  return std::log (x) / ln2;
-}
-
-float
-xexp2 (float x)
-{
+    float
+    exp2 (float x)
+    {
 #if defined (HAVE_EXP2F)
-  return exp2f (x);
+      return exp2f (x);
 #elif defined (HAVE_EXP2)
-  return exp2 (x);
+      return ::exp2 (x);
 #else
 #  if defined (M_LN2)
-  static float ln2 = M_LN2;
-#else
-  static float ln2 = log2 (2);
-#endif
-
-  return exp (x * ln2);
+      static float ln2 = M_LN2;
+#  else
+      static float ln2 = log2 (2.0f);
+#  endif
+      return exp (x * ln2);
 #endif
-}
+    }
+
+    double copysign (double x, double y) { return gnulib::copysign (x, y); }
+    float copysign (float x, float y) { return gnulib::copysignf (x, y); }
+
+    double signbit (double x) { return ::signbit (x); }
+    float signbit (float x) { return ::signbit (x); }
 
-float
-xlog2 (float x, int& exp)
-{
-  return gnulib::frexpf (x, &exp);
-}
+    bool negative_sign (double x) { return __lo_ieee_signbit (x); }
+    bool negative_sign (float x) { return __lo_ieee_float_signbit (x); }
+
+    double trunc (double x) { return gnulib::trunc (x); }
+    float trunc (float x) { return gnulib::truncf (x); }
+
+    double floor (double x) { return gnulib::floor (x); }
+    float floor (float x) { return gnulib::floor (x); }
+
+    double round (double x) { return gnulib::round (x); }
+    float round (float x) { return gnulib::roundf (x); }
 
-FloatComplex
-xlog2 (const FloatComplex& x, int& exp)
-{
-  float ax = std::abs (x);
-  float lax = xlog2 (ax, exp);
-  return (ax != lax) ? (x / ax) * lax : x;
-}
-
-// float -> bool mappers.
+    bool
+    isnan (double x)
+    {
+#if defined (HAVE_CMATH_ISNAN)
+      return std::isnan (x);
+#else
+      return lo_ieee_isnan (x);
+#endif
+    }
 
-bool
-xisnan (float x)
-{
+    bool
+    isnan (float x)
+    {
 #if defined (HAVE_CMATH_ISNANF)
-  return std::isnan (x);
+      return std::isnan (x);
 #else
-  return lo_ieee_isnan (x);
+      return lo_ieee_isnan (x);
 #endif
-}
+    }
+
+    bool
+    finite (double x)
+    {
+#if defined (HAVE_CMATH_ISFINITE)
+      return std::isfinite (x);
+#else
+      return lo_ieee_finite (x);
+#endif
+    }
 
-bool
-xfinite (float x)
-{
+    bool
+    finite (float x)
+    {
 #if defined (HAVE_CMATH_ISFINITEF)
-  return std::isfinite (x);
+      return std::isfinite (x);
 #else
-  return lo_ieee_finite (x);
+      return lo_ieee_finite (x);
 #endif
-}
+    }
 
-bool
-xisinf (float x)
-{
+    bool
+    isinf (double x)
+    {
+#if defined (HAVE_CMATH_ISINF)
+      return std::isinf (x);
+#else
+      return lo_ieee_isinf (x);
+#endif
+    }
+
+    bool
+    isinf (float x)
+    {
 #if defined (HAVE_CMATH_ISINFF)
-  return std::isinf (x);
+      return std::isinf (x);
 #else
-  return lo_ieee_isinf (x);
+      return lo_ieee_isinf (x);
 #endif
-}
+    }
 
-bool
-octave_is_NA (float x)
-{
-  return lo_ieee_is_NA (x);
-}
-
-// (float, float) -> float mappers.
+    // Sometimes you need a large integer, but not always.
 
-// complex -> complex mappers.
+    octave_idx_type
+    nint_big (double x)
+    {
+      if (x > std::numeric_limits<octave_idx_type>::max ())
+        return std::numeric_limits<octave_idx_type>::max ();
+      else if (x < std::numeric_limits<octave_idx_type>::min ())
+        return std::numeric_limits<octave_idx_type>::min ();
+      else
+        return static_cast<octave_idx_type> ((x > 0.0) ? (x + 0.5) : (x - 0.5));
+    }
 
-FloatComplex
-acos (const FloatComplex& x)
-{
-  static FloatComplex i (0, 1);
+    octave_idx_type
+    nint_big (float x)
+    {
+      if (x > std::numeric_limits<octave_idx_type>::max ())
+        return std::numeric_limits<octave_idx_type>::max ();
+      else if (x < std::numeric_limits<octave_idx_type>::min ())
+        return std::numeric_limits<octave_idx_type>::min ();
+      else
+        return static_cast<octave_idx_type> ((x > 0.0f) ? (x + 0.5f) : (x - 0.5f));
+    }
 
-  FloatComplex tmp;
-
-  if (imag (x) == 0.0f)
+    int
+    nint (double x)
     {
-      // If the imaginary part of X is 0, then avoid generating an
-      // imaginary part of -0 for the expression 1-x*x.
-      // This effectively chooses the same phase of the branch cut as Matlab.
-      float xr = real (x);
-      tmp = FloatComplex (1.0f - xr*xr);
+      if (x > std::numeric_limits<int>::max ())
+        return std::numeric_limits<int>::max ();
+      else if (x < std::numeric_limits<int>::min ())
+        return std::numeric_limits<int>::min ();
+      else
+        return static_cast<int> ((x > 0.0) ? (x + 0.5) : (x - 0.5));
     }
-  else
-    tmp = 1.0f - x*x;
 
-  return -i * log (x + i * sqrt (tmp));
-}
+    int
+    nint (float x)
+    {
+      if (x > std::numeric_limits<int>::max ())
+        return std::numeric_limits<int>::max ();
+      else if (x < std::numeric_limits<int>::min ())
+        return std::numeric_limits<int>::min ();
+      else
+        return static_cast<int> ((x > 0.0f) ? (x + 0.5f) : (x - 0.5f));
+    }
 
-FloatComplex
-asin (const FloatComplex& x)
-{
-  static FloatComplex i (0, 1);
-
-  FloatComplex tmp;
+    Complex
+    rc_acos (double x)
+    {
+      return fabs (x) > 1.0 ? acos (Complex (x)) : Complex (::acos (x));
+    }
 
-  if (imag (x) == 0.0f)
+    FloatComplex
+    rc_acos (float x)
+    {
+      return fabsf (x) > 1.0f ? acos (FloatComplex (x)) : FloatComplex (::acosf (x));
+    }
+
+    Complex
+    rc_acosh (double x)
     {
-      // If the imaginary part of X is 0, then avoid generating an
-      // imaginary part of -0 for the expression 1-x*x.
-      // This effectively chooses the same phase of the branch cut as Matlab.
-      float xr = real (x);
-      tmp = FloatComplex (1.0f - xr*xr);
+      return x < 1.0 ? acosh (Complex (x)) : Complex (acosh (x));
     }
-  else
-    tmp = 1.0f - x*x;
+
+    FloatComplex
+    rc_acosh (float x)
+    {
+      return x < 1.0f ? acosh (FloatComplex (x)) : FloatComplex (acosh (x));
+    }
 
-  return -i * log (i*x + sqrt (tmp));
-}
+    Complex
+    rc_asin (double x)
+    {
+      return fabs (x) > 1.0 ? asin (Complex (x)) : Complex (::asin (x));
+    }
 
-FloatComplex
-atan (const FloatComplex& x)
-{
-  static FloatComplex i (0, 1);
+    FloatComplex
+    rc_asin (float x)
+    {
+      return fabsf (x) > 1.0f ? asin (FloatComplex (x)) : FloatComplex (::asinf (x));
+    }
 
-  return i * log ((i + x) / (i - x)) / 2.0f;
-}
+    Complex
+    rc_atanh (double x)
+    {
+      return fabs (x) > 1.0 ? atanh (Complex (x)) : Complex (atanh (x));
+    }
 
-// complex -> bool mappers.
+    FloatComplex
+    rc_atanh (float x)
+    {
+      return fabsf (x) > 1.0f ? xatanh (FloatComplex (x)) : FloatComplex (atanh (x));
+    }
 
-bool
-octave_is_NA (const FloatComplex& x)
-{
-  return (octave_is_NA (real (x)) || octave_is_NA (imag (x)));
-}
+    Complex
+    rc_log (double x)
+    {
+      const double pi = 3.14159265358979323846;
+      return x < 0.0 ? Complex (gnulib::log (-x), pi) : Complex (gnulib::log (x));
+    }
 
-bool
-octave_is_NaN_or_NA (const FloatComplex& x)
-{
-  return (xisnan (real (x)) || xisnan (imag (x)));
-}
+    FloatComplex
+    rc_log (float x)
+    {
+      const float pi = 3.14159265358979323846f;
+      return x < 0.0f ? FloatComplex (gnulib::logf (-x), pi) : FloatComplex (gnulib::logf (x));
+    }
 
-// (complex, complex) -> complex mappers.
-
-// FIXME: need to handle NA too?
+    Complex
+    rc_log2 (double x)
+    {
+      const double pil2 = 4.53236014182719380962; // = pi / log(2)
+      return x < 0.0 ? Complex (log2 (-x), pil2) : Complex (log2 (x));
+    }
 
-FloatComplex
-xmin (const FloatComplex& x, const FloatComplex& y)
-{
-  return abs (x) <= abs (y) ? x : (xisnan (x) ? x : y);
-}
+    FloatComplex
+    rc_log2 (float x)
+    {
+      const float pil2 = 4.53236014182719380962f; // = pi / log(2)
+      return x < 0.0f ? FloatComplex (log2 (-x), pil2) : FloatComplex (log2 (x));
+    }
+
+    Complex
+    rc_log10 (double x)
+    {
+      const double pil10 = 1.36437635384184134748; // = pi / log(10)
+      return x < 0.0 ? Complex (log10 (-x), pil10) : Complex (log10 (x));
+    }
 
-FloatComplex
-xmax (const FloatComplex& x, const FloatComplex& y)
-{
-  return abs (x) >= abs (y) ? x : (xisnan (x) ? x : y);
-}
+    FloatComplex
+    rc_log10 (float x)
+    {
+      const float pil10 = 1.36437635384184134748f; // = pi / log(10)
+      return x < 0.0f ? FloatComplex (log10 (-x), pil10) : FloatComplex (log10f (x));
+    }
 
-Complex
-rc_acos (double x)
-{
-  return fabs (x) > 1.0 ? acos (Complex (x)) : Complex (acos (x));
-}
+    Complex
+    rc_sqrt (double x)
+    {
+      return x < 0.0 ? Complex (0.0, sqrt (-x)) : Complex (sqrt (x));
+    }
 
-FloatComplex
-rc_acos (float x)
-{
-  return fabsf (x) > 1.0f ? acos (FloatComplex (x)) : FloatComplex (acosf (x));
+    FloatComplex
+    rc_sqrt (float x)
+    {
+      return x < 0.0f ? FloatComplex (0.0f, sqrtf (-x)) : FloatComplex (sqrtf (x));
+    }
+  }
 }
-
-Complex
-rc_acosh (double x)
-{
-  return x < 1.0 ? xacosh (Complex (x)) : Complex (xacosh (x));
-}
-
-FloatComplex
-rc_acosh (float x)
-{
-  return x < 1.0f ? xacosh (FloatComplex (x)) : FloatComplex (xacosh (x));
-}
-
-Complex
-rc_asin (double x)
-{
-  return fabs (x) > 1.0 ? asin (Complex (x)) : Complex (asin (x));
-}
-
-FloatComplex
-rc_asin (float x)
-{
-  return fabsf (x) > 1.0f ? asin (FloatComplex (x)) : FloatComplex (asinf (x));
-}
-
-Complex
-rc_atanh (double x)
-{
-  return fabs (x) > 1.0 ? xatanh (Complex (x)) : Complex (xatanh (x));
-}
-
-FloatComplex
-rc_atanh (float x)
-{
-  return fabsf (x) > 1.0f ? xatanh (FloatComplex (x))
-                          : FloatComplex (xatanh (x));
-}
-
-Complex
-rc_log (double x)
-{
-  const double pi = 3.14159265358979323846;
-  return x < 0.0 ? Complex (gnulib::log (-x), pi) : Complex (gnulib::log (x));
-}
-
-FloatComplex
-rc_log (float x)
-{
-  const float pi = 3.14159265358979323846f;
-  return (x < 0.0f
-          ? FloatComplex (gnulib::logf (-x), pi)
-          : FloatComplex (gnulib::logf (x)));
-}
-
-Complex
-rc_log2 (double x)
-{
-  const double pil2 = 4.53236014182719380962; // = pi / log(2)
-  return x < 0.0 ? Complex (xlog2 (-x), pil2) : Complex (xlog2 (x));
-}
-
-FloatComplex
-rc_log2 (float x)
-{
-  const float pil2 = 4.53236014182719380962f; // = pi / log(2)
-  return x < 0.0f ? FloatComplex (xlog2 (-x), pil2) : FloatComplex (xlog2 (x));
-}
-
-Complex
-rc_log10 (double x)
-{
-  const double pil10 = 1.36437635384184134748; // = pi / log(10)
-  return x < 0.0 ? Complex (log10 (-x), pil10) : Complex (log10 (x));
-}
-
-FloatComplex
-rc_log10 (float x)
-{
-  const float pil10 = 1.36437635384184134748f; // = pi / log(10)
-  return x < 0.0f ? FloatComplex (log10 (-x), pil10)
-                  : FloatComplex (log10f (x));
-}
-
-Complex
-rc_sqrt (double x)
-{
-  return x < 0.0 ? Complex (0.0, sqrt (-x)) : Complex (sqrt (x));
-}
-
-FloatComplex
-rc_sqrt (float x)
-{
-  return x < 0.0f ? FloatComplex (0.0f, sqrtf (-x)) : FloatComplex (sqrtf (x));
-}
-
-bool
-xnegative_sign (double x)
-{
-  return __lo_ieee_signbit (x);
-}
-
-bool
-xnegative_sign (float x)
-{
-  return __lo_ieee_float_signbit (x);
-}
-
-// Convert X to the nearest integer value.  Should not pass NaN to
-// this function.
-
-// Sometimes you need a large integer, but not always.
-
-octave_idx_type
-NINTbig (double x)
-{
-  if (x > std::numeric_limits<octave_idx_type>::max ())
-    return std::numeric_limits<octave_idx_type>::max ();
-  else if (x < std::numeric_limits<octave_idx_type>::min ())
-    return std::numeric_limits<octave_idx_type>::min ();
-  else
-    return static_cast<octave_idx_type> ((x > 0) ? (x + 0.5) : (x - 0.5));
-}
-
-octave_idx_type
-NINTbig (float x)
-{
-  if (x > std::numeric_limits<octave_idx_type>::max ())
-    return std::numeric_limits<octave_idx_type>::max ();
-  else if (x < std::numeric_limits<octave_idx_type>::min ())
-    return std::numeric_limits<octave_idx_type>::min ();
-  else
-    return static_cast<octave_idx_type> ((x > 0) ? (x + 0.5) : (x - 0.5));
-}
-
-int
-NINT (double x)
-{
-  if (x > std::numeric_limits<int>::max ())
-    return std::numeric_limits<int>::max ();
-  else if (x < std::numeric_limits<int>::min ())
-    return std::numeric_limits<int>::min ();
-  else
-    return static_cast<int> ((x > 0) ? (x + 0.5) : (x - 0.5));
-}
-
-int
-NINT (float x)
-{
-  if (x > std::numeric_limits<int>::max ())
-    return std::numeric_limits<int>::max ();
-  else if (x < std::numeric_limits<int>::min ())
-    return std::numeric_limits<int>::min ();
-  else
-    return static_cast<int> ((x > 0) ? (x + 0.5) : (x - 0.5));
-}
--- a/liboctave/numeric/lo-mappers.h	Fri May 27 10:20:48 2016 -0400
+++ b/liboctave/numeric/lo-mappers.h	Wed May 25 16:51:16 2016 -0400
@@ -29,322 +29,817 @@
 #include <limits>
 
 #include "oct-cmplx.h"
+#include "oct-inttypes.h"
 #include "lo-math.h"
 #include "lo-ieee.h"
 
-// Double Precision
-extern OCTAVE_API double xtrunc (double x);
-extern OCTAVE_API double xcopysign (double x, double y);
-inline double xceil (double x) { return ceil (x); }
-extern OCTAVE_API double xfloor (double x);
-inline double arg (double x) { return atan2 (0.0, x); }
-inline double conj (double x) { return x; }
-inline double fix (double x) { return xtrunc (x); }
-inline double imag (double) { return 0.0; }
-inline double real (double x) { return x; }
-extern OCTAVE_API double xround (double x);
-extern OCTAVE_API double xroundb (double x);
-extern OCTAVE_API double signum (double x);
-extern OCTAVE_API double xlog2 (double x);
-extern OCTAVE_API Complex xlog2 (const Complex& x);
-extern OCTAVE_API double xlog2 (double x, int& exp);
-extern OCTAVE_API Complex xlog2 (const Complex& x, int& exp);
-extern OCTAVE_API double xexp2 (double x);
+namespace octave
+{
+  namespace math
+  {
+    extern OCTAVE_API bool is_NA (double x);
+    extern OCTAVE_API bool is_NA (float x);
+
+    extern OCTAVE_API bool is_NA (const Complex& x);
+    extern OCTAVE_API bool is_NA (const FloatComplex& x);
+
+    extern OCTAVE_API bool is_NaN_or_NA (const Complex& x);
+    extern OCTAVE_API bool is_NaN_or_NA (const FloatComplex& x);
+
+    extern OCTAVE_API Complex acos (const Complex& x);
+    extern OCTAVE_API FloatComplex acos (const FloatComplex& x);
+
+    extern OCTAVE_API Complex asin (const Complex& x);
+    extern OCTAVE_API FloatComplex asin (const FloatComplex& x);
+
+    extern OCTAVE_API Complex atan (const Complex& x);
+    extern OCTAVE_API FloatComplex atan (const FloatComplex& x);
+
+    inline double arg (double x) { return atan2 (0.0, x); }
+    inline float arg (float x) { return atan2f (0.0f, x); }
+
+    using std::arg;
+
+    inline double conj (double x) { return x; }
+    inline float conj (float x) { return x; }
+
+    using std::conj;
+
+    inline double imag (double) { return 0.0; }
+    inline float imag (float) { return 0.0f; }
+
+    using std::imag;
+
+    inline double real (double x) { return x; }
+    inline float real (float x) { return x; }
+
+    using std::real;
+
+    extern OCTAVE_API double log2 (double x);
+    extern OCTAVE_API float log2 (float x);
+
+    extern OCTAVE_API Complex log2 (const Complex& x);
+    extern OCTAVE_API FloatComplex log2 (const FloatComplex& x);
+
+    extern OCTAVE_API double log2 (double x, int& exp);
+    extern OCTAVE_API float log2 (float x, int& exp);
+
+    extern OCTAVE_API Complex log2 (const Complex& x, int& exp);
+    extern OCTAVE_API FloatComplex log2 (const FloatComplex& x, int& exp);
+
+    extern OCTAVE_API double exp2 (double x);
+    extern OCTAVE_API float exp2 (float x);
+
+    inline double ceil (double x) { return ::ceil (x); }
+    inline float ceil (float x) { return ::ceilf (x); }
+
+    template <typename T>
+    std::complex<T>
+    ceil (const std::complex<T>& x)
+    {
+      return std::complex<T> (ceil (real (x)), ceil (imag (x)));
+    }
+
+    extern OCTAVE_API double copysign (double x, double y);
+    extern OCTAVE_API float copysign (float x, float y);
+
+    extern OCTAVE_API double signbit (double x);
+    extern OCTAVE_API float signbit (float x);
+
+    // Test for negative sign.
+    extern OCTAVE_API bool negative_sign (double x);
+    extern OCTAVE_API bool negative_sign (float x);
+
+    // Test for positive sign.
+    inline bool positive_sign (double x) { return ! negative_sign (x); }
+    inline bool positive_sign (float x) { return ! negative_sign (x); }
+
+    extern OCTAVE_API double trunc (double x);
+    extern OCTAVE_API float trunc (float x);
+
+    template <typename T>
+    std::complex<T>
+    trunc (const std::complex<T>& x)
+    {
+      return std::complex<T> (trunc (real (x)), trunc (imag (x)));
+    }
+
+    inline double fix (double x) { return trunc (x); }
+    inline float fix (float x) { return trunc (x); }
 
-// These are used by the BOOL_OP macros in mx-op-defs.h.
-inline bool xisnan (bool) { return false; }
-inline bool xisnan (char) { return false; }
+    template <typename T>
+    std::complex<T>
+    fix (const std::complex<T>& x)
+    {
+      return trunc (x);
+    }
+
+    extern OCTAVE_API double floor (double x);
+    extern OCTAVE_API float floor (float x);
+
+    template <typename T>
+    std::complex<T>
+    floor (const std::complex<T>& x)
+    {
+      return std::complex<T> (floor (real (x)), floor (imag (x)));
+    }
+
+    extern OCTAVE_API double round (double x);
+    extern OCTAVE_API float round (float x);
+
+    template <typename T>
+    std::complex<T>
+    round (const std::complex<T>& x)
+    {
+      return std::complex<T> (round (real (x)), round (imag (x)));
+    }
+
+    inline double
+    roundb (double x)
+    {
+      double t = round (x);
+
+      if (fabs (x - t) == 0.5)
+        t = 2 * trunc (0.5 * t);
+
+      return t;
+    }
+
+    inline float
+    roundb (float x)
+    {
+      float t = round (x);
+
+      if (fabsf (x - t) == 0.5)
+        t = 2 * trunc (0.5 * t);
+
+      return t;
+    }
 
-extern OCTAVE_API bool xisnan (double x);
-extern OCTAVE_API bool xfinite (double x);
-extern OCTAVE_API bool xisinf (double x);
+    template <typename T>
+    std::complex<T>
+    roundb (const std::complex<T>& x)
+    {
+      return std::complex<T> (roundb (real (x)), roundb (imag (x)));
+    }
+
+    inline bool isnan (bool) { return false; }
+    inline bool isnan (char) { return false; }
+    extern OCTAVE_API bool isnan (double x);
+    extern OCTAVE_API bool isnan (float x);
+
+    template <typename T>
+    bool
+    isnan (const std::complex<T>& x)
+    {
+      return (isnan (real (x)) || isnan (imag (x)));
+    }
+
+    extern OCTAVE_API bool finite (double x);
+    extern OCTAVE_API bool finite (float x);
+
+    template <typename T>
+    bool
+    finite (const std::complex<T>& x)
+    {
+      return (finite (real (x)) && finite (imag (x)));
+    }
+
+    extern OCTAVE_API bool isinf (double x);
+    extern OCTAVE_API bool isinf (float x);
+
+    template <typename T>
+    bool
+    isinf (const std::complex<T>& x)
+    {
+      return (isinf (real (x)) || isinf (imag (x)));
+    }
+
+    // Some useful tests, that are commonly repeated.
+    // Test for a finite integer.
+
+    inline bool isinteger (double x) { return finite (x) && x == round (x); }
+    inline bool isinteger (float x) { return finite (x) && x == round (x); }
+
+    inline double
+    signum (double x)
+    {
+      double tmp = 0.0;
+
+      if (x < 0.0)
+        tmp = -1.0;
+      else if (x > 0.0)
+        tmp = 1.0;
+
+      return isnan (x) ? octave::numeric_limits<double>::NaN () : tmp;
+    }
 
-extern OCTAVE_API bool octave_is_NA (double x);
+    inline float
+    signum (float x)
+    {
+      float tmp = 0.0f;
+
+      if (x < 0.0f)
+        tmp = -1.0f;
+      else if (x > 0.0f)
+        tmp = 1.0f;
+
+      return isnan (x) ? octave::numeric_limits<float>::NaN () : tmp;
+    }
+       
+    template <typename T>
+    std::complex<T>
+    signum (const std::complex<T>& x)
+    {
+      T tmp = abs (x);
+
+      return tmp == 0 ? 0.0 : x / tmp;
+    }
+
+    // Convert X to the nearest integer value.  Should not pass NaN to
+    // this function.
+
+    // For integer types?  Hmm.  Need to be sure T is an integer type...
+    template <typename T>
+    T
+    x_nint (T x)
+    {
+      return x;
+    }
+
+    template <>
+    inline double x_nint (double x) { return (finite (x) ? floor (x + 0.5) : x); }
+    template <>
+    inline float x_nint (float x) { return (finite (x) ? floor (x + 0.5f) : x); }
+
+    extern OCTAVE_API octave_idx_type nint_big (double x);
+    extern OCTAVE_API octave_idx_type nint_big (float x);
+
+    extern OCTAVE_API int nint (double x);
+    extern OCTAVE_API int nint (float x);
+
+    template <typename T>
+    T
+    mod (T x, T y)
+    {
+      T retval;
 
-// Generic xmin, xmax definitions
-template <typename T>
-inline T xmin (T x, T y)
-{
-  return x <= y ? x : y;
-}
+      if (y == 0)
+        retval = x;
+      else
+        {
+          T q = x / y;
+
+          if (x_nint (y) != y
+              && (std::abs ((q - x_nint (q)) / x_nint (q))
+                  < std::numeric_limits<T>::epsilon ()))
+            retval = 0;
+          else
+            {
+              T n = floor (q);
+
+              // Prevent use of extra precision.
+              volatile T tmp = y * n;
+
+              retval = x - tmp;
+            }
+        }
+
+      if (x != y && y != 0)
+        retval = copysign (retval, y);
+
+      return retval;
+    }
+
+    template <typename T>
+    T
+    rem (T x, T y)
+    {
+      T retval;
+
+      if (y == 0)
+        retval = octave::numeric_limits<T>::NaN ();
+      else
+        {
+          T q = x / y;
+
+          if (x_nint (y) != y
+              && (std::abs ((q - x_nint (q)) / x_nint (q))
+                  < std::numeric_limits<T>::epsilon ()))
+            retval = 0;
+          else
+            {
+              T n = trunc (q);
+
+              // Prevent use of extra precision.
+              volatile T tmp = y * n;
 
-template <typename T>
-inline T xmax (T x, T y)
-{
-  return x >= y ? x : y;
-}
+              retval = x - tmp;
+            }
+        }
+
+      if (x != y && y != 0)
+        retval = copysign (retval, x);
+
+      return retval;
+    }
+
+    // Generic min, max definitions
+    template <typename T>
+    T
+    min (T x, T y)
+    {
+      return x <= y ? x : y;
+    }
+
+    template <typename T>
+    T
+    max (T x, T y)
+    {
+      return x >= y ? x : y;
+    }
+
+    // This form is favorable.  GCC will translate (x <= y ? x : y) without a
+    // jump, hence the only conditional jump involved will be the first
+    // (isnan), infrequent and hence friendly to branch prediction.
+
+    inline double
+    min (double x, double y)
+    {
+      return isnan (y) ? x : (x <= y ? x : y);
+    }
+
+    inline double
+    max (double x, double y)
+    {
+      return isnan (y) ? x : (x >= y ? x : y);
+    }
+
+    inline float
+    min (float x, float y)
+    {
+      return isnan (y) ? x : (x <= y ? x : y);
+    }
 
-// This form is favorable.  GCC will translate (x <= y ? x : y) without a
-// jump, hence the only conditional jump involved will be the first
-// (xisnan), infrequent and hence friendly to branch prediction.
-inline double
-xmin (double x, double y)
-{
-  return xisnan (y) ? x : (x <= y ? x : y);
-}
+    inline float
+    max (float x, float y)
+    {
+      return isnan (y) ? x : (x >= y ? x : y);
+    }
+
+    inline std::complex<double>
+    min (const std::complex<double>& x, const std::complex<double>& y)
+    {
+      return abs (x) <= abs (y) ? x : (isnan (x) ? x : y);
+    }
+
+    inline std::complex<float>
+    min (const std::complex<float>& x, const std::complex<float>& y)
+    {
+      return abs (x) <= abs (y) ? x : (isnan (x) ? x : y);
+    }
+
+    inline std::complex<double>
+    max (const std::complex<double>& x, const std::complex<double>& y)
+    {
+      return abs (x) >= abs (y) ? x : (isnan (x) ? x : y);
+    }
 
-inline double
-xmax (double x, double y)
-{
-  return xisnan (y) ? x : (x >= y ? x : y);
+    inline std::complex<float>
+    max (const std::complex<float>& x, const std::complex<float>& y)
+    {
+      return abs (x) >= abs (y) ? x : (isnan (x) ? x : y);
+    }
+
+    // These map reals to Complex.
+
+    extern OCTAVE_API Complex rc_acos (double);
+    extern OCTAVE_API FloatComplex rc_acos (float);
+
+    extern OCTAVE_API Complex rc_acosh (double);
+    extern OCTAVE_API FloatComplex rc_acosh (float);
+
+    extern OCTAVE_API Complex rc_asin (double);
+    extern OCTAVE_API FloatComplex rc_asin (float);
+
+    extern OCTAVE_API Complex rc_atanh (double);
+    extern OCTAVE_API FloatComplex rc_atanh (float);
+
+    extern OCTAVE_API Complex rc_log (double);
+    extern OCTAVE_API FloatComplex rc_log (float);
+
+    extern OCTAVE_API Complex rc_log2 (double);
+    extern OCTAVE_API FloatComplex rc_log2 (float);
+
+    extern OCTAVE_API Complex rc_log10 (double);
+    extern OCTAVE_API FloatComplex rc_log10 (float);
+
+    extern OCTAVE_API Complex rc_sqrt (double);
+    extern OCTAVE_API FloatComplex rc_sqrt (float);
+  }
 }
 
-extern OCTAVE_API Complex acos (const Complex& x);
-extern OCTAVE_API Complex asin (const Complex& x);
-extern OCTAVE_API Complex atan (const Complex& x);
+#if defined (OCTAVE_USE_DEPRECATED_FUNCTIONS)
+
+OCTAVE_DEPRECATED ("use 'octave::math::is_NA' instead")
+inline bool octave_is_NA (double x) { return octave::math::is_NA (x); }
+OCTAVE_DEPRECATED ("use 'octave::math::is_NA' instead")
+inline bool octave_is_NA (float x) { return octave::math::is_NA (x); }
+OCTAVE_DEPRECATED ("use 'octave::math::is_NA' instead")
+inline bool octave_is_NA (const Complex& x) { return octave::math::is_NA (x); }
+OCTAVE_DEPRECATED ("use 'octave::math::is_NA' instead")
+inline bool octave_is_NA (const FloatComplex& x) { return octave::math::is_NA (x); }
+
+OCTAVE_DEPRECATED ("use 'octave::math::is_NaN_or_NA' instead")
+inline bool octave_is_NaN_or_NA (const Complex& x) { return octave::math::is_NaN_or_NA (x); }
+OCTAVE_DEPRECATED ("use 'octave::math::is_NaN_or_NA' instead")
+inline bool octave_is_NaN_or_NA (const FloatComplex& x) { return octave::math::is_NaN_or_NA (x); }
+
+OCTAVE_DEPRECATED ("use 'octave::math::acos' instead")
+inline Complex acos (const Complex& x) { return octave::math::acos (x); }
+OCTAVE_DEPRECATED ("use 'octave::math::acos' instead")
+inline FloatComplex acos (const FloatComplex& x) { return octave::math::acos (x); }
 
-extern OCTAVE_API bool octave_is_NA (const Complex& x);
-extern OCTAVE_API bool octave_is_NaN_or_NA (const Complex& x);
+OCTAVE_DEPRECATED ("use 'octave::math::asin' instead")
+inline Complex asin (const Complex& x) { return octave::math::asin (x); }
+OCTAVE_DEPRECATED ("use 'octave::math::asin' instead")
+inline FloatComplex asin (const FloatComplex& x) { return octave::math::asin (x); }
+
+OCTAVE_DEPRECATED ("use 'octave::math::atan' instead")
+inline Complex atan (const Complex& x) { return octave::math::atan (x); }
+OCTAVE_DEPRECATED ("use 'octave::math::atan' instead")
+inline FloatComplex atan (const FloatComplex& x) { return octave::math::atan (x); }
 
-extern OCTAVE_API Complex xmin (const Complex& x, const Complex& y);
-extern OCTAVE_API Complex xmax (const Complex& x, const Complex& y);
+OCTAVE_DEPRECATED ("use 'octave::math::arg' instead")
+inline double arg (double x) { return octave::math::arg (x); }
+OCTAVE_DEPRECATED ("use 'octave::math::arg' instead")
+inline float arg (float x) { return octave::math::arg (x); }
+
+OCTAVE_DEPRECATED ("use 'octave::math::conj' instead")
+inline double conj (double x) { return octave::math::conj (x); }
+OCTAVE_DEPRECATED ("use 'octave::math::conj' instead")
+inline float conj (float x) { return octave::math::conj (x); }
+
+OCTAVE_DEPRECATED ("use 'octave::math::imag' instead")
+inline double imag (double x) { return octave::math::imag (x); }
+OCTAVE_DEPRECATED ("use 'octave::math::imag' instead")
+inline float imag (float x) { return octave::math::imag (x); }
 
-// Single Precision
-extern OCTAVE_API float xtrunc (float x);
-extern OCTAVE_API float xcopysign (float x, float y);
-inline float xceil (float x) { return ceilf (x); }
-extern OCTAVE_API float xfloor (float x);
-inline float arg (float x) { return atan2f (0.0f, x); }
-inline float conj (float x) { return x; }
-inline float fix (float x) { return xtrunc (x); }
-inline float imag (float) { return 0.0f; }
-inline float real (float x) { return x; }
-extern OCTAVE_API float xround (float x);
-extern OCTAVE_API float xroundb (float x);
-extern OCTAVE_API float signum (float x);
-extern OCTAVE_API float xlog2 (float x);
-extern OCTAVE_API FloatComplex xlog2 (const FloatComplex& x);
-extern OCTAVE_API float xlog2 (float x, int& exp);
-extern OCTAVE_API FloatComplex xlog2 (const FloatComplex& x, int& exp);
-extern OCTAVE_API float xexp2 (float x);
+OCTAVE_DEPRECATED ("use 'octave::math::real' instead")
+inline double real (double x) { return octave::math::real (x); }
+OCTAVE_DEPRECATED ("use 'octave::math::real' instead")
+inline float real (float x) { return octave::math::real (x); }
+
+OCTAVE_DEPRECATED ("use 'octave::math::log2' instead")
+inline double xlog2 (double x) { return octave::math::log2 (x); }
+OCTAVE_DEPRECATED ("use 'octave::math::log2' instead")
+inline float xlog2 (float x) { return octave::math::log2 (x); }
+
+OCTAVE_DEPRECATED ("use 'octave::math::log2' instead")
+inline Complex xlog2 (const Complex& x) { return octave::math::log2 (x); }
+OCTAVE_DEPRECATED ("use 'octave::math::log2' instead")
+inline FloatComplex xlog2 (const FloatComplex& x) { return octave::math::log2 (x); }
+
+OCTAVE_DEPRECATED ("use 'octave::math::log2' instead")
+inline double xlog2 (double x, int& exp) { return octave::math::log2 (x, exp); }
+OCTAVE_DEPRECATED ("use 'octave::math::log2' instead")
+inline float xlog2 (float x, int& exp) { return octave::math::log2 (x, exp); }
+
+OCTAVE_DEPRECATED ("use 'octave::math::log2' instead")
+inline Complex xlog2 (const Complex& x, int& exp) { return octave::math::log2 (x, exp); }
+OCTAVE_DEPRECATED ("use 'octave::math::log2' instead")
+inline FloatComplex xlog2 (const FloatComplex& x, int& exp) { return octave::math::log2 (x, exp); }
 
-extern OCTAVE_API bool xisnan (float x);
-extern OCTAVE_API bool xfinite (float x);
-extern OCTAVE_API bool xisinf (float x);
+OCTAVE_DEPRECATED ("use 'octave::math::exp2' instead")
+inline double xexp2 (double x) { return octave::math::exp2 (x); }
+OCTAVE_DEPRECATED ("use 'octave::math::exp2' instead")
+inline float xexp2 (float x) { return octave::math::exp2 (x); }
+
+OCTAVE_DEPRECATED ("use 'octave::math::ceil' instead")
+inline double xceil (double x) { return octave::math::ceil (x); }
+OCTAVE_DEPRECATED ("use 'octave::math::ceil' instead")
+inline float xceil (float x) { return octave::math::ceil (x); }
 
-extern OCTAVE_API bool octave_is_NA (float x);
+template <typename T>
+OCTAVE_DEPRECATED ("use 'octave::math::ceil' instead")
+std::complex<T>
+ceil (const std::complex<T>& x)
+{
+  return octave::math::ceil (x);
+}
 
-inline float
-xmin (float x, float y)
+OCTAVE_DEPRECATED ("use 'octave::math::copysign' instead")
+inline double xcopysign (double x, double y) { return octave::math::copysign (x, y); }
+OCTAVE_DEPRECATED ("use 'octave::math::copysign' instead")
+inline float xcopysign (float x, float y) { return octave::math::copysign (x, y); }
+
+template <typename T>
+OCTAVE_DEPRECATED ("use 'octave::math::signbit' instead")
+T
+xsignbit (T x)
 {
-  return xisnan (y) ? x : (x <= y ? x : y);
+  return octave::math::signbit (x);
 }
 
-inline float
-xmax (float x, float y)
+OCTAVE_DEPRECATED ("use 'octave::math::negative_sign' instead")
+inline bool xnegative_sign (double x) { return octave::math::negative_sign (x); }
+OCTAVE_DEPRECATED ("use 'octave::math::negative_sign' instead")
+inline bool xnegative_sign (float x) { return octave::math::negative_sign (x); }
+
+OCTAVE_DEPRECATED ("use 'octave::math::positive_sign' instead")
+inline bool xpositive_sign (double x) { return octave::math::positive_sign (x); }
+OCTAVE_DEPRECATED ("use 'octave::math::positive_sign' instead")
+inline bool xpositive_sign (float x) { return octave::math::positive_sign (x); }
+
+OCTAVE_DEPRECATED ("use 'octave::math::signum' instead")
+inline double signum (double x) { return octave::math::signum (x); }
+OCTAVE_DEPRECATED ("use 'octave::math::signum' instead")
+inline float signum (float x) { return octave::math::signum (x); }
+       
+template <typename T>
+OCTAVE_DEPRECATED ("use 'octave::math::signum' instead")
+std::complex<T>
+signum (const std::complex<T>& x)
 {
-  return xisnan (y) ? x : (x >= y ? x : y);
+  return octave::math::signum (x);
+}
+
+OCTAVE_DEPRECATED ("use 'octave::math::trunc' instead")
+inline double xtrunc (double x) { return octave::math::trunc (x); }
+OCTAVE_DEPRECATED ("use 'octave::math::trunc' instead")
+inline float xtrunc (float x) { return octave::math::trunc (x); }
+
+template <typename T>
+OCTAVE_DEPRECATED ("use 'octave::math::trunc' instead")
+std::complex<T>
+xtrunc (const std::complex<T>& x)
+{
+  return octave::math::trunc (x);
+}
+    
+OCTAVE_DEPRECATED ("use 'octave::math::fix' instead")
+inline double fix (double x) { return octave::math::fix (x); }
+OCTAVE_DEPRECATED ("use 'octave::math::fix' instead")
+inline float fix (float x) { return octave::math::fix (x); }
+
+template <typename T>
+OCTAVE_DEPRECATED ("use 'octave::math::fix' instead")
+std::complex<T>
+fix (const std::complex<T>& x)
+{
+  return octave::math::fix (x);
+}
+    
+OCTAVE_DEPRECATED ("use 'octave::math::floor' instead")
+inline double xfloor (double x) { return octave::math::floor (x); }
+OCTAVE_DEPRECATED ("use 'octave::math::floor' instead")
+inline float xfloor (float x) { return octave::math::floor (x); }
+
+template <typename T>
+OCTAVE_DEPRECATED ("use 'octave::math::floor' instead")
+std::complex<T>
+floor (const std::complex<T>& x)
+{
+  return octave::math::floor (x);
 }
 
-extern OCTAVE_API FloatComplex acos (const FloatComplex& x);
-extern OCTAVE_API FloatComplex asin (const FloatComplex& x);
-extern OCTAVE_API FloatComplex atan (const FloatComplex& x);
+OCTAVE_DEPRECATED ("use 'octave::math::round' instead")
+inline double xround (double x) { return octave::math::round (x); }
+OCTAVE_DEPRECATED ("use 'octave::math::round' instead")
+inline float xround (float x) { return octave::math::round (x); }
 
-extern OCTAVE_API bool octave_is_NA (const FloatComplex& x);
-extern OCTAVE_API bool octave_is_NaN_or_NA (const FloatComplex& x);
+template <typename T>
+OCTAVE_DEPRECATED ("use 'octave::math::round' instead")
+std::complex<T>
+xround (const std::complex<T>& x)
+{
+  return octave::math::round (x);
+}
 
-extern OCTAVE_API FloatComplex xmin (const FloatComplex& x,
-                                     const FloatComplex& y);
-extern OCTAVE_API FloatComplex xmax (const FloatComplex& x,
-                                     const FloatComplex& y);
+OCTAVE_DEPRECATED ("use 'octave::math::roundb' instead")
+inline double xroundb (double x) { return octave::math::roundb (x); }
+OCTAVE_DEPRECATED ("use 'octave::math::roundb' instead")
+inline float xroundb (float x) { return octave::math::roundb (x); }
 
-// These map reals to Complex.
+template <typename T>
+OCTAVE_DEPRECATED ("use 'octave::math::roundb' instead")
+std::complex<T>
+xroundb (const std::complex<T>& x)
+{
+  return octave::math::roundb (x);
+}
 
-extern OCTAVE_API Complex rc_acos (double);
-extern OCTAVE_API FloatComplex rc_acos (float);
-extern OCTAVE_API Complex rc_acosh (double);
-extern OCTAVE_API FloatComplex rc_acosh (float);
-extern OCTAVE_API Complex rc_asin (double);
-extern OCTAVE_API FloatComplex rc_asin (float);
-extern OCTAVE_API Complex rc_atanh (double);
-extern OCTAVE_API FloatComplex rc_atanh (float);
-extern OCTAVE_API Complex rc_log (double);
-extern OCTAVE_API FloatComplex rc_log (float);
-extern OCTAVE_API Complex rc_log2 (double);
-extern OCTAVE_API FloatComplex rc_log2 (float);
-extern OCTAVE_API Complex rc_log10 (double);
-extern OCTAVE_API FloatComplex rc_log10 (float);
-extern OCTAVE_API Complex rc_sqrt (double);
-extern OCTAVE_API FloatComplex rc_sqrt (float);
+OCTAVE_DEPRECATED ("use 'octave::math::isnan' instead")
+inline bool xisnan (bool x) { return octave::math::isnan (x); }
+OCTAVE_DEPRECATED ("use 'octave::math::isnan' instead")
+inline bool xisnan (char x) { return octave::math::isnan (x); }
+OCTAVE_DEPRECATED ("use 'octave::math::isnan' instead")
+inline bool xisnan (double x) { return octave::math::isnan (x); }
+OCTAVE_DEPRECATED ("use 'octave::math::isnan' instead")
+inline bool xisnan (float x) { return octave::math::isnan (x); }
+
+template <typename T>
+OCTAVE_DEPRECATED ("use 'octave::math::isnan' instead")
+bool
+xisnan (const std::complex<T>& x)
+{
+  return octave::math::isnan (x);
+}
+
+OCTAVE_DEPRECATED ("use 'octave::math::finite' instead")
+inline bool xfinite (double x) { return octave::math::finite (x); }
+OCTAVE_DEPRECATED ("use 'octave::math::finite' instead")
+inline bool xfinite (float x) { return octave::math::finite (x); }
+
+template <typename T>
+OCTAVE_DEPRECATED ("use 'octave::math::finite' instead")
+bool
+xfinite (const std::complex<T>& x)
+{
+  return octave::math::finite (x);
+}
+
+OCTAVE_DEPRECATED ("use 'octave::math::isinf' instead")
+inline bool xisinf (double x) { return octave::math::isinf (x); }
+OCTAVE_DEPRECATED ("use 'octave::math::isinf' instead")
+inline bool xisinf (float x) { return octave::math::isinf (x); }
+
+template <typename T>
+OCTAVE_DEPRECATED ("use 'octave::math::isinf' instead")
+bool
+xisinf (const std::complex<T>& x)
+{
+  return octave::math::isinf (x);
+}
 
 // Some useful tests, that are commonly repeated.
 // Test for a finite integer.
+
+OCTAVE_DEPRECATED ("use 'octave::math::isinteger' instead")
 inline bool
 xisinteger (double x)
 {
-  return xfinite (x) && x == xround (x);
+  return octave::math::isinteger (x);
 }
 
+OCTAVE_DEPRECATED ("use 'octave::math::isinteger' instead")
 inline bool
 xisinteger (float x)
 {
-  return xfinite (x) && x == xround (x);
-}
-
-// Test for negative sign.
-extern OCTAVE_API bool xnegative_sign (double x);
-extern OCTAVE_API bool xnegative_sign (float x);
-
-// Test for positive sign.
-inline bool xpositive_sign (double x) { return ! xnegative_sign (x); }
-inline bool xpositive_sign (float x) { return ! xnegative_sign (x); }
-
-// Some old rounding functions.
-
-extern OCTAVE_API octave_idx_type NINTbig (double x);
-extern OCTAVE_API octave_idx_type NINTbig (float x);
-
-extern OCTAVE_API int NINT (double x);
-extern OCTAVE_API int NINT (float x);
-
-template <typename T>
-T
-X_NINT (T x)
-{
-  return (xfinite (x) ? xfloor (x + 0.5) : x);
-}
-
-inline OCTAVE_API double D_NINT (double x) { return X_NINT (x); }
-inline OCTAVE_API float F_NINT (float x) { return X_NINT (x); }
-
-// Template functions can have either float or double arguments.
-
-template <typename T>
-bool
-xisnan (const std::complex<T>& x)
-{
-  return (xisnan (real (x)) || xisnan (imag (x)));
+  return octave::math::isinteger (x);
 }
 
 template <typename T>
-bool
-xfinite (const std::complex<T>& x)
+OCTAVE_DEPRECATED ("use 'octave::math::x_nint' instead")
+T
+X_NINT (T x)
 {
-  return (xfinite (real (x)) && xfinite (imag (x)));
+  return octave::math::x_nint (x);
 }
 
+OCTAVE_DEPRECATED ("use 'octave::math::x_nint (x)' instead")
+inline double D_NINT (double x) { return octave::math::x_nint (x); }
+OCTAVE_DEPRECATED ("use 'octave::math::x_nint (x)' instead")
+inline float F_NINT (float x) { return octave::math::x_nint (x); }
+
+OCTAVE_DEPRECATED ("use 'octave::math::nint_big' instead")
+inline octave_idx_type NINTbig (double x) { return octave::math::nint_big (x); }
+OCTAVE_DEPRECATED ("use 'octave::math::nint_big' instead")
+inline octave_idx_type NINTbig (float x) { return octave::math::nint_big (x); }
+
+OCTAVE_DEPRECATED ("use 'octave::math::nint' instead")
+inline int NINT (double x) { return octave::math::nint (x); }
+OCTAVE_DEPRECATED ("use 'octave::math::nint' instead")
+inline int NINT (float x) { return octave::math::nint (x); }
+
 template <typename T>
-bool
-xisinf (const std::complex<T>& x)
+OCTAVE_DEPRECATED ("use 'octave::math::mod' instead")
+T
+xmod (T x, T y)
 {
-  return (xisinf (real (x)) || xisinf (imag (x)));
+  return octave::math::mod (x, y);
 }
 
 template <typename T>
-std::complex<T>
-fix (const std::complex<T>& x)
+OCTAVE_DEPRECATED ("use 'octave::math::rem' instead")
+T
+xrem (T x, T y)
 {
-  return std::complex<T> (fix (real (x)), fix (imag (x)));
+  return octave::math::rem (x, y);
 }
 
 template <typename T>
-std::complex<T>
-ceil (const std::complex<T>& x)
+OCTAVE_DEPRECATED ("use 'octave::math::min' instead")
+T
+xmin (T x, T y)
 {
-  return std::complex<T> (xceil (real (x)), xceil (imag (x)));
-}
-
-template <typename T>
-std::complex<T>
-floor (const std::complex<T>& x)
-{
-  return std::complex<T> (xfloor (real (x)), xfloor (imag (x)));
-}
-
-template <typename T>
-std::complex<T>
-xround (const std::complex<T>& x)
-{
-  return std::complex<T> (xround (real (x)), xround (imag (x)));
+  return octave::math::min (x, y);
 }
 
 template <typename T>
-std::complex<T>
-xroundb (const std::complex<T>& x)
+OCTAVE_DEPRECATED ("use 'octave::math::max' instead")
+T
+xmax (T x, T y)
 {
-  return std::complex<T> (xroundb (real (x)), xroundb (imag (x)));
+  return octave::math::max (x, y);
+}
+
+OCTAVE_DEPRECATED ("use 'octave::math::min' instead")
+inline double
+xmin (double x, double y)
+{
+  return octave::math::min (x, y);
+}
+
+OCTAVE_DEPRECATED ("use 'octave::math::max' instead")
+inline double
+xmax (double x, double y)
+{
+  return octave::math::max (x, y);
 }
 
-template <typename T>
-std::complex<T>
-signum (const std::complex<T>& x)
+OCTAVE_DEPRECATED ("use 'octave::math::min' instead")
+inline float
+xmin (float x, float y)
+{
+  return octave::math::min (x, y);
+}
+
+OCTAVE_DEPRECATED ("use 'octave::math::max' instead")
+inline float
+xmax (float x, float y)
 {
-  T tmp = abs (x);
+  return octave::math::max (x, y);
+}
 
-  return tmp == 0 ? 0.0 : x / tmp;
+OCTAVE_DEPRECATED ("use 'octave::math::min' instead")
+inline Complex
+xmin (const Complex& x, const Complex& y)
+{
+  return octave::math::min (x, y);
+}
+
+OCTAVE_DEPRECATED ("use 'octave::math::max' instead")
+inline Complex
+xmax (const Complex& x, const Complex& y)
+{
+  return octave::math::max (x, y);
 }
 
-template <typename T>
-T
-xmod (T x, T y)
+OCTAVE_DEPRECATED ("use 'octave::math::min' instead")
+inline OCTAVE_API FloatComplex
+xmin (const FloatComplex& x, const FloatComplex& y)
 {
-  T retval;
-
-  if (y == 0)
-    retval = x;
-  else
-    {
-      T q = x / y;
+  return octave::math::min (x, y);
+}
 
-      if (X_NINT (y) != y
-          && (std::abs ((q - X_NINT (q)) / X_NINT (q))
-              < std::numeric_limits<T>::epsilon ()))
-        retval = 0;
-      else
-        {
-          T n = xfloor (q);
-
-          // Prevent use of extra precision.
-          volatile T tmp = y * n;
-
-          retval = x - tmp;
-        }
-    }
-
-  if (x != y && y != 0)
-    retval = xcopysign (retval, y);
-
-  return retval;
+OCTAVE_DEPRECATED ("use 'octave::math::max' instead")
+inline FloatComplex
+xmax (const FloatComplex& x, const FloatComplex& y)
+{
+  return octave::math::max (x, y);
 }
 
-template <typename T>
-T
-xrem (T x, T y)
-{
-  T retval;
+OCTAVE_DEPRECATED ("use 'octave::math::rc_acos' instead")
+inline Complex rc_acos (double x) { return octave::math::rc_acos (x); }
+OCTAVE_DEPRECATED ("use 'octave::math::rc_acos' instead")
+inline FloatComplex rc_acos (float x) { return octave::math::rc_acos (x); }
+
+OCTAVE_DEPRECATED ("use 'octave::math::rc_acosh' instead")
+inline Complex rc_acosh (double x) { return octave::math::rc_acosh (x); }
+OCTAVE_DEPRECATED ("use 'octave::math::rc_acosh' instead")
+inline FloatComplex rc_acosh (float x) { return octave::math::rc_acosh (x); }
 
-  if (y == 0)
-    retval = octave::numeric_limits<T>::NaN ();
-  else
-    {
-      T q = x / y;
+OCTAVE_DEPRECATED ("use 'octave::math::rc_asin' instead")
+inline Complex rc_asin (double x) { return octave::math::rc_asin (x); }
+OCTAVE_DEPRECATED ("use 'octave::math::rc_asin' instead")
+inline FloatComplex rc_asin (float x) { return octave::math::rc_asin (x); }
 
-      if (X_NINT (y) != y
-          && (std::abs ((q - X_NINT (q)) / X_NINT (q))
-              < std::numeric_limits<T>::epsilon ()))
-        retval = 0;
-      else
-        {
-          T n = xtrunc (q);
+OCTAVE_DEPRECATED ("use 'octave::math::rc_atanh' instead")
+inline Complex rc_atanh (double x) { return octave::math::rc_atanh (x); }
+OCTAVE_DEPRECATED ("use 'octave::math::rc_atanh' instead")
+inline FloatComplex rc_atanh (float x) { return octave::math::rc_atanh (x); }
 
-          // Prevent use of extra precision.
-          volatile T tmp = y * n;
+OCTAVE_DEPRECATED ("use 'octave::math::rc_log' instead")
+inline Complex rc_log (double x) { return octave::math::rc_log (x); }
+OCTAVE_DEPRECATED ("use 'octave::math::rc_log' instead")
+inline FloatComplex rc_log (float x) { return octave::math::rc_log (x); }
 
-          retval = x - tmp;
-        }
-    }
-
-  if (x != y && y != 0)
-    retval = xcopysign (retval, x);
+OCTAVE_DEPRECATED ("use 'octave::math::rc_log2' instead")
+inline Complex rc_log2 (double x) { return octave::math::rc_log2 (x); }
+OCTAVE_DEPRECATED ("use 'octave::math::rc_log2' instead")
+inline FloatComplex rc_log2 (float x) { return octave::math::rc_log2 (x); }
 
-  return retval;
-}
+OCTAVE_DEPRECATED ("use 'octave::math::rc_log10' instead")
+inline Complex rc_log10 (double x) { return octave::math::rc_log10 (x); }
+OCTAVE_DEPRECATED ("use 'octave::math::rc_log10' instead")
+inline FloatComplex rc_log10 (float x) { return octave::math::rc_log10 (x); }
 
-template <typename T>
-T
-xsignbit (T x)
-{
-  return signbit (x);
-}
+OCTAVE_DEPRECATED ("use 'octave::math::rc_sqrt' instead")
+inline Complex rc_sqrt (double x) { return octave::math::rc_sqrt (x); }
+OCTAVE_DEPRECATED ("use 'octave::math::rc_sqrt' instead")
+inline FloatComplex rc_sqrt (float x) { return octave::math::rc_sqrt (x); }
 
 #endif
+
+#endif
--- a/liboctave/numeric/lo-specfun.cc	Fri May 27 10:20:48 2016 -0400
+++ b/liboctave/numeric/lo-specfun.cc	Wed May 25 16:51:16 2016 -0400
@@ -441,12 +441,12 @@
   // tgamma.  Matlab does not have -0.
 
   if (x == 0)
-    result = (xnegative_sign (x)
+    result = (octave::math::negative_sign (x)
               ? -octave::numeric_limits<double>::Inf ()
               : octave::numeric_limits<double>::Inf ());
-  else if ((x < 0 && D_NINT (x) == x) || xisinf (x))
+  else if ((x < 0 && octave::math::x_nint (x) == x) || octave::math::isinf (x))
     result = octave::numeric_limits<double>::Inf ();
-  else if (xisnan (x))
+  else if (octave::math::isnan (x))
     result = octave::numeric_limits<double>::NaN ();
   else
     {
@@ -469,9 +469,9 @@
   double result;
   double sgngam;
 
-  if (xisnan (x))
+  if (octave::math::isnan (x))
     result = x;
-  else if ((x <= 0 && D_NINT (x) == x) || xisinf (x))
+  else if ((x <= 0 && octave::math::x_nint (x) == x) || octave::math::isinf (x))
     result = octave::numeric_limits<double>::Inf ();
   else
     F77_XFCN (dlgams, DLGAMS, (x, result, sgngam));
@@ -491,9 +491,9 @@
 #else
   double sgngam = 0.0;
 
-  if (xisnan (x))
+  if (octave::math::isnan (x))
     result = x;
-  else if ((x <= 0 && D_NINT (x) == x) || xisinf (x))
+  else if ((x <= 0 && octave::math::x_nint (x) == x) || octave::math::isinf (x))
     result = octave::numeric_limits<double>::Inf ();
   else
     F77_XFCN (dlgams, DLGAMS, (x, result, sgngam));
@@ -515,12 +515,12 @@
   // tgamma.  Matlab does not have -0.
 
   if (x == 0)
-    result = (xnegative_sign (x)
+    result = (octave::math::negative_sign (x)
               ? -octave::numeric_limits<float>::Inf ()
               : octave::numeric_limits<float>::Inf ());
-  else if ((x < 0 && D_NINT (x) == x) || xisinf (x))
+  else if ((x < 0 && octave::math::x_nint (x) == x) || octave::math::isinf (x))
     result = octave::numeric_limits<float>::Inf ();
-  else if (xisnan (x))
+  else if (octave::math::isnan (x))
     result = octave::numeric_limits<float>::NaN ();
   else
     {
@@ -543,9 +543,9 @@
   float result;
   float sgngam;
 
-  if (xisnan (x))
+  if (octave::math::isnan (x))
     result = x;
-  else if ((x <= 0 && D_NINT (x) == x) || xisinf (x))
+  else if ((x <= 0 && octave::math::x_nint (x) == x) || octave::math::isinf (x))
     result = octave::numeric_limits<float>::Inf ();
   else
     F77_XFCN (algams, ALGAMS, (x, result, sgngam));
@@ -565,9 +565,9 @@
 #else
   float sgngam = 0.0f;
 
-  if (xisnan (x))
+  if (octave::math::isnan (x))
     result = x;
-  else if ((x <= 0 && D_NINT (x) == x) || xisinf (x))
+  else if ((x <= 0 && octave::math::x_nint (x) == x) || octave::math::isinf (x))
     result = octave::numeric_limits<float>::Inf ();
   else
     F77_XFCN (algams, ALGAMS, (x, result, sgngam));
@@ -744,7 +744,7 @@
 xxcbrt (T x)
 {
   static const T one_third = 0.3333333333333333333f;
-  if (xfinite (x))
+  if (octave::math::finite (x))
     {
       // Use pow.
       T y = std::pow (std::abs (x), one_third) * signum (x);
@@ -3046,10 +3046,10 @@
       const double q = sqrt (-2*gnulib::log (0.5*(1-ax)));
       const double yn = ((((c[0]*q + c[1])*q + c[2])*q + c[3])*q + c[4])*q + c[5];
       const double yd = (((d[0]*q + d[1])*q + d[2])*q + d[3])*q + 1.0;
-      y = yn / yd * signum (-x);
+      y = yn / yd * octave::math::signum (-x);
     }
   else if (ax == 1.0)
-    return octave::numeric_limits<double>::Inf () * signum (x);
+    return octave::numeric_limits<double>::Inf () * octave::math::signum (x);
   else
     return octave::numeric_limits<double>::NaN ();
 
@@ -3767,7 +3767,7 @@
 {
   static const double euler_mascheroni = 0.577215664901532860606512090082402431042;
 
-  const bool is_int = (xfloor (z) == z);
+  const bool is_int = (octave::math::floor (z) == z);
 
   T p = 0;
   if (z <= 0)
@@ -3786,7 +3786,7 @@
       for (octave_idx_type k = z - 1; k > 0; k--)
         p += 1.0 / k;
     }
-  else if (xfloor (z + 0.5) == z + 0.5)
+  else if (octave::math::floor (z + 0.5) == z + 0.5)
     {
       // Abramowitz and Stegun, page 258, eq 6.3.3 and 6.3.4
       for (octave_idx_type k = z; k > 0; k--)
--- a/liboctave/numeric/oct-norm.cc	Fri May 27 10:20:48 2016 -0400
+++ b/liboctave/numeric/oct-norm.cc	Wed May 25 16:51:16 2016 -0400
@@ -179,7 +179,7 @@
   template <typename U>
   void accum (U val)
   {
-    if (xisnan (val))
+    if (octave::math::isnan (val))
       max = octave::numeric_limits<R>::NaN ();
     else
       max = std::max (max, std::abs (val));
@@ -197,7 +197,7 @@
   template <typename U>
   void accum (U val)
   {
-    if (xisnan (val))
+    if (octave::math::isnan (val))
       min = octave::numeric_limits<R>::NaN ();
     else
       min = std::min (min, std::abs (val));
@@ -403,7 +403,7 @@
 template <typename T, typename R>
 inline T elem_dual_p (T x, R p)
 {
-  return signum (x) * std::pow (std::abs (x), p-1);
+  return octave::math::signum (x) * std::pow (std::abs (x), p-1);
 }
 
 // the VectorT is used for vectors, but actually it has to be
--- a/liboctave/numeric/oct-rand.cc	Fri May 27 10:20:48 2016 -0400
+++ b/liboctave/numeric/oct-rand.cc	Wed May 25 16:51:16 2016 -0400
@@ -356,7 +356,7 @@
           break;
 
         case poisson_dist:
-          if (a < 0.0 || ! xfinite (a))
+          if (a < 0.0 || ! octave::math::finite (a))
             retval = octave::numeric_limits<double>::NaN ();
           else
             {
@@ -367,7 +367,7 @@
           break;
 
         case gamma_dist:
-          if (a <= 0.0 || ! xfinite (a))
+          if (a <= 0.0 || ! octave::math::finite (a))
             retval = octave::numeric_limits<double>::NaN ();
           else
             F77_FUNC (dgengam, DGENGAM) (1.0, a, retval);
@@ -439,7 +439,7 @@
           break;
 
         case poisson_dist:
-          if (da < 0.0 || ! xfinite (a))
+          if (da < 0.0 || ! octave::math::finite (a))
             dretval = octave::numeric_limits<double>::NaN ();
           else
             {
@@ -450,7 +450,7 @@
           break;
 
         case gamma_dist:
-          if (da <= 0.0 || ! xfinite (a))
+          if (da <= 0.0 || ! octave::math::finite (a))
             dretval = octave::numeric_limits<double>::NaN ();
           else
             F77_FUNC (dgengam, DGENGAM) (1.0, da, dretval);
@@ -670,7 +670,7 @@
   uint32_t u;
   static const double TWOUP32 = std::numeric_limits<uint32_t>::max() + 1.0;
 
-  if (! xfinite (d))
+  if (! octave::math::finite (d))
     u = 0;
   else
     {
@@ -768,7 +768,7 @@
     case poisson_dist:
       if (use_old_generators)
         {
-          if (a < 0.0 || ! xfinite (a))
+          if (a < 0.0 || ! octave::math::finite (a))
 #define RAND_FUNC(x) x = octave::numeric_limits<double>::NaN ();
             MAKE_RAND (len);
 #undef RAND_FUNC
@@ -789,7 +789,7 @@
     case gamma_dist:
       if (use_old_generators)
         {
-          if (a <= 0.0 || ! xfinite (a))
+          if (a <= 0.0 || ! octave::math::finite (a))
 #define RAND_FUNC(x) x = octave::numeric_limits<double>::NaN ();
             MAKE_RAND (len);
 #undef RAND_FUNC
@@ -858,7 +858,7 @@
       if (use_old_generators)
         {
           double da = a;
-          if (da < 0.0 || ! xfinite (a))
+          if (da < 0.0 || ! octave::math::finite (a))
 #define RAND_FUNC(x) x = octave::numeric_limits<double>::NaN ();
             MAKE_RAND (len);
 #undef RAND_FUNC
@@ -880,7 +880,7 @@
       if (use_old_generators)
         {
           double da = a;
-          if (da <= 0.0 || ! xfinite (a))
+          if (da <= 0.0 || ! octave::math::finite (a))
 #define RAND_FUNC(x) x = octave::numeric_limits<double>::NaN ();
             MAKE_RAND (len);
 #undef RAND_FUNC
--- a/liboctave/numeric/sparse-lu.cc	Fri May 27 10:20:48 2016 -0400
+++ b/liboctave/numeric/sparse-lu.cc	Wed May 25 16:51:16 2016 -0400
@@ -388,33 +388,33 @@
   umfpack_defaults<lu_elt_type> (control);
 
   double tmp = octave_sparse_params::get_key ("spumoni");
-  if (! xisnan (tmp))
+  if (! octave::math::isnan (tmp))
     Control (UMFPACK_PRL) = tmp;
 
   if (piv_thres.numel () == 2)
     {
       tmp = (piv_thres (0) > 1. ? 1. : piv_thres (0));
-      if (! xisnan (tmp))
+      if (! octave::math::isnan (tmp))
         Control (UMFPACK_PIVOT_TOLERANCE) = tmp;
 
       tmp = (piv_thres (1) > 1. ? 1. : piv_thres (1));
-      if (! xisnan (tmp))
+      if (! octave::math::isnan (tmp))
         Control (UMFPACK_SYM_PIVOT_TOLERANCE) = tmp;
     }
   else
     {
       tmp = octave_sparse_params::get_key ("piv_tol");
-      if (! xisnan (tmp))
+      if (! octave::math::isnan (tmp))
         Control (UMFPACK_PIVOT_TOLERANCE) = tmp;
 
       tmp = octave_sparse_params::get_key ("sym_tol");
-      if (! xisnan (tmp))
+      if (! octave::math::isnan (tmp))
         Control (UMFPACK_SYM_PIVOT_TOLERANCE) = tmp;
     }
 
   // Set whether we are allowed to modify Q or not
   tmp = octave_sparse_params::get_key ("autoamd");
-  if (! xisnan (tmp))
+  if (! octave::math::isnan (tmp))
     Control (UMFPACK_FIXQ) = tmp;
 
   // Turn-off UMFPACK scaling for LU
@@ -586,26 +586,26 @@
   umfpack_defaults<lu_elt_type> (control);
 
   double tmp = octave_sparse_params::get_key ("spumoni");
-  if (! xisnan (tmp))
+  if (! octave::math::isnan (tmp))
     Control (UMFPACK_PRL) = tmp;
 
   if (piv_thres.numel () == 2)
     {
       tmp = (piv_thres (0) > 1. ? 1. : piv_thres (0));
-      if (! xisnan (tmp))
+      if (! octave::math::isnan (tmp))
         Control (UMFPACK_PIVOT_TOLERANCE) = tmp;
       tmp = (piv_thres (1) > 1. ? 1. : piv_thres (1));
-      if (! xisnan (tmp))
+      if (! octave::math::isnan (tmp))
         Control (UMFPACK_SYM_PIVOT_TOLERANCE) = tmp;
     }
   else
     {
       tmp = octave_sparse_params::get_key ("piv_tol");
-      if (! xisnan (tmp))
+      if (! octave::math::isnan (tmp))
         Control (UMFPACK_PIVOT_TOLERANCE) = tmp;
 
       tmp = octave_sparse_params::get_key ("sym_tol");
-      if (! xisnan (tmp))
+      if (! octave::math::isnan (tmp))
         Control (UMFPACK_SYM_PIVOT_TOLERANCE) = tmp;
     }
 
@@ -618,7 +618,7 @@
   else
     {
       tmp = octave_sparse_params::get_key ("autoamd");
-      if (! xisnan (tmp))
+      if (! octave::math::isnan (tmp))
         Control (UMFPACK_FIXQ) = tmp;
     }
 
--- a/liboctave/operators/mx-inlines.cc	Fri May 27 10:20:48 2016 -0400
+++ b/liboctave/operators/mx-inlines.cc	Wed May 25 16:51:16 2016 -0400
@@ -187,7 +187,7 @@
 {
   for (size_t i = 0; i < n; i++)
     {
-      if (xisnan (x[i]))
+      if (octave::math::isnan (x[i]))
         return true;
     }
 
@@ -200,7 +200,7 @@
 {
   for (size_t i = 0; i < n; i++)
     {
-      if (! xfinite (x[i]))
+      if (! octave::math::finite (x[i]))
         return false;
     }
 
@@ -270,15 +270,15 @@
 inline void F (size_t n, T *r, T x, const T *y) throw () \
 { for (size_t i = 0; i < n; i++) r[i] = FUN (x, y[i]); }
 
-DEFMXMAPPER2 (mx_inline_xmin, xmin)
-DEFMXMAPPER2 (mx_inline_xmax, xmax)
+DEFMXMAPPER2 (mx_inline_xmin, octave::math::min)
+DEFMXMAPPER2 (mx_inline_xmax, octave::math::max)
 
 // Specialize array-scalar max/min
 #define DEFMINMAXSPEC(T, F, OP) \
 template <> \
 inline void F<T> (size_t n, T *r, const T *x, T y) throw () \
 { \
-  if (xisnan (y)) \
+  if (octave::math::isnan (y)) \
     std::memcpy (r, x, n * sizeof (T)); \
   else \
     for (size_t i = 0; i < n; i++) r[i] = (x[i] OP y) ? x[i] : y; \
@@ -286,7 +286,7 @@
 template <> \
 inline void F<T> (size_t n, T *r, T x, const T *y) throw () \
 { \
-  if (xisnan (x)) \
+  if (octave::math::isnan (x)) \
     std::memcpy (r, y, n * sizeof (T)); \
   else \
     for (size_t i = 0; i < n; i++) r[i] = (y[i] OP x) ? y[i] : x; \
@@ -469,14 +469,14 @@
 template <typename T>
 inline bool xis_false (const octave_int<T>& x) { return ! x.value (); }
 // for reals, we want to ignore NaNs.
-inline bool xis_true (double x) { return ! xisnan (x) && x != 0.0; }
+inline bool xis_true (double x) { return ! octave::math::isnan (x) && x != 0.0; }
 inline bool xis_false (double x) { return x == 0.0; }
-inline bool xis_true (float x) { return ! xisnan (x) && x != 0.0f; }
+inline bool xis_true (float x) { return ! octave::math::isnan (x) && x != 0.0f; }
 inline bool xis_false (float x) { return x == 0.0f; }
 // Ditto for complex.
-inline bool xis_true (const Complex& x) { return ! xisnan (x) && x != 0.0; }
+inline bool xis_true (const Complex& x) { return ! octave::math::isnan (x) && x != 0.0; }
 inline bool xis_false (const Complex& x) { return x == 0.0; }
-inline bool xis_true (const FloatComplex& x) { return ! xisnan (x) && x != 0.0f; }
+inline bool xis_true (const FloatComplex& x) { return ! octave::math::isnan (x) && x != 0.0f; }
 inline bool xis_false (const FloatComplex& x) { return x == 0.0f; }
 
 #define OP_RED_SUM(ac, el) ac += el
@@ -705,9 +705,9 @@
   if (! n) return; \
   T tmp = v[0]; \
   octave_idx_type i = 1; \
-  if (xisnan (tmp)) \
+  if (octave::math::isnan (tmp)) \
     { \
-      for (; i < n && xisnan (v[i]); i++) ; \
+      for (; i < n && octave::math::isnan (v[i]); i++) ; \
       if (i < n) tmp = v[i]; \
     } \
   for (; i < n; i++) \
@@ -721,9 +721,9 @@
   T tmp = v[0]; \
   octave_idx_type tmpi = 0; \
   octave_idx_type i = 1; \
-  if (xisnan (tmp)) \
+  if (octave::math::isnan (tmp)) \
     { \
-      for (; i < n && xisnan (v[i]); i++) ; \
+      for (; i < n && octave::math::isnan (v[i]); i++) ; \
       if (i < n) { tmp = v[i]; tmpi = i; } \
     } \
   for (; i < n; i++) \
@@ -750,7 +750,7 @@
   for (octave_idx_type i = 0; i < m; i++) \
     {  \
       r[i] = v[i]; \
-      if (xisnan (v[i])) nan = true;  \
+      if (octave::math::isnan (v[i])) nan = true;  \
     } \
   j++; v += m; \
   while (nan && j < n) \
@@ -758,9 +758,9 @@
       nan = false; \
       for (octave_idx_type i = 0; i < m; i++) \
         {  \
-          if (xisnan (v[i])) \
+          if (octave::math::isnan (v[i])) \
             nan = true;  \
-          else if (xisnan (r[i]) || v[i] OP r[i]) \
+          else if (octave::math::isnan (r[i]) || v[i] OP r[i]) \
             r[i] = v[i]; \
         } \
       j++; v += m; \
@@ -783,7 +783,7 @@
   for (octave_idx_type i = 0; i < m; i++) \
     {  \
       r[i] = v[i]; ri[i] = j; \
-      if (xisnan (v[i])) nan = true;  \
+      if (octave::math::isnan (v[i])) nan = true;  \
     } \
   j++; v += m; \
   while (nan && j < n) \
@@ -791,9 +791,9 @@
       nan = false; \
       for (octave_idx_type i = 0; i < m; i++) \
         {  \
-          if (xisnan (v[i])) \
+          if (octave::math::isnan (v[i])) \
             nan = true;  \
-          else if (xisnan (r[i]) || v[i] OP r[i]) \
+          else if (octave::math::isnan (r[i]) || v[i] OP r[i]) \
             { r[i] = v[i]; ri[i] = j; } \
         } \
       j++; v += m; \
@@ -871,9 +871,9 @@
   T tmp = v[0]; \
   octave_idx_type i = 1; \
   octave_idx_type j = 0; \
-  if (xisnan (tmp)) \
+  if (octave::math::isnan (tmp)) \
     { \
-      for (; i < n && xisnan (v[i]); i++) ; \
+      for (; i < n && octave::math::isnan (v[i]); i++) ; \
       for (; j < i; j++) r[j] = tmp; \
       if (i < n) tmp = v[i]; \
     } \
@@ -892,9 +892,9 @@
   T tmp = v[0]; octave_idx_type tmpi = 0; \
   octave_idx_type i = 1; \
   octave_idx_type j = 0; \
-  if (xisnan (tmp)) \
+  if (octave::math::isnan (tmp)) \
     { \
-      for (; i < n && xisnan (v[i]); i++) ; \
+      for (; i < n && octave::math::isnan (v[i]); i++) ; \
       for (; j < i; j++) { r[j] = tmp; ri[j] = tmpi; } \
       if (i < n) { tmp = v[i]; tmpi = i; } \
     } \
@@ -926,7 +926,7 @@
   for (octave_idx_type i = 0; i < m; i++) \
     {  \
       r[i] = v[i]; \
-      if (xisnan (v[i])) nan = true;  \
+      if (octave::math::isnan (v[i])) nan = true;  \
     } \
   j++; v += m; r0 = r; r += m; \
   while (nan && j < n) \
@@ -934,9 +934,9 @@
       nan = false; \
       for (octave_idx_type i = 0; i < m; i++) \
         {  \
-          if (xisnan (v[i])) \
+          if (octave::math::isnan (v[i])) \
             { r[i] = r0[i]; nan = true; } \
-          else if (xisnan (r0[i]) || v[i] OP r0[i]) \
+          else if (octave::math::isnan (r0[i]) || v[i] OP r0[i]) \
             r[i] = v[i]; \
           else \
             r[i] = r0[i]; \
@@ -965,7 +965,7 @@
   for (octave_idx_type i = 0; i < m; i++) \
     {  \
       r[i] = v[i]; ri[i] = 0; \
-      if (xisnan (v[i])) nan = true;  \
+      if (octave::math::isnan (v[i])) nan = true;  \
     } \
   j++; v += m; r0 = r; r += m; r0i = ri; ri += m;  \
   while (nan && j < n) \
@@ -973,9 +973,9 @@
       nan = false; \
       for (octave_idx_type i = 0; i < m; i++) \
         {  \
-          if (xisnan (v[i])) \
+          if (octave::math::isnan (v[i])) \
             { r[i] = r0[i]; ri[i] = r0i[i]; nan = true; } \
-          else if (xisnan (r0[i]) || v[i] OP r0[i]) \
+          else if (octave::math::isnan (r0[i]) || v[i] OP r0[i]) \
             { r[i] = v[i]; ri[i] = j; }\
           else \
             { r[i] = r0[i]; ri[i] = r0i[i]; }\
--- a/liboctave/operators/mx-op-defs.h	Fri May 27 10:20:48 2016 -0400
+++ b/liboctave/operators/mx-op-defs.h	Wed May 25 16:51:16 2016 -0400
@@ -32,7 +32,7 @@
 #include "mx-inlines.cc"
 
 #define SNANCHK(s) \
-  if (xisnan (s)) \
+  if (octave::math::isnan (s)) \
     err_nan_to_logical_conversion ()
 
 #define MNANCHK(m, MT) \
--- a/liboctave/util/lo-utils.cc	Fri May 27 10:20:48 2016 -0400
+++ b/liboctave/util/lo-utils.cc	Wed May 25 16:51:16 2016 -0400
@@ -45,7 +45,7 @@
 #include "lo-utils.h"
 
 bool xis_int_or_inf_or_nan (double x)
-{ return xisnan (x) || D_NINT (x) == x; }
+{ return octave::math::isnan (x) || octave::math::x_nint (x) == x; }
 
 bool xis_one_or_zero (double x)
 { return x == 0 || x == 1; }
@@ -55,7 +55,7 @@
 
 bool xtoo_large_for_float (double x)
 {
-  return (xfinite (x) && fabs (x) > std::numeric_limits<float>::max ());
+  return (octave::math::finite (x) && fabs (x) > std::numeric_limits<float>::max ());
 }
 
 bool xtoo_large_for_float (const Complex& x)
@@ -65,7 +65,7 @@
 }
 
 bool xis_int_or_inf_or_nan (float x)
-{ return xisnan (x) || D_NINT (x) == x; }
+{ return octave::math::isnan (x) || octave::math::x_nint (x) == x; }
 
 bool xis_one_or_zero (float x)
 { return x == 0 || x == 1; }
--- a/liboctave/util/oct-inttypes.cc	Fri May 27 10:20:48 2016 -0400
+++ b/liboctave/util/oct-inttypes.cc	Wed May 25 16:51:16 2016 -0400
@@ -62,7 +62,7 @@
                                             min_val ());
   static const S thmax = compute_threshold (static_cast<S> (max_val ()),
                                             max_val ());
-  if (xisnan (value))
+  if (octave::math::isnan (value))
     {
       return static_cast<T> (0);
     }
@@ -76,7 +76,7 @@
     }
   else
     {
-      S rvalue = xround (value);
+      S rvalue = octave::math::round (value);
       return static_cast<T> (rvalue);
     }
 }
@@ -596,7 +596,7 @@
 
 INT_DOUBLE_BINOP_DECL (*, uint64)
 {
-  if (y >= 0 && y < octave_uint64::max () && y == xround (y))
+  if (y >= 0 && y < octave_uint64::max () && y == octave::math::round (y))
     {
       return x * octave_uint64 (static_cast<uint64_t> (y));
     }
@@ -604,7 +604,7 @@
     {
       return x / octave_uint64 (static_cast<uint64_t> (2));
     }
-  else if (y < 0 || xisnan (y) || xisinf (y))
+  else if (y < 0 || octave::math::isnan (y) || octave::math::isinf (y))
     {
       return octave_uint64 (x.value () * y);
     }
@@ -631,7 +631,7 @@
 
 INT_DOUBLE_BINOP_DECL (*, int64)
 {
-  if (fabs (y) < octave_int64::max () && y == xround (y))
+  if (fabs (y) < octave_int64::max () && y == octave::math::round (y))
     {
       return x * octave_int64 (static_cast<int64_t> (y));
     }
@@ -639,7 +639,7 @@
     {
       return x / octave_int64 (static_cast<uint64_t> (4*y));
     }
-  else if (xisnan (y) || xisinf (y))
+  else if (octave::math::isnan (y) || octave::math::isinf (y))
     {
       return octave_int64 (x.value () * y);
     }
@@ -677,7 +677,7 @@
 
 INT_DOUBLE_BINOP_DECL (/, uint64)
 {
-  if (y >= 0 && y < octave_uint64::max () && y == xround (y))
+  if (y >= 0 && y < octave_uint64::max () && y == octave::math::round (y))
     {
       return x / octave_uint64 (y);
     }
@@ -687,7 +687,7 @@
 
 INT_DOUBLE_BINOP_DECL (/, int64)
 {
-  if (fabs (y) < octave_int64::max () && y == xround (y))
+  if (fabs (y) < octave_int64::max () && y == octave::math::round (y))
     {
       return x / octave_int64 (y);
     }
@@ -765,7 +765,7 @@
 octave_int<T>
 pow (const octave_int<T>& a, const double& b)
 {
-  return ((b >= 0 && b < std::numeric_limits<T>::digits && b == xround (b))
+  return ((b >= 0 && b < std::numeric_limits<T>::digits && b == octave::math::round (b))
           ? pow (a, octave_int<T> (static_cast<T> (b)))
           : octave_int<T> (pow (a.double_value (), b)));
 }
@@ -779,7 +779,7 @@
 octave_int<T>
 pow (const octave_int<T>& a, const float& b)
 {
-  return ((b >= 0 && b < std::numeric_limits<T>::digits && b == xround (b))
+  return ((b >= 0 && b < std::numeric_limits<T>::digits && b == octave::math::round (b))
           ? pow (a, octave_int<T> (static_cast<T> (b)))
           : octave_int<T> (pow (a.double_value (), static_cast<double> (b))));
 }
@@ -796,7 +796,7 @@
 octave_int<T>
 powf (const octave_int<T>& a, const float& b)
 {
-  return ((b >= 0 && b < std::numeric_limits<T>::digits && b == xround (b))
+  return ((b >= 0 && b < std::numeric_limits<T>::digits && b == octave::math::round (b))
           ? pow (a, octave_int<T> (static_cast<T> (b)))
           : octave_int<T> (pow (a.double_value (), static_cast<double> (b))));
 }
--- a/liboctave/util/oct-inttypes.h	Fri May 27 10:20:48 2016 -0400
+++ b/liboctave/util/oct-inttypes.h	Wed May 25 16:51:16 2016 -0400
@@ -36,9 +36,27 @@
 #include "lo-mappers.h"
 
 #if defined (OCTAVE_INT_USE_LONG_DOUBLE)
-inline long double xround (long double x) { return roundl (x); }
-inline long double xisnan (long double x)
-{ return xisnan (static_cast<double> (x)); }
+
+namespace octave
+{
+  namespace math
+  {
+    inline long double round (long double x) { return roundl (x); }
+
+    inline long double isnan (long double x) { return isnan (static_cast<double> (x)); }
+  }
+}
+
+#if defined (OCTAVE_USE_DEPRECATED_FUNCTIONS)
+
+OCTAVE_DEPRECATED ("use 'octave::math::isnan' instead")
+inline long double xround (long double x) { return octave::math::round (x); }
+
+OCTAVE_DEPRECATED ("use 'octave::math::isnan' instead")
+inline bool xisnan (long double x) { return octave::math::isnan (x); }
+
+#endif
+
 #endif
 
 // FIXME: we define this by our own because some compilers, such as
@@ -309,9 +327,9 @@
   static S
   compute_threshold (S val, T orig_val)
   {
-    val = xround (val); // Fool optimizations (maybe redundant)
+    val = octave::math::round (val); // Fool optimizations (maybe redundant)
     // If val is even, but orig_val is odd, we're one unit off.
-    if (orig_val % 2 && val / 2 == xround (val / 2))
+    if (orig_val % 2 && val / 2 == octave::math::round (val / 2))
       // FIXME: is this always correct?
       val *= (static_cast<S> (1) - (std::numeric_limits<S>::epsilon () / 2));
     return val;
@@ -949,10 +967,30 @@
 
 // No mixed integer binary operations!
 
+namespace octave
+{
+  namespace math
+  {
+    template <typename T>
+    bool
+    isnan (const octave_int<T>&)
+    {
+      return false;
+    }
+  }
+}
+
+#if defined (OCTAVE_USE_DEPRECATED_FUNCTIONS)
+
 template <typename T>
-inline bool
-xisnan (const octave_int<T>&)
-{ return false; }
+OCTAVE_DEPRECATED ("use 'octave::math::isnan' instead")
+bool
+xisnan (const octave_int<T>& x)
+{
+  return octave::math::isnan (x);
+}
+
+#endif
 
 // FIXME: can/should any of these be inline?