diff liboctave/lo-mappers.cc @ 3248:68259f410026

[project @ 1999-07-13 03:34:54 by jwe]
author jwe
date Tue, 13 Jul 1999 03:40:17 +0000
parents d0d2b69dc6c2
children fdc7dd08cd85
line wrap: on
line diff
--- a/liboctave/lo-mappers.cc
+++ b/liboctave/lo-mappers.cc
@@ -49,7 +49,7 @@
 #define M_PI 3.14159265358979323846
 #endif
 
-// Double -> double mappers.
+// double -> double mappers.
 
 double
 arg (double x)
@@ -136,17 +136,19 @@
 #endif
 }
 
-double
+// double -> bool mappers.
+
+bool
 xisnan (double x)
 {
 #if defined (HAVE_ISNAN)
   return isnan (x) != 0;
 #else
-  return 0;
+  return false;
 #endif
 }
 
-double
+bool
 xfinite (double x)
 {
 #if defined (HAVE_FINITE)
@@ -154,11 +156,11 @@
 #elif defined (HAVE_ISINF) && defined (HAVE_ISNAN)
   return (! isinf (x) && ! isnan (x));
 #else
-  return 1;
+  return true;
 #endif
 }
 
-double
+bool
 xisinf (double x)
 {
 #if defined (HAVE_ISINF)
@@ -166,35 +168,25 @@
 #elif defined (HAVE_FINITE) && defined (HAVE_ISNAN)
   return (! (finite (x) || isnan (x)));
 #else
-  return 0;
+  return false;
 #endif
 }
 
-// Complex -> double mappers.
+// (double, double) -> double mappers.
 
 double
-xisnan (const Complex& x)
+xmin (double x, double y)
 {
-#if defined (HAVE_ISNAN)
-  return (isnan (real (x)) || isnan (imag (x)));
-#else
-  return 0;
-#endif
+  return x < y ? x : (xisnan (x) ? x : y);
 }
 
 double
-xfinite (const Complex& x)
+xmax (double x, double y)
 {
-  return (xfinite (real (x)) && xfinite (imag (x)));
+  return x > y ? x : (xisnan (x) ? x : y);
 }
 
-double
-xisinf (const Complex& x)
-{
-  return (xisinf (real (x)) || xisinf (imag (x)));
-}
-
-// Complex -> complex mappers.
+// complex -> complex mappers.
 
 Complex
 acos (const Complex& x)
@@ -286,6 +278,44 @@
   return sinh (x) / cosh (x);
 }
 
+// complex -> bool mappers.
+
+bool
+xisnan (const Complex& x)
+{
+#if defined (HAVE_ISNAN)
+  return (isnan (real (x)) || isnan (imag (x)));
+#else
+  return false;
+#endif
+}
+
+bool
+xfinite (const Complex& x)
+{
+  return (xfinite (real (x)) && xfinite (imag (x)));
+}
+
+bool
+xisinf (const Complex& x)
+{
+  return (xisinf (real (x)) || xisinf (imag (x)));
+}
+
+// (complex, complex) -> complex mappers.
+
+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);
+}
+
 /*
 ;;; Local Variables: ***
 ;;; mode: C++ ***