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, 2016 - Samuel GOUGEON : 5.5.0 extensions, page overhauled
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"
18 xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns5="http://www.w3.org/1999/xhtml"
19 xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook"
20 xmlns:scilab="http://www.scilab.org" xml:id="flipdim" xml:lang="en">
22 <refname>flipdim</refname>
23 <refpurpose>reverses the order of (blocks of) rows, columns, pages.. of a matrix or hypermatrix</refpurpose>
29 y = flipdim(x, dim, blockSize)
32 <refsection role="parameters">
33 <title>Arguments</title>
39 vectors, matrices, or hypermatrices of any regular data type.
40 <varname>y</varname> gets the sizes of <varname>x</varname>.
48 positive integer : index of the dimension / direction of <literal>x</literal>
49 along which the order of <varname>x</varname> components must be inverted.
54 <term>blockSize</term>
57 a positive integer, sub-multiple of <literal>size(x,dim)</literal>:
58 number of rows, of columns, of pages etc in each block. Default value = 1
64 <refsection role="description">
65 <title>Description</title>
67 <literal>flipdim(x, 1)</literal> inverts the order of
68 <emphasis role="italic">rows</emphasis> in the matrix or hypermatrix
72 <literal>flipdim(x, 2)</literal> inverts the order of
73 <emphasis role="italic">columns</emphasis> of <varname>x</varname>.
76 <literal>flipdim(x, 3)</literal> inverts the order of
77 <emphasis role="italic">pages</emphasis> in the hypermatrix
78 <varname>x</varname>. Etc.
81 The optional parameter <literal>blockSize</literal> allows splitting
82 <varname>x</varname> in <literal>size(x,1)/blockSize</literal> blocks
83 of <varname>blockSize</varname> rows (<literal>dim=1</literal>),
84 or in <literal>size(x,2)/blockSize</literal> blocks of <varname>blockSize</varname>
85 columns (<literal>dim=2</literal>), etc (<literal>dim>2</literal>)
86 and to invert their order.
87 In each block, the order of components (rows, columns, pages etc)
91 <refsection role="examples">
92 <title>Examples</title>
93 <programlisting role="example"><![CDATA[
94 // Example 1: flip x rows (= components along the first dimension)
95 x = [1 2 3 4; 5 6 7 8]
98 // Example 2: flip x columns (= components along the second dimension)
101 // Example 3: flip x pages (= components along the third dimension)
102 x = matrix(1:24, [3 2 4])
105 // Example 4: the first example with complex
106 x = [1+%i 2*%i 3 4; 5 6-%i 7 8*%pi*%i]
109 // Integer-encoded numbers:
110 x = int16(grand(4, 3, 2, "uin", -9, 9))
114 x = (grand(3, 4, "uin", -9, 9) > 0)
118 x = matrix(strsplit("a":"x", 1:23), 4, 6);
123 x = inv_coeff(grand(3, 9, "uin", 0, 3), 2)
127 n = inv_coeff(grand(3, 9, "uin", 0, 3), 2);
128 d = inv_coeff(grand(3, 9, "uin", 0, 3), 2);
133 Examples using <literal>blockSize</literal> :
135 <programlisting role="example"><![CDATA[
136 X = [0 1 2 3 4 5 6 7 8 9 10 11];
137 flipdim(X, 2, 2) // => [10 11 8 9 6 7 4 5 2 3 0 1] // Block size = 2.
138 flipdim(X, 2, 3) // => [9 10 11 6 7 8 3 4 5 0 1 2]
139 flipdim(X, 2, 4) // => [8 9 10 11 4 5 6 7 0 1 2 3]
140 flipdim(X, 2, 6) // => [6 7 8 9 10 11 0 1 2 3 4 5]
142 // Error if blockSize does not divide the targeted dimension of x.
143 y = flipdim(x, 2, 5); // size(X) = [1 12] and blockSize=5 does not divide 12.
145 <para>Example of results:</para>
208 <refsection role="see also">
209 <title>See also</title>
210 <simplelist type="inline">
212 <link linkend="fftshift">fftshift</link>
215 <link linkend="ifftshift">ifftshift</link>
218 <link linkend="colon">colon</link>
222 <refsection role="history">
223 <title>History</title>
226 <revnumber>5.5.0</revnumber>
230 Extension to all regular data types: booleans, integers,
231 strings, polynomials, rationals, graphic handles, etc.
234 New input argument <literal>blockSize</literal> to flip
235 <literal>x</literal> blockwise.