Mercurial > hg > octave-lyh
changeset 2408:e22aae3ccfad
[project @ 1996-10-15 16:37:52 by jwe]
author | jwe |
---|---|
date | Tue, 15 Oct 1996 16:39:38 +0000 |
parents | 4f55dc039a7e |
children | 47e5f57fb4bd |
files | liboctave/CMatrix.cc liboctave/CMatrix.h liboctave/ChangeLog src/pr-output.cc src/symtab.cc |
diffstat | 5 files changed, 33 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/CMatrix.cc +++ b/liboctave/CMatrix.cc @@ -2956,6 +2956,22 @@ return false; } +// Return true if no elements have imaginary components. + +bool +ComplexMatrix::all_elements_are_real (void) const +{ + int nr = rows (); + int nc = cols (); + + for (int j = 0; j < nc; j++) + for (int i = 0; i < nr; i++) + if (imag (elem (i, j)) != 0.0) + return false; + + return true; +} + // Return nonzero if any element of CM has a non-integer real or // imaginary part. Also extract the largest and smallest (real or // imaginary) values and return them in MAX_VAL and MIN_VAL.
--- a/liboctave/CMatrix.h +++ b/liboctave/CMatrix.h @@ -321,6 +321,7 @@ void map (c_c_Mapper f); bool any_element_is_inf_or_nan (void) const; + bool all_elements_are_real (void) const; bool all_integers (double& max_val, double& min_val) const; bool too_large_for_float (void) const;
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,7 @@ +Tue Oct 15 11:34:48 1996 John W. Eaton <jwe@bevo.che.wisc.edu> + + * CMatrix.cc (ComplexMatrix::all_elements_are_real): new function. + Sun Oct 13 11:19:00 1996 John W. Eaton <jwe@bevo.che.wisc.edu> * sun-utils.h: Conditionally declare MAIN__ too. Declare MAIN_
--- a/src/pr-output.cc +++ b/src/pr-output.cc @@ -1101,9 +1101,12 @@ int nr = m.rows (); int nc = m.columns (); +#if 0 if (nr == 1 && nc == 1 && ! pr_as_read_syntax) octave_print_internal (os, m (0, 0), pr_as_read_syntax); - else if (nr == 0 || nc == 0) + else +#endif + if (nr == 0 || nc == 0) print_empty_matrix (os, nr, nc, pr_as_read_syntax); else if (plus_format && ! pr_as_read_syntax) { @@ -1255,9 +1258,12 @@ int nr = cm.rows (); int nc = cm.columns (); +#if 0 if (nr == 1 && nc == 1 && ! pr_as_read_syntax) octave_print_internal (os, cm (0, 0), pr_as_read_syntax); - else if (nr == 0 || nc == 0) + else +#endif + if (nr == 0 || nc == 0) print_empty_matrix (os, nr, nc, pr_as_read_syntax); else if (plus_format && ! pr_as_read_syntax) {