changeset 19107:ec1e295402fa

doc: explain permute's PERM variable and give examples * data.cc (Fpermute): Explain how the PERM variable is used. Give four quick examples.
author Jordi Gutiérrez Hermoso <jordigh@octave.org>
date Mon, 08 Sep 2014 12:05:37 -0400
parents afc1a8965664
children 43f50a269cbc
files libinterp/corefcn/data.cc
diffstat 1 files changed, 21 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/data.cc	Mon Sep 08 08:09:45 2014 +0200
+++ b/libinterp/corefcn/data.cc	Mon Sep 08 12:05:37 2014 -0400
@@ -2602,6 +2602,27 @@
 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 only once).\n\
+\n\
+The @var{N}th dimension of @var{A} gets remapped to dimension \n\
+@code{@var{PERM}(@var{N})}.\n\ For example,\n\
+\n\
+@example\n\
+@group\n\
+@var{x} = zeros ([2, 3, 5, 7]);\n\
+size (@var{x})\n\
+   @result{}  2   3   5   7\n\
+\n\
+size (permute (@var{x}, [2, 1, 3, 4]))\n\
+   @result{}  3   2   5   7\n\
+\n\
+size (permute (@var{x}, [1, 3, 4, 2]))\n\
+   @result{}  2   5   7   3\n\
+\n\
+## The identity permutation\n\
+size (permute (@var{x}, [1, 2, 3, 4]))\n\
+   @result{}  2   3   5   7\n\
+@end group\n\
+@end example\n\
 @seealso{ipermute}\n\
 @end deftypefn")
 {