1 <?xml version="1.0" encoding="UTF-8"?>
3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4 * Copyright (C) 2008 - INRIA - Farid BELAHCENE
5 * Copyright (C) 2013 - Samuel GOUGEON: restriction to decimal numbers removed. Examples added for booleans, integer-encoded numbers, text, polynomials, rationals
7 * Copyright (C) 2012 - 2016 - Scilab Enterprises
9 * This file is hereby licensed under the terms of the GNU GPL v2.0,
10 * pursuant to article 5.3.4 of the CeCILL v.2.1.
11 * This file was originally licensed under the terms of the CeCILL v2.1,
12 * and continues to be available under such terms.
13 * For more information, see the COPYING file which you should have received
14 * along with this program.
17 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns5="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:id="flipdim" xml:lang="en">
19 <refname>flipdim</refname>
20 <refpurpose>reverses the order of (blocs of) rows, columns, pages.. of a matrix or hypermatrix</refpurpose>
24 <synopsis>y = flipdim(x, dim [,sb])</synopsis>
26 <refsection role="parameters">
27 <title>Arguments</title>
32 <para>scalars, vectors, matrices, or hypermatrices of any type, of same sizes</para>
38 <para>a positive integer, the dimension number along which the flipping should occur</para>
44 <para>a positive integer, the size of the blocks to permute</para>
49 <refsection role="description">
50 <title>Description</title>
52 Given <literal>x</literal>, a scalar/vector/matrix/hypermatrix of any type and
53 two positive integers <literal>dim</literal> and <literal>sb</literal>,
54 this function flips the x components by blocks of size <literal>sb</literal>
55 along the dimension number <literal>dim</literal> of <literal>x</literal>
56 (<literal>x</literal> and <literal>y</literal> have the same size).
59 The optional parameter <literal>sb</literal> (for Size Block) allows flipping
60 <literal>x</literal> by blocks of size <literal>sb*size(x,2)</literal>
61 (<literal>dim=1</literal>) or <literal>size(x,1)*sb</literal> (<literal>dim=2</literal>).
64 <refsection role="examples">
65 <title>Examples</title>
66 <programlisting role="example"><![CDATA[
67 // Example 1: flip x components along the first dimension
68 x = [1 2 3 4; 5 6 7 8]
72 // Example 2: flip x components along the second dimension
76 // Example 3: flip x components along the third dimension
77 x = matrix(1:24, [3 2 4])
81 // Example 4: the first example with complex
82 x = [1+%i 2*%i 3 4; 5 6-%i 7 8*%pi*%i]
86 // Integer-encoded numbers:
87 x = int16(grand(4, 3, 2, "uin", -9, 9))
91 x = (grand(3, 4, "uin", -9, 9) > 0)
95 x = matrix(strsplit("a":"x", 1:23), 4, 6);
100 x = inv_coeff(grand(3, 9, "uin", 0, 3), 2)
104 n = inv_coeff(grand(3, 9, "uin", 0, 3), 2);
105 d = inv_coeff(grand(3, 9, "uin", 0, 3), 2);
110 Examples using <literal>sb</literal>:
112 <programlisting role="example"><![CDATA[
113 X = [0 1 2 3 4 5 6 7 8 9 10 11];
114 flipdim(X, 2, 2) // => [10 11 8 9 6 7 4 5 2 3 0 1] // Block size = 2.
115 flipdim(X, 2, 3) // => [9 10 11 6 7 8 3 4 5 0 1 2]
116 flipdim(X, 2, 4) // => [8 9 10 11 4 5 6 7 0 1 2 3]
117 flipdim(X, 2, 6) // => [6 7 8 9 10 11 0 1 2 3 4 5]
119 // Error if sb does not divide the targeted dimension of x.
120 y = flipdim(x, 2, 5); // size(X) = [1 12] and sb=5 does not divide 12.
123 <refsection role="history">
124 <title>History</title>
127 <revnumber>5.5.0</revnumber>
129 Extension from decimals to any type: booleans, integers, strings, polynomials and rationals.
130 New input argument <literal>sb</literal> to flip <literal>x</literal> blockwise.