<?xml version="1.0" encoding="UTF-8"?>
<!--
 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 * Copyright (C) INRIA
 * Copyright (C) 2017 - Samuel GOUGEON
 *
 * 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:mml="http://www.w3.org/1998/Math/MathML"
    xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org"
    xml:lang="ja" xml:id="type">
    <refnamediv>
        <refname>type</refname>
        <refpurpose>変数の型を返す</refpurpose>
    </refnamediv>
    <refsynopsisdiv>
        <title>呼び出し手順</title>
        <synopsis>i = type(x)</synopsis>
    </refsynopsisdiv>
    <refsection>
        <title>パラメータ</title>
        <variablelist>
            <varlistentry>
                <term>x</term>
                <listitem>
                    <para>Scilab オブジェクト</para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>i</term>
                <listitem>
                    <para>整数</para>
                </listitem>
            </varlistentry>
        </variablelist>
    </refsection>
    <refsection>
        <title>説明</title>
        <para>
            <literal>type(x)</literal>  は,以下のように
            <literal>x</literal>の型の種類を整数で返します :
        </para>
        <para>
            1
            :  実数または複素数の定数行列.
        </para>
        <para>
            2
            :  多項式行列.
        </para>
        <para>
            4
            :  論理値行列.
        </para>
        <para>
            5
            :  疎行列.
        </para>
        <para>
            6
            :  論理値疎行列.
        </para>
        <para>
            7
            :  Matlab 疎行列.
        </para>
        <para>
            8
            :  1 2 4 または 8 バイトに保存される整数行列.
        </para>
        <para>
            9
            :  グラフィックハンドルの行列.
        </para>
        <para>
            10
            :  文字列の行列.
        </para>
        <para>
            13
            :  コンパイル済みの関数 (Scilab コード).
        </para>
        <para>
            14
            :  関数ライブラリ.
        </para>
        <para>
            15
            :  リスト.
        </para>
        <para>
            16
            :  型付リスト (tlist).
        </para>
        <para>
            17
            :  行列の型付リスト (mlist).
        </para>
        <para>
            128
            : Xcosブロックへのポインタ(参照)、<link linkend="lufact">lufact</link>()の結果へのポインタな.
        </para>
        <para>
            129
            : 添字に使用される暗黙の大きさの多項式.
        </para>
        <para>
            130
            : Scilab 内部コード (C または Fortran コード).
        </para>
        <para>0 :
          An undefined element of a list (with a typeof <literal>void</literal>, such as
          in the function call <literal>foo(a,,b)</literal>, or in
          <literal>list(%pi,,%i,,,%z)</literal>), or a null object of typeof
          <literal>listdelete</literal> returned by <literal>null()</literal>.
        </para>
        <refsect2>
            <title>Remarks</title>
            <para>
                Some data may be stored in custom containers defined as typed lists of type 16
                (tlist) or 17 (matrix-oriented typed mlist). This is also the case for embedded
                types like (<emphasis role="italic">rationals</emphasis>), structures
                (<emphasis role="italic">struct</emphasis>),
                <emphasis role="italic">state-space</emphasis>, interactive trees
                (<emphasis role="italic">uitree</emphasis>), etc, for which
                <literal>type(..)</literal> will return 16 or 17. One will use
                <link linkend="typeof">typeof</link> to get more information about their actual
                (sub)type.
            </para>
            <para>
                <emphasis role="bold">Type conversion in mixed operations</emphasis>:
            </para>
            <para>
                When a binary operator (like the multiplication) or an n-ary iterated one
                (like the concatenation) is applied beween two operands of distinct but
                compatible types, usually the type of one of both is implicitely converted,
                and the other operand sets the type of the result to its own type.
                <para>
                    Examples with the <link linkend="brackets">concatenation</link> :
                    <literal>[%t, 3.124]</literal>, <literal>[int8(5), 3.124]</literal>, etc.
                </para>
                <para>
                For the concatenation, addition, substraction, multiplication, division,
                and the power operation, the hierarchy between operands types is as follows
                (read "A &lt; B": B imposes its type to A) :
                <simplelist>
                    <member>
                        boolean &lt; (decimal number, complex encoded number)
                    </member>
                    <member>
                        <warning>
                            (decimal number, complex-encoded number) &lt; encoded integer.
                        </warning>
                    </member>
                    <member>
                        polynomial (real | complex) &lt; rational (real | complex)
                    </member>
                </simplelist>
                </para>
            </para>
        </refsect2>
    </refsection>
    <refsection>
        <title>Examples</title>
        <programlisting role="example"><![CDATA[
// (Select some lines, right-click and choose "Execute.." to run the selection)
L = list(%pi,,"abc");
type(L(2))                  // undefined component of a list

type(42)                    // decimal numbers
type(%nan)
type(%inf)

type(1+%i)                  // complex numbers

s = sparse([1,2;4,5;3,10],[1,2,3]);
type(s)                     // sparse-encoded decimal or complex numbers

type(%t)                    // booleans

type(s>2)                   // sparse-encoded booleans

g = int8([1 -120 127 312]); // encoded integers
type(g)
type(1.23 * int8(4))

type(1-%z+%z^2)             // polynomials

type(gdf())                 // graphic handles

type("foo")                 // texts

deff('[x] = mymacro(y,z)',['a=3*y+1'; 'x=a*z+y']);
type(mymacro)               // Scilab functions

type(disp)                  // Built-in functions

l = list(1,["a" "b"]);      // simple lists
type(l)

e = tlist(["listtype","field1","field2"], [], []);
type(e)                     // Typed list

h = mlist(['V','name','value'],['a','b';'c' 'd'],[1 2; 3 4]);
type(h)                     // Typed matrix-oriented list

clear s, s.r = %pi          // structures
type(s)

c = {%t %pi %i %z "abc" s}  // cells
type(c)

r = [%z/(1-%z) (1-%z)/%z^2]
type(r)                     // rational fractions
]]></programlisting>
    </refsection>
    <refsection role="see also">
        <title>参照</title>
        <simplelist type="inline">
            <member>
                <link linkend="typeof">typeof</link>
            </member>
            <member>
                <link linkend="inttype">inttype</link>
            </member>
            <member>
                <link linkend="isreal">isreal</link>
            </member>
            <member>
                <link linkend="brackets">brackets</link>
            </member>
            <member>
                <link linkend="overloading">overloading</link>
            </member>
            <member>
                <link linkend="poly">poly</link>
            </member>
            <member>
                <link linkend="rational">rational</link>
            </member>
            <member>
                <link linkend="tlist">tlist</link>
            </member>
            <member>
                <link linkend="mlist">mlist</link>
            </member>
            <member>
                <link linkend="null">null</link>
            </member>
        </simplelist>
    </refsection>
    <refsection role="history">
        <title>履歴</title>
        <revhistory>
            <revision>
                <revnumber>6.0</revnumber>
                <revdescription>
                  The type 11 is removed. It was used for uncompiled Scilab functions.
                </revdescription>
            </revision>
        </revhistory>
    </refsection>
</refentry>
