# HG changeset patch # User jwe # Date 845397578 0 # Node ID e22aae3ccfad47fe594c4bc8f01c707cdfd605ee # Parent 4f55dc039a7eddf14c0766d2fc45084561bde83b [project @ 1996-10-15 16:37:52 by jwe] diff --git a/liboctave/CMatrix.cc b/liboctave/CMatrix.cc --- 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. diff --git a/liboctave/CMatrix.h b/liboctave/CMatrix.h --- 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; diff --git a/liboctave/ChangeLog b/liboctave/ChangeLog --- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,7 @@ +Tue Oct 15 11:34:48 1996 John W. Eaton + + * CMatrix.cc (ComplexMatrix::all_elements_are_real): new function. + Sun Oct 13 11:19:00 1996 John W. Eaton * sun-utils.h: Conditionally declare MAIN__ too. Declare MAIN_ diff --git a/src/pr-output.cc b/src/pr-output.cc --- 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) { diff --git a/src/symtab.cc b/src/symtab.cc --- a/src/symtab.cc +++ b/src/symtab.cc @@ -144,7 +144,11 @@ void symbol_def::define (tree_constant *t) { + if (t) + t->maybe_mutate (); + definition = t; + if (! is_builtin_variable ()) type = USER_VARIABLE; }