changeset 4451:ea1d3e1a4b1b

[project @ 2003-07-09 19:09:09 by jwe]
author jwe
date Wed, 09 Jul 2003 19:09:09 +0000
parents c81dd5832ad8
children f3c21a1d1c62
files ChangeLog doc/faq/Octave-FAQ.texi doc/interpreter/basics.txi doc/interpreter/matrix.txi doc/interpreter/var.txi emacs/octave-mod.el scripts/ChangeLog scripts/miscellaneous/dump_prefs.m src/ChangeLog src/octave.cc src/ov-complex.cc src/ov-cx-mat.cc src/ov.cc src/ov.h
diffstat 14 files changed, 80 insertions(+), 81 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2003-07-09  John W. Eaton  <jwe@bevo.che.wisc.edu>
+
+	* emacs/octave-mod.el (octave-variables): Include
+	DEFAULT_EXEC_PATH, DEFAULT_LOAD_PATH, crash_dumps_octave_core,
+	sighup_dumps_octave_core, sigterm_dumps_octave_core, and
+	warn_imag_to_real in the list.
+	Delete ok_to_lose_imaginary_part from list.	
+
 2003-07-08  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
 	* Makeconf.in (do-subst-default-vals): Substitute OCTAVE_API_VERSION.
--- a/doc/faq/Octave-FAQ.texi
+++ b/doc/faq/Octave-FAQ.texi
@@ -727,7 +727,6 @@
   fixed_point_format = 1.0
   implicit_num_to_str_ok = 1.0
   implicit_str_to_num_ok = 1.0
-  ok_to_lose_imaginary_part = 1.0
   page_screen_output = 0.0
   prefer_column_vectors = 0.0
   prefer_zero_one_indexing = 1.0
--- a/doc/interpreter/basics.txi
+++ b/doc/interpreter/basics.txi
@@ -164,7 +164,6 @@
 crash_dumps_octave_core       = 0
 empty_list_elements_ok        = 1
 implicit_str_to_num_ok        = 1
-ok_to_lose_imaginary_part     = 1
 page_screen_output            = 0
 prefer_column_vectors         = 0
 print_empty_dimensions        = 0
--- a/doc/interpreter/matrix.txi
+++ b/doc/interpreter/matrix.txi
@@ -177,7 +177,7 @@
 
 @c XXX FIXME XXX -- is this really worth documenting?
 @c
-@c DOCSTRING(ok_to_lose_imaginary_part)
+@c DOCSTRING(warn_imag_to_real)
 @c 
 @c XXX FIXME XXX -- this is here because it is used by @code{ones},
 @c @code{zeros}, @code{rand}, etc.
@@ -192,7 +192,7 @@
 
 @DOCSTRING(treat_neg_dim_as_zero)
 
-@DOCSTRING(ok_to_lose_imaginary_part)
+@DOCSTRING(warn_imag_to_real)
 
 @node Famous Matrices
 @section Famous Matrices
--- a/doc/interpreter/var.txi
+++ b/doc/interpreter/var.txi
@@ -316,11 +316,6 @@
 
 Default value: 256.
 
-@item ok_to_lose_imaginary_part
-@xref{Special Utility Matrices}.
-
-Default value: @code{"warn"}.
-
 @item output_max_field_width
 @xref{Matrices}.
 
@@ -421,6 +416,11 @@
 
 Default value: 1.
 
+@item warn_imag_to_real
+@xref{Special Utility Matrices}.
+
+Default value: 0.
+
 @item warn_function_name_clash
 @xref{Function Files}.
 
--- a/emacs/octave-mod.el
+++ b/emacs/octave-mod.el
@@ -125,7 +125,8 @@
   "Text functions in Octave (these names are also reserved).")
 
 (defvar octave-variables
-  '("EDITOR" "EXEC_PATH" "F_DUPFD" "F_GETFD" "F_GETFL" "F_SETFD"
+  '("DEFAULT_EXEC_PATH" "DEFAULT_LOADPATH"
+    "EDITOR" "EXEC_PATH" "F_DUPFD" "F_GETFD" "F_GETFL" "F_SETFD"
     "F_SETFL" "I" "IMAGEPATH" "INFO_FILE" "INFO_PROGRAM" "Inf" "J"
     "LOADPATH" "NaN" "OCTAVE_VERSION" "O_APPEND" "O_CREAT" "O_EXCL"
     "O_NONBLOCK" "O_RDONLY" "O_RDWR" "O_TRUNC" "O_WRONLY" "PAGER" "PS1"
@@ -139,12 +140,13 @@
     "__program_invocation_name__" "__program_name__" "__realmax__"
     "__realmin__" "__stderr__" "__stdin__" "__stdout__" "ans" "argv"
     "automatic_replot" "beep_on_error" "completion_append_char"
+    "crash_dumps_octave_core"
     "default_return_value" "default_save_format"
     "define_all_return_values" "do_fortran_indexing" "e"
     "echo_executing_commands" "empty_list_elements_ok" "eps"
     "error_text" "gnuplot_binary" "history_file"
     "history_size" "ignore_function_time_stamp" "implicit_str_to_num_ok"
-    "inf" "nan" "nargin" "ok_to_lose_imaginary_part"
+    "inf" "nan" "nargin"
     "output_max_field_width" "output_precision"
     "page_output_immediately" "page_screen_output" "pi"
     "prefer_column_vectors" "prefer_zero_one_indexing"
@@ -152,11 +154,13 @@
     "program_invocation_name" "program_name" "propagate_empty_matrices"
     "realmax" "realmin" "resize_on_range_error"
     "return_last_computed_value" "save_precision" "saving_history"
+    "sighup_dumps_octave_core" "sigterm_dumps_octave_core"
     "silent_functions" "split_long_rows" "stderr" "stdin" "stdout"
     "string_fill_char" "struct_levels_to_print"
     "suppress_verbose_help_message" "treat_neg_dim_as_zero"
     "warn_assign_as_truth_value" "warn_comma_in_global_decl"
     "warn_divide_by_zero" "warn_function_name_clash"
+    "warn_imag_to_real"
     "warn_missing_semicolon" "whitespace_in_literal_matrix")
   "Builtin variables in Octave.")
 
--- a/scripts/ChangeLog
+++ b/scripts/ChangeLog
@@ -1,3 +1,11 @@
+2003-07-09  John W. Eaton  <jwe@bevo.che.wisc.edu>
+
+	* miscellaneous/dump_prefs.m: Include DEFAULT_EXEC_PATH,
+	DEFAULT_LOAD_PATH, crash_dumps_octave_core,
+	sighup_dumps_octave_core, sigterm_dumps_octave_core, and
+	warn_imag_to_real in the list.
+	Delete ok_to_lose_imaginary_part from list.	
+
 2003-07-02  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
 	* Makefile.in (distclean, maintainer-clean): Also remove
--- a/scripts/miscellaneous/dump_prefs.m
+++ b/scripts/miscellaneous/dump_prefs.m
@@ -37,7 +37,9 @@
   ## remember to update it each time the list of preference variables
   ## changes
 
-  var_list = ["EDITOR";
+  var_list = ["DEFAULT_EXEC_PATH";
+	      "DEFAULT_LOADPATH";
+	      "EDITOR";
               "EXEC_PATH";
               "IMAGEPATH";
               "INFO_FILE";
@@ -50,6 +52,7 @@
               "automatic_replot";
               "beep_on_error";
               "completion_append_char";
+              "crash_dumps_octave_core";
               "default_eval_print_flag";
               "default_global_variable_value";
               "default_return_value";
@@ -75,7 +78,6 @@
               "implicit_str_to_num_ok";
               "initialize_global_variables";
               "max_recursion_depth";
-              "ok_to_lose_imaginary_part";
               "output_max_field_width";
               "output_precision";
               "page_output_immediately";
@@ -89,6 +91,8 @@
               "return_last_computed_value";
               "save_precision";
               "saving_history";
+              "sighup_dumps_octave_core";
+              "sigterm_dumps_octave_core";
               "silent_functions";
               "split_long_rows";
               "string_fill_char";
@@ -99,6 +103,7 @@
               "warn_divide_by_zero";
               "warn_function_name_clash";
               "warn_future_time_stamp";
+              "warn_imag_to_real";
               "warn_missing_semicolon";
               "warn_variable_switch_label";
               "whitespace_in_literal_matrix"];
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,23 @@
+2003-07-09  John W. Eaton  <jwe@bevo.che.wisc.edu>
+
+	* ov.cc (Vwarn_imag_to_real): New variable.
+	(warn_imag_to_real): New function.
+	(symbols_of_ov): Add DEFVAR for warn_imag_to_real.
+	* ov.h (Vwarn_imag_to_real): Provide decl.
+
+	* ov.cc (Vok_to_lose_imaginary_part): Delete unused variable.
+	(ok_to_lose_imaginary_part): Delete unused function.
+	(symbols_of_ov): Delete DEFVAR for ok_to_lose_imaginary_part.
+	* ov.h (Vok_to_lose_imaginary_part): Delete decl.
+
+	* ov-complex.cc (octave_complex::double_value): Warn based on
+	Vwarn_imag_to_real instead of Vok_to_lose_imaginary_part.
+	(octave_complex::matrix_value): Likewise.
+	* ov-cx-mat.cc (octave_complex_matrix::double_value): Likewise.
+	(octave_complex_matrix::matrix_value): Likewise.
+
+	* octave.cc (maximum_braindamage): Don't set ok_to_lose_imaginary_part.
+
 2003-07-08  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
 	* sighandlers.cc (sig_hup_or_term_handler): New function.
--- a/src/octave.cc
+++ b/src/octave.cc
@@ -355,7 +355,6 @@
   bind_builtin_variable ("implicit_num_to_str_ok", true);
   bind_builtin_variable ("implicit_str_to_num_ok", true);
   bind_builtin_variable ("initialize_global_variables", true);
-  bind_builtin_variable ("ok_to_lose_imaginary_part", true);
   bind_builtin_variable ("page_screen_output", false);
   bind_builtin_variable ("prefer_column_vectors", false);
   bind_builtin_variable ("print_empty_dimensions", false);
--- a/src/ov-complex.cc
+++ b/src/ov-complex.cc
@@ -92,18 +92,10 @@
 {
   double retval = lo_ieee_nan_value ();
 
-  int flag = force_conversion;
-
-  if (! flag)
-    flag = Vok_to_lose_imaginary_part;
-
-  if (flag < 0)
+  if (! force_conversion && Vwarn_imag_to_real)
     gripe_implicit_conversion ("complex scalar", "real scalar");
 
-  if (flag)
-    retval = std::real (scalar);
-  else
-    gripe_invalid_conversion ("complex scalar", "real scalar");
+  retval = std::real (scalar);
 
   return retval;
 }
@@ -113,18 +105,10 @@
 {
   Matrix retval;
 
-  int flag = force_conversion;
-
-  if (! flag)
-    flag = Vok_to_lose_imaginary_part;
-
-  if (flag < 0)
+  if (! force_conversion && Vwarn_imag_to_real)
     gripe_implicit_conversion ("complex scalar", "real matrix");
 
-  if (flag)
-    retval = Matrix (1, 1, std::real (scalar));
-  else
-    gripe_invalid_conversion ("complex scalar", "real matrix");
+  retval = Matrix (1, 1, std::real (scalar));
 
   return retval;
 }
--- a/src/ov-cx-mat.cc
+++ b/src/ov-cx-mat.cc
@@ -132,22 +132,12 @@
 {
   double retval = lo_ieee_nan_value ();
 
-  int flag = force_conversion;
-
-  if (! flag)
-    flag = Vok_to_lose_imaginary_part;
-
-  if (flag < 0)
+  if (! force_conversion && Vwarn_imag_to_real)
     gripe_implicit_conversion ("complex matrix", "real scalar");
 
-  if (flag)
-    {
-      if ((rows () == 1 && columns () == 1)
-	  || (Vdo_fortran_indexing && rows () > 0 && columns () > 0))
-	retval = std::real (matrix (0, 0));
-      else
-	gripe_invalid_conversion ("complex matrix", "real scalar");
-    }
+  if ((rows () == 1 && columns () == 1)
+      || (Vdo_fortran_indexing && rows () > 0 && columns () > 0))
+    retval = std::real (matrix (0, 0));
   else
     gripe_invalid_conversion ("complex matrix", "real scalar");
 
@@ -159,18 +149,10 @@
 {
   Matrix retval;
 
-  int flag = force_conversion;
-
-  if (! flag)
-    flag = Vok_to_lose_imaginary_part;
-
-  if (flag < 0)
+  if (! force_conversion && Vwarn_imag_to_real)
     gripe_implicit_conversion ("complex matrix", "real matrix");
 
-  if (flag)
-    retval = ::real (matrix);
-  else
-    gripe_invalid_conversion ("complex matrix", "real matrix");
+  retval = ::real (matrix);
 
   return retval;
 }
--- a/src/ov.cc
+++ b/src/ov.cc
@@ -95,11 +95,8 @@
 // considered an error.
 int Vimplicit_str_to_num_ok;
 
-// Should we allow silent conversion of complex to real when a real
-// type is what we're really looking for?  A positive value means yes.
-// A negative value means yes, but print a warning message.  Zero
-// means it should be considered an error.
-int Vok_to_lose_imaginary_part;
+// Should we warn about conversions from complex to real?
+int Vwarn_imag_to_real;
 
 // If TRUE, create column vectors when doing assignments like:
 //
@@ -1773,9 +1770,9 @@
 }
 
 static int
-ok_to_lose_imaginary_part (void)
+warn_imag_to_real (void)
 {
-  Vok_to_lose_imaginary_part = check_preference ("ok_to_lose_imaginary_part");
+  Vwarn_imag_to_real = check_preference ("warn_imag_to_real");
 
   return 0;
 }
@@ -1890,17 +1887,6 @@
 top level.  The default value is 0.\n\
 @end defvr");
 
-  DEFVAR (ok_to_lose_imaginary_part, "warn", ok_to_lose_imaginary_part,
-    "-*- texinfo -*-\n\
-@defvr {Built-in Variable} ok_to_lose_imaginary_part\n\
-If the value of @code{ok_to_lose_imaginary_part} is nonzero, implicit\n\
-conversions of complex numbers to real numbers are allowed (for example,\n\
-by fsolve).  If the value is @code{\"warn\"}, the conversion is allowed,\n\
-but a warning is printed.  Otherwise, an error message is printed and\n\
-control is returned to the top level.  The default value is\n\
-@code{\"warn\"}.\n\
-@end defvr");
-
   DEFVAR (prefer_column_vectors, true, prefer_column_vectors,
     "-*- texinfo -*-\n\
 @defvr {Built-in Variable} prefer_column_vectors\n\
@@ -1992,6 +1978,14 @@
 is issued when Octave encounters a division by zero.  If the value is\n\
 0, the warning is omitted.  The default value is 1.\n\
 @end defvr");
+
+  DEFVAR (warn_imag_to_real, false, warn_imag_to_real,
+    "-*- texinfo -*-\n\
+@defvr {Built-in Variable} warn_imag_to_real\n\
+If the value of @code{warn_imag_to_real} is nonzero, a warning is\n\
+printed for implicit conversions of complex numbers to real numbers.\n\
+The default value is 0.\n\
+@end defvr");
 }
 
 /*
--- a/src/ov.h
+++ b/src/ov.h
@@ -736,11 +736,8 @@
 // considered an error.
 extern int Vimplicit_str_to_num_ok;
 
-// Should we allow silent conversion of complex to real when a real
-// type is what we're really looking for?  A positive value means yes.
-// A negative value means yes, but print a warning message.  Zero
-// means it should be considered an error.
-extern int Vok_to_lose_imaginary_part;
+// Should we warn about conversions from complex to real?
+extern int Vwarn_imag_to_real;
 
 // If TRUE, print the name along with the value.
 extern bool Vprint_answer_id_name;