comparison scripts/general/accumarray.m @ 13929:9cae456085c2

Grammarcheck of documentation before 3.6.0 release. * accumarray.m, blkdiag.m, nargoutchk.m, nthargout.m, profexplore.m, profile.m, computer.m, orderfields.m, recycle.m, version.m, sqp.m, matlabroot.m, __plt_get_axis_arg__.m, isonormals.m, isosurface.m, __fltk_file_filter__.m, __is_function__.m, __uigetdir_fltk__.m, __uigetfile_fltk__.m, __uiobject_split_args__.m, __uiputfile_fltk__.m, uicontextmenu.m, uiresume.m, uiwait.m, mkpp.m, ppder.m, residue.m, addpref.m, getpref.m, ispref.m, loadprefs.m, prefsfile.m, saveprefs.m, rmpref.m, setpref.m, fftshift.m, bicg.m, bicgstab.m, cgs.m, gmres.m, __sprand_impl__.m, quantile.m, deblank.m, strsplit.m, addtodate.m, bsxfun.cc, kron.cc, regexp.cc, data.cc, file-io.cc, graphics.cc, load-save.cc, mappers.cc: Grammarcheck of documentation before 3.6.0 release.
author Rik <octave@nomad.inbox5.com>
date Wed, 23 Nov 2011 08:38:19 -0800
parents 9ab64f063c96
children 9de488c6c59c
comparison
equal deleted inserted replaced
13928:2892fd834446 13929:9cae456085c2
22 ## @deftypefnx {Function File} {} accumarray (@var{subs}, @var{vals}, @dots{}) 22 ## @deftypefnx {Function File} {} accumarray (@var{subs}, @var{vals}, @dots{})
23 ## 23 ##
24 ## Create an array by accumulating the elements of a vector into the 24 ## Create an array by accumulating the elements of a vector into the
25 ## positions defined by their subscripts. The subscripts are defined by 25 ## positions defined by their subscripts. The subscripts are defined by
26 ## the rows of the matrix @var{subs} and the values by @var{vals}. Each 26 ## the rows of the matrix @var{subs} and the values by @var{vals}. Each
27 ## row of @var{subs} corresponds to one of the values in @var{vals}. If 27 ## row of @var{subs} corresponds to one of the values in @var{vals}. If
28 ## @var{vals} is a scalar, it will be used for each of the row of 28 ## @var{vals} is a scalar, it will be used for each of the row of
29 ## @var{subs}. 29 ## @var{subs}.
30 ## 30 ##
31 ## The size of the matrix will be determined by the subscripts 31 ## The size of the matrix will be determined by the subscripts
32 ## themselves. However, if @var{sz} is defined it determines the matrix 32 ## themselves. However, if @var{sz} is defined it determines the matrix
33 ## size. The length of @var{sz} must correspond to the number of columns 33 ## size. The length of @var{sz} must correspond to the number of columns
34 ## in @var{subs}. An exception is if @var{subs} has only one column, in 34 ## in @var{subs}. An exception is if @var{subs} has only one column, in
35 ## which case @var{sz} may be the dimensions of a vector and the subscripts 35 ## which case @var{sz} may be the dimensions of a vector and the subscripts
36 ## of @var{subs} are taken as the indices into it. 36 ## of @var{subs} are taken as the indices into it.
37 ## 37 ##
38 ## The default action of @code{accumarray} is to sum the elements with 38 ## The default action of @code{accumarray} is to sum the elements with
39 ## the same subscripts. This behavior can be modified by defining the 39 ## the same subscripts. This behavior can be modified by defining the
40 ## @var{func} function. This should be a function or function handle 40 ## @var{func} function. This should be a function or function handle
41 ## that accepts a column vector and returns a scalar. The result of the 41 ## that accepts a column vector and returns a scalar. The result of the
42 ## function should not depend on the order of the subscripts. 42 ## function should not depend on the order of the subscripts.
43 ## 43 ##
44 ## The elements of the returned array that have no subscripts associated 44 ## The elements of the returned array that have no subscripts associated
45 ## with them are set to zero. Defining @var{fillval} to some other value 45 ## with them are set to zero. Defining @var{fillval} to some other value
46 ## allows these values to be defined. This behaviour changes, however, 46 ## allows these values to be defined. This behaviour changes, however,
47 ## for certain values of @var{func}. If @var{func} is @code{min} 47 ## for certain values of @var{func}. If @var{func} is @code{min}
48 ## (respectively, @code{max}) then the result will be filled with the 48 ## (respectively, @code{max}) then the result will be filled with the
49 ## minimum (respectively, maximum) integer if @var{vals} is of integral 49 ## minimum (respectively, maximum) integer if @var{vals} is of integral
50 ## type, logical false (respectively, logical true) if @var{vals} is of 50 ## type, logical false (respectively, logical true) if @var{vals} is of
51 ## logical type, zero if @var{fillval} is zero and all values are 51 ## logical type, zero if @var{fillval} is zero and all values are
52 ## nonpositive (respectively, nonnegative), and NaN otherwise. 52 ## nonpositive (respectively, non-negative), and NaN otherwise.
53 ## 53 ##
54 ## By default @code{accumarray} returns a full matrix. If 54 ## By default @code{accumarray} returns a full matrix. If
55 ## @var{issparse} is logically true, then a sparse matrix is returned 55 ## @var{issparse} is logically true, then a sparse matrix is returned
56 ## instead. 56 ## instead.
57 ## 57 ##
58 ## The following @code{accumarray} example constructs a frequency table 58 ## The following @code{accumarray} example constructs a frequency table
59 ## that in the first column counts how many occurrences each number in 59 ## that in the first column counts how many occurrences each number in
60 ## the second column has, taken from the vector @var{x}. Note the usage 60 ## the second column has, taken from the vector @var{x}. Note the usage
61 ## of @code{unique} for assigning to all repeated elements of @var{x} 61 ## of @code{unique} for assigning to all repeated elements of @var{x}
62 ## the same index (@pxref{doc-unique}). 62 ## the same index (@pxref{doc-unique}).
63 ## 63 ##
64 ## @example 64 ## @example
65 ## @group 65 ## @group
72 ## 2 92 72 ## 2 92
73 ## 3 100 73 ## 3 100
74 ## @end group 74 ## @end group
75 ## @end example 75 ## @end example
76 ## 76 ##
77 ## Another example, where the result is a multidimensional 3D array and 77 ## Another example, where the result is a multi-dimensional 3-D array and
78 ## the default value (zero) appears in the output: 78 ## the default value (zero) appears in the output:
79 ## 79 ##
80 ## @example 80 ## @example
81 ## @group 81 ## @group
82 ## accumarray ([1, 1, 1; 82 ## accumarray ([1, 1, 1;
89 ## @end group 89 ## @end group
90 ## @end example 90 ## @end example
91 ## 91 ##
92 ## The complexity in the non-sparse case is generally O(M+N), where N is 92 ## The complexity in the non-sparse case is generally O(M+N), where N is
93 ## the number of subscripts and M is the maximum subscript (linearized 93 ## the number of subscripts and M is the maximum subscript (linearized
94 ## in multi-dimensional case). If @var{func} is one of @code{@@sum} 94 ## in multi-dimensional case). If @var{func} is one of @code{@@sum}
95 ## (default), @code{@@max}, @code{@@min} or @code{@@(x) @{x@}}, an 95 ## (default), @code{@@max}, @code{@@min} or @code{@@(x) @{x@}}, an
96 ## optimized code path is used. Note that for general reduction function 96 ## optimized code path is used. Note that for general reduction function
97 ## the interpreter overhead can play a major part and it may be more 97 ## the interpreter overhead can play a major part and it may be more
98 ## efficient to do multiple accumarray calls and compute the results in 98 ## efficient to do multiple accumarray calls and compute the results in
99 ## a vectorized manner. 99 ## a vectorized manner.
100 ## 100 ##
101 ## @seealso{accumdim, unique} 101 ## @seealso{accumdim, unique}