# HG changeset patch # User jwe # Date 1055951230 0 # Node ID c4bde1d5eb984d62a2d3db9c381409e4c30f3531 # Parent 1541c3ed2c93621ee540dacd766e59cfa487aa30 [project @ 2003-06-18 15:47:09 by jwe] diff --git a/liboctave/ChangeLog b/liboctave/ChangeLog --- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,8 @@ +2003-06-18 John W. Eaton + + * 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 * DASSL.cc (DASSL::do_integrate): Set liw to 21 + n, not 20 + n. diff --git a/liboctave/dMatrix.cc b/liboctave/dMatrix.cc --- a/liboctave/dMatrix.cc +++ b/liboctave/dMatrix.cc @@ -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; } diff --git a/liboctave/dMatrix.h b/liboctave/dMatrix.h --- a/liboctave/dMatrix.h +++ b/liboctave/dMatrix.h @@ -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; diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2003-06-18 John W. Eaton + + * 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 * toplev.cc (main_loop): Set octave_interrupt_hook and diff --git a/src/pr-output.cc b/src/pr-output.cc --- a/src/pr-output.cc +++ b/src/pr-output.cc @@ -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 ();