changeset 20252:b5d2f6954c48

maint: Periodic merge of stable to default.
author John W. Eaton <jwe@octave.org>
date Sat, 23 May 2015 10:19:50 -0400
parents 4e15a4c331e7 (current diff) 9866b3202c52 (diff)
children b2100e1659ac
files scripts/io/strread.m
diffstat 9 files changed, 139 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/CITATION	Fri May 22 19:12:57 2015 -0400
+++ b/CITATION	Sat May 23 10:19:50 2015 -0400
@@ -1,19 +1,16 @@
 To cite GNU Octave in publications use:
 
-  John W. Eaton, David Bateman, Søren Hauberg, Rik Wehbring (2014).
-  GNU Octave version 3.8.1 manual: a high-level interactive language for
+  John W. Eaton, David Bateman, Søren Hauberg, Rik Wehbring (2015).
+  GNU Octave version 4.0.0 manual: a high-level interactive language for
   numerical computations.
-  CreateSpace Independent Publishing Platform.  ISBN 1441413006,
   URL http://www.gnu.org/software/octave/doc/interpreter/
 
 A BibTeX entry for LaTeX users is:
 
   @book{,
     author    = {John W. Eaton, David Bateman, S\oren Hauberg, and Rik Wehbring},
-    title     = {{GNU Octave} version 3.8.1 manual: a high-level interactive language for numerical computations},
-    publisher = {CreateSpace Independent Publishing Platform},
-    year      = {2014},
-    note      = {{ISBN} 1441413006},
+    title     = {{GNU Octave} version 4.0.0 manual: a high-level interactive language for numerical computations},
+    year      = {2015},
     url       = {http://www.gnu.org/software/octave/doc/interpreter},
   }
 
--- a/examples/code/make_int.cc	Fri May 22 19:12:57 2015 -0400
+++ b/examples/code/make_int.cc	Sat May 23 10:19:50 2015 -0400
@@ -102,7 +102,7 @@
 
   void decrement (void) { --scalar; }
 
-  void print (std::ostream& os, bool pr_as_read_syntax = false) const;
+  void print (std::ostream& os, bool pr_as_read_syntax = false);
 
 private:
 
@@ -113,10 +113,10 @@
 };
 
 void
-octave_integer::print (std::ostream& os, bool pr_as_read_syntax) const
+octave_integer::print (std::ostream& os, bool pr_as_read_syntax)
 {
   os << scalar;
-  // octave_print_internal (os, scalar, pr_as_read_syntax);
+  newline (os);
 }
 
 #ifdef DEFUNOP_OP
--- a/libgui/graphics/Canvas.cc	Fri May 22 19:12:57 2015 -0400
+++ b/libgui/graphics/Canvas.cc	Sat May 23 10:19:50 2015 -0400
@@ -253,24 +253,22 @@
         {
           axes::properties& ap = Utils::properties<axes> (ax);
 
-          if (ap.handlevisibility_is ("on") && ap.is_visible ())
-            {
-              std::string tmp;
+          std::string tmp;
 
-              // If any grid is off, then turn them all on.  If they are all
-              // on, then turn them off.
+          // If any grid is off, then turn them all on.  If they are all
+          // on, then turn them off.
 
-              std::string state = ((ap.get_xgrid () == "off"
-                                    || ap.get_ygrid () == "off"
-                                    || ap.get_zgrid () == "off")
-                                   ? "on" : "off");
+          std::string state = ((ap.get_xgrid () == "off"
+                                || ap.get_ygrid () == "off"
+                                || ap.get_zgrid () == "off")
+                               ? "on" : "off");
 
-              ap.set_xgrid (state);
-              ap.set_ygrid (state);
-              ap.set_zgrid (state);
+          ap.set_xgrid (state);
+          ap.set_ygrid (state);
+          ap.set_zgrid (state);
 
-              redraw (true);
-            }
+          redraw (true);
+            
         }
     }
 }
@@ -304,12 +302,9 @@
         {
           axes::properties& ap = Utils::properties<axes> (ax);
 
-          if (ap.handlevisibility_is ("on") && ap.is_visible ())
-            {
-              autoscale_axes (ap);
+          autoscale_axes (ap);
 
-              redraw (true);
-            }
+          redraw (true);
         }
     }
 }
--- a/libinterp/corefcn/dlmread.cc	Fri May 22 19:12:57 2015 -0400
+++ b/libinterp/corefcn/dlmread.cc	Sat May 23 10:19:50 2015 -0400
@@ -474,11 +474,14 @@
       if (c1 >= c)
         c1 = c - 1;
 
-      // Now take the subset of the matrix.
-      if (iscmplx)
-        cdata = cdata.extract (0, c0, r1, c1);
-      else
-        rdata = rdata.extract (0, c0, r1, c1);
+      // Now take the subset of the matrix if there are any values.
+      if (i > 0 || j > 0)
+        {
+          if (iscmplx)
+            cdata = cdata.extract (0, c0, r1, c1);
+          else
+            rdata = rdata.extract (0, c0, r1, c1);
+        }
 
       if (iscmplx)
         retval(0) = cdata;
--- a/liboctave/array/Array.h	Fri May 22 19:12:57 2015 -0400
+++ b/liboctave/array/Array.h	Sat May 23 10:19:50 2015 -0400
@@ -249,11 +249,29 @@
   void clear (octave_idx_type r, octave_idx_type c)
   { clear (dim_vector (r, c)); }
 
+  // Number of elements in the array. These are all synonyms.
   //@{
-  //! Number of elements in the array. These are all synonyms.
+  //! Number of elements in the array.
+  //! Synonymous with length(), nelem(), and numel().
   octave_idx_type capacity (void) const { return slice_len; }
+
+  //! Number of elements in the array.
+  /*! Synonymous with capacity(), nelem(), and numel().
+
+      @note
+      This is @em not the same as @c %length() at the Octave interpreter.
+      At the Octave interpreter, the function @c %length() returns the
+      length of the greatest dimension.  This method returns the total
+      number of elements.
+   */
   octave_idx_type length (void) const { return capacity (); }
+
+  //! Number of elements in the array.
+  //! Synonymous with capacity(), length(), and numel().
   octave_idx_type nelem (void) const { return capacity (); }
+
+  //! Number of elements in the array.
+  //! Synonymous with capacity(), length(), and nelem().
   octave_idx_type numel (void) const { return nelem (); }
   //@}
 
--- a/liboctave/array/dim-vector.h	Fri May 22 19:12:57 2015 -0400
+++ b/liboctave/array/dim-vector.h	Sat May 23 10:19:50 2015 -0400
@@ -140,6 +140,8 @@
 
 public:
 
+// There are constructors for up to 7 dimensions initialized this way.
+// More can be added if necessary.
 #define ASSIGN_REP(i) rep[i] = d ## i;
 #define DIM_VECTOR_CTOR(N) \
   dim_vector (OCT_MAKE_DECL_LIST (octave_idx_type, d, N)) \
@@ -148,12 +150,54 @@
     OCT_ITERATE_MACRO (ASSIGN_REP, N) \
   }
 
-  // Add more if needed.
+  //! Construct dim_vector for 2 dimensional array.
+  /*!
+    It can be used to construct a 2D array.  Example:
+
+    @code{.cc}
+    dim_vector dv (7, 5);
+    Matrix mat (dv);
+    @endcode
+
+    The constructed dim_vector @c dv will have two elements, @f$[7, 5]@f$,
+    one for each dimension.  It can then be used to construct a Matrix
+    with such dimensions, i.e., 7 rows and 5 columns.
+
+    There are constructors available for up to 7 dimensions.  For a higher
+    number of dimensions, use redim() or resize().
+
+    Note that that there is no constructor for a 1 element dim_vector.
+    This is because there are no 1 dimensional Array in liboctave.  Such
+    constructor did exist in liboctave but was removed in version 4.0.0
+    due to its potential for confusion.
+  */
   DIM_VECTOR_CTOR (2)
+
+  //! Construct dim_vector for 3 dimensional array.
+  /*!
+    It can be used to construct a 3D array.  Example:
+
+    @code{.cc}
+    NDArray A (dim_vector (7, 5, 4));
+    @endcode
+
+    This will construct a 3 dimensional NDArray of lengths 7, 5, and 4,
+    on the first, second, and third dimension (rows, columns, and pages)
+    respectively.
+  */
   DIM_VECTOR_CTOR (3)
+
+  //! Construct dim_vector for 4 dimensional array.
+  //! @see dim_vector(octave_idx_type d0, octave_idx_type d1)
   DIM_VECTOR_CTOR (4)
+  //! Construct dim_vector for 5 dimensional array.
+  //! @see dim_vector(octave_idx_type d0, octave_idx_type d1)
   DIM_VECTOR_CTOR (5)
+  //! Construct dim_vector for 6 dimensional array.
+  //! @see dim_vector(octave_idx_type d0, octave_idx_type d1)
   DIM_VECTOR_CTOR (6)
+  //! Construct dim_vector for 7 dimensional array.
+  //! @see dim_vector(octave_idx_type d0, octave_idx_type d1)
   DIM_VECTOR_CTOR (7)
 
 #undef ASSIGN_REP
--- a/scripts/io/strread.m	Fri May 22 19:12:57 2015 -0400
+++ b/scripts/io/strread.m	Sat May 23 10:19:50 2015 -0400
@@ -703,6 +703,9 @@
         lastline = ...
           min (num_words_per_line * format_repeat_count + m - 1, numel (words));
         data = words(m:num_words_per_line:lastline);
+        if (num_lines > format_repeat_count)
+          num_lines = format_repeat_count;
+        endif
       endif
 
       ## Map to format
@@ -879,6 +882,18 @@
 %! a = strread ("a b c, d e, , f", "%s", "delimiter", ",");
 %! assert (a, {"a b c"; "d e"; ""; "f"});
 
+%! ## Format repeat counters w & w/o trailing EOL even within partly read files
+%!test
+%! [a, b] = strread ("10 a 20 b\n 30 c 40", "%d %s", 4);
+%! assert (a, int32 ([10; 20; 30; 40]));
+%! assert (b, {"a"; "b"; "c"});
+%! [a, b] = strread ("10 a 20 b\n 30 c 40\n", "%d %s", 4);
+%! assert (a, int32 ([10; 20; 30; 40]));
+%! assert (b, {"a"; "b"; "c"; ""});
+%! [a, b] = strread ("10 a 20 b\n 30 c 40", "%d %s", 1);
+%! assert (a, int32 (10));
+%! assert (b, {"a"});
+
 %!test
 %! ## Bug #33536
 %! [a, b, c] = strread ("1,,2", "%s%s%s", "delimiter", ",");
@@ -1040,7 +1055,7 @@
 %! assert (b, [2; 5; 8]);
 %! assert (c, [3; 6; 9]);
 
-## Test #3 bug #42609
+## Test #4 bug #42609
 %!test
 %! [a, b, c] = strread ("1 2\n3\n4 5\n6\n7 8\n9\n", '%f %f\n%f');
 %! assert (a, [1;4;7]);
--- a/scripts/io/textread.m	Fri May 22 19:12:57 2015 -0400
+++ b/scripts/io/textread.m	Sat May 23 10:19:50 2015 -0400
@@ -115,7 +115,12 @@
   endofline = find (strcmpi (varargin, "endofline"), 1);
   if (! isempty (endofline))
     ## 'endofline' option set by user.
-    if (! ischar (varargin{endofline + 1}));
+    if (ischar (varargin{endofline + 1}))
+      eol_char = varargin{endofline + 1};
+      if (! any (strcmp (eol_char, {"", "\n", "\r", "\r\n"})))
+        error ("textscan: illegal EndOfLine character value specified");
+      endif
+    else
       error ("character value required for EndOfLine");
     endif
   else
@@ -310,6 +315,20 @@
 %! unlink (f);
 %! assert (A, [0 2 0 4; 5 0 0 0], 1e-6);
 
+## Test endofline
+%!test
+%! f = tempname ();
+%! fid = fopen (f, "w");
+%! fprintf (fid, "a\rb\rc");
+%! fclose (fid);
+%! ## Test EOL detection
+%! d = textread (f, "%s");
+%! assert (d, {"a";"b";"c"});
+%! ## Test explicit EOL specification (bug #45046)
+%! d = textread (f, "%s", "endofline", "\r");
+%! assert (d, {"a"; "b"; "c"});
+%! unlink (f);
+
 ## Test input validation
 %!error textread ()
 %!error textread (1)
--- a/scripts/plot/draw/fplot.m	Fri May 22 19:12:57 2015 -0400
+++ b/scripts/plot/draw/fplot.m	Sat May 23 10:19:50 2015 -0400
@@ -60,10 +60,18 @@
 ## @end group
 ## @end example
 ##
-## Note: @code{fplot} works best with continuous functions.  Functions with
+## Programming Notes:
+##
+## @code{fplot} works best with continuous functions.  Functions with
 ## discontinuities are unlikely to plot well.  This restriction may be removed
 ## in the future.
-## @seealso{ezplot, plot}
+##
+## @code{fplot} requires that the function accept and return a vector argument.
+## Consider this when writing user-defined functions and use @code{.*},
+## @code{./}, etc.  See the function @code{vectorize} for potentially
+## converting inline or anonymous functions to vectorized versions.
+##  
+## @seealso{ezplot, plot, vectorize}
 ## @end deftypefn
 
 ## Author: Paul Kienzle <pkienzle@users.sf.net>