# HG changeset patch # User jwe # Date 848450068 0 # Node ID 80a42c3fefc9468638c61103ece7a40514be238b # Parent c3d634d49ce4e63a455ebadcd02de8151cfdb317 [project @ 1996-11-20 00:34:27 by jwe] diff --git a/doc/interpreter/arith.texi b/doc/interpreter/arith.texi --- a/doc/interpreter/arith.texi +++ b/doc/interpreter/arith.texi @@ -155,6 +155,20 @@ @end ifinfo @end deftypefn +@deftypefn {Function File} {} nextpow2 (@var{x}) +If @var{x} is a scalar, returns the first integer @var{n} such that +@iftex +@tex + $2^n \ge |x|$. +@end tex +@end iftex +@ifinfo + 2^n >= abs (x). +@end ifinfo + +If @var{x} is a vector, return @code{nextpow2 (length (@var{x}))}. +@end deftypefn + @deftypefn {Mapping Function} {} sqrt (@var{x}) Compute the square root of @var{x}. To compute the matrix square root, see @ref{Linear Algebra}. @@ -468,6 +482,124 @@ Returns the natural logarithm of the gamma function. @end deftypefn +@deftypefn {Function File} {} cross (@var{x}, @var{y}) +Computes the vector cross product of the two 3-dimensional vectors +@var{x} and @var{y}. +@end deftypefn + +@deftypefn {Function File} {} commutation_matrix (@var{m}, @var{n}) +Returns the commutation matrix +@iftex + $K_{m,n}$ +@tex +@end tex +@end iftex +@ifinfo + K(m,n) +@end ifinfo + which is the unique +@iftex +@tex + $m n \times m n$ +@end tex +@end iftex +@ifinfo + @var{m}*@var{n} by @var{m}*@var{n} +@end ifinfo + matrix such that +@iftex +@tex + $K_{m,n} * {\rm vec} (A) = {\rm vec} (A^T)$ +@end tex +@end iftex +@ifinfo + @var{K}(@var{m},@var{n}) * vec (@var{A}) = vec (@var{A}') +@end ifinfo + for all +@iftex +@tex + $m\times n$ +@end tex +@end iftex +@ifinfo + @var{m} by @var{n} +@end ifinfo + matrices +@iftex +@tex + $A$. +@end tex +@end iftex +@ifinfo + @var{A}. +@end ifinfo + +If only one argument @var{m} is given, +@iftex +@tex + $K_{m,m}$ +@end tex +@end iftex +@ifinfo + K(m,m) +@end ifinfo + is returned. + +See Magnus and Neudecker (1988), Matrix differential calculus with +applications in statistics and econometrics. +@end deftypefn + +@deftypefn {Function File} {} duplication_matrix (@var{n}) +Returns the duplication matrix +@iftex +@tex + $D_n$ +@end tex +@end iftex +@ifinfo + @var{D}_@var{n} +@end ifinfo + which is the unique +@iftex +@tex + $n^2 \times n(n+1)/2$ +@end tex +@end iftex +@ifinfo + @var{n}^2 by @var{n}*(@var{n}+1)/2 +@end ifinfo + matrix such that +@iftex +@tex + $D_n * {\rm vech} (A) = {\rm vec} (A)$ +@end tex +@end iftex +@ifinfo + @var{D}_@var{n} * vech (@var{A}) = vec (@var{A}) +@end ifinfo + for all symmetric +@iftex +@tex +@end tex + $n \times n$ +@end iftex +@ifinfo + @var{n} by @var{n} +@end ifinfo + matrices +@iftex +@tex + $A$. +@end tex +@end iftex +@ifinfo + @var{A}. +@end ifinfo + +See Magnus and Neudecker (1988), Matrix differential calculus with +applications in statistics and econometrics. +@end deftypefn + @node Mathematical Constants, , Special Functions, Arithmetic @section Mathematical Constants diff --git a/doc/interpreter/linalg.texi b/doc/interpreter/linalg.texi --- a/doc/interpreter/linalg.texi +++ b/doc/interpreter/linalg.texi @@ -366,13 +366,12 @@ is a unitary matrix @iftex @tex -($U' U$ +($U^T U$ is identity) @end tex @end iftex @ifinfo -(@code{u'* u} +(@code{u'* u} is identity) @end ifinfo - is identity) and @iftex @tex diff --git a/doc/interpreter/matrix.texi b/doc/interpreter/matrix.texi --- a/doc/interpreter/matrix.texi +++ b/doc/interpreter/matrix.texi @@ -75,6 +75,47 @@ @code{while} statements) Octave treats the test as if you had typed @code{all (all (condition))}. +@deftypefn {Function File} {[@var{errorcode}, @var{y_1}, ...] =} common_size (@var{x_1}, ...) +Determine if all input arguments are either scalar or of common +size. If so, errorcode is zero, and @var{y_i} is a matrix of the +common size with all entries equal to @var{x_i} if this is a scalar or +@var{x_i} otherwise. If the inputs cannot be brought to a common size, +errorcode is 1, and @var{y_i} is @var{x_i}. For example, + +@example +@group +[errorcode, a, b] = common_size ([1 2; 3 4], 5) + @result{} errorcode = 0 + @result{} a = [1 2, 3 4] + @result{} b = [5 5; 5 5] +@end group +@end example + +@noindent +This is useful for implementing functions where arguments can either +be scalars or of common size. +@end deftypefn + +@deftypefn {Function File} {} diff (@var{x}, @var{k}) +If @var{x} is a vector of length @var{n}, @code{diff (@var{x})} is the +vector of first differences +@iftex +@tex + $x_2 - x_1, \ldots{}, x_n - x_{n-1}$. +@end tex +@end iftex +@ifinfo + @var{x}(2) - @var{x}(1), @dots{}, @var{x}(n) - @var{x}(n-1). +@end ifinfo + +If @var{x} is a matrix, @code{diff (@var{x})} is the matrix of column +differences. + +The second argument is optional. If supplied, @code{diff (@var{x}, +@var{k})}, where @var{k} is a nonnegative integer, returns the +@var{k}-th differences. +@end deftypefn + @deftypefn {Mapping Function} {} isinf (@var{x}) Return 1 for elements of @var{x} that are infinite and zero otherwise. For example, @@ -250,6 +291,13 @@ matrix must match the total number of elements in the new matrix. @end deftypefn +@deftypefn {Function File} {} shift (@var{x}, @var{b}) +If @var{x} is a vector, perform a circular shift of length @var{b} of +the elements of @var{x}. + +If @var{x} is a matrix, do the same for each column of @var{x}. +@end deftypefn + @deftypefn {Loadable Function} {[s, i] =} sort (@var{x}) Returns a copy of @var{x} with the elements elements arranged in increasing order. For matrices, @code{sort} orders the elements in each @@ -352,3 +400,20 @@ @end group @end example @end deftypefn + +@deftypefn {Function File} {} vec (@var{x}) +For a matrix @var{x}, returns the vector obtained by stacking the +columns of @var{x} one above the other. + +See Magnus and Neudecker (1988), Matrix differential calculus with +applications in statistics and econometrics. +@end deftypefn + +@deftypefn {Function File} {} vech (@var{x}) +For a square matrix @var{x}, returns the vector obtained from @var{x} +by eliminating all supradiagonal elements and stacking the result +one column above the other. + +See Magnus and Neudecker (1988), Matrix differential calculus with +applications in statistics and econometrics. +@end deftypefn