changeset 12602:dc5920733a96

Trivial merge with stable except for ChangeLogs
author Jordi Gutiérrez Hermoso <jordigh@gmail.com>
date Tue, 12 Apr 2011 23:22:26 -0500
parents 7c000c70f873 (current diff) 8c52ab9842c9 (diff)
children 114ccc6da959
files doc/ChangeLog scripts/ChangeLog src/ChangeLog
diffstat 9 files changed, 125 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/doc/ChangeLog	Tue Apr 12 17:42:00 2011 -0700
+++ b/doc/ChangeLog	Tue Apr 12 23:22:26 2011 -0500
@@ -1,3 +1,13 @@
+2011-04-12  Ben Abbott  <bpabbott@mac.com>
+
+	* interpreter/data.txi: Replace xref{Data Structures} with
+	xref{Structures}.
+
+2011-04-11  Rik  <octave@nomad.inbox5.com>
+
+	* interpreter/func.txi: Add discussion of isargout to Ignoring
+	Arguments section of documentation.
+
 2011-04-08  Rik  <octave@nomad.inbox5.com>
 
 	* interpreter/stats.txi: Deprecate studentize(), replace with
--- a/doc/interpreter/container.txi	Tue Apr 12 17:42:00 2011 -0700
+++ b/doc/interpreter/container.txi	Tue Apr 12 23:22:26 2011 -0500
@@ -28,13 +28,13 @@
 another data container, the comma separated list.
 
 @menu
-* Data Structures::
+* Structures::
 * Cell Arrays::
 * Comma Separated Lists::
 @end menu
 
-@node Data Structures
-@section Data Structures
+@node Structures
+@section Structures
 @cindex structures
 @cindex data structures
 
@@ -370,12 +370,50 @@
 
 @node Creating Structures
 @subsection Creating Structures
+@cindex dynamic naming
 
-As well as indexing a structure with ".", Octave can create a structure
-with the @code{struct} command.  @code{struct} takes pairs of arguments,
-where the first argument in the pair is the fieldname to include in the
-structure and the second is a scalar or cell array, representing the
-values to include in the structure or structure array.  For example:
+Besides the index operator ".", Octave can use dynamic naming "(var)" or the
+@code{struct} function to create structures.  Dynamic naming uses the string
+value of a variable as the field name.  For example,
+@example
+@group
+a = "field2";
+x.a = 1;
+x.(a) = 2;
+x
+     @result{} x =
+        @{
+          a =  1
+          field2 =  2
+        @}
+@end group
+@end example
+
+More realistically, all of the functions that operate on strings can be used
+to build the correct field name before it is entered into the data structure.
+
+@example
+@group
+names = ["Bill"; "Mary"; "John"];
+ages  = [37; 26; 31];
+for i = 1:rows (names)
+  database.(names(i,:)) = ages(i);
+endfor
+database
+     @result{} database =
+        @{
+          Bill =  37
+          Mary =  26
+          John =  31
+        @}
+@end group
+@end example
+
+The third way to create structures is the @code{struct} command.  @code{struct}
+takes pairs of arguments, where the first argument in the pair is the fieldname
+to include in the structure and the second is a scalar or cell array,
+representing the values to include in the structure or structure array.  For
+example:
 
 @example
 @group
@@ -414,7 +452,7 @@
 @end example
 
 If you want to create a struct which contains a cell array as an
-individual field, you have to put it into another cell array like in
+individual field, you must wrap it in another cell array as shown in
 the following example:
 
 @example
--- a/doc/interpreter/data.txi	Tue Apr 12 17:42:00 2011 -0700
+++ b/doc/interpreter/data.txi	Tue Apr 12 23:22:26 2011 -0500
@@ -146,7 +146,7 @@
 with indices limited to strings, but the syntax is more like C-style
 structures.
 
-@xref{Data Structures}, for more information.
+@xref{Structures}, for more information.
 
 @node Cell Array Objects
 @subsection Cell Array Objects
--- a/doc/interpreter/func.txi	Tue Apr 12 17:42:00 2011 -0700
+++ b/doc/interpreter/func.txi	Tue Apr 12 23:22:26 2011 -0500
@@ -342,8 +342,6 @@
 
 @DOCSTRING(nargoutchk)
 
-@DOCSTRING(isargout)
-
 @anchor{doc-varargin} @anchor{doc-varargout}
 @node Variable-length Argument Lists
 @section Variable-length Argument Lists
@@ -456,6 +454,26 @@
 
 The value of @code{nargin} is not affected by using this declaration.
 
+Return arguments can also be ignored using the same syntax.  Functions may
+take advantage of ignored outputs to reduce the number of calculations
+performed.  To do so, use the @code{isargout} function to query whether the
+output argument is wanted.  For example:
+
+@example
+@group
+function [out1, out2] = long_function (x, y, z)
+  if (isargout (1))
+    ## Long calculation
+    @dots{}
+    out1 = result;
+  endif
+  @dots{}
+endfunction
+@end group
+@end example
+
+@DOCSTRING(isargout)
+
 @node Variable-length Return Lists
 @section Variable-length Return Lists
 @cindex variable-length return lists
--- a/doc/interpreter/octave.texi	Tue Apr 12 17:42:00 2011 -0700
+++ b/doc/interpreter/octave.texi	Tue Apr 12 23:22:26 2011 -0500
@@ -326,11 +326,11 @@
 
 Data Containers
 
-* Data Structures::
+* Structures::
 * Cell Arrays::
 * Comma Separated Lists::
 
-Data Structures
+Structures
 
 * Basic Usage and Examples::
 * Structure Arrays::
--- a/scripts/ChangeLog	Tue Apr 12 17:42:00 2011 -0700
+++ b/scripts/ChangeLog	Tue Apr 12 23:22:26 2011 -0500
@@ -1,3 +1,18 @@
+2011-04-12  Ben Abbott  <bpabbott@mac.com>
+
+	* miscellaneous/getappdata.m: If no property name is provided, return
+	a structure representing the appdata.
+
+2011-04-12  Marco Caliari  <marco.caliari@univr.it>
+
+	* general/quadgk.m: Fix problem with -Inf bound on integral (bug
+	#33055). 
+
+2011-04-11  Ben Abbott  <bpabbott@mac.com>
+
+	* miscellaneous/getappdata.m: If appdata propery does not exist, return
+	an empty matrix.
+
 2011-04-08  Rik  <octave@nomad.inbox5.com>
 
 <<<<<<< local
--- a/scripts/general/quadgk.m	Tue Apr 12 17:42:00 2011 -0700
+++ b/scripts/general/quadgk.m	Tue Apr 12 23:22:26 2011 -0500
@@ -223,9 +223,9 @@
       if (!isempty (waypoints))
         tmp = sqrt (b - waypoints);
         trans = @(x)  - x ./ (x + 1);
-        subs = [0; trans(tmp); 1];
+        subs = [-1; trans(tmp); 0];
       else
-        subs = linspace (0, 1, 11)';
+        subs = linspace (-1, 0, 11)';
       endif
       h = 1;
       h0 = b - a;
@@ -449,3 +449,4 @@
 %!assert (quadgk (@(z) log (z), 1+1i, 1+1i, 'WayPoints', [1-1i, -1,-1i, -1+1i]), -pi * 1i, 1e-6)
 
 %!assert (quadgk (@(x) exp(-x .^ 2), -Inf, Inf), sqrt(pi), 1e-6)
+%!assert (quadgk (@(x) exp(-x .^ 2), -Inf, 0), sqrt(pi)/2, 1e-6)
--- a/scripts/miscellaneous/getappdata.m	Tue Apr 12 17:42:00 2011 -0700
+++ b/scripts/miscellaneous/getappdata.m	Tue Apr 12 23:22:26 2011 -0500
@@ -18,6 +18,9 @@
 ## @deftypefn {Function File} {@var{value} =} getappdata (@var{h}, @var{name})
 ## Return the @var{value} for named application data for the object(s) with
 ## handle(s) @var{h}.
+## @deftypefnx {Function File} {@var{appdata} =} getappdata (@var{h})
+## Returns a structure, @var{appdata}, whose fields correspond to the appdata
+## properties.
 ## @end deftypefn
 
 ## Author: Ben Abbott <bpabbott@mac.com>
@@ -25,19 +28,31 @@
 
 function val = getappdata (h, name)
 
-  if (! (all (ishandle (h)) && ischar (name)))
+  if (all (ishandle (h)) && nargin == 2 && ischar (name))
+    ## FIXME - Is there a better way to handle non-existent appdata
+    ## and missing fields?
+    val = cell (numel (h), 1);
+    appdata = struct();
+    for nh = 1:numel(h)
+      try
+        appdata = get (h(nh), "__appdata__");
+      catch
+        appdata.(name) = [];
+      end_try_catch
+      val(nh) = {appdata.(name)};
+    end
+    if (nh == 1)
+      val = val{1};
+    endif
+  elseif (ishandle (h) && numel (h) == 1 && nargin == 1)
+    try
+      val = get (h, "__appdata__");
+    catch
+      val = struct ();
+    end_try_catch
+  else
     error ("getappdata: invalid input");
   endif
 
-  appdata(numel(h)) = struct();
-  for nh = 1:numel(h)
-    appdata(nh) = get (h(nh), "__appdata__");
-  end
-  if (nh > 1)
-    val = {appdata.(name)};
-  else
-    val = appdata.(name);
-  endif
-
 endfunction
 
--- a/src/ChangeLog	Tue Apr 12 17:42:00 2011 -0700
+++ b/src/ChangeLog	Tue Apr 12 23:22:26 2011 -0500
@@ -1,6 +1,6 @@
 2011-04-10  John Eaton  <jwe@octave.org>
 
-	* graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
+	* graphics.cc (Fishandle) Accept vector of handles (bug #33025).
 
 2011-04-08  Rik  <octave@nomad.inbox5.com>