changeset 5260:deed800e7bef

[project @ 2005-03-30 23:18:58 by jwe]
author jwe
date Wed, 30 Mar 2005 23:18:58 +0000
parents 462fd886f33f
children 90a9058de7e8
files liboctave/CColVector.cc liboctave/CMatrix.cc liboctave/CNDArray.cc liboctave/CRowVector.cc liboctave/ChangeLog liboctave/DiagArray2.h liboctave/oct-cmplx.h src/ChangeLog src/ov-complex.h src/ov-cx-mat.cc src/xpow.cc
diffstat 11 files changed, 149 insertions(+), 274 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/CColVector.cc	Wed Mar 30 21:13:28 2005 +0000
+++ b/liboctave/CColVector.cc	Wed Mar 30 23:18:58 2005 +0000
@@ -502,13 +502,13 @@
     return 0.0;
 
   Complex res = elem (0);
-  double absres = abs (res);
+  double absres = std::abs (res);
 
   for (int i = 1; i < len; i++)
-    if (abs (elem (i)) < absres)
+    if (std::abs (elem (i)) < absres)
       {
 	res = elem (i);
-	absres = abs (res);
+	absres = std::abs (res);
       }
 
   return res;
@@ -522,13 +522,13 @@
     return 0.0;
 
   Complex res = elem (0);
-  double absres = abs (res);
+  double absres = std::abs (res);
 
   for (int i = 1; i < len; i++)
-    if (abs (elem (i)) > absres)
+    if (std::abs (elem (i)) > absres)
       {
 	res = elem (i);
-	absres = abs (res);
+	absres = std::abs (res);
       }
 
   return res;
--- a/liboctave/CMatrix.cc	Wed Mar 30 21:13:28 2005 +0000
+++ b/liboctave/CMatrix.cc	Wed Mar 30 23:18:58 2005 +0000
@@ -1,3 +1,5 @@
+#define STD_OCTAVE std
+
 // Matrix manipulations.
 /*
 
@@ -996,7 +998,7 @@
 	  return retval;
 	}
 
-      lwork = static_cast<int> (real(z(0)));
+      lwork = static_cast<int> (STD_OCTAVE::real(z(0)));
       lwork = (lwork <  2 *nc ? 2*nc : lwork);
       z.resize (lwork);
       Complex *pz = z.fortran_vec ();
@@ -1505,12 +1507,12 @@
 		      if (ipvt(i) != (i+1)) d[0] = -d[0];
 		      d[0] = d[0] * atmp(i,i);
 		      if (d[0] == 0.) break;
-		      while (::abs(d[0]) < 1.) 
+		      while (STD_OCTAVE::abs(d[0]) < 1.) 
 			{
 			  d[0] = 10. * d[0];
 			  d[1] = d[1] - 1.0;
 			}
-		      while (::abs(d[0]) >= 10.) 
+		      while (STD_OCTAVE::abs(d[0]) >= 10.) 
 			{
 			  d[0] = 0.1 * d[0];
 			  d[1] = d[1] + 1.0;
@@ -1917,7 +1919,7 @@
 	(*current_liboctave_error_handler) ("unrecoverable error in zgelss");
       else
 	{
-	  lwork = static_cast<int> (real (work(0)));
+	  lwork = static_cast<int> (STD_OCTAVE::real (work(0)));
 	  work.resize (lwork);
 
 	  F77_XFCN (zgelss, ZGELSS, (m, n, nrhs, tmp_data, m, presult,
@@ -2030,7 +2032,7 @@
 	(*current_liboctave_error_handler) ("unrecoverable error in zgelss");
       else
 	{
-	  lwork = static_cast<int> (real (work(0)));
+	  lwork = static_cast<int> (STD_OCTAVE::real (work(0)));
 	  work.resize (lwork);
 
 	  F77_XFCN (zgelss, ZGELSS, (m, n, nrhs, tmp_data, m, presult,
@@ -2526,7 +2528,7 @@
     {
       for (int i = 0; i < nr; i++)
 	{
-	  double ip = imag (elem (i, j));
+	  double ip = STD_OCTAVE::imag (elem (i, j));
 
 	  if (ip != 0.0 || lo_ieee_signbit (ip))
 	    return false;
@@ -2550,8 +2552,8 @@
     {
       Complex val = elem (0, 0);
 
-      double r_val = real (val);
-      double i_val = imag (val);
+      double r_val = STD_OCTAVE::real (val);
+      double i_val = STD_OCTAVE::imag (val);
 
       max_val = r_val;
       min_val = r_val;
@@ -2570,8 +2572,8 @@
       {
 	Complex val = elem (i, j);
 
-	double r_val = real (val);
-	double i_val = imag (val);
+	double r_val = STD_OCTAVE::real (val);
+	double i_val = STD_OCTAVE::imag (val);
 
 	if (r_val > max_val)
 	  max_val = r_val;
@@ -2603,8 +2605,8 @@
       {
 	Complex val = elem (i, j);
 
-	double r_val = real (val);
-	double i_val = imag (val);
+	double r_val = STD_OCTAVE::real (val);
+	double i_val = STD_OCTAVE::imag (val);
 
 	if (r_val > FLT_MAX
 	    || i_val > FLT_MAX
@@ -2681,7 +2683,7 @@
 
   for (int j = 0; j < nc; j++)
     for (int i = 0; i < nr; i++)
-      retval (i, j) = ::abs (elem (i, j));
+      retval (i, j) = STD_OCTAVE::abs (elem (i, j));
 
   return retval;
 }
@@ -2742,7 +2744,7 @@
 
   for (int j = 0; j < nc; j++)
     {
-      if (imag (elem (i, j)) != 0.0)
+      if (STD_OCTAVE::imag (elem (i, j)) != 0.0)
 	{
 	  retval = false;
 	  break;
@@ -2761,7 +2763,7 @@
 
   for (int i = 0; i < nr; i++)
     {
-      if (imag (elem (i, j)) != 0.0)
+      if (STD_OCTAVE::imag (elem (i, j)) != 0.0)
 	{
 	  retval = false;
 	  break;
@@ -2807,7 +2809,7 @@
 
 	      if (! octave_is_NaN_or_NA (tmp_min))
 		{
-		  abs_min = real_only ? real (tmp_min) : ::abs (tmp_min);
+		  abs_min = real_only ? STD_OCTAVE::real (tmp_min) : STD_OCTAVE::abs (tmp_min);
 		  break;
 		}
 	    }
@@ -2819,7 +2821,7 @@
 	      if (octave_is_NaN_or_NA (tmp))
 		continue;
 
-	      double abs_tmp = real_only ? real (tmp) : ::abs (tmp);
+	      double abs_tmp = real_only ? STD_OCTAVE::real (tmp) : STD_OCTAVE::abs (tmp);
 
 	      if (abs_tmp < abs_min)
 		{
@@ -2881,7 +2883,7 @@
 
 	      if (! octave_is_NaN_or_NA (tmp_max))
 		{
-		  abs_max = real_only ? real (tmp_max) : ::abs (tmp_max);
+		  abs_max = real_only ? STD_OCTAVE::real (tmp_max) : STD_OCTAVE::abs (tmp_max);
 		  break;
 		}
 	    }
@@ -2893,7 +2895,7 @@
 	      if (octave_is_NaN_or_NA (tmp))
 		continue;
 
-	      double abs_tmp = real_only ? real (tmp) : ::abs (tmp);
+	      double abs_tmp = real_only ? STD_OCTAVE::real (tmp) : STD_OCTAVE::abs (tmp);
 
 	      if (abs_tmp > abs_max)
 		{
@@ -2955,7 +2957,7 @@
 
 	      if (! octave_is_NaN_or_NA (tmp_min))
 		{
-		  abs_min = real_only ? real (tmp_min) : ::abs (tmp_min);
+		  abs_min = real_only ? STD_OCTAVE::real (tmp_min) : STD_OCTAVE::abs (tmp_min);
 		  break;
 		}
 	    }
@@ -2967,7 +2969,7 @@
 	      if (octave_is_NaN_or_NA (tmp))
 		continue;
 
-	      double abs_tmp = real_only ? real (tmp) : ::abs (tmp);
+	      double abs_tmp = real_only ? STD_OCTAVE::real (tmp) : STD_OCTAVE::abs (tmp);
 
 	      if (abs_tmp < abs_min)
 		{
@@ -3029,7 +3031,7 @@
 
 	      if (! octave_is_NaN_or_NA (tmp_max))
 		{
-		  abs_max = real_only ? real (tmp_max) : ::abs (tmp_max);
+		  abs_max = real_only ? STD_OCTAVE::real (tmp_max) : STD_OCTAVE::abs (tmp_max);
 		  break;
 		}
 	    }
@@ -3041,7 +3043,7 @@
 	      if (octave_is_NaN_or_NA (tmp))
 		continue;
 
-	      double abs_tmp = real_only ? real (tmp) : ::abs (tmp);
+	      double abs_tmp = real_only ? STD_OCTAVE::real (tmp) : STD_OCTAVE::abs (tmp);
 
 	      if (abs_tmp > abs_max)
 		{
@@ -3310,7 +3312,7 @@
       for (int i = 0; i < nr; i++)
 	{
 	  OCTAVE_QUIT;
-	  if (imag (a (i, j)) != 0.0 || imag (b (i, j)) != 0.0)
+	  if (STD_OCTAVE::imag (a (i, j)) != 0.0 || STD_OCTAVE::imag (b (i, j)) != 0.0)
 	    {
 	      columns_are_real_only = 0;
 	      break;
@@ -3320,7 +3322,7 @@
       if (columns_are_real_only)
 	{
 	  for (int i = 0; i < nr; i++)
-	    result (i, j) = xmin (real (a (i, j)), real (b (i, j)));
+	    result (i, j) = xmin (STD_OCTAVE::real (a (i, j)), STD_OCTAVE::real (b (i, j)));
 	}
       else
 	{
@@ -3398,7 +3400,7 @@
       for (int i = 0; i < nr; i++)
 	{
 	  OCTAVE_QUIT;
-	  if (imag (a (i, j)) != 0.0 || imag (b (i, j)) != 0.0)
+	  if (STD_OCTAVE::imag (a (i, j)) != 0.0 || STD_OCTAVE::imag (b (i, j)) != 0.0)
 	    {
 	      columns_are_real_only = 0;
 	      break;
@@ -3410,7 +3412,7 @@
 	  for (int i = 0; i < nr; i++)
 	    {
 	      OCTAVE_QUIT;
-	      result (i, j) = xmax (real (a (i, j)), real (b (i, j)));
+	      result (i, j) = xmax (STD_OCTAVE::real (a (i, j)), STD_OCTAVE::real (b (i, j)));
 	    }
 	}
       else
@@ -3426,13 +3428,13 @@
   return result;
 }
 
-MS_CMP_OPS(ComplexMatrix, real, Complex, real)
+MS_CMP_OPS(ComplexMatrix, STD_OCTAVE::real, Complex, STD_OCTAVE::real)
 MS_BOOL_OPS(ComplexMatrix, Complex, 0.0)
 
-SM_CMP_OPS(Complex, real, ComplexMatrix, real)
+SM_CMP_OPS(Complex, STD_OCTAVE::real, ComplexMatrix, STD_OCTAVE::real)
 SM_BOOL_OPS(Complex, ComplexMatrix, 0.0)
 
-MM_CMP_OPS(ComplexMatrix, real, ComplexMatrix, real)
+MM_CMP_OPS(ComplexMatrix, STD_OCTAVE::real, ComplexMatrix, STD_OCTAVE::real)
 MM_BOOL_OPS(ComplexMatrix, ComplexMatrix, 0.0)
 
 /*
--- a/liboctave/CNDArray.cc	Wed Mar 30 21:13:28 2005 +0000
+++ b/liboctave/CNDArray.cc	Wed Mar 30 23:18:58 2005 +0000
@@ -518,7 +518,7 @@
 
   for (int i = 0; i < nel; i++)
     {
-      double ip = imag (elem (i));
+      double ip = std::imag (elem (i));
 
       if (ip != 0.0 || lo_ieee_signbit (ip))
 	return false;
@@ -540,8 +540,8 @@
     {
       Complex val = elem (0);
 
-      double r_val = real (val);
-      double i_val = imag (val);
+      double r_val = std::real (val);
+      double i_val = std::imag (val);
       
       max_val = r_val;
       min_val = r_val;
@@ -559,8 +559,8 @@
     {
       Complex val = elem (i);
 
-      double r_val = real (val);
-      double i_val = imag (val);
+      double r_val = std::real (val);
+      double i_val = std::imag (val);
 
       if (r_val > max_val)
 	max_val = r_val;
@@ -590,8 +590,8 @@
     {
       Complex val = elem (i);
 
-      double r_val = real (val);
-      double i_val = imag (val);
+      double r_val = std::real (val);
+      double i_val = std::imag (val);
 
       if (r_val > FLT_MAX
 	  || i_val > FLT_MAX
@@ -615,8 +615,8 @@
 {
   MX_ND_ANY_ALL_REDUCTION
     (MX_ND_ANY_EVAL (elem (iter_idx) != Complex (0, 0)
-		     && ! (lo_ieee_isnan (::real (elem (iter_idx)))
-			   || lo_ieee_isnan (::imag (elem (iter_idx))))),
+		     && ! (lo_ieee_isnan (std::real (elem (iter_idx)))
+			   || lo_ieee_isnan (std::imag (elem (iter_idx))))),
 		     false);
 }
 
@@ -642,7 +642,7 @@
 ComplexNDArray::sumsq (int dim) const
 {
   MX_ND_COMPLEX_OP_REDUCTION
-    (+= imag (elem (iter_idx))
+    (+= std::imag (elem (iter_idx))
      ? elem (iter_idx) * conj (elem (iter_idx))
      : std::pow (elem (iter_idx), 2), Complex (0, 0));
 }
@@ -736,7 +736,7 @@
 	  
 	  if (! octave_is_NaN_or_NA (tmp_max))
 	    {
-	      abs_max = ::abs(tmp_max);
+	      abs_max = std::abs(tmp_max);
 	      break;
 	    }
 	}
@@ -748,7 +748,7 @@
 	  if (octave_is_NaN_or_NA (tmp))
 	    continue;
 
-	  double abs_tmp = ::abs (tmp);
+	  double abs_tmp = std::abs (tmp);
 
 	  if (abs_tmp > abs_max)
 	    {
@@ -828,7 +828,7 @@
 	  
 	  if (! octave_is_NaN_or_NA (tmp_min))
 	    {
-	      abs_min = ::abs(tmp_min);
+	      abs_min = std::abs(tmp_min);
 	      break;
 	    }
 	}
@@ -840,7 +840,7 @@
 	  if (octave_is_NaN_or_NA (tmp))
 	    continue;
 
-	  double abs_tmp = ::abs (tmp);
+	  double abs_tmp = std::abs (tmp);
 
 	  if (abs_tmp < abs_min)
 	    {
@@ -873,7 +873,7 @@
   int nel = nelem ();
 
   for (int i = 0; i < nel; i++)
-    retval(i) = ::abs (elem (i));
+    retval(i) = std::abs (elem (i));
       
   return retval;
 }
@@ -1160,13 +1160,13 @@
   return result;
 }
 
-NDS_CMP_OPS(ComplexNDArray, real, Complex, real)
+NDS_CMP_OPS(ComplexNDArray, std::real, Complex, std::real)
 NDS_BOOL_OPS(ComplexNDArray, Complex, 0.0)
 
-SND_CMP_OPS(Complex, real, ComplexNDArray, real)
+SND_CMP_OPS(Complex, std::real, ComplexNDArray, std::real)
 SND_BOOL_OPS(Complex, ComplexNDArray, 0.0)
 
-NDND_CMP_OPS(ComplexNDArray, real, ComplexNDArray, real)
+NDND_CMP_OPS(ComplexNDArray, std::real, ComplexNDArray, std::real)
 NDND_BOOL_OPS(ComplexNDArray, ComplexNDArray, 0.0)
 
 /*
--- a/liboctave/CRowVector.cc	Wed Mar 30 21:13:28 2005 +0000
+++ b/liboctave/CRowVector.cc	Wed Mar 30 23:18:58 2005 +0000
@@ -408,13 +408,13 @@
     return Complex (0.0);
 
   Complex res = elem (0);
-  double absres = abs (res);
+  double absres = std::abs (res);
 
   for (int i = 1; i < len; i++)
-    if (abs (elem (i)) < absres)
+    if (std::abs (elem (i)) < absres)
       {
 	res = elem (i);
-	absres = abs (res);
+	absres = std::abs (res);
       }
 
   return res;
@@ -428,13 +428,13 @@
     return Complex (0.0);
 
   Complex res = elem (0);
-  double absres = abs (res);
+  double absres = std::abs (res);
 
   for (int i = 1; i < len; i++)
-    if (abs (elem (i)) > absres)
+    if (std::abs (elem (i)) > absres)
       {
 	res = elem (i);
-	absres = abs (res);
+	absres = std::abs (res);
       }
 
   return res;
--- a/liboctave/ChangeLog	Wed Mar 30 21:13:28 2005 +0000
+++ b/liboctave/ChangeLog	Wed Mar 30 23:18:58 2005 +0000
@@ -1,3 +1,15 @@
+2005-03-30  John W. Eaton  <jwe@octave.org>
+
+	* liboctave/CColVector.cc, liboctave/CNDArray.cc,
+	liboctave/CRowVector.cc: Use std:: for Complex functions instead
+	of relying on wrappers from oct-cmplx.h.
+
+	* oct-cmplx.h: Provide typedef only.
+
+	* DiagArray2.cc (xelem): Don't use initializer for static data.
+	* DiagArray2.h (DiagArray<T>::Proxy::operator T ()):
+	Likewise.
+
 2005-03-26  John W. Eaton  <jwe@octave.org>
 
 	* cmd-edit.cc (do_readline): Wrap call to ::octave_rl_readline
--- a/liboctave/DiagArray2.h	Wed Mar 30 21:13:28 2005 +0000
+++ b/liboctave/DiagArray2.h	Wed Mar 30 23:18:58 2005 +0000
@@ -82,7 +82,7 @@
 	  return object->get (i);
 	else
 	  {
-	    static T foo (0);
+	    static T foo;
 	    return foo;
 	  }
       }
--- a/liboctave/oct-cmplx.h	Wed Mar 30 21:13:28 2005 +0000
+++ b/liboctave/oct-cmplx.h	Wed Mar 30 23:18:58 2005 +0000
@@ -23,145 +23,10 @@
 #if !defined (octave_oct_cmplx_h)
 #define octave_oct_cmplx_h 1
 
-// By using this file instead of <complex>, we can easily avoid buggy
-// implementations of the standard complex data type (if needed).
-
 #include <complex>
 
 typedef std::complex<double> Complex;
 
-#if defined (CXX_ISO_COMPLIANT_LIBRARY)
-
-// If namespaces don't work, we will end up with some infinite looping.
-
-inline double
-real (const Complex& z)
-{
-  return std::real (z);
-}
-
-inline double
-imag (const Complex& z)
-{
-  return std::imag (z);
-}
-
-inline double
-abs (const Complex& z)
-{
-  return std::abs (z);
-}
-
-inline double
-arg (const Complex& z)
-{
-  return std::arg (z);
-}
-
-inline double
-norm (const Complex& z)
-{
-  return std::norm (z);
-}
-
-inline Complex
-conj (const Complex& z)
-{
-  return std::conj (z);
-}
-
-inline Complex
-polar (const double& x, const double& y);
-
-inline Complex
-cos (const Complex& z)
-{
-  return std::cos (z);
-}
-
-inline Complex
-cosh (const Complex& z)
-{
-  return std::cosh (z);
-}
-
-inline Complex
-exp (const Complex& z)
-{
-  return std::exp (z);
-}
-
-inline Complex
-log (const Complex& z)
-{
-  return std::log (z);
-}
-
-inline Complex
-log10 (const Complex& z)
-{
-  return std::log10 (z);
-}
-
-inline Complex
-pow (const Complex& z, int n)
-{
-  return std::pow (z, n);
-}
-
-inline Complex
-pow (const Complex& z, const double& x)
-{
-  // XXX FIXME XXX -- this should not be needed, but it avoids a bug
-  // in some versions of libstdc++ (3.3.x and possibly others).
-
-  return std::pow (z, Complex (x));
-}
-
-inline Complex
-pow (const Complex& z1, const Complex& z2)
-{
-  return std::pow (z1, z2);
-}
-
-inline Complex
-pow (const double& x, const Complex& z)
-{
-  return std::pow (x, z);
-}
-
-inline Complex
-sin (const Complex& z)
-{
-  return std::sin (z);
-}
-
-inline Complex
-sinh (const Complex& z)
-{
-  return std::sinh (z);
-}
-
-inline Complex
-sqrt (const Complex& z)
-{
-  return std::sqrt (z);
-}
-
-inline Complex
-tan (const Complex& z)
-{
-  return std::tan (z);
-}
-
-inline Complex
-tanh (const Complex& z)
-{
-  return std::tanh (z);
-}
-
-#endif
-
 #endif
 
 /*
--- a/src/ChangeLog	Wed Mar 30 21:13:28 2005 +0000
+++ b/src/ChangeLog	Wed Mar 30 23:18:58 2005 +0000
@@ -1,3 +1,10 @@
+2005-03-30  John W. Eaton  <jwe@octave.org>
+
+	* src/ov-complex.cc, src/ov-cx-mat.cc, src/xpow.cc: Use std:: for
+	Complex functions instead of relying on wrappers from oct-cmplx.h.
+
+	* oct-stream.cc (octave_scan): Initialize c1 to EOF.
+
 2005-03-29  John W. Eaton  <jwe@octave.org>
 
 	* utils.cc (get_dimensions): Produce error instead of warning if
--- a/src/ov-complex.h	Wed Mar 30 21:13:28 2005 +0000
+++ b/src/ov-complex.h	Wed Mar 30 23:18:58 2005 +0000
@@ -1,3 +1,4 @@
+#define OCTAVE_STD std
 /*
 
 Copyright (C) 1996, 1997 John W. Eaton
@@ -78,8 +79,8 @@
   octave_value any (int = 0) const
     {
       return (scalar != Complex (0, 0)
-	      && ! (lo_ieee_isnan (::real (scalar))
-		    || lo_ieee_isnan (::imag (scalar))));
+	      && ! (lo_ieee_isnan (OCTAVE_STD::real (scalar))
+		    || lo_ieee_isnan (OCTAVE_STD::imag (scalar))));
     }
 
   bool is_complex_scalar (void) const { return true; }
--- a/src/ov-cx-mat.cc	Wed Mar 30 21:13:28 2005 +0000
+++ b/src/ov-cx-mat.cc	Wed Mar 30 23:18:58 2005 +0000
@@ -73,7 +73,7 @@
 	{
 	  Complex c = matrix (0, 0);
 
-	  if (imag (c) == 0.0)
+	  if (std::imag (c) == 0.0)
 	    retval = new octave_scalar (std::real (c));
 	  else
 	    retval = new octave_complex (c);
@@ -216,8 +216,8 @@
 	    goto next_row;
 	  else
 	    {
-	      double re = real (c);
-	      double im = imag (c);
+	      double re = std::real (c);
+	      double im = std::imag (c);
 
 	      re = xisinf (re) ? (re > 0 ? OCT_RBV : -OCT_RBV) : re;
 	      im = xisinf (im) ? (im > 0 ? OCT_RBV : -OCT_RBV) : im;
--- a/src/xpow.cc	Wed Mar 30 21:13:28 2005 +0000
+++ b/src/xpow.cc	Wed Mar 30 23:18:58 2005 +0000
@@ -70,16 +70,12 @@
 {
   if (a < 0.0 && static_cast<int> (b) != b)
     {
-      // XXX FIXME XXX -- avoid apparent GNU libm bug by converting
-      // A and B to complex instead of just A.
+      Complex atmp (a);
 
-      Complex atmp (a);
-      Complex btmp (b);
-
-      return pow (atmp, btmp);
+      return std::pow (atmp, b);
     }
   else
-    return pow (a, b);
+    return std::pow (a, b);
 }
 
 // -*- 2 -*-
@@ -102,10 +98,10 @@
       for (int i = 0; i < nr; i++)
 	{
 	  Complex elt = lambda (i);
-	  if (imag (elt) == 0.0)
-	    lambda (i) = pow (a, real (elt));
+	  if (std::imag (elt) == 0.0)
+	    lambda (i) = std::pow (a, std::real (elt));
 	  else
-	    lambda (i) = pow (a, elt);
+	    lambda (i) = std::pow (a, elt);
 	}
       ComplexDiagMatrix D (lambda);
 
@@ -121,7 +117,7 @@
 {
   Complex result;
   Complex atmp (a);
-  result = pow (atmp, b);
+  result = std::pow (atmp, b);
   return result;
 }
 
@@ -145,10 +141,10 @@
       for (int i = 0; i < nr; i++)
 	{
 	  Complex elt = lambda (i);
-	  if (imag (elt) == 0.0)
-	    lambda (i) = pow (a, real (elt));
+	  if (std::imag (elt) == 0.0)
+	    lambda (i) = std::pow (a, std::real (elt));
 	  else
-	    lambda (i) = pow (a, elt);
+	    lambda (i) = std::pow (a, elt);
 	}
       ComplexDiagMatrix D (lambda);
 
@@ -226,7 +222,7 @@
 	  ComplexMatrix Q (a_eig.eigenvectors ());
 
 	  for (int i = 0; i < nr; i++)
-	    lambda (i) = pow (lambda (i), b);
+	    lambda (i) = std::pow (lambda (i), b);
 
 	  ComplexDiagMatrix D (lambda);
 
@@ -255,7 +251,7 @@
       ComplexMatrix Q (a_eig.eigenvectors ());
 
       for (int i = 0; i < nr; i++)
-	lambda (i) = pow (lambda (i), b);
+	lambda (i) = std::pow (lambda (i), b);
 
       ComplexDiagMatrix D (lambda);
 
@@ -272,9 +268,9 @@
   Complex result;
 
   if (xisint (b))
-    result = pow (a, static_cast<int> (b));
+    result = std::pow (a, static_cast<int> (b));
   else
-    result = pow (a, b);
+    result = std::pow (a, b);
 
   return result;
 }
@@ -299,10 +295,10 @@
       for (int i = 0; i < nr; i++)
 	{
 	  Complex elt = lambda (i);
-	  if (imag (elt) == 0.0)
-	    lambda (i) = pow (a, real (elt));
+	  if (std::imag (elt) == 0.0)
+	    lambda (i) = std::pow (a, std::real (elt));
 	  else
-	    lambda (i) = pow (a, elt);
+	    lambda (i) = std::pow (a, elt);
 	}
       ComplexDiagMatrix D (lambda);
 
@@ -317,7 +313,7 @@
 xpow (const Complex& a, const Complex& b)
 {
   Complex result;
-  result = pow (a, b);
+  result = std::pow (a, b);
   return result;
 }
 
@@ -341,10 +337,10 @@
       for (int i = 0; i < nr; i++)
 	{
 	  Complex elt = lambda (i);
-	  if (imag (elt) == 0.0)
-	    lambda (i) = pow (a, real (elt));
+	  if (std::imag (elt) == 0.0)
+	    lambda (i) = std::pow (a, std::real (elt));
 	  else
-	    lambda (i) = pow (a, elt);
+	    lambda (i) = std::pow (a, elt);
 	}
       ComplexDiagMatrix D (lambda);
 
@@ -422,7 +418,7 @@
 	  ComplexMatrix Q (a_eig.eigenvectors ());
 
 	  for (int i = 0; i < nr; i++)
-	    lambda (i) = pow (lambda (i), b);
+	    lambda (i) = std::pow (lambda (i), b);
 
 	  ComplexDiagMatrix D (lambda);
 
@@ -451,7 +447,7 @@
       ComplexMatrix Q (a_eig.eigenvectors ());
 
       for (int i = 0; i < nr; i++)
-	lambda (i) = pow (lambda (i), b);
+	lambda (i) = std::pow (lambda (i), b);
 
       ComplexDiagMatrix D (lambda);
 
@@ -509,7 +505,7 @@
 	for (int i = 0; i < nr; i++)
 	  {
 	    OCTAVE_QUIT;
-	    result (i, j) = pow (atmp, b (i, j));
+	    result (i, j) = std::pow (atmp, b (i, j));
 	  }
 
       retval = result;
@@ -521,7 +517,7 @@
 	for (int i = 0; i < nr; i++)
 	  {
 	    OCTAVE_QUIT;
-	    result (i, j) = pow (a, b (i, j));
+	    result (i, j) = std::pow (a, b (i, j));
 	  }
 
       retval = result;
@@ -543,7 +539,7 @@
     for (int i = 0; i < nr; i++)
       {
 	OCTAVE_QUIT;
-	result (i, j) = pow (atmp, b (i, j));
+	result (i, j) = std::pow (atmp, b (i, j));
       }
 
   return result;
@@ -566,13 +562,9 @@
 	  {
 	    OCTAVE_QUIT;
       
-	    // XXX FIXME XXX -- avoid apparent GNU libm bug by
-	    // converting A and B to complex instead of just A.
+	    Complex atmp (a (i, j));
 
-	    Complex atmp (a (i, j));
-	    Complex btmp (b);
-
-	    result (i, j) = pow (atmp, btmp);
+	    result (i, j) = std::pow (atmp, b);
 	  }
 
       retval = result;
@@ -584,7 +576,7 @@
 	for (int i = 0; i < nr; i++)
 	  {
 	    OCTAVE_QUIT;
-	    result (i, j) = pow (a (i, j), b);
+	    result (i, j) = std::pow (a (i, j), b);
 	  }
 
       retval = result;
@@ -637,7 +629,7 @@
 	    OCTAVE_QUIT;
 	    Complex atmp (a (i, j));
 	    Complex btmp (b (i, j));
-	    complex_result (i, j) = pow (atmp, btmp);
+	    complex_result (i, j) = std::pow (atmp, btmp);
 	  }
 
       retval = complex_result;
@@ -650,7 +642,7 @@
 	for (int i = 0; i < nr; i++)
 	  {
 	    OCTAVE_QUIT;
-	    result (i, j) = pow (a (i, j), b (i, j));
+	    result (i, j) = std::pow (a (i, j), b (i, j));
 	  }
 
       retval = result;
@@ -671,7 +663,7 @@
     for (int i = 0; i < nr; i++)
       {
 	OCTAVE_QUIT;
-	result (i, j) = pow (Complex (a (i, j)), b);
+	result (i, j) = std::pow (Complex (a (i, j)), b);
       }
 
   return result;
@@ -698,7 +690,7 @@
     for (int i = 0; i < nr; i++)
       {
 	OCTAVE_QUIT;
-	result (i, j) = pow (Complex (a (i, j)), b (i, j));
+	result (i, j) = std::pow (Complex (a (i, j)), b (i, j));
       }
 
   return result;
@@ -718,9 +710,9 @@
 	OCTAVE_QUIT;
 	double btmp = b (i, j);
 	if (xisint (btmp))
-	  result (i, j) = pow (a, static_cast<int> (btmp));
+	  result (i, j) = std::pow (a, static_cast<int> (btmp));
 	else
-	  result (i, j) = pow (a, btmp);
+	  result (i, j) = std::pow (a, btmp);
       }
 
   return result;
@@ -738,7 +730,7 @@
     for (int i = 0; i < nr; i++)
       {
 	OCTAVE_QUIT;
-	result (i, j) = pow (a, b (i, j));
+	result (i, j) = std::pow (a, b (i, j));
       }
 
   return result;
@@ -759,7 +751,7 @@
 	for (int i = 0; i < nr; i++)
 	  {
 	    OCTAVE_QUIT;
-	    result (i, j) = pow (a (i, j), static_cast<int> (b));
+	    result (i, j) = std::pow (a (i, j), static_cast<int> (b));
 	  }
     }
   else
@@ -768,7 +760,7 @@
 	for (int i = 0; i < nr; i++)
 	  {
 	    OCTAVE_QUIT;
-	    result (i, j) = pow (a (i, j), b);
+	    result (i, j) = std::pow (a (i, j), b);
 	  }
     }
 
@@ -798,9 +790,9 @@
 	OCTAVE_QUIT;
 	double btmp = b (i, j);
 	if (xisint (btmp))
-	  result (i, j) = pow (a (i, j), static_cast<int> (btmp));
+	  result (i, j) = std::pow (a (i, j), static_cast<int> (btmp));
 	else
-	  result (i, j) = pow (a (i, j), btmp);
+	  result (i, j) = std::pow (a (i, j), btmp);
       }
 
   return result;
@@ -818,7 +810,7 @@
     for (int i = 0; i < nr; i++)
       {
 	OCTAVE_QUIT;
-	result (i, j) = pow (a (i, j), b);
+	result (i, j) = std::pow (a (i, j), b);
       }
 
   return result;
@@ -845,7 +837,7 @@
     for (int i = 0; i < nr; i++)
       {
 	OCTAVE_QUIT;
-	result (i, j) = pow (a (i, j), b (i, j));
+	result (i, j) = std::pow (a (i, j), b (i, j));
       }
 
   return result;
@@ -895,7 +887,7 @@
       for (int i = 0; i < b.length (); i++)
 	{
 	  OCTAVE_QUIT;
-	  result(i) = pow (atmp, b(i));
+	  result(i) = std::pow (atmp, b(i));
 	}
 
       retval = result;
@@ -906,7 +898,7 @@
       for (int i = 0; i < b.length (); i++)
 	{
 	  OCTAVE_QUIT;
-	  result (i) = pow (a, b(i));
+	  result (i) = std::pow (a, b(i));
 	}
 
       retval = result;
@@ -924,7 +916,7 @@
   for (int i = 0; i < b.length (); i++)
     {
       OCTAVE_QUIT;
-      result(i) = pow (atmp, b(i));
+      result(i) = std::pow (atmp, b(i));
     }
 
   return result;
@@ -944,13 +936,9 @@
 	{
 	  OCTAVE_QUIT;
 
-	  // XXX FIXME XXX -- avoid apparent GNU libm bug by
-	  // converting A and B to complex instead of just A.
+	  Complex atmp (a (i));
 
-	  Complex atmp (a (i));
-	  Complex btmp (b);
-
-	  result(i) = pow (atmp, btmp);
+	  result(i) = std::pow (atmp, b);
 	}
 
       retval = result;
@@ -962,7 +950,7 @@
       for (int i = 0; i < a.length (); i++)
 	{
 	  OCTAVE_QUIT;
-	  result(i) = pow (a(i), b);
+	  result(i) = std::pow (a(i), b);
 	}
 
       retval = result;
@@ -1013,7 +1001,7 @@
 	  OCTAVE_QUIT;
 	  Complex atmp (a(i));
 	  Complex btmp (b(i));
-	  complex_result(i) = pow (atmp, btmp);
+	  complex_result(i) = std::pow (atmp, btmp);
 	}
 
       retval = complex_result;
@@ -1025,7 +1013,7 @@
       for (int i = 0; i < len; i++)
 	{
 	  OCTAVE_QUIT;
-	  result(i) = pow (a(i), b(i));
+	  result(i) = std::pow (a(i), b(i));
 	}
 
       retval = result;
@@ -1043,7 +1031,7 @@
   for (int i = 0; i < a.length (); i++)
     {
       OCTAVE_QUIT;
-      result(i) = pow (Complex (a(i)), b);
+      result(i) = std::pow (Complex (a(i)), b);
     }
 
   return result;
@@ -1066,7 +1054,7 @@
   for (int i = 0; i < a.length (); i++)
     {
       OCTAVE_QUIT;
-      result(i) = pow (Complex (a(i)), b(i));
+      result(i) = std::pow (Complex (a(i)), b(i));
     }
 
   return result;
@@ -1082,9 +1070,9 @@
       OCTAVE_QUIT;
       double btmp = b(i);
       if (xisint (btmp))
-	result(i) = pow (a, static_cast<int> (btmp));
+	result(i) = std::pow (a, static_cast<int> (btmp));
       else
-	result(i) = pow (a, btmp);
+	result(i) = std::pow (a, btmp);
     }
 
   return result;
@@ -1098,7 +1086,7 @@
   for (int i = 0; i < b.length (); i++)
     {
       OCTAVE_QUIT;
-      result(i) = pow (a, b(i));
+      result(i) = std::pow (a, b(i));
     }
 
   return result;
@@ -1115,7 +1103,7 @@
       for (int i = 0; i < a.length (); i++)
 	{
 	  OCTAVE_QUIT;
-	  result(i) = pow (a(i), static_cast<int> (b));
+	  result(i) = std::pow (a(i), static_cast<int> (b));
 	}
     }
   else
@@ -1123,7 +1111,7 @@
       for (int i = 0; i < a.length (); i++)
 	{
 	  OCTAVE_QUIT;
-	  result(i) = pow (a(i), b);
+	  result(i) = std::pow (a(i), b);
 	}
     }
 
@@ -1149,9 +1137,9 @@
       OCTAVE_QUIT;
       double btmp = b(i);
       if (xisint (btmp))
-	result(i) = pow (a(i), static_cast<int> (btmp));
+	result(i) = std::pow (a(i), static_cast<int> (btmp));
       else
-	result(i) = pow (a(i), btmp);
+	result(i) = std::pow (a(i), btmp);
     }
 
   return result;
@@ -1165,7 +1153,7 @@
   for (int i = 0; i < a.length (); i++)
     {
       OCTAVE_QUIT;
-      result(i) = pow (a(i), b);
+      result(i) = std::pow (a(i), b);
     }
 
   return result;
@@ -1188,7 +1176,7 @@
   for (int i = 0; i < a.length (); i++)
     {
       OCTAVE_QUIT;
-      result(i) = pow (a(i), b(i));
+      result(i) = std::pow (a(i), b(i));
     }
 
   return result;