changeset 14069:88029530ffbc

maint: periodic merge of stable to default
author John W. Eaton <jwe@octave.org>
date Mon, 19 Dec 2011 02:18:28 -0500
parents 024a050fc147 (current diff) 6eeb9e8e63cf (diff)
children 7efa14e5a53c 42581c3b5cb4
files
diffstat 30 files changed, 123 insertions(+), 68 deletions(-) [+]
line wrap: on
line diff
--- a/configure.ac
+++ b/configure.ac
@@ -1499,7 +1499,7 @@
 
 AC_ARG_ENABLE([no-undefined],
   [AS_HELP_STRING([--enable-no-undefined],
-    [pass -no-undefined to libtool when linking linking Octave and its shared libraries (on by default)])],
+    [pass -no-undefined to libtool when linking Octave and its shared libraries (on by default)])],
   [case "${enableval}" in
     yes) NO_UNDEFINED_LDFLAG="-no-undefined" ;;
     no)  NO_UNDEFINED_LDFLAG="" ;;
old mode 100755
new mode 100644
--- a/liboctave/bsxfun.h
+++ b/liboctave/bsxfun.h
@@ -26,10 +26,12 @@
 
 #include "Array.h"
 #include "dim-vector.h"
+#include "lo-error.h"
 
 inline
 bool
-is_valid_bsxfun (const dim_vector& dx, const dim_vector& dy)
+is_valid_bsxfun (const std::string& name, const dim_vector& dx,
+                 const dim_vector& dy)
 {
   for (int i = 0; i < std::min (dx.length (), dy.length ()); i++)
     {
@@ -38,6 +40,10 @@
       if (! ( (xk == yk) || (xk == 1 && yk > 1) || (xk > 1 && yk == 1)))
         return false;
     }
+
+  (*current_liboctave_warning_with_id_handler)
+    ("Octave:auto-bsxfun", "%s: automatic broadcasting operation applied", name.c_str ());
+
   return true;
 }
 
@@ -46,7 +52,8 @@
 // different here.
 inline
 bool
-is_valid_inplace_bsxfun (const dim_vector& dr, const dim_vector& dx)
+is_valid_inplace_bsxfun (const std::string& name, const dim_vector& dr,
+                         const dim_vector& dx)
 {
   octave_idx_type drl = dr.length (), dxl = dx.length ();
   if (drl < dxl)
@@ -60,6 +67,10 @@
       if (! ( (rk == xk) || (rk > 1 && xk == 1)))
         return false;
     }
+
+  (*current_liboctave_warning_with_id_handler)
+    ("Octave:auto-bsxfun", "%s: automatic broadcasting operation applied", name.c_str ());
+
   return true;
 }
 
--- a/liboctave/mx-inlines.cc
+++ b/liboctave/mx-inlines.cc
@@ -372,7 +372,7 @@
       op (r.length (), r.fortran_vec (), x.data (), y.data ());
       return r;
     }
-  else if (is_valid_bsxfun (dx, dy))
+  else if (is_valid_bsxfun (opname, dx, dy))
     {
       return do_bsxfun_op (x, y, op, op1, op2);
     }
@@ -415,7 +415,7 @@
     {
       op (r.length (), r.fortran_vec (), x.data ());
     }
-  else if (is_valid_inplace_bsxfun (dr, dx))
+  else if (is_valid_inplace_bsxfun (opname, dr, dx))
     {
       do_inplace_bsxfun_op (r, x, op, op1);
     }
--- a/liboctave/oct-binmap.h
+++ b/liboctave/oct-binmap.h
@@ -174,7 +174,7 @@
     return binmap<U, T, R, F> (xa, ya(0), fcn);
   else if (xad != yad)
     {
-      if (is_valid_bsxfun (xad, yad))
+      if (is_valid_bsxfun (name, xad, yad))
         {
           bsxfun_wrapper<U, T, R, F>::set_f(fcn);
           return do_bsxfun_op (xa, ya,
old mode 100755
new mode 100644
--- a/liboctave/regexp.cc
+++ b/liboctave/regexp.cc
@@ -417,7 +417,7 @@
 {
   octave_idx_type len = buffer.length ();
 
-  Array<bool> retval (len, 1);
+  Array<bool> retval (dim_vector (len, 1));
 
   for (octave_idx_type i = 0; i < buffer.length (); i++)
     retval(i) = is_match (buffer(i));
old mode 100755
new mode 100644
old mode 100755
new mode 100644
--- a/scripts/general/accumarray.m
+++ b/scripts/general/accumarray.m
@@ -264,7 +264,7 @@
       elseif (islogical (vals))
         zero = true;
       elseif (fillval == 0 && all (vals(:) <= 0))
-        ## This is a common case - fillval is zero, all numbers nonpositive.
+        ## This is a common case - fillval is zero, all numbers non-positive.
         zero = 0;
       else
         zero = NaN; # Neutral value.
--- a/scripts/general/quadl.m
+++ b/scripts/general/quadl.m
@@ -203,11 +203,11 @@
 
 ## the values here are very high so it may be unavoidable that this fails
 %!assert (quadl (@(x) sin (3*x).*cosh (x).*sinh (x),10,15),
-%!         2.588424538641647e+10, -9e-15)
+%!         2.588424538641647e+10, -1.1e-14)
 
 ## extra parameters
 %!assert (quadl (@(x,a,b) sin (a + b*x), 0, 1, [], [], 2, 3),
-%!        cos(2)/3 - cos(5)/3, - 3e-16)
+%!        cos(2)/3 - cos(5)/3, -3e-16)
 
 ## test different tolerances.
 %!assert (quadl (@(x) sin (2 + 3*x).^2, 0, 10, 0.3, []),
--- a/scripts/gethelp.cc
+++ b/scripts/gethelp.cc
@@ -31,7 +31,7 @@
   // Perhaps someday we will want to do more here, so leave this as a
   // separate function.
 
-  return (s.substr (0, 9) == "Copyright");
+  return (s.substr (0, 9) == "Copyright" || s.substr (0, 6) == "Author");
 }
 
 // Eat whitespace and comments from FFILE, returning the text of the
--- a/scripts/linear-algebra/isdefinite.m
+++ b/scripts/linear-algebra/isdefinite.m
@@ -37,16 +37,16 @@
     print_usage ();
   endif
 
-  if (! ishermitian (x))
-    error ("isdefinite: X must be a hermitian matrix");
-  endif
-
   if (! isfloat (x))
     x = double (x);
   endif
 
   if (nargin == 1)
-    tol = 100 * eps(class (x)) * norm (x, "fro");
+    tol = 100 * eps (class (x)) * norm (x, "fro");
+  endif
+
+  if (! ishermitian (x, tol))
+    error ("isdefinite: X must be a Hermitian matrix");
   endif
 
   e = tol * eye (rows (x));
@@ -64,6 +64,7 @@
 
 endfunction
 
+
 %!test
 %! A = [-1 0; 0 -1];
 %! assert (isdefinite (A), -1)
@@ -81,4 +82,6 @@
 %! assert (isdefinite (A), 0)
 
 %!error isdefinite ()
-%!error isdefinite ([1 2; 3 4])
\ No newline at end of file
+%!error isdefinite (1,2,3)
+%!error <X must be a Hermitian matrix> isdefinite ([1 2; 3 4])
+
--- a/scripts/miscellaneous/debug.m
+++ b/scripts/miscellaneous/debug.m
@@ -42,7 +42,9 @@
 ##
 ## @item  dbstep
 ## @itemx dbnext
-## Execute one or more lines of code and re-enter debug mode.
+## Execute (step) one or more lines, follow execution into (step into) a
+## function call, or execute until the end of a function (step out), and
+## re-enter debug mode.
 ##
 ## @item dbcont
 ## Continue normal code execution from the debug prompt.
--- a/scripts/miscellaneous/fileattrib.m
+++ b/scripts/miscellaneous/fileattrib.m
@@ -17,7 +17,7 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn {Function File} {[@var{status}, @var{msg}, @var{msgid}] =} fileattrib (@var{file})
+## @deftypefn {Function File} {[@var{status}, @var{result}, @var{msgid}] =} fileattrib (@var{file})
 ## Return information about @var{file}.
 ##
 ## If successful, @var{status} is 1, with @var{result} containing a
--- a/scripts/plot/axis.m
+++ b/scripts/plot/axis.m
@@ -309,9 +309,9 @@
   ## Get the limits for axis ("tight").
   ## AX should be one of "x", "y", or "z".
   kids = findobj (ca, "-property", strcat (ax, "data"));
-  ## Since contours set the cdata for the patches to the hggroup zdata property, exclude
-  ## hgroups when determining the tight limits.
-  hg_kids = findobj (ca, "-property", strcat (ax, "data"), "type", "hggroup");
+  ## The data properties for hggroups mirror their children.
+  ## Exclude the redundant hgroup values.
+  hg_kids = findobj (kids, "type", "hggroup");
   kids = setdiff (kids, hg_kids);
   if (isempty (kids))
     ## Return the current limits.
@@ -319,20 +319,23 @@
   else
     data = get (kids, strcat (ax, "data"));
     scale = get (ca, strcat (ax, "scale"));
-    if (strcmp (scale, "log") && any (data > 0))
-      data(data<=0) = NaN;
+    if (! iscell (data))
+      data = {data};
+    end
+    if (strcmp (scale, "log"))
+      tmp = data;
+      data = cellfun (@(x) x(x>0), tmp, "uniformoutput", false);
+      n = cellfun (@isempty, data);
+      data(n) = cellfun (@(x) x(x<0), tmp(n), "uniformoutput", false);
     endif
-    if (iscell (data))
-      data = data (find (! cellfun ("isempty", data)));
-      if (! isempty (data))
-        lims_min = min (cellfun ("min", cellfun ("min", data, 'uniformoutput', false)(:)));
-        lims_max = max (cellfun ("max", cellfun ("max", data, 'uniformoutput', false)(:)));
-        lims = [lims_min, lims_max];
-      else
-        lims = [0, 1];
-      endif
+    data = cellfun (@(x) x(isfinite(x)), data, "uniformoutput", false);
+    data = data(! cellfun ("isempty", data));
+    if (! isempty (data))
+      lims_min = min (cellfun (@(x) min (x(:)), data(:)));
+      lims_max = max (cellfun (@(x) max (x(:)), data(:)));
+      lims = [lims_min, lims_max];
     else
-      lims = [min(data(:)), max(data(:))];
+      lims = [0, 1];
     endif
   endif
 
@@ -547,3 +550,26 @@
 %! set (gca, "yaxislocation", "zero")
 %! box off
 
+%!test
+%! hf = figure ("visible", "off");
+%! unwind_protect
+%!   plot (11:20, [21:24, NaN, -Inf, 27:30]);
+%!   hold all;
+%!   plot (11:20, 25.5 + rand (10));
+%!   axis tight;
+%!   assert (axis (), [11 20 21 30]);
+%! unwind_protect_cleanup
+%!   close (hf);
+%! end_unwind_protect
+
+%!test
+%! hf = figure ("visible", "off");
+%! unwind_protect
+%!   a = logspace (-5, 1, 10);
+%!   loglog (a, -a)
+%!   axis tight;
+%!   assert (axis (), [1e-5, 10, -10, -1e-5])
+%! unwind_protect_cleanup
+%!   close (hf);
+%! end_unwind_protect
+
--- a/scripts/polynomial/polyfit.m
+++ b/scripts/polynomial/polyfit.m
@@ -77,7 +77,7 @@
   endif
 
   if (! (isscalar (n) && n >= 0 && ! isinf (n) && n == fix (n)))
-    error ("polyfit: N must be a nonnegative integer");
+    error ("polyfit: N must be a non-negative integer");
   endif
 
   y_is_row_vector = (rows (y) == 1);
--- a/scripts/specfun/factorial.m
+++ b/scripts/specfun/factorial.m
@@ -30,7 +30,7 @@
   if (nargin != 1)
     print_usage ();
   elseif (any (n(:) < 0 | n(:) != fix (n(:))))
-    error ("factorial: N must all be nonnegative integers");
+    error ("factorial: N must all be non-negative integers");
   endif
   x = round (gamma (n+1));
 endfunction
@@ -38,5 +38,5 @@
 %!assert (factorial(5), prod(1:5))
 %!assert (factorial([1,2;3,4]), [1,2;6,24])
 %!assert (factorial(70), exp(sum(log(1:70))), -128*eps)
-%!fail ('factorial(5.5)', "must all be nonnegative integers")
-%!fail ('factorial(-3)', "must all be nonnegative integers")
+%!fail ('factorial(5.5)', "must all be non-negative integers")
+%!fail ('factorial(-3)', "must all be non-negative integers")
--- a/scripts/specfun/nchoosek.m
+++ b/scripts/specfun/nchoosek.m
@@ -68,7 +68,7 @@
   endif
   if ((isscalar(v) && v < k) || k < 0
       || k != round(k) || any (v < 0 || v != round(v)))
-    error ("nchoosek: args are nonnegative integers with V not less than K");
+    error ("nchoosek: args are non-negative integers with V not less than K");
   endif
 
   n = length (v);
--- a/scripts/statistics/tests/mcnemar_test.m
+++ b/scripts/statistics/tests/mcnemar_test.m
@@ -43,7 +43,7 @@
   if (! (min (size (x)) > 1) && issquare (x))
     error ("mcnemar_test: X must be a square matrix of size > 1");
   elseif (! (all (all (x >= 0)) && all (all (x == fix (x)))))
-    error ("mcnemar_test: all entries of X must be nonnegative integers");
+    error ("mcnemar_test: all entries of X must be non-negative integers");
   endif
 
   r = rows (x);
--- a/scripts/testfun/demo.m
+++ b/scripts/testfun/demo.m
@@ -122,11 +122,19 @@
     ## Process each demo without failing
     try
       block = code(idx(doidx(i)):idx(doidx(i)+1)-1);
-      ## Use an environment without variables
-      eval (cstrcat ("function __demo__()\n", block, "\nendfunction"));
-      ## Display the code that will be executed before executing it
-      printf ("%s example %d:%s\n\n", name, doidx(i), block);
-      __demo__;
+      ## FIXME: need to check for embedded test functions, which cause
+      ## segfaults, until issues with subfunctions in functions are resolved.
+      embed_func = regexp (block, '^\s*function ', 'once', 'lineanchors');
+      if (isempty (embed_func))
+        ## Use an environment without variables
+        eval (cstrcat ("function __demo__()\n", block, "\nendfunction"));
+        ## Display the code that will be executed before executing it
+        printf ("%s example %d:%s\n\n", name, doidx(i), block);
+        __demo__;
+      else
+        error (["Functions embedded in %!demo blocks are not allowed.\n", ...
+                "Use the %!function/%!endfunction syntax instead to define shared functions for testing.\n"]);
+      endif
     catch
       ## Let the programmer know which demo failed.
       printf ("%s example %d: failed\n%s\n", name, doidx(i), lasterr ());
--- a/scripts/testfun/test.m
+++ b/scripts/testfun/test.m
@@ -491,9 +491,17 @@
     ## evaluate code for test, shared, and assert.
     if (! isempty(__code))
       try
-        eval (sprintf ("function %s__test__(%s)\n%s\nendfunction",
-                       __shared_r,__shared, __code));
-        eval (sprintf ("%s__test__(%s);", __shared_r, __shared));
+        ## FIXME: need to check for embedded test functions, which cause
+        ## segfaults, until issues with subfunctions in functions are resolved.
+        embed_func = regexp (__code, '^\s*function ', 'once', 'lineanchors');
+        if (isempty (embed_func))
+          eval (sprintf ("function %s__test__(%s)\n%s\nendfunction",
+                         __shared_r,__shared, __code));
+          eval (sprintf ("%s__test__(%s);", __shared_r, __shared));
+        else
+          error (["Functions embedded in %!test blocks are not allowed.\n", ...
+                  "Use the %!function/%!endfunction syntax instead to define shared functions for testing.\n"]);
+        endif
       catch
         if (strcmp (__type, "xtest"))
            __msg = sprintf ("%sknown failure\n%s", __signal_fail, lasterr ());
--- a/src/DLD-FUNCTIONS/find.cc
+++ b/src/DLD-FUNCTIONS/find.cc
@@ -413,7 +413,7 @@
 
       if (error_state || (val < 0 || (! xisinf (val) && val != xround (val))))
         {
-          error ("find: N must be a nonnegative integer");
+          error ("find: N must be a non-negative integer");
           return retval;
         }
       else if (! xisinf (val))
--- a/src/OPERATORS/op-int.h
+++ b/src/OPERATORS/op-int.h
@@ -704,7 +704,7 @@
     dim_vector b_dims = b.dims (); \
     if (a_dims != b_dims) \
       { \
-        if (is_valid_bsxfun (a_dims, b_dims)) \
+        if (is_valid_bsxfun ("operator .^", a_dims, b_dims))     \
           { \
             return bsxfun_pow (a, b); \
           } \
@@ -730,7 +730,7 @@
     dim_vector b_dims = b.dims (); \
     if (a_dims != b_dims) \
       { \
-        if (is_valid_bsxfun (a_dims, b_dims)) \
+        if (is_valid_bsxfun ("operator .^", a_dims, b_dims))     \
           { \
             return bsxfun_pow (a, b); \
           } \
@@ -756,7 +756,7 @@
     dim_vector b_dims = b.dims (); \
     if (a_dims != b_dims) \
       { \
-        if (is_valid_bsxfun (a_dims, b_dims)) \
+        if (is_valid_bsxfun ("operator .^", a_dims, b_dims))     \
           { \
             return bsxfun_pow (a, b); \
           } \
@@ -782,7 +782,7 @@
     dim_vector b_dims = b.dims (); \
     if (a_dims != b_dims) \
       { \
-        if (is_valid_bsxfun (a_dims, b_dims)) \
+        if (is_valid_bsxfun ("operator .^", a_dims, b_dims))     \
           { \
             return bsxfun_pow (a, b); \
           } \
@@ -808,7 +808,7 @@
     dim_vector b_dims = b.dims (); \
     if (a_dims != b_dims) \
       { \
-        if (is_valid_bsxfun (a_dims, b_dims)) \
+        if (is_valid_bsxfun ("operator .^", a_dims, b_dims))     \
           { \
             return bsxfun_pow (a, b); \
           } \
--- a/src/error.cc
+++ b/src/error.cc
@@ -1577,7 +1577,7 @@
               if (! error_state && new_err.contains ("stack"))
                 {
                   octave_scalar_map new_err_stack =
-                    new_err.getfield("identifier").scalar_map_value ();
+                    new_err.getfield("stack").scalar_map_value ();
 
                   if (! error_state && new_err_stack.contains ("file"))
                     {
old mode 100755
new mode 100644
--- a/src/graphics.cc
+++ b/src/graphics.cc
@@ -5682,7 +5682,7 @@
             }
           if ((min_val <= 0 && max_val > 0))
             {
-              warning ("axis: omitting nonpositive data in log plot");
+              warning ("axis: omitting non-positive data in log plot");
               min_val = min_pos;
             }
           // FIXME -- maybe this test should also be relative?
old mode 100755
new mode 100644
--- a/src/pt-eval.cc
+++ b/src/pt-eval.cc
@@ -323,7 +323,6 @@
         octave_idx_type steps = rng.nelem ();
         double b = rng.base ();
         double increment = rng.inc ();
-        bool quit = false;
 
         for (octave_idx_type i = 0; i < steps; i++)
           {
@@ -363,8 +362,6 @@
         // A matrix or cell is reshaped to 2 dimensions and iterated by
         // columns.
 
-        bool quit = false;
-
         dim_vector dv = rhs.dims ().redim (2);
 
         octave_idx_type nrows = dv(0), steps = dv(1);
--- a/src/sparse.cc
+++ b/src/sparse.cc
@@ -177,7 +177,7 @@
 
 
                if (! error_state && (m < 0 || n < 0))
-                 error ("sparse: dimensions must be nonnegative");
+                 error ("sparse: dimensions must be non-negative");
              }
            else if (nargin != 3)
              print_usage ();
--- a/src/xpow.cc
+++ b/src/xpow.cc
@@ -1245,7 +1245,7 @@
 
   if (a_dims != b_dims)
     {
-      if (is_valid_bsxfun (a_dims, b_dims))
+      if (is_valid_bsxfun ("operator .^", a_dims, b_dims))
         {
           //Potentially complex results
           NDArray xa = octave_value_extract<NDArray> (a);
@@ -1333,7 +1333,7 @@
 
   if (a_dims != b_dims)
     {
-      if (is_valid_bsxfun (a_dims, b_dims))
+      if (is_valid_bsxfun ("operator .^", a_dims, b_dims))
         {
           return bsxfun_pow (a, b);
         }
@@ -1432,7 +1432,7 @@
 
   if (a_dims != b_dims)
     {
-      if (is_valid_bsxfun (a_dims, b_dims))
+      if (is_valid_bsxfun ("operator .^", a_dims, b_dims))
         {
           return bsxfun_pow (a, b);
         }
@@ -1482,7 +1482,7 @@
 
   if (a_dims != b_dims)
     {
-      if (is_valid_bsxfun (a_dims, b_dims))
+      if (is_valid_bsxfun ("operator .^", a_dims, b_dims))
         {
           return bsxfun_pow (a, b);
         }
@@ -2598,7 +2598,7 @@
 
   if (a_dims != b_dims)
     {
-      if (is_valid_bsxfun (a_dims, b_dims))
+      if (is_valid_bsxfun ("operator .^", a_dims, b_dims))
         {
           //Potentially complex results
           FloatNDArray xa = octave_value_extract<FloatNDArray> (a);
@@ -2686,7 +2686,7 @@
 
   if (a_dims != b_dims)
     {
-      if (is_valid_bsxfun (a_dims, b_dims))
+      if (is_valid_bsxfun ("operator .^", a_dims, b_dims))
         {
           return bsxfun_pow (a, b);
         }
@@ -2785,7 +2785,7 @@
 
   if (a_dims != b_dims)
     {
-      if (is_valid_bsxfun (a_dims, b_dims))
+      if (is_valid_bsxfun ("operator .^", a_dims, b_dims))
         {
           return bsxfun_pow (a, b);
         }
@@ -2835,7 +2835,7 @@
 
   if (a_dims != b_dims)
     {
-      if (is_valid_bsxfun (a_dims, b_dims))
+      if (is_valid_bsxfun ("operator .^", a_dims, b_dims))
         {
           return bsxfun_pow (a, b);
         }