changeset 4431:c4bde1d5eb98

[project @ 2003-06-18 15:47:09 by jwe]
author jwe
date Wed, 18 Jun 2003 15:47:10 +0000
parents 1541c3ed2c93
children ff7187bd3075
files liboctave/ChangeLog liboctave/dMatrix.cc liboctave/dMatrix.h src/ChangeLog src/pr-output.cc
diffstat 5 files changed, 29 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/ChangeLog	Tue Jun 17 16:50:23 2003 +0000
+++ b/liboctave/ChangeLog	Wed Jun 18 15:47:10 2003 +0000
@@ -1,3 +1,8 @@
+2003-06-18  John W. Eaton  <jwe@bevo.che.wisc.edu>
+
+	* dMatrix.cc (any_element_is_negative): If new optional arg
+	neg_zero is true, also return true for negative zero.
+
 2003-06-16  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
 	* DASSL.cc (DASSL::do_integrate): Set liw to 21 + n, not 20 + n.
--- a/liboctave/dMatrix.cc	Tue Jun 17 16:50:23 2003 +0000
+++ b/liboctave/dMatrix.cc	Wed Jun 18 15:47:10 2003 +0000
@@ -1984,15 +1984,25 @@
 }
 
 bool
-Matrix::any_element_is_negative (void) const
+Matrix::any_element_is_negative (bool neg_zero) const
 {
   int nr = rows ();
   int nc = cols ();
 
-  for (int j = 0; j < nc; j++)
-    for (int i = 0; i < nr; i++)
-      if (elem (i, j) < 0.0)
-	return true;
+  if (neg_zero)
+    {
+      for (int j = 0; j < nc; j++)
+	for (int i = 0; i < nr; i++)
+	  if (lo_ieee_signbit (elem (i, j)))
+	    return true;
+    }
+  else
+    {
+      for (int j = 0; j < nc; j++)
+	for (int i = 0; i < nr; i++)
+	  if (elem (i, j) < 0)
+	    return true;
+    }
 
   return false;
 }
--- a/liboctave/dMatrix.h	Tue Jun 17 16:50:23 2003 +0000
+++ b/liboctave/dMatrix.h	Wed Jun 18 15:47:10 2003 +0000
@@ -194,7 +194,7 @@
 
   Matrix& apply (d_d_Mapper f);
 
-  bool any_element_is_negative (void) const;
+  bool any_element_is_negative (bool = false) const;
   bool any_element_is_inf_or_nan (void) const;
   bool all_elements_are_int_or_inf_or_nan (void) const;
   bool all_integers (double& max_val, double& min_val) const;
--- a/src/ChangeLog	Tue Jun 17 16:50:23 2003 +0000
+++ b/src/ChangeLog	Wed Jun 18 15:47:10 2003 +0000
@@ -1,3 +1,9 @@
+2003-06-18  John W. Eaton  <jwe@bevo.che.wisc.edu>
+
+	* pr-output.cc (set_format (const Matrix&, int&, double&)): Ask
+	any_element_is_negative to return true for negative zero as well.
+	(set_format (const ComplexMatrix&, int&, int&, double&)): Likewise.
+
 2003-06-16  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
 	* toplev.cc (main_loop): Set octave_interrupt_hook and
--- a/src/pr-output.cc	Tue Jun 17 16:50:23 2003 +0000
+++ b/src/pr-output.cc	Wed Jun 18 15:47:10 2003 +0000
@@ -483,7 +483,7 @@
   if (free_format)
     return;
 
-  bool sign = m.any_element_is_negative ();
+  bool sign = m.any_element_is_negative (true);
 
   bool inf_or_nan = m.any_element_is_inf_or_nan ();
 
@@ -820,7 +820,7 @@
   Matrix rp = real (cm);
   Matrix ip = imag (cm);
 
-  bool sign = rp.any_element_is_negative ();
+  bool sign = rp.any_element_is_negative (true);
 
   bool inf_or_nan = cm.any_element_is_inf_or_nan ();