<?xml version="1.0" encoding="UTF-8"?>
<!--
 * Scilab ( https://www.scilab.org/ ) - This file is part of Scilab
 * Copyright (C) 2008 - INRIA - Farid BELAHCENE
 * Copyright (C) 2013, 2016 - Samuel GOUGEON : 5.5.0 extensions, page overhauled
 *
 * Copyright (C) 2012 - 2016 - Scilab Enterprises
 *
 * This file is hereby licensed under the terms of the GNU GPL v2.0,
 * pursuant to article 5.3.4 of the CeCILL v.2.1.
 * This file was originally licensed under the terms of the CeCILL v2.1,
 * and continues to be available under such terms.
 * For more information, see the COPYING file which you should have received
 * along with this program.
 *
 -->
<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="ja">
    <refnamediv>
        <refname>flipdim</refname>
        <refpurpose>指定した次元に沿って x ブロック要素を反転</refpurpose>
    </refnamediv>
    <refsynopsisdiv>
        <title>呼び出し手順</title>
        <synopsis>
            y = flipdim(x, dim)
            y = flipdim(x, dim, blockSize)
        </synopsis>
    </refsynopsisdiv>
    <refsection>
        <title>引数</title>
        <variablelist>
            <varlistentry>
                <term>x, y</term>
                <listitem>
                    <para>
                        ベクトル、行列、または任意の通常のデータ型のハイパーマトリックスを含む、
                        or cells array.
                        <varname> y </varname>は<varname> x </varname>のサイズを取得します.
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>dim</term>
                <listitem>
                    <para>
                        positive integer : index of the dimension / direction of <literal>x</literal>
                        along which the order of <varname>x</varname> components must be inverted.
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>blockSize</term>
                <listitem>
                    <para>
                        a positive integer, sub-multiple of <literal>size(x,dim)</literal>:
                        number of rows, of columns, of pages etc in each block. Default value = 1
                    </para>
                </listitem>
            </varlistentry>
        </variablelist>
    </refsection>
    <refsection>
        <title>説明</title>
        <para>
            <literal>flipdim(x, 1)</literal> inverts the order of
            <emphasis role="italic">rows</emphasis> of <varname>x</varname>.
        </para>
        <para>
            <literal>flipdim(x, 2)</literal> inverts the order of
            <emphasis role="italic">columns</emphasis> of <varname>x</varname>.
        </para>
        <para>
            <literal>flipdim(x, 3)</literal> inverts the order of
            <emphasis role="italic">pages</emphasis> of <varname>x</varname>. Etc.
        </para>
        <para>
            The optional parameter <literal>blockSize</literal> allows splitting
            <varname>x</varname> in <literal>size(x,1)/blockSize</literal> blocks
            of <varname>blockSize</varname> rows (<literal>dim=1</literal>),
            or in <literal>size(x,2)/blockSize</literal> blocks of <varname>blockSize</varname>
            columns (<literal>dim=2</literal>), etc (<literal>dim>2</literal>)
            and to invert their order.
            In each block, the order of components (rows, columns, pages etc)
            is unchanged.
        </para>
    </refsection>
    <refsection>
        <title>例</title>
        <programlisting role="example"><![CDATA[
// 例 1: x の要素を最初の次元に沿って反転
x = [1 2 3 4; 5 6 7 8];
y = flipdim(x, 1)

// 例2: x の要素を2番目の次元に沿って反転
y = flipdim(x, 2)

// 例3: x の要素を3番目の次元に沿って反転
x = matrix(1:48,[3 2,4,2]);
y = flipdim(x, 3)

// 例4: 最初の例を複素数に
x = [1+%i 2*%i 3 4; 5 6-%i 7 8*%pi*%i]
y = flipdim(x, 1)

// 整数エンコードされた数値
x = int16(grand(4, 3, 2, "uin", -9, 9))
y = flipdim(x, 1)

// 論理値:
x = (grand(3, 4, "uin", -9, 9) > 0)
y = flipdim(x, 2)

// テキスト:
x = matrix(strsplit("a":"x", 1:23), 4, 6);
x = x+x
flipdim(x, 2)

// 多項式:
x = inv_coeff(grand(3, 9, "uin", 0, 3), 2)
flipdim(x, 1)

// 有理数:
n = inv_coeff(grand(3, 9, "uin", 0, 3), 2);
d = inv_coeff(grand(3, 9, "uin", 0, 3), 2);
d(d == 0) = 1;
r = n./d
flipdim(r, 2)
 ]]></programlisting>
        <para>
            <literal>blockSize</literal>の使用例 :
        </para>
        <programlisting role="example"><![CDATA[
X = [0 1 2 3 4 5 6 7 8 9 10 11];
flipdim(X, 2, 2) // => [10 11   8 9   6 7   4 5   2 3   0 1] // ブロックサイズ = 2.
flipdim(X, 2, 3) // => [9 10 11   6 7 8   3 4 5   0 1 2]
flipdim(X, 2, 4) // => [8 9 10 11   4 5 6 7   0 1 2 3]
flipdim(X, 2, 6) // => [6 7 8 9 10 11   0 1 2 3 4 5]
 ]]></programlisting>
    <para>Example of results:</para>
    <screen><![CDATA[
--> x
 x  =
 -5 -2  0  9
  0 -7 -6  9
 -1 -8 -7  8

--> flipdim(x, 1)
 ans  =
 -1 -8 -7  8
  0 -7 -6  9
 -5 -2  0  9

--> flipdim(x, 2)
 ans  =
  9  0 -2 -5
  9 -6 -7  0
  8 -7 -8 -1
]]></screen>
    <para></para>
    <screen><![CDATA[
--> x
 x  =
(:,:,1)
  9  4 -3
 -4 -8 -3

(:,:,2)
  5  8  9
  4  4  9

--> flipdim(x, 3)
 ans  =
(:,:,1)
  5  8  9
  4  4  9

(:,:,2)
  9  4 -3
 -4 -8 -3
]]></screen>
    <para></para>
    <screen><![CDATA[
--> x
 x  =
 -2  3 -5  9 -4 -8
  2  8  4 -9  6 -6
 -9  8  3  4 -3  4

--> flipdim(x, 2, 2)
 ans  =
 -4 -8 -5  9 -2  3
  6 -6  4 -9  2  8
 -3  4  3  4 -9  8

--> flipdim(x, 2, 3)
 ans  =
  9 -4 -8 -2  3 -5
 -9  6 -6  2  8  4
  4 -3  4 -9  8  3
]]></screen>
    </refsection>
    <refsection role="see also">
        <title>参照</title>
        <simplelist type="inline">
            <member>
                <link linkend="circshift">circshift</link>
            </member>
            <member>
                <link linkend="fftshift">fftshift</link>
            </member>
            <member>
                <link linkend="ifftshift">ifftshift</link>
            </member>
            <member>
                <link linkend="colon">colon</link>
            </member>
        </simplelist>
    </refsection>
    <refsection>
        <title>履歴</title>
        <revhistory>
            <revision>
                <revnumber>5.5.0</revnumber>
                <revremark>
                    10進数から任意の型に拡張: 論理値, 整数, 文字列, 多項式および有理数.
                    <literal>x</literal>ブロック毎に反転するために,
                    新しい入力引数 <literal>blockSize</literal>が追加されました.
                </revremark>
            </revision>
        </revhistory>
    </refsection>
</refentry>
