changeset 7536:4dda6fbc8ba6

oct-rand.cc: fix typo
author John W. Eaton <jwe@octave.org>
date Tue, 26 Feb 2008 20:29:58 -0500
parents bda16af4fd2f
children a2950622f070
files liboctave/ChangeLog liboctave/oct-rand.cc
diffstat 2 files changed, 20 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/ChangeLog	Tue Feb 26 18:45:57 2008 -0500
+++ b/liboctave/ChangeLog	Tue Feb 26 20:29:58 2008 -0500
@@ -1,5 +1,9 @@
 2008-02-26  John W. Eaton  <jwe@octave.org>
 
+	* oct-rand.cc (get_dist_id): Fix typo.
+	(get_dist_id, octave_rand::distribution, octave_rand::scalar,
+	fill_rand): Improve error messages.
+
 	* oct-rand.cc (unknown_dist): New dist type.
 	(uniform_dist, normal_dist, expon_dist, poisson_dist, gamma_dist):
 	Use static const int instead of #define.
--- a/liboctave/oct-rand.cc	Tue Feb 26 18:45:57 2008 -0500
+++ b/liboctave/oct-rand.cc	Tue Feb 26 20:29:58 2008 -0500
@@ -197,10 +197,11 @@
     retval = expon_dist;
   else if (d == "poisson" || d == "randp")
     retval = poisson_dist;
-  else if (d == "gamma" || d == "rangd")
+  else if (d == "gamma" || d == "randg")
     retval = gamma_dist;
   else
-    (*current_liboctave_error_handler) ("rand: invalid distribution");
+    (*current_liboctave_error_handler)
+      ("rand: invalid distribution `%s'", d.c_str ());
 
   return retval;
 }
@@ -349,7 +350,8 @@
       break;
 
     default:
-      (*current_liboctave_error_handler) ("rand: invalid distribution");
+      (*current_liboctave_error_handler)
+	("rand: invalid distribution ID = %d", current_distribution);
       break;
     }
 
@@ -359,7 +361,9 @@
 void
 octave_rand::distribution (const std::string& d)
 {
-  switch (get_dist_id (d))
+  int id = get_dist_id (d);
+
+  switch (id)
     {
     case uniform_dist:
       octave_rand::uniform_distribution ();
@@ -382,7 +386,8 @@
       break;
 
     default:
-      (*current_liboctave_error_handler) ("rand: invalid distribution");
+      (*current_liboctave_error_handler)
+	("rand: invalid distribution ID = %d", id);
       break;
     }
 }
@@ -480,7 +485,8 @@
 	  break;
 
 	default:
-	  (*current_liboctave_error_handler) ("rand: invalid distribution");
+	  (*current_liboctave_error_handler) 
+	    ("rand: invalid distribution ID = %d", current_distribution);
 	  break;
 	}
     }
@@ -509,7 +515,8 @@
 	  break;
 
 	default:
-	  (*current_liboctave_error_handler) ("rand: invalid distribution");
+	  (*current_liboctave_error_handler)
+	    ("rand: invalid distribution ID = %d", current_distribution);
 	  break;
 	}
 
@@ -613,7 +620,8 @@
       break;
 
     default:
-      (*current_liboctave_error_handler) ("rand: invalid distribution");
+      (*current_liboctave_error_handler)
+	("rand: invalid distribution ID = %d", current_distribution);
       break;
     }