Mercurial > hg > octave-jordi
changeset 12639:4d777e05d47c stable
doc: Review and update documentation for "Matrix Manipulation" chapter.
* matrix.txi, arrayfun.m, blkdiag.m, fliplr.m, flipud.m, logspace.m,
postpad.m, prepad.m, randi.m, repmat.m, rot90.m, rotdim.m, shiftdim.m,
sortrows.m, vech.m, xor.m, hadamard.m, hankel.m, hilb.m, invhilb.m, magic.m,
pascal.m, rosser.m, sylvester_matrix.m, toeplitz.m, vander.m, wilkinson.m,
bsxfun.cc, find.cc, lookup.cc, rand.cc, tril.cc, data.cc, arrayfun.m,
blkdiag.m, fliplr.m, flipud.m, logspace.m, postpad.m, prepad.m, randi.m,
repmat.m, rot90.m, rotdim.m, shiftdim.m, sortrows.m, vech.m, xor.m, hadamard.m,
hankel.m, hilb.m, invhilb.m, magic.m, pascal.m, rosser.m, sylvester_matrix.m,
toeplitz.m, vander.m, wilkinson.m, bsxfun.cc (bsxfun), find.cc (find),
lookup.cc (lookup), rand.cc (rand, randn, rande, randg, randp),
tril.cc (triu), data.cc (all, any, horzcat, vertcat, cat, permute, ipermute,
ones, zeros, eye, linspace, resize, reshape, issorted, diff):
Improve docstrings
line wrap: on
line diff
--- a/doc/interpreter/matrix.txi +++ b/doc/interpreter/matrix.txi @@ -75,11 +75,11 @@ @DOCSTRING(isfinite) +@DOCSTRING(common_size) + @DOCSTRING(find) @DOCSTRING(lookup) - -@DOCSTRING(common_size) @node Rearranging Matrices @section Rearranging Matrices @@ -110,9 +110,9 @@ @DOCSTRING(circshift) -@DOCSTRING(shiftdim) +@DOCSTRING(shift) -@DOCSTRING(shift) +@DOCSTRING(shiftdim) @DOCSTRING(sort) @@ -120,27 +120,6 @@ @DOCSTRING(issorted) -Since the @code{sort} function does not allow sort keys to be specified, -it can't be used to order the rows of a matrix according to the values -of the elements in various columns@footnote{For example, to first sort -based on the values in column 1, and then, for any values that are -repeated in column 1, sort based on the values found in column 2, etc.} -in a single call. Using the second output, however, it is possible to -sort all rows based on the values in a given column. Here's an example -that sorts the rows of a matrix based on the values in the second -column. - -@example -@group -a = [1, 2; 2, 3; 3, 1]; -[s, i] = sort (a (:, 2)); -a (i, :) - @result{} 3 1 - 1 2 - 2 3 -@end group -@end example - @DOCSTRING(nth_element) @anchor{doc-triu} @@ -178,6 +157,14 @@ @DOCSTRING(repelems) +The functions @code{linspace} and @code{logspace} make it very easy to +create vectors with evenly or logarithmically spaced elements. +@xref{Ranges}. + +@DOCSTRING(linspace) + +@DOCSTRING(logspace) + @DOCSTRING(rand) @DOCSTRING(randi) @@ -248,14 +235,6 @@ @DOCSTRING(randperm) -The functions @code{linspace} and @code{logspace} make it very easy to -create vectors with evenly or logarithmically spaced elements. -@xref{Ranges}. - -@DOCSTRING(linspace) - -@DOCSTRING(logspace) - @node Famous Matrices @section Famous Matrices
--- a/scripts/general/arrayfun.m +++ b/scripts/general/arrayfun.m @@ -30,9 +30,9 @@ ## accept array arguments it is better to call the function directly. ## ## The first input argument @var{func} can be a string, a function -## handle, an inline function or an anonymous function. The input +## handle, an inline function, or an anonymous function. The input ## argument @var{A} can be a logic array, a numeric array, a string -## array, a structure array or a cell array. By a call of the function +## array, a structure array, or a cell array. By a call of the function ## @command{arrayfun} all elements of @var{A} are passed on to the named ## function @var{func} individually. ## @@ -96,7 +96,7 @@ ## ## If the parameter @var{errfunc} after a further string input argument ## "ErrorHandler" is another string, a function handle, an inline -## function or an anonymous function, then @var{errfunc} defines a +## function, or an anonymous function, then @var{errfunc} defines a ## function to call in the case that @var{func} generates an error. ## The definition of the function must be of the form ## @@ -107,8 +107,8 @@ ## @noindent ## where there is an additional input argument to @var{errfunc} ## relative to @var{func}, given by @var{s}. This is a structure with -## the elements "identifier", "message" and "index", giving -## respectively the error identifier, the error message and the index of +## the elements "identifier", "message", and "index" giving, +## respectively, the error identifier, the error message, and the index of ## the array elements that caused the error. The size of the output ## argument of @var{errfunc} must have the same size as the output ## argument of @var{func}, otherwise a real error is thrown. For
--- a/scripts/general/blkdiag.m +++ b/scripts/general/blkdiag.m @@ -18,7 +18,7 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {} blkdiag (@var{A}, @var{B}, @var{C}, @dots{}) -## Build a block diagonal matrix from @var{A}, @var{B}, @var{C}, @dots{}. +## Build a block diagonal matrix from @var{A}, @var{B}, @var{C}, @dots{} ## All the arguments must be numeric and are two-dimensional matrices or ## scalars. ## @seealso{diag, horzcat, vertcat}
--- a/scripts/general/fliplr.m +++ b/scripts/general/fliplr.m @@ -18,7 +18,8 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {} fliplr (@var{x}) -## Return a copy of @var{x} with the order of the columns reversed. For +## Return a copy of @var{x} with the order of the columns reversed. In +## other words, @var{x} is flipped left-to-right about a vertical axis. For ## example: ## ## @example @@ -29,7 +30,7 @@ ## @end group ## @end example ## -## Note that @code{fliplr} only work with 2-D arrays. To flip N-d arrays +## Note that @code{fliplr} only works with 2-D arrays. To flip N-D arrays ## use @code{flipdim} instead. ## @seealso{flipud, flipdim, rot90, rotdim} ## @end deftypefn
--- a/scripts/general/flipud.m +++ b/scripts/general/flipud.m @@ -18,7 +18,8 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {} flipud (@var{x}) -## Return a copy of @var{x} with the order of the rows reversed. For +## Return a copy of @var{x} with the order of the rows reversed. In +## other words, @var{x} is flipped upside-down about a horizontal axis. For ## example: ## ## @example @@ -29,8 +30,7 @@ ## @end group ## @end example ## -## Due to the difficulty of defining which axis about which to flip the -## matrix @code{flipud} only work with 2-d arrays. To flip N-d arrays +## Note that @code{flipud} only works with 2-D arrays. To flip N-D arrays ## use @code{flipdim} instead. ## @seealso{fliplr, flipdim, rot90, rotdim} ## @end deftypefn
--- a/scripts/general/logspace.m +++ b/scripts/general/logspace.m @@ -17,18 +17,19 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} logspace (@var{base}, @var{limit}) -## @deftypefnx {Function File} {} logspace (@var{base}, @var{limit}, @var{n}) -## Similar to @code{linspace} except that the values are logarithmically -## spaced from +## @deftypefn {Function File} {} logspace (@var{a}, @var{b}) +## @deftypefnx {Function File} {} logspace (@var{b}, @var{b}, @var{n}) +## @deftypefnx {Function File} {} logspace (@var{a}, pi, @var{n}) +## Return a row vector with @var{n} elements logarithmically spaced from ## @tex -## $10^{base}$ to $10^{limit}$. +## $10^{a}$ to $10^{b}$. ## @end tex ## @ifnottex -## 10^base to 10^limit. +## 10^@var{a} to 10^@var{b}. ## @end ifnottex +## If @var{n} is unspecified it defaults to 50. ## -## If @var{limit} is equal to +## If @var{b} is equal to ## @tex ## $\pi$, ## @end tex @@ -37,24 +38,22 @@ ## @end ifnottex ## the points are between ## @tex -## $10^{base}$ and $\pi$, +## $10^{a}$ and $\pi$, ## @end tex ## @ifnottex -## 10^base and pi, +## 10^@var{a} and pi, ## @end ifnottex ## @emph{not} ## @tex -## $10^{base}$ and $10^{\pi}$, +## $10^{a}$ and $10^{\pi}$, ## @end tex ## @ifnottex -## 10^base and 10^pi, +## 10^@var{a} and 10^pi, ## @end ifnottex -## in order to be compatible with the corresponding @sc{matlab} -## function. -## If @var{n} is unspecified it defaults to 50. +## in order to be compatible with the corresponding @sc{matlab} function. ## -## Also for compatibility with @sc{matlab}, return the second argument if -## fewer than two values are requested. +## Also for compatibility with @sc{matlab}, return the second argument @var{b} +## if fewer than two values are requested. ## @seealso{linspace} ## @end deftypefn
--- a/scripts/general/postpad.m +++ b/scripts/general/postpad.m @@ -20,9 +20,8 @@ ## @deftypefn {Function File} {} postpad (@var{x}, @var{l}) ## @deftypefnx {Function File} {} postpad (@var{x}, @var{l}, @var{c}) ## @deftypefnx {Function File} {} postpad (@var{x}, @var{l}, @var{c}, @var{dim}) -## Append the scalar value @var{c} to the vector @var{x} -## until it is of length @var{l}. If the third argument is not -## supplied, a value of 0 is used. +## Append the scalar value @var{c} to the vector @var{x} until it is of length +## @var{l}. If @var{c} is not given, a value of 0 is used. ## ## If @code{length (@var{x}) > @var{l}}, elements from the end of ## @var{x} are removed until a vector of length @var{l} is obtained.
--- a/scripts/general/prepad.m +++ b/scripts/general/prepad.m @@ -20,9 +20,8 @@ ## @deftypefn {Function File} {} prepad (@var{x}, @var{l}) ## @deftypefnx {Function File} {} prepad (@var{x}, @var{l}, @var{c}) ## @deftypefnx {Function File} {} prepad (@var{x}, @var{l}, @var{c}, @var{dim}) -## Prepend the scalar value @var{c} to the vector @var{x} -## until it is of length @var{l}. If the third argument is not -## supplied, a value of 0 is used. +## Prepend the scalar value @var{c} to the vector @var{x} until it is of length +## @var{l}. If @var{c} is not given, a value of 0 is used. ## ## If @code{length (@var{x}) > @var{l}}, elements from the beginning of ## @var{x} are removed until a vector of length @var{l} is obtained.
--- a/scripts/general/randi.m +++ b/scripts/general/randi.m @@ -20,7 +20,7 @@ ## @deftypefn {Function File} {} randi (@var{imax}) ## @deftypefnx {Function File} {} randi (@var{imax}, @var{n}) ## @deftypefnx {Function File} {} randi (@var{imax}, @var{m}, @var{n}, @dots{}) -## @deftypefnx {Function File} {} randi ([@var{imin}, @var{imax}], @dots{}) +## @deftypefnx {Function File} {} randi ([@var{imin} @var{imax}], @dots{}) ## @deftypefnx {Function File} {} randi (@dots{}, "@var{class}") ## Return random integers in the range 1:@var{imax}. ## @@ -47,7 +47,7 @@ ## uses class "double" to represent numbers. This limits the maximum ## integer (@var{imax}) and range (@var{imax} - @var{imin}) to the value ## returned by the @code{bitmax} function. For IEEE floating point numbers -## this value is @w{@code{2^53 - 1}}. +## this value is @w{@math{2^{53} - 1}}. ## ## @seealso{rand} ## @end deftypefn
--- a/scripts/general/repmat.m +++ b/scripts/general/repmat.m @@ -18,7 +18,9 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} repmat (@var{A}, @var{m}, @var{n}) +## @deftypefn {Function File} {} repmat (@var{A}, @var{m}) +## @deftypefnx {Function File} {} repmat (@var{A}, @var{m}, @var{n}) +## @deftypefnx {Function File} {} repmat (@var{A}, @var{m}, @var{n}, @var{p}, @dots{}) ## @deftypefnx {Function File} {} repmat (@var{A}, [@var{m} @var{n}]) ## @deftypefnx {Function File} {} repmat (@var{A}, [@var{m} @var{n} @var{p} @dots{}]) ## Form a block matrix of size @var{m} by @var{n}, with a copy of matrix
--- a/scripts/general/rot90.m +++ b/scripts/general/rot90.m @@ -17,7 +17,8 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} rot90 (@var{A}, @var{k}) +## @deftypefn {Function File} {} rot90 (@var{A}) +## @deftypefnx {Function File} {} rot90 (@var{A}, @var{k}) ## Return a copy of @var{A} with the elements rotated counterclockwise in ## 90-degree increments. The second argument is optional, and specifies ## how many 90-degree rotations are to be applied (the default value is 1). @@ -44,8 +45,7 @@ ## @end group ## @end example ## -## Due to the difficulty of defining an axis about which to rotate the -## matrix @code{rot90} only work with 2-D arrays. To rotate N-d arrays +## Note that @code{rot90} only works with 2-D arrays. To rotate N-D arrays ## use @code{rotdim} instead. ## @seealso{rotdim, flipud, fliplr, flipdim} ## @end deftypefn
--- a/scripts/general/rotdim.m +++ b/scripts/general/rotdim.m @@ -17,14 +17,17 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} rotdim (@var{x}, @var{n}, @var{plane}) +## @deftypefn {Function File} {} rotdim (@var{x}) +## @deftypefnx {Function File} {} rotdim (@var{x}, @var{n}) +## @deftypefnx {Function File} {} rotdim (@var{x}, @var{n}, @var{plane}) ## Return a copy of @var{x} with the elements rotated counterclockwise in -## 90-degree increments. The second argument is optional, and specifies -## how many 90-degree rotations are to be applied (the default value is 1). +## 90-degree increments. +## The second argument @var{n} is optional, and specifies how many 90-degree +## rotations are to be applied (the default value is 1). ## The third argument is also optional and defines the plane of the -## rotation. As such @var{plane} is a two element vector containing two -## different valid dimensions of the matrix. If @var{plane} is not given -## Then the first two non-singleton dimensions are used. +## rotation. If present, @var{plane} is a two element vector containing two +## different valid dimensions of the matrix. When @var{plane} is not given +## the first two non-singleton dimensions are used. ## ## Negative values of @var{n} rotate the matrix in a clockwise direction. ## For example,
--- a/scripts/general/shiftdim.m +++ b/scripts/general/shiftdim.m @@ -19,7 +19,7 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {@var{y} =} shiftdim (@var{x}, @var{n}) ## @deftypefnx {Function File} {[@var{y}, @var{ns}] =} shiftdim (@var{x}) -## Shift the dimension of @var{x} by @var{n}, where @var{n} must be +## Shift the dimensions of @var{x} by @var{n}, where @var{n} must be ## an integer scalar. When @var{n} is positive, the dimensions of ## @var{x} are shifted to the left, with the leading dimensions ## circulated to the end. If @var{n} is negative, then the dimensions
--- a/scripts/general/sortrows.m +++ b/scripts/general/sortrows.m @@ -18,7 +18,8 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} sortrows (@var{A}, @var{c}) +## @deftypefn {Function File} {[@var{s}, @var{i}] =} sortrows (@var{A}) +## @deftypefnx {Function File} {[@var{s}, @var{i}] =} sortrows (@var{A}, @var{c}) ## Sort the rows of the matrix @var{A} according to the order of the ## columns specified in @var{c}. If @var{c} is omitted, a ## lexicographical sort is used. By default ascending order is used
--- a/scripts/linear-algebra/vech.m +++ b/scripts/linear-algebra/vech.m @@ -21,7 +21,10 @@ ## @deftypefn {Function File} {} vech (@var{x}) ## Return the vector obtained by eliminating all supradiagonal elements of ## the square matrix @var{x} and stacking the result one column above the -## other. +## other. This has uses in matrix calculus where the underlying matrix +## is symmetric and it would be pointless to keep values above the main +## diagonal. +## @seealso{vec} ## @end deftypefn ## See Magnus and Neudecker (1988), Matrix differential calculus with
--- a/scripts/miscellaneous/xor.m +++ b/scripts/miscellaneous/xor.m @@ -17,11 +17,24 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Mapping Function} {} xor (@var{x}, @var{y}) +## @deftypefn {Mapping Function} {@var{z} =} xor (@var{x}, @var{y}) ## Return the `exclusive or' of the entries of @var{x} and @var{y}. ## For boolean expressions @var{x} and @var{y}, -## @code{xor (@var{x}, @var{y})} is true if and only if @var{x} or @var{y} -## is true, but not if both @var{x} and @var{y} are true. +## @code{xor (@var{x}, @var{y})} is true if and only if one of @var{x} or +## @var{y} is true. Otherwise, for @var{x} and @var{y} both true or both +## false, @code{xor} returns false. +## +## The truth table for the xor operation is +## +## @multitable @columnfractions 0.44 .03 .05 .03 0.44 +## @item @tab @var{x} @tab @var{y} @tab @var{z} @tab +## @item @tab 0 @tab 0 @tab 0 @tab +## @item @tab 1 @tab 0 @tab 1 @tab +## @item @tab 0 @tab 1 @tab 1 @tab +## @item @tab 1 @tab 1 @tab 0 @tab +## @end multitable +## +## @seealso{and, or, not} ## @end deftypefn ## Author: KH <Kurt.Hornik@wu-wien.ac.at>
--- a/scripts/special-matrix/hadamard.m +++ b/scripts/special-matrix/hadamard.m @@ -21,32 +21,32 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {} hadamard (@var{n}) -## Construct a Hadamard matrix @var{Hn} of size @var{n}-by-@var{n}. The -## size @var{n} must be of the form @code{2 ^ @var{k} * @var{p}} in which -## @var{p} is one of 1, 12, 20 or 28. The returned matrix is normalized, -## meaning @code{Hn(:,1) == 1} and @code{Hn(1,:) == 1}. +## Construct a Hadamard matrix (@nospell{Hn}) of size @var{n}-by-@var{n}. The +## size @var{n} must be of the form @math{2^k * p} in which +## p is one of 1, 12, 20 or 28. The returned matrix is normalized, +## meaning @w{@code{Hn(:,1) == 1}} and @w{@code{Hn(1,:) == 1}}. ## ## Some of the properties of Hadamard matrices are: ## ## @itemize @bullet ## @item -## @code{kron (@var{Hm}, @var{Hn})} is a Hadamard matrix of size -## @var{m}-by-@var{n}. +## @code{kron (Hm, Hn)} is a Hadamard matrix of size @var{m}-by-@var{n}. ## ## @item -## @code{Hn * Hn' == @var{n} * eye (@var{n})}. +## @code{Hn * Hn' = @var{n} * eye (@var{n})}. +## +## @item +## The rows of @nospell{Hn} are orthogonal. ## ## @item -## The rows of @var{Hn} are orthogonal. +## @code{det (@var{A}) <= abs (det (Hn))} for all @var{A} with +## @w{@code{abs (@var{A}(i, j)) <= 1}}. ## ## @item -## @code{det (@var{A}) <= abs(det (@var{Hn}))} for all @var{A} with -## @code{abs (@var{A} (@var{i}, @var{j})) <= 1}. -## -## @item -## Multiply any row or column by -1 and still have a Hadamard matrix. +## Multiplying any row or column by -1 and the matrix will remain a Hadamard +## matrix. ## @end itemize -## +## @seealso{compan, hankel, toeplitz} ## @end deftypefn
--- a/scripts/special-matrix/hankel.m +++ b/scripts/special-matrix/hankel.m @@ -19,7 +19,7 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {} hankel (@var{c}) ## @deftypefnx {Function File} {} hankel (@var{c}, @var{r}) -## Return the Hankel matrix constructed given the first column @var{c}, and +## Return the Hankel matrix constructed from the first column @var{c}, and ## (optionally) the last row @var{r}. If the last element of @var{c} is ## not the same as the first element of @var{r}, the last element of ## @var{c} is used. If the second argument is omitted, it is assumed to @@ -42,7 +42,7 @@ ## @end example ## ## @end ifnottex -## @seealso{vander, sylvester_matrix, hilb, invhilb, toeplitz} +## @seealso{hadamard, toeplitz} ## @end deftypefn ## Author: jwe
--- a/scripts/special-matrix/hilb.m +++ b/scripts/special-matrix/hilb.m @@ -18,14 +18,8 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {} hilb (@var{n}) -## Return the Hilbert matrix of order @var{n}. The -## @tex -## $i,\,j$ -## @end tex -## @ifnottex -## i, j -## @end ifnottex -## element of a Hilbert matrix is defined as +## Return the Hilbert matrix of order @var{n}. The @math{i,j} element +## of a Hilbert matrix is defined as ## @tex ## $$ ## H (i, j) = {1 \over (i + j - 1)} @@ -38,7 +32,22 @@ ## @end example ## ## @end ifnottex -## @seealso{hankel, vander, sylvester_matrix, invhilb, toeplitz} +## +## Hilbert matrices are close to being singular which make them difficult to +## invert with numerical routines. +## Comparing the condition number of a random matrix 5x5 matrix with that of +## a Hilbert matrix of order 5 reveals just how difficult the problem is. +## +## @example +## @group +## cond (rand (5)) +## @result{} 14.392 +## cond (hilb (5)) +## @result{} 4.7661e+05 +## @end group +## @end example +## +## @seealso{invhilb} ## @end deftypefn ## Author: jwe
--- a/scripts/special-matrix/invhilb.m +++ b/scripts/special-matrix/invhilb.m @@ -68,7 +68,7 @@ ## Compare this with the numerical calculation of @code{inverse (hilb (n))}, ## which suffers from the ill-conditioning of the Hilbert matrix, and the ## finite precision of your computer's floating point arithmetic. -## @seealso{hilb, hankel, vander, sylvester_matrix, toeplitz} +## @seealso{hilb} ## @end deftypefn ## Author: Dirk Laurie <dlaurie@na-net.ornl.gov>
--- a/scripts/special-matrix/magic.m +++ b/scripts/special-matrix/magic.m @@ -19,9 +19,11 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {} magic (@var{n}) ## -## Create an @var{n}-by-@var{n} magic square. Note that @code{magic -## (@var{2})} is undefined since there is no 2-by-2 magic square. +## Create an @var{n}-by-@var{n} magic square. A magic square is an arrangement +## of the integers @code{1:n^2} such that the row sums, column sums, and +## diagonal sums are all equal to the same value. ## +## Note: @var{n} must be greater than 2 for the magic square to exist. ## @end deftypefn function A = magic(n)
--- a/scripts/special-matrix/pascal.m +++ b/scripts/special-matrix/pascal.m @@ -20,19 +20,17 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {} pascal (@var{n}) ## @deftypefnx {Function File} {} pascal (@var{n}, @var{t}) -## Return the Pascal matrix of order @var{n} if @code{@var{t} = 0}. -## @var{t} defaults to 0. Return the pseudo-lower triangular -## Cholesky@tie{}factor of the Pascal matrix if @code{@var{t} = 1} (The sign -## of some columns may be negative). This matrix is its own -## inverse, that is @code{pascal (@var{n}, 1) ^ 2 == eye (@var{n})}. -## If @code{@var{t} = -1}, return the true Cholesky@tie{}factor with strictly -## positive values on the diagonal. -## If @code{@var{t} = 2}, return a transposed and permuted version of -## @code{pascal (@var{n}, 1)}, which is the cube root of the identity -## matrix. That is, @code{pascal (@var{n}, 2) ^ 3 == eye (@var{n})}. +## Return the Pascal matrix of order @var{n} if @code{@var{t} = 0}. @var{t} +## defaults to 0. Return the pseudo-lower triangular Cholesky@tie{}factor of +## the Pascal matrix if @code{@var{t} = 1} (The sign of some columns may be +## negative). This matrix is its own inverse, that is @code{pascal (@var{n}, +## 1) ^ 2 == eye (@var{n})}. If @code{@var{t} = -1}, return the true +## Cholesky@tie{}factor with strictly positive values on the diagonal. If +## @code{@var{t} = 2}, return a transposed and permuted version of @code{pascal +## (@var{n}, 1)}, which is the cube root of the identity matrix. That is, +## @code{pascal (@var{n}, 2) ^ 3 == eye (@var{n})}. ## -## @seealso{hankel, vander, sylvester_matrix, hilb, invhilb, toeplitz, -## hadamard, wilkinson, compan, rosser} +## @seealso{chol} ## @end deftypefn ## Author: Peter Ekberg
--- a/scripts/special-matrix/rosser.m +++ b/scripts/special-matrix/rosser.m @@ -21,8 +21,7 @@ ## Return the Rosser matrix. This is a difficult test case used to evaluate ## eigenvalue algorithms. ## -## @seealso{hankel, vander, sylvester_matrix, hilb, invhilb, toeplitz, -## hadamard, wilkinson, compan, pascal} +## @seealso{wilkinson, eig} ## @end deftypefn ## Author: Peter Ekberg @@ -42,6 +41,7 @@ -52, -43, 49, 44, -599, 411, 208, 208; -49, -8, 8, 59, 208, 208, 99, -911; 29, -44, 52, -23, 208, 208, -911, 99]; + endfunction %!assert (size(rosser()), [8,8])
--- a/scripts/special-matrix/sylvester_matrix.m +++ b/scripts/special-matrix/sylvester_matrix.m @@ -23,9 +23,10 @@ ## $n = 2^k$. ## @end tex ## @ifnottex -## n = 2^k. +## n = 2^@var{k}. ## @end ifnottex -## @seealso{hankel, vander, hilb, invhilb, toeplitz} +## +## @seealso{toeplitz, hankel} ## @end deftypefn ## Author: jwe
--- a/scripts/special-matrix/toeplitz.m +++ b/scripts/special-matrix/toeplitz.m @@ -20,9 +20,9 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {} toeplitz (@var{c}) ## @deftypefnx {Function File} {} toeplitz (@var{c}, @var{r}) -## Return the Toeplitz matrix constructed given the first column @var{c}, -## and (optionally) the first row @var{r}. If the first element of @var{c} -## is not the same as the first element of @var{r}, the first element of +## Return the Toeplitz matrix constructed from the first column @var{c}, +## and (optionally) the first row @var{r}. If the first element of @var{r} +## is not the same as the first element of @var{c}, the first element of ## @var{c} is used. If the second argument is omitted, the first row is ## taken to be the same as the first column. ## @@ -51,7 +51,7 @@ ## @end example ## ## @end ifnottex -## @seealso{hankel, vander, sylvester_matrix, hilb, invhilb} +## @seealso{hankel} ## @end deftypefn ## Author: jwe && jh
--- a/scripts/special-matrix/vander.m +++ b/scripts/special-matrix/vander.m @@ -47,7 +47,7 @@ ## @end example ## ## @end ifnottex -## @seealso{hankel, sylvester_matrix, hilb, invhilb, toeplitz} +## @seealso{polyfit} ## @end deftypefn ## Author: jwe
--- a/scripts/special-matrix/wilkinson.m +++ b/scripts/special-matrix/wilkinson.m @@ -20,10 +20,10 @@ ## @deftypefn {Function File} {} wilkinson (@var{n}) ## Return the Wilkinson matrix of order @var{n}. Wilkinson matrices are ## symmetric and tridiagonal with pairs of nearly, but not exactly, equal -## eigenvalues. +## eigenvalues. They are useful in testing the behavior and performance +## of eigenvalue solvers. ## -## @seealso{hankel, vander, sylvester_matrix, hilb, invhilb, toeplitz, -## hadamard, rosser, compan, pascal} +## @seealso{rosser, eig} ## @end deftypefn ## Author: Peter Ekberg
--- a/src/DLD-FUNCTIONS/bsxfun.cc +++ b/src/DLD-FUNCTIONS/bsxfun.cc @@ -313,9 +313,10 @@ "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {} bsxfun (@var{f}, @var{A}, @var{B})\n\ Apply a binary function @var{f} element-by-element to two matrix arguments\n\ -@var{A} and @var{B}. The function @var{f} must be capable of accepting\n\ -two column-vector arguments of equal length, or one column vector\n\ -argument and a scalar.\n\ +@var{A} and @var{B}. @var{f} is a function handle, inline function, or\n\ +string containing the name of the function to evaluate.\n\ +The function @var{f} must be capable of accepting two column-vector\n\ +arguments of equal length, or one column vector argument and a scalar.\n\ \n\ The dimensions of @var{A} and @var{B} must be equal or singleton. The\n\ singleton dimensions of the matrices will be expanded to the same\n\
--- a/src/DLD-FUNCTIONS/find.cc +++ b/src/DLD-FUNCTIONS/find.cc @@ -341,11 +341,11 @@ @deftypefnx {Loadable Function} {@var{idx} =} find (@var{x}, @var{n})\n\ @deftypefnx {Loadable Function} {@var{idx} =} find (@var{x}, @var{n}, @var{direction})\n\ @deftypefnx {Loadable Function} {[i, j] =} find (@dots{})\n\ -@deftypefnx {Loadable Function} {[i, j, v]] =} find (@dots{})\n\ +@deftypefnx {Loadable Function} {[i, j, v] =} find (@dots{})\n\ Return a vector of indices of nonzero elements of a matrix, as a row if\n\ -@var{x} is a row or as a column otherwise. To obtain a single index for\n\ -each matrix element, Octave pretends that the columns of a matrix form one\n\ -long vector (like Fortran arrays are stored). For example:\n\ +@var{x} is a row vector or as a column otherwise. To obtain a single index\n\ +for each matrix element, Octave pretends that the columns of a matrix form\n\ +one long vector (like Fortran arrays are stored). For example:\n\ \n\ @example\n\ @group\n\ @@ -390,9 +390,9 @@ \n\ @example\n\ @group\n\ -sz = size(a);\n\ +sz = size (a);\n\ [i, j, v] = find (a);\n\ -b = sparse(i, j, v, sz(1), sz(2));\n\ +b = sparse (i, j, v, sz(1), sz(2));\n\ @end group\n\ @end example\n\ @seealso{nonzeros}\n\
--- a/src/DLD-FUNCTIONS/lookup.cc +++ b/src/DLD-FUNCTIONS/lookup.cc @@ -188,13 +188,14 @@ DEFUN_DLD (lookup, args, , "-*- texinfo -*-\n\ -@deftypefn {Loadable Function} {@var{idx} =} lookup (@var{table}, @var{y}, @var{opt})\n\ +@deftypefn {Loadable Function} {@var{idx} =} lookup (@var{table}, @var{y})\n\ +@deftypefnx {Loadable Function} {@var{idx} =} lookup (@var{table}, @var{y}, @var{opt})\n\ Lookup values in a sorted table. Usually used as a prelude to\n\ interpolation.\n\ \n\ If table is increasing and @code{idx = lookup (table, y)}, then\n\ @code{table(idx(i)) <= y(i) < table(idx(i+1))} for all @code{y(i)}\n\ -within the table. If @code{y(i) < table (1)} then\n\ +within the table. If @code{y(i) < table(1)} then\n\ @code{idx(i)} is 0. If @code{y(i) >= table(end)} or @code{isnan (y(i))} then\n\ @code{idx(i)} is @code{n}.\n\ \n\ @@ -211,7 +212,7 @@ (or @var{y} can be a single string). In this case, string lookup\n\ is performed using lexicographical comparison.\n\ \n\ -If @var{opts} is specified, it shall be a string with letters indicating\n\ +If @var{opts} is specified, it must be a string with letters indicating\n\ additional options.\n\ \n\ @table @code\n\
--- a/src/DLD-FUNCTIONS/rand.cc +++ b/src/DLD-FUNCTIONS/rand.cc @@ -326,8 +326,9 @@ DEFUN_DLD (rand, args, , "-*- texinfo -*-\n\ -@deftypefn {Loadable Function} {} rand (@var{x})\n\ -@deftypefnx {Loadable Function} {} rand (@var{n}, @var{m})\n\ +@deftypefn {Loadable Function} {} rand (@var{n})\n\ +@deftypefnx {Loadable Function} {} rand (@var{n}, @var{m}, @dots{})\n\ +@deftypefnx {Loadable Function} {} rand ([@var{n} @var{m} @dots{}])\n\ @deftypefnx {Loadable Function} {@var{v} =} rand (\"state\")\n\ @deftypefnx {Loadable Function} {} rand (\"state\", @var{v})\n\ @deftypefnx {Loadable Function} {} rand (\"state\", \"reset\")\n\ @@ -359,13 +360,13 @@ value of @var{v}, not @var{v} itself.\n\ \n\ By default, the generator is initialized from @code{/dev/urandom} if it is\n\ -available, otherwise from CPU time, wall clock time and the current\n\ +available, otherwise from CPU time, wall clock time, and the current\n\ fraction of a second.\n\ \n\ To compute the pseudo-random sequence, @code{rand} uses the Mersenne\n\ Twister with a period of @math{2^{19937}-1} (See M. Matsumoto and\n\ T. Nishimura,\n\ -@cite{Mersenne Twister: A 623-dimensionally equidistributed uniform \n\ +@cite{Mersenne Twister: A 623-dimensionally equidistributed uniform\n\ pseudorandom number generator}, ACM Trans. on\n\ Modeling and Computer Simulation Vol. 8, No. 1, pp. 3-30, January 1998,\n\ @url{http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html}).\n\ @@ -490,8 +491,9 @@ DEFUN_DLD (randn, args, , "-*- texinfo -*-\n\ -@deftypefn {Loadable Function} {} randn (@var{x})\n\ -@deftypefnx {Loadable Function} {} randn (@var{n}, @var{m})\n\ +@deftypefn {Loadable Function} {} randn (@var{n})\n\ +@deftypefnx {Loadable Function} {} randn (@var{n}, @var{m}, @dots{})\n\ +@deftypefnx {Loadable Function} {} randn ([@var{n} @var{m} @dots{}])\n\ @deftypefnx {Loadable Function} {@var{v} =} randn (\"state\")\n\ @deftypefnx {Loadable Function} {} randn (\"state\", @var{v})\n\ @deftypefnx {Loadable Function} {} randn (\"state\", \"reset\")\n\ @@ -555,8 +557,9 @@ DEFUN_DLD (rande, args, , "-*- texinfo -*-\n\ -@deftypefn {Loadable Function} {} rande (@var{x})\n\ -@deftypefnx {Loadable Function} {} rande (@var{n}, @var{m})\n\ +@deftypefn {Loadable Function} {} rande (@var{n})\n\ +@deftypefnx {Loadable Function} {} rande (@var{n}, @var{m}, @dots{})\n\ +@deftypefnx {Loadable Function} {} rande ([@var{n} @var{m} @dots{}])\n\ @deftypefnx {Loadable Function} {@var{v} =} rande (\"state\")\n\ @deftypefnx {Loadable Function} {} rande (\"state\", @var{v})\n\ @deftypefnx {Loadable Function} {} rande (\"state\", \"reset\")\n\ @@ -621,8 +624,9 @@ DEFUN_DLD (randg, args, , "-*- texinfo -*-\n\ -@deftypefn {Loadable Function} {} randg (@var{a}, @var{x})\n\ -@deftypefnx {Loadable Function} {} randg (@var{a}, @var{n}, @var{m})\n\ +@deftypefn {Loadable Function} {} randg (@var{n})\n\ +@deftypefnx {Loadable Function} {} randg (@var{n}, @var{m}, @dots{})\n\ +@deftypefnx {Loadable Function} {} randg ([@var{n} @var{m} @dots{}])\n\ @deftypefnx {Loadable Function} {@var{v} =} randg (\"state\")\n\ @deftypefnx {Loadable Function} {} randg (\"state\", @var{v})\n\ @deftypefnx {Loadable Function} {} randg (\"state\", \"reset\")\n\ @@ -663,7 +667,7 @@ r = 2 * randg (df / 2)\n\ @end example\n\ \n\ -@item @code{t(df)} for @code{0 < df < inf} (use randn if df is infinite)\n\ +@item @code{t (df)} for @code{0 < df < inf} (use randn if df is infinite)\n\ \n\ @example\n\ r = randn () / sqrt (2 * randg (df / 2) / df)\n\ @@ -877,8 +881,9 @@ DEFUN_DLD (randp, args, , "-*- texinfo -*-\n\ -@deftypefn {Loadable Function} {} randp (@var{l}, @var{x})\n\ -@deftypefnx {Loadable Function} {} randp (@var{l}, @var{n}, @var{m})\n\ +@deftypefn {Loadable Function} {} randp (@var{l}, @var{n})\n\ +@deftypefnx {Loadable Function} {} randp (@var{l}, @var{n}, @var{m}, @dots{})\n\ +@deftypefnx {Loadable Function} {} randp (@var{l}, [@var{n} @var{m} @dots{}])\n\ @deftypefnx {Loadable Function} {@var{v} =} randp (\"state\")\n\ @deftypefnx {Loadable Function} {} randp (\"state\", @var{v})\n\ @deftypefnx {Loadable Function} {} randp (\"state\", \"reset\")\n\ @@ -1022,7 +1027,7 @@ @deftypefnx {Loadable Function} {} randperm (@var{n}, @var{m})\n\ Return a row vector containing a random permutation of @code{1:@var{n}}.\n\ If @var{m} is supplied, return @var{m} permutations,\n\ -one in each row of an @nospell{NxM} matrix. The complexity is O(M*N) in both\n\ +one in each row of an @nospell{MxN} matrix. The complexity is O(M*N) in both\n\ time and memory. The randomization is performed using rand().\n\ All permutations are equally likely.\n\ @seealso{perms}\n\
--- a/src/DLD-FUNCTIONS/tril.cc +++ b/src/DLD-FUNCTIONS/tril.cc @@ -389,7 +389,7 @@ If the option \"pack\" is given as third argument, the extracted elements\n\ are not inserted into a matrix, but rather stacked column-wise one above\n\ other.\n\ -@seealso{triu, diag}\n\ +@seealso{diag}\n\ @end deftypefn") { return do_trilu ("tril", args);
--- a/src/data.cc +++ b/src/data.cc @@ -106,10 +106,25 @@ DEFUN (all, args, , "-*- texinfo -*-\n\ -@deftypefn {Built-in Function} {} all (@var{x}, @var{dim})\n\ -The function @code{all} behaves like the function @code{any}, except\n\ -that it returns true only if all the elements of a vector, or all the\n\ -elements along dimension @var{dim} of a matrix, are nonzero.\n\ +@deftypefn {Built-in Function} {} all (@var{x})\n\ +@deftypefnx {Built-in Function} {} all (@var{x}, @var{dim})\n\ +For a vector argument, return true (logical 1) if all elements of the vector\n\ +are nonzero.\n\ +\n\ +For a matrix argument, return a row vector of logical ones and\n\ +zeros with each element indicating whether all of the elements of the\n\ +corresponding column of the matrix are nonzero. For example:\n\ +\n\ +@example\n\ +@group\n\ +all ([2, 3; 1, 0]))\n\ + @result{} [ 1, 0 ]\n\ +@end group\n\ +@end example\n\ +\n\ +If the optional argument @var{dim} is supplied, work along dimension\n\ +@var{dim}.\n\ +@seealso{any}\n\ @end deftypefn") { ANY_ALL (all); @@ -140,11 +155,12 @@ DEFUN (any, args, , "-*- texinfo -*-\n\ -@deftypefn {Built-in Function} {} any (@var{x}, @var{dim})\n\ -For a vector argument, return 1 if any element of the vector is\n\ -nonzero.\n\ +@deftypefn {Built-in Function} {} any (@var{x})\n\ +@deftypefnx {Built-in Function} {} any (@var{x}, @var{dim})\n\ +For a vector argument, return true (logical 1) if any element of the vector\n\ +is nonzero.\n\ \n\ -For a matrix argument, return a row vector of ones and\n\ +For a matrix argument, return a row vector of logical ones and\n\ zeros with each element indicating whether any of the elements of the\n\ corresponding column of the matrix are nonzero. For example:\n\ \n\ @@ -164,6 +180,7 @@ @result{} [ 1; 1 ]\n\ @end group\n\ @end example\n\ +@seealso{all}\n\ @end deftypefn") { ANY_ALL (any); @@ -1686,8 +1703,15 @@ DEFUN (horzcat, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} horzcat (@var{array1}, @var{array2}, @dots{}, @var{arrayN})\n\ -Return the horizontal concatenation of N-d array objects, @var{array1},\n\ +Return the horizontal concatenation of N-D array objects, @var{array1},\n\ @var{array2}, @dots{}, @var{arrayN} along dimension 2.\n\ +\n\ +Arrays may also be concatenated horizontally using the syntax for creating\n\ +new matrices. For example:\n\ +\n\ +@example\n\ +@var{hcat} = [ @var{array1}, @var{array2}, @dots{} ];\n\ +@end example\n\ @seealso{cat, vertcat}\n\ @end deftypefn") { @@ -1697,8 +1721,15 @@ DEFUN (vertcat, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} vertcat (@var{array1}, @var{array2}, @dots{}, @var{arrayN})\n\ -Return the vertical concatenation of N-d array objects, @var{array1},\n\ +Return the vertical concatenation of N-D array objects, @var{array1},\n\ @var{array2}, @dots{}, @var{arrayN} along dimension 1.\n\ +\n\ +Arrays may also be concatenated vertically using the syntax for creating\n\ +new matrices. For example:\n\ +\n\ +@example\n\ +@var{vcat} = [ @var{array1}; @var{array2}; @dots{} ];\n\ +@end example\n\ @seealso{cat, horzcat}\n\ @end deftypefn") { @@ -1708,7 +1739,7 @@ DEFUN (cat, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} cat (@var{dim}, @var{array1}, @var{array2}, @dots{}, @var{arrayN})\n\ -Return the concatenation of N-d array objects, @var{array1},\n\ +Return the concatenation of N-D array objects, @var{array1},\n\ @var{array2}, @dots{}, @var{arrayN} along dimension @var{dim}.\n\ \n\ @example\n\ @@ -1716,10 +1747,8 @@ A = ones (2, 2);\n\ B = zeros (2, 2);\n\ cat (2, A, B)\n\ -@result{} ans =\n\ -\n\ - 1 1 0 0\n\ - 1 1 0 0\n\ + @result{} 1 1 0 0\n\ + 1 1 0 0\n\ @end group\n\ @end example\n\ \n\ @@ -1732,23 +1761,23 @@ @end group\n\ @end example\n\ \n\ -@var{dim} can be larger than the dimensions of the N-d array objects\n\ +@var{dim} can be larger than the dimensions of the N-D array objects\n\ and the result will thus have @var{dim} dimensions as the\n\ following example shows:\n\ \n\ @example\n\ @group\n\ -cat (4, ones(2, 2), zeros (2, 2))\n\ -@result{} ans =\n\ +cat (4, ones (2, 2), zeros (2, 2))\n\ + @result{} ans =\n\ \n\ - ans(:,:,1,1) =\n\ + ans(:,:,1,1) =\n\ \n\ - 1 1\n\ - 1 1\n\ + 1 1\n\ + 1 1\n\ \n\ - ans(:,:,1,2) =\n\ - 0 0\n\ - 0 0\n\ + ans(:,:,1,2) =\n\ + 0 0\n\ + 0 0\n\ @end group\n\ @end example\n\ @seealso{horzcat, vertcat}\n\ @@ -1946,10 +1975,10 @@ DEFUN (permute, args, , "-*- texinfo -*-\n\ -@deftypefn {Built-in Function} {} permute (@var{a}, @var{perm})\n\ -Return the generalized transpose for an N-d array object @var{a}.\n\ +@deftypefn {Built-in Function} {} permute (@var{A}, @var{perm})\n\ +Return the generalized transpose for an N-D array object @var{A}.\n\ The permutation vector @var{perm} must contain the elements\n\ -@code{1:ndims(a)} (in any order, but each element must appear just once).\n\ +@code{1:ndims(A)} (in any order, but each element must appear only once).\n\ @seealso{ipermute}\n\ @end deftypefn") { @@ -1958,15 +1987,15 @@ DEFUN (ipermute, args, , "-*- texinfo -*-\n\ -@deftypefn {Built-in Function} {} ipermute (@var{a}, @var{iperm})\n\ +@deftypefn {Built-in Function} {} ipermute (@var{A}, @var{iperm})\n\ The inverse of the @code{permute} function. The expression\n\ \n\ @example\n\ -ipermute (permute (a, perm), perm)\n\ +ipermute (permute (A, perm), perm)\n\ @end example\n\ \n\ @noindent\n\ -returns the original array @var{a}.\n\ +returns the original array @var{A}.\n\ @seealso{permute}\n\ @end deftypefn") { @@ -3433,28 +3462,29 @@ DEFUN (ones, args, , "-*- texinfo -*-\n\ -@deftypefn {Built-in Function} {} ones (@var{x})\n\ -@deftypefnx {Built-in Function} {} ones (@var{n}, @var{m})\n\ -@deftypefnx {Built-in Function} {} ones (@var{n}, @var{m}, @var{k}, @dots{})\n\ +@deftypefn {Built-in Function} {} ones (@var{n})\n\ +@deftypefnx {Built-in Function} {} ones (@var{m}, @var{n})\n\ +@deftypefnx {Built-in Function} {} ones (@var{m}, @var{n}, @var{k}, @dots{})\n\ +@deftypefnx {Built-in Function} {} ones ([@var{m} @var{n} @dots{}])\n\ @deftypefnx {Built-in Function} {} ones (@dots{}, @var{class})\n\ Return a matrix or N-dimensional array whose elements are all 1.\n\ -If invoked with a single scalar integer argument, return a square\n\ -matrix of the specified size. If invoked with two or more scalar\n\ +If invoked with a single scalar integer argument @var{n}, return a square\n\ +@nospell{NxN} matrix. If invoked with two or more scalar\n\ integer arguments, or a vector of integer values, return an array with\n\ -given dimensions.\n\ +the given dimensions.\n\ \n\ If you need to create a matrix whose values are all the same, you should\n\ use an expression like\n\ \n\ @example\n\ -val_matrix = val * ones (n, m)\n\ +val_matrix = val * ones (m, n)\n\ @end example\n\ \n\ The optional argument @var{class} specifies the class of the return array\n\ and defaults to double. For example:\n\ \n\ @example\n\ -val = ones (n,m, \"uint8\")\n\ +val = ones (m,n, \"uint8\")\n\ @end example\n\ @seealso{zeros}\n\ @end deftypefn") @@ -3483,21 +3513,22 @@ DEFUN (zeros, args, , "-*- texinfo -*-\n\ -@deftypefn {Built-in Function} {} zeros (@var{x})\n\ -@deftypefnx {Built-in Function} {} zeros (@var{n}, @var{m})\n\ -@deftypefnx {Built-in Function} {} zeros (@var{n}, @var{m}, @var{k}, @dots{})\n\ +@deftypefn {Built-in Function} {} zeros (@var{n})\n\ +@deftypefnx {Built-in Function} {} zeros (@var{m}, @var{n})\n\ +@deftypefnx {Built-in Function} {} zeros (@var{m}, @var{n}, @var{k}, @dots{})\n\ +@deftypefnx {Built-in Function} {} zeros ([@var{m} @var{n} @dots{}])\n\ @deftypefnx {Built-in Function} {} zeros (@dots{}, @var{class})\n\ Return a matrix or N-dimensional array whose elements are all 0.\n\ If invoked with a single scalar integer argument, return a square\n\ -matrix of the specified size. If invoked with two or more scalar\n\ +@nospell{NxN} matrix. If invoked with two or more scalar\n\ integer arguments, or a vector of integer values, return an array with\n\ -given dimensions.\n\ +the given dimensions.\n\ \n\ The optional argument @var{class} specifies the class of the return array\n\ and defaults to double. For example:\n\ \n\ @example\n\ -val = zeros (n,m, \"uint8\")\n\ +val = zeros (m,n, \"uint8\")\n\ @end example\n\ @seealso{ones}\n\ @end deftypefn") @@ -4113,14 +4144,15 @@ DEFUN (eye, args, , "-*- texinfo -*-\n\ -@deftypefn {Built-in Function} {} eye (@var{x})\n\ -@deftypefnx {Built-in Function} {} eye (@var{n}, @var{m})\n\ +@deftypefn {Built-in Function} {} eye (@var{n})\n\ +@deftypefnx {Built-in Function} {} eye (@var{m}, @var{n})\n\ +@deftypefnx {Built-in Function} {} eye ([@var{m} @var{n}])\n\ @deftypefnx {Built-in Function} {} eye (@dots{}, @var{class})\n\ -Return an identity matrix. If invoked with a single scalar argument,\n\ -@code{eye} returns a square matrix with the dimension specified. If you\n\ -supply two scalar arguments, @code{eye} takes them to be the number of\n\ -rows and columns. If given a vector with two elements, @code{eye} uses\n\ -the values of the elements as the number of rows and columns,\n\ +Return an identity matrix. If invoked with a single scalar argument @var{n},\n\ +return a square @nospell{NxN} identity matrix. If\n\ +supplied two scalar arguments (@var{m}, @var{n}), @code{eye} takes them to be\n\ +the number of rows and columns. If given a vector with two elements,\n\ +@code{eye} uses the values of the elements as the number of rows and columns,\n\ respectively. For example:\n\ \n\ @example\n\ @@ -4154,6 +4186,7 @@ Calling @code{eye} with no arguments is equivalent to calling it\n\ with an argument of 1. This odd definition is for compatibility\n\ with @sc{matlab}.\n\ +@seealso{speye}\n\ @end deftypefn") { octave_value retval; @@ -4271,20 +4304,21 @@ DEFUN (linspace, args, , "-*- texinfo -*-\n\ -@deftypefn {Built-in Function} {} linspace (@var{base}, @var{limit}, @var{n})\n\ +@deftypefn {Built-in Function} {} linspace (@var{base}, @var{limit})\n\ +@deftypefnx {Built-in Function} {} linspace (@var{base}, @var{limit}, @var{n})\n\ Return a row vector with @var{n} linearly spaced elements between\n\ @var{base} and @var{limit}. If the number of elements is greater than one,\n\ -then the @var{base} and @var{limit} are always included in\n\ +then the endpoints @var{base} and @var{limit} are always included in\n\ the range. If @var{base} is greater than @var{limit}, the elements are\n\ stored in decreasing order. If the number of points is not specified, a\n\ value of 100 is used.\n\ \n\ The @code{linspace} function always returns a row vector if both\n\ -@var{base} and @var{limit} are scalars. If one of them or both are column\n\ +@var{base} and @var{limit} are scalars. If one, or both, of them are column\n\ vectors, @code{linspace} returns a matrix.\n\ \n\ -For compatibility with @sc{matlab}, return the second argument if\n\ -fewer than two values are requested.\n\ +For compatibility with @sc{matlab}, return the second argument (@var{limit})\n\ +if fewer than two values are requested.\n\ @end deftypefn") { octave_value retval; @@ -4357,8 +4391,8 @@ DEFUN (resize, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} resize (@var{x}, @var{m})\n\ -@deftypefnx {Built-in Function} {} resize (@var{x}, @var{m}, @var{n})\n\ @deftypefnx {Built-in Function} {} resize (@var{x}, @var{m}, @var{n}, @dots{})\n\ +@deftypefnx {Built-in Function} {} resize (@var{x}, [@var{m} @var{n} @dots{}])\n\ Resize @var{x} cutting off elements as necessary.\n\ \n\ In the result, element with certain indices is equal to the corresponding\n\ @@ -4386,11 +4420,12 @@ @noindent\n\ but is performed more efficiently.\n\ \n\ -If only @var{m} is supplied and it is a scalar, the dimension of the\n\ -result is @var{m}-by-@var{m}. If @var{m} is a vector, then the\n\ -dimensions of the result are given by the elements of @var{m}.\n\ -If both @var{m} and @var{n} are scalars, then the dimensions of\n\ -the result are @var{m}-by-@var{n}.\n\ +If only @var{m} is supplied, and it is a scalar, the dimension of the\n\ +result is @var{m}-by-@var{m}.\n\ +If @var{m}, @var{n}, @dots{} are all scalars, then the dimensions of\n\ +the result are @var{m}-by-@var{n}-by-@dots{}.\n\ +If given a vector as input, then the\n\ +dimensions of the result are given by the elements of that vector.\n\ \n\ An object can be resized to more dimensions than it has;\n\ in such case the missing dimensions are assumed to be 1.\n\ @@ -4443,13 +4478,16 @@ DEFUN (reshape, args, , "-*- texinfo -*-\n\ -@deftypefn {Built-in Function} {} reshape (@var{a}, @var{m}, @var{n}, @dots{})\n\ -@deftypefnx {Built-in Function} {} reshape (@var{a}, @var{size})\n\ -Return a matrix with the given dimensions whose elements are taken\n\ -from the matrix @var{a}. The elements of the matrix are accessed in\n\ -column-major order (like Fortran arrays are stored).\n\ +@deftypefn {Built-in Function} {} reshape (@var{A}, @var{m}, @var{n}, @dots{})\n\ +@deftypefnx {Built-in Function} {} reshape (@var{A}, [@var{m} @var{n} @dots{}])\n\ +@deftypefnx {Built-in Function} {} reshape (@var{A}, @dots{}, [], @dots{})\n\ +@deftypefnx {Built-in Function} {} reshape (@var{A}, @var{size})\n\ +Return a matrix with the specified dimensions (@var{m}, @var{n}, @dots{})\n\ +whose elements are taken from the matrix @var{A}. The elements of the\n\ +matrix are accessed in column-major order (like Fortran arrays are stored).\n\ \n\ -For example:\n\ +The following code demonstrates reshaping a 1x4 row vector into a 2x2 square\n\ +matrix.\n\ \n\ @example\n\ @group\n\ @@ -4461,10 +4499,13 @@ \n\ @noindent\n\ Note that the total number of elements in the original\n\ -matrix must match the total number of elements in the new matrix.\n\ +matrix (@code{prod (size (@var{A}))}) must match the total number of elements\n\ +in the new matrix (@code{prod ([@var{m} @var{n} @dots{}])}).\n\ \n\ -A single dimension of the return matrix can be unknown and is flagged\n\ -by an empty argument.\n\ +A single dimension of the return matrix may be left unspecified and Octave\n\ +will determine its size automatically. An empty matrix ([]) is used to flag\n\ +the unspecified dimension.\n\ +@seealso{resize}\n\ @end deftypefn") { octave_value retval; @@ -4584,6 +4625,7 @@ @code{@var{x}(:)}. If @var{dim} is supplied, the dimensions of @var{v}\n\ are set to @var{dim} with all elements along the last dimension.\n\ This is equivalent to @code{shiftdim (@var{x}(:), 1-@var{dim})}.\n\ +@seealso{vech}\n\ @end deftypefn") { octave_value retval; @@ -4871,7 +4913,7 @@ @deftypefn {Built-in Function} {} not (@var{x})\n\ Return the logical NOT of @var{x}. This function is equivalent to\n\ @code{! x}.\n\ -@seealso{and, or}\n\ +@seealso{and, or, xor}\n\ @end deftypefn") { return unary_op_defun_body (octave_value::op_not, args); @@ -5214,7 +5256,7 @@ @end example\n\ \n\ At least one argument is required.\n\ -@seealso{or, not}\n\ +@seealso{or, not, xor}\n\ @end deftypefn") { return binary_assoc_op_defun_body (octave_value::op_el_and, @@ -5235,7 +5277,7 @@ @end example\n\ \n\ At least one argument is required.\n\ -@seealso{and, not}\n\ +@seealso{and, not, xor}\n\ @end deftypefn") { return binary_assoc_op_defun_body (octave_value::op_el_or, @@ -5425,7 +5467,7 @@ @deftypefnx {Loadable Function} {[@var{s}, @var{i}] =} sort (@var{x}, @var{mode})\n\ @deftypefnx {Loadable Function} {[@var{s}, @var{i}] =} sort (@var{x}, @var{dim}, @var{mode})\n\ Return a copy of @var{x} with the elements arranged in increasing\n\ -order. For matrices, @code{sort} orders the elements in each column.\n\ +order. For matrices, @code{sort} orders the elements within columns\n\ \n\ For example:\n\ \n\ @@ -5438,6 +5480,11 @@ @end group\n\ @end example\n\ \n\ +If the optional argument @var{dim} is given, then the matrix is sorted\n\ +along the dimension defined by @var{dim}. The optional argument @code{mode}\n\ +defines the order in which the values will be sorted. Valid values of\n\ +@code{mode} are `ascend' or `descend'.\n\ +\n\ The @code{sort} function may also be used to produce a matrix\n\ containing the original row indices of the elements in the sorted\n\ matrix. For example:\n\ @@ -5454,16 +5501,27 @@ @end group\n\ @end example\n\ \n\ -If the optional argument @var{dim} is given, then the matrix is sorted\n\ -along the dimension defined by @var{dim}. The optional argument @code{mode}\n\ -defines the order in which the values will be sorted. Valid values of\n\ -@code{mode} are `ascend' or `descend'.\n\ +For equal elements, the indices are such that equal elements are listed\n\ +in the order in which they appeared in the original list.\n\ +\n\ +Sorting of complex entries is done first by magnitude (@code{abs (@var{z})})\n\ +and for any ties by phase angle (@code{angle (z)}). For example:\n\ \n\ -For equal elements, the indices are such that the equal elements are listed\n\ -in the order that appeared in the original list.\n\ +@example\n\ +@group\n\ +sort ([1+i; 1; 1-i])\n\ + @result{} 1 + 0i\n\ + 1 - 1i\n\ + 1 + 1i\n\ +@end group\n\ +@end example\n\ +\n\ +NaN values are treated as being greater than any other value and are sorted\n\ +to the end of the list.\n\ \n\ The @code{sort} function may also be used to sort strings and cell arrays\n\ -of strings, in which case the dictionary order of the strings is used.\n\ +of strings, in which case ASCII dictionary order (uppercase 'A' precedes\n\ +lowercase 'a') of the strings is used.\n\ \n\ The algorithm used in @code{sort} is optimized for the sorting of partially\n\ ordered lists.\n\ @@ -5813,7 +5871,8 @@ DEFUN (issorted, args, , "-*- texinfo -*-\n\ -@deftypefn {Built-in Function} {} issorted (@var{a}, @var{mode})\n\ +@deftypefn {Built-in Function} {} issorted (@var{a})\n\ +@deftypefnx {Built-in Function} {} issorted (@var{a}, @var{mode})\n\ @deftypefnx {Built-in Function} {} issorted (@var{a}, @code{\"rows\"}, @var{mode})\n\ Return true if the array is sorted according to @var{mode}, which\n\ may be either \"ascending\", \"descending\", or \"either\". By default,\n\ @@ -5936,7 +5995,8 @@ \n\ nth_element encapsulates the C++ standard library algorithms nth_element and\n\ partial_sort. On average, the complexity of the operation is O(M*log(K)),\n\ -where @code{M = size(@var{x}, @var{dim})} and @code{K = length (@var{n})}.\n\ +where @w{@code{M = size (@var{x}, @var{dim})}} and\n\ +@w{@code{K = length (@var{n})}}.\n\ This function is intended for cases where the ratio K/M is small; otherwise,\n\ it may be better to use @code{sort}.\n\ @seealso{sort, min, max}\n\ @@ -6550,8 +6610,10 @@ DEFUN (diff, args, , "-*- texinfo -*-\n\ -@deftypefn {Built-in Function} {} diff (@var{x}, @var{k}, @var{dim})\n\ -If @var{x} is a vector of length @var{n}, @code{diff (@var{x})} is the\n\ +@deftypefn {Built-in Function} {} diff (@var{x})\n\ +@deftypefnx {Built-in Function} {} diff (@var{x}, @var{k})\n\ +@deftypefnx {Built-in Function} {} diff (@var{x}, @var{k}, @var{dim})\n\ +If @var{x} is a vector of length @math{n}, @code{diff (@var{x})} is the\n\ vector of first differences\n\ @tex\n\ $x_2 - x_1, \\ldots{}, x_n - x_{n-1}$.\n\ @@ -6566,15 +6628,15 @@ The second argument is optional. If supplied, @code{diff (@var{x},\n\ @var{k})}, where @var{k} is a non-negative integer, returns the\n\ @var{k}-th differences. It is possible that @var{k} is larger than\n\ -then first non-singleton dimension of the matrix. In this case,\n\ +the first non-singleton dimension of the matrix. In this case,\n\ @code{diff} continues to take the differences along the next\n\ non-singleton dimension.\n\ \n\ The dimension along which to take the difference can be explicitly\n\ -stated with the optional variable @var{dim}. In this case the \n\ +stated with the optional variable @var{dim}. In this case the\n\ @var{k}-th order differences are calculated along this dimension.\n\ In the case where @var{k} exceeds @code{size (@var{x}, @var{dim})}\n\ -then an empty matrix is returned.\n\ +an empty matrix is returned.\n\ @end deftypefn") { int nargin = args.length ();