* Bug #12813 fixed - Elementary_functions: open flipdim() to all data types
[scilab.git] / scilab / modules / elementary_functions / help / en_US / matrixmanipulation / flipdim.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
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
6  *
7  * This file must be used under the terms of the CeCILL.
8  * This source file is licensed as described in the file COPYING, which
9  * you should have received as part of this distribution.  The terms
10  * are also available at
11  * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
12  *
13  -->
14 <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">
15     <refnamediv>
16         <refname>flipdim</refname>
17         <refpurpose>flip x components along a given dimension</refpurpose>
18     </refnamediv>
19     <refsynopsisdiv>
20         <title>Calling Sequence</title>
21         <synopsis>y = flipdim(x, dim)</synopsis>
22     </refsynopsisdiv>
23     <refsection>
24         <title>Arguments</title>
25         <variablelist>
26             <varlistentry>
27                 <term>x, y</term>
28                 
29                 <listitem>
30                     <para>scalars, vectors, matrices, or hypermatrices of any type, of same sizes</para>
31                     
32                 </listitem>
33             </varlistentry>
34             <varlistentry>
35                 <term>dim</term>
36                 <listitem>
37                     <para>a positive integer</para>
38                 </listitem>
39             </varlistentry>
40         </variablelist>
41     </refsection>
42     <refsection>
43         <title>Description</title>
44         <para>
45             Given <literal>x</literal>, a scalar/vector/matrix/hypermatrix of any type and
46             <literal>dim</literal> a positive integer, this function flips the x
47             components along the dimension number <literal>dim</literal> of
48             <literal>x</literal> (<literal>x</literal> and <literal>y</literal> have
49             the same size)
50         </para>
51     </refsection>
52     <refsection>
53         <title>Examples</title>
54         <programlisting role="example"><![CDATA[
55 // Example 1: flip x components along the first dimension
56 x = [1 2 3 4; 5 6 7 8];
57 dim = 1;
58 y = flipdim(x, dim)
59
60 // Example 2: flip x components along the second dimension
61 dim = 2;
62 y = flipdim(x, dim)
63
64 // Example 3: flip x components along the third dimension
65 x = matrix(1:24, [3 2 4]);
66 dim = 3;
67 y = flipdim(x, dim)
68
69 // Example 4: the first example with complex
70 x = [1+%i 2*%i 3 4; 5 6-%i 7 8*%pi*%i];
71 dim = 1;
72 y = flipdim(x, dim)
73
74 // Integer-encoded numbers:
75 x = int16(grand(4, 3, 2, "uin", -9, 9));
76 y = flipdim(x, 1)
77
78 // Booleans:
79 x = (grand(3, 4, "uin", -9, 9) > 0);
80 y = flipdim(x, 2)
81
82 // Texts:
83 x = matrix(strsplit("a":"x", 1:23), 4, 6);
84 x = x+x;
85 flipdim(x, 2)
86
87 // Polynomials:
88 x = inv_coeff(grand(3, 9, "uin", 0, 3), 2);
89 flipdim(x, 1)
90
91 // Rationals:
92 n = inv_coeff(grand(3, 9, "uin", 0, 3), 2);
93 d = inv_coeff(grand(3, 9, "uin", 0, 3), 2);
94 r = n./d;
95 flipdim(r, 2)
96
97  ]]></programlisting>
98     </refsection>
99     <refsection>
100         <title>History</title>
101         <revhistory>
102             <revision>
103                 <revnumber>5.5.0</revnumber>
104                 <revremark>Extension from decimals to any type: booleans, integer-encoded numbers, texts, polynomials and rationals.</revremark>
105             </revision>
106         </revhistory>
107     </refsection>
108 </refentry>