changeset 8845:5a6db6bd1a02

eigs.cc (Feigs): fix handling of sigma arg
author John W. Eaton <jwe@octave.org>
date Mon, 23 Feb 2009 16:29:20 -0500
parents c84a5b6377c4
children 492801cd65eb
files scripts/sparse/svds.m src/ChangeLog src/DLD-FUNCTIONS/eigs.cc src/pt-eval.cc
diffstat 4 files changed, 77 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/sparse/svds.m	Mon Feb 23 12:55:32 2009 -0500
+++ b/scripts/sparse/svds.m	Mon Feb 23 16:29:20 2009 -0500
@@ -212,7 +212,6 @@
 %! s = s(idx);
 %! u = u(:,idx);
 %! v = v(:,idx);
-%! randn('state',42)
 %!testif HAVE_ARPACK
 %! [u2,s2,v2,flag] = svds(a,k);
 %! s2 = diag(s2);
--- a/src/ChangeLog	Mon Feb 23 12:55:32 2009 -0500
+++ b/src/ChangeLog	Mon Feb 23 16:29:20 2009 -0500
@@ -1,5 +1,29 @@
 2009-02-23  John W. Eaton  <jwe@octave.org>
 
+	* DLD-FUNCTIONS/eigs.cc (Feigs): If sigma argument is not a
+	string, try extraction as complex value and check for error
+	instead of inquiring about type first.
+
+	* pt-eval.cc (tree_evaluator::visit_break_command,
+	tree_evaluator::visit_return_command,
+	tree_evaluator::visit_global_command,
+	tree_evaluator::visit_static_command): Handle breakpoint.
+	(tree_evaluator::visit_simple_for_command,
+	tree_evaluator::visit_complex_for_command): Handle breakpoint once
+	at beginning of loop.
+	(tree_evaluator::visit_if_command_list): Don't call do_breakpoint
+	for else clauses.
+	(tree_evaluator::visit_no_op_command): Handle breakpoint if no-op
+	command is end of function or script.
+	(tree_evaluator::visit_statement): Handle breakpoint for
+	expressions but not commands.
+	(tree_evaluator::visit_while_command,
+	tree_evaluator::visit_do_until_command):
+	Check for breakpoint set on cmd, not expr.
+	(tree_evaluator::visit_do_until_command): Handle breakpoint
+	between check for breaking out of loop and loop control
+	expression.
+
 	* pt-cmd.h (tree_no_op_command::eof): New data member
 	(tree_no_op_command::tree_no_op_command): Initialize it.
 	(tree_no_op_command::is_end_of_fcn_or_script): New function.
--- a/src/DLD-FUNCTIONS/eigs.cc	Mon Feb 23 12:55:32 2009 -0500
+++ b/src/DLD-FUNCTIONS/eigs.cc	Mon Feb 23 16:29:20 2009 -0500
@@ -452,13 +452,7 @@
 
   if (!error_state && nargin > (2+arg_offset))
     {
-      if (args(2+arg_offset).is_real_scalar ()
-	  || args(2+arg_offset).is_complex_scalar ())
-	{
-	  sigma = args(2+arg_offset).complex_value ();
-	  have_sigma = true;
-	}
-      else if (args(2+arg_offset).is_string ())
+      if (args(2+arg_offset).is_string ())
 	{
 	  typ = args(2+arg_offset).string_value ();
 
@@ -469,8 +463,15 @@
 	}
       else
 	{
-	  error ("eigs: sigma must be a scalar or a string");
-	  return retval;
+	  sigma = args(2+arg_offset).complex_value ();
+
+	  if (! error_state)
+	    have_sigma = true;
+	  else
+	    {
+	      error ("eigs: sigma must be a scalar or a string");
+	      return retval;
+	    }
 	}
     }
 
--- a/src/pt-eval.cc	Mon Feb 23 12:55:32 2009 -0500
+++ b/src/pt-eval.cc	Mon Feb 23 16:29:20 2009 -0500
@@ -85,10 +85,15 @@
 }
 
 void
-tree_evaluator::visit_break_command (tree_break_command&)
+tree_evaluator::visit_break_command (tree_break_command& cmd)
 {
   if (! error_state)
-    tree_break_command::breaking = 1;
+    {
+      if (debug_mode)
+	do_breakpoint (cmd.is_breakpoint (), cmd.line (), cmd.column ());
+
+      tree_break_command::breaking = 1;
+    }
 }
 
 void
@@ -183,12 +188,18 @@
 void
 tree_evaluator::visit_global_command (tree_global_command& cmd)
 {
+  if (debug_mode)
+    do_breakpoint (cmd.is_breakpoint (), cmd.line (), cmd.column ());
+
   do_decl_init_list (do_global_init, cmd.initializer_list ());
 }
 
 void
 tree_evaluator::visit_static_command (tree_static_command& cmd)
 {
+  if (debug_mode)
+    do_breakpoint (cmd.is_breakpoint (), cmd.line (), cmd.column ());
+
   do_decl_init_list (do_static_init, cmd.initializer_list ());
 }
 
@@ -268,6 +279,9 @@
   if (error_state)
     return;
 
+  if (debug_mode)
+    do_breakpoint (cmd.is_breakpoint (), cmd.line (), cmd.column ());
+
   unwind_protect::begin_frame ("tree_evaluator::visit_simple_for_command");
 
   unwind_protect_bool (in_loop_command);
@@ -408,6 +422,9 @@
   if (error_state)
     return;
 
+  if (debug_mode)
+    do_breakpoint (cmd.is_breakpoint (), cmd.line (), cmd.column ());
+
   unwind_protect::begin_frame ("tree_evaluator::visit_complex_for_command");
 
   unwind_protect_bool (in_loop_command);
@@ -544,9 +561,8 @@
 
       tree_expression *expr = tic->condition ();
 
-      if (debug_mode)
-	do_breakpoint (! tic->is_else_clause () && tic->is_breakpoint (),
-		       tic->line (), tic->column ());
+      if (debug_mode && ! tic->is_else_clause ())
+	do_breakpoint (tic->is_breakpoint (), tic->line (), tic->column ());
 
       if (tic->is_else_clause () || expr->is_logically_true ("if"))
 	{
@@ -588,9 +604,10 @@
 }
 
 void
-tree_evaluator::visit_no_op_command (tree_no_op_command&)
+tree_evaluator::visit_no_op_command (tree_no_op_command& cmd)
 {
-  // Do nothing.
+  if (debug_mode && cmd.is_end_of_fcn_or_script ())
+    do_breakpoint (cmd.is_breakpoint (), cmd.line (), cmd.column (), true);
 }
 
 void
@@ -624,10 +641,15 @@
 }
 
 void
-tree_evaluator::visit_return_command (tree_return_command&)
+tree_evaluator::visit_return_command (tree_return_command& cmd)
 {
   if (! error_state)
-    tree_return_command::returning = 1;
+    {
+      if (debug_mode)
+	do_breakpoint (cmd.is_breakpoint (), cmd.line (), cmd.column ());
+
+      tree_return_command::returning = 1;
+    }
 }
 
 void
@@ -645,9 +667,6 @@
 void
 tree_evaluator::visit_statement (tree_statement& stmt)
 {
-  if (debug_mode)
-    do_breakpoint (stmt);
-
   tree_command *cmd = stmt.command ();
   tree_expression *expr = stmt.expression ();
 
@@ -667,6 +686,10 @@
 	    cmd->accept (*this);
 	  else
 	    {
+	      if (debug_mode)
+		do_breakpoint (expr->is_breakpoint (), expr->line (),
+			       expr->column ());
+
 	      if (in_fcn_or_script_body && Vsilent_functions)
 		expr->set_print_flag (false);
 
@@ -794,9 +817,8 @@
 	    {
 	      tree_switch_case *t = *p;
 
-	      if (debug_mode)
-		do_breakpoint (! t->is_default_case () && t->is_breakpoint (),
-			       t->line (), t->column ());
+	      if (debug_mode && ! t->is_default_case ())
+		do_breakpoint (t->is_breakpoint (), t->line (), t->column ());
 
 	      if (t->is_default_case () || t->label_matches (val))
 		{
@@ -1016,7 +1038,7 @@
   for (;;)
     {
       if (debug_mode)
-	do_breakpoint (expr->is_breakpoint (), l, c);
+	do_breakpoint (cmd.is_breakpoint (), l, c);
 
       if (expr->is_logically_true ("while"))
 	{
@@ -1073,10 +1095,13 @@
 	    goto cleanup;
 	}
 
+      if (quit_loop_now ())
+	break;
+
       if (debug_mode)
-	do_breakpoint (expr->is_breakpoint (), l, c);
+	do_breakpoint (cmd.is_breakpoint (), l, c);
 
-      if (quit_loop_now () || expr->is_logically_true ("do-until"))
+      if (expr->is_logically_true ("do-until"))
 	break;
     }