<?xml version="1.0" encoding="UTF-8"?>
<!--
 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 * Copyright (C) 2008 - INRIA
 * Copyright (C) 2015 - 2016 - 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:ns3="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="typeof" xml:lang="pt">
    <refnamediv>
        <refname>typeof</refname>
        <refpurpose>tipo do objeto</refpurpose>
    </refnamediv>
    <refsynopsisdiv>
        <title>Seqüência de Chamamento</title>
        <synopsis>
            t = typeof(object)
            oc = typeof(object, "overload")
        </synopsis>
    </refsynopsisdiv>
    <refsection role="arguments">
        <title>Parâmetros</title>
        <variablelist>
            <varlistentry>
                <term>object</term>
                <listitem>
                    <para>objeto Scilab</para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>t</term>
                <listitem>
                    <para>
                        a string (may have spaces): the name of the type of <varname>object</varname>
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>oc</term>
                <listitem>
                    <para>a string (without spaces): the name of the overloading code for the
                        <varname>object</varname>.
                    </para>
                </listitem>
            </varlistentry>
        </variablelist>
    </refsection>
    <refsection role="description">
        <title>Descrição</title>
        <para>
            <literal>t = typeof(object)</literal> retorna um dos seguintes
            strings:
        </para>
        <table>
            <tr>
                <td>
                    <emphasis role="bold">string</emphasis>
                </td>
                <td>
                    <varname>object</varname> é uma matriz ou hipermatriz de
                    <link linkend="strings">caracteres</link> e/o textos.
                </td>
            </tr>
            <tr>
                <td>
                    <emphasis role="bold">boolean</emphasis>
                </td>
                <td>
                    <varname>object</varname> é uma matriz ou hipermatriz de valores
                    booleanos.
                </td>
            </tr>
            <tr><td colspan="2">
                    <emphasis role="bold">int8</emphasis> ou
                    <emphasis role="bold">int16</emphasis> ou
                    <emphasis role="bold">int32</emphasis> ou
                    <emphasis role="bold">int64</emphasis> ou
                    <emphasis role="bold">uint8</emphasis> ou
                    <emphasis role="bold">uint16</emphasis> ou
                    <emphasis role="bold">uint32</emphasis> ou
                    <emphasis role="bold">uint64</emphasis>
                </td>
            </tr>
            <tr>
                <td> </td>
                <td>
                    <varname>object</varname> is a matrix or hypermatrix of [unsigned]
                    integers stored
                    on 8, 16, 32 or 64 bits. (see <link linkend="inttype">inttype</link>)
                </td>
            </tr>
            <tr>
                <td>
                    <emphasis role="bold">constant</emphasis>
                </td>
                <td>
                    <varname>object</varname> é uma matriz ou hipermatriz
                    de números reais ou complexos
                </td>
            </tr>
            <tr>
                <td>
                    <emphasis role="bold">polynomial</emphasis>
                </td>
                <td>
                    <varname>object</varname> é uma matriz ou hipermatriz de
                    <link linkend="poly">polinômios</link>
                    com coeficientes reais ou complexos.
                </td>
            </tr>
            <tr>
                <td>
                    <emphasis role="bold">rational</emphasis>
                </td>
                <td>
                    <varname>object</varname> é uma matriz ou hipermatriz de
                    <link linkend="rational">razões </link>
                    de polinômios (matriz de transferência), com coeficientes
                    reais ou complexos.
                </td>
            </tr>
            <tr>
                <td>
                    <emphasis role="bold">handle</emphasis>
                </td>
                <td>
                    <varname>object</varname> is a graphics
                    <link linkend="graphics_entities">handle</link>.
                    The subtype of graphics handles (Figure, Axes, Polyline,
                    Compound, etc) is available in their <literal>.type</literal>
                    property. See examples below.
                </td>
            </tr>
            <tr>
                <td>
                    <emphasis role="bold">list</emphasis>
                </td>
                <td>
                    <varname>object</varname> é uma
                    <link linkend="list">lista</link>.
                </td>
            </tr>
            <tr>
                <td>
                    <emphasis role="bold">st</emphasis>
                </td>
                <td>
                    <varname>object</varname> é uma
                    <link linkend="struct">estrutura</link> ou
                    um nD-array de estruturas.
                </td>
            </tr>
            <tr>
                <td>
                    <emphasis role="bold">ce</emphasis>
                </td>
                <td>
                    <varname>object</varname> é uma célula
                    ou um nD-array de <link linkend="cell">células</link>.
                </td>
            </tr>
            <tr>
                <td>
                    <emphasis role="bold">boolean sparse</emphasis>
                </td>
                <td>
                    <varname>object</varname> é uma matriz de valores
                    <link linkend="sparse">booleanos esparsa</link>.
                    <warning>Sparse boolean hypermatrices are not supported.
                    </warning>
                </td>
            </tr>
            <tr>
                <td>
                    <emphasis role="bold">sparse</emphasis>
                </td>
                <td>
                    <varname>object</varname> é uma matriz
                    <link linkend="sparse">esparsa</link> de números
                    reais ou complexos.
                    <warning>Sparse numerical hypermatrices are not supported.</warning>
                </td>
            </tr>
            <tr>
                <td style="white-space:nowrap">
                    <emphasis role="bold">"Matlab sparse"</emphasis>
                </td>
                <td>
                    <varname>object</varname> is a Matlab-like-encoded sparse
                    matrix (see <link linkend="mtlb_sparse">mtlb_sparse()</link>).
                </td>
            </tr>
            <tr>
                <td>
                    <emphasis role="bold">fptr</emphasis>
                </td>
                <td>
                    <varname>object</varname> is a built-in Scilab function,
                    called also <emphasis role="italic">gateway</emphasis>
                    (C, C++ or Fortran code), a.k.a. a primitive.
                </td>
            </tr>
            <tr>
                <td>
                    <emphasis role="bold">function</emphasis>
                </td>
                <td>
                    <varname>object</varname> is a <link linkend="function">function</link>
                    (Scilab code). See also <link linkend="deff">deff</link>.
                </td>
            </tr>
            <tr>
                <td>
                    <emphasis role="bold">library</emphasis>
                </td>
                <td>
                    <varname>object</varname> is a
                    <link linkend="library">library</link>
                    of functions in Scilab language.
                </td>
            </tr>
            <tr>
                <td>
                    <emphasis role="bold">pointer</emphasis>
                </td>
                <td>
                    <varname>object</varname> é um ponteiro (ver
                    <link linkend="lufact">lufact</link>).
                </td>
            </tr>
            <tr>
                <td>
                    <emphasis role="bold">implicitlist</emphasis>
                </td>
                <td>
                    <varname>object</varname> é um polinômio de tamanho
                    implícito para indexação.
                    Ver  <link linkend="dollar">n:$</link> e
                    <link linkend="colon">: (colon)</link>
                </td>
            </tr>
            <tr>
                <td>
                    <emphasis role="bold">listdelete</emphasis>
                </td>
                <td>
                    is returned by
                    <function>
                        typeof(<literal>null()</literal>)
                    </function>
                    .
                    See  <link linkend="null">null()</link>.
                </td>
            </tr>
            <tr>
                <td>
                    <emphasis role="bold">void</emphasis>
                </td>
                <td>is the typeof undefined elements in lists.
                </td>
            </tr>
            <tr>
                <td colspan="2"></td>
            </tr>
            <tr><td colspan="2">
                    <emphasis role="bold italic">Typed T-Lists or M-Lists:</emphasis>
                </td>
            </tr>
            <tr><td colspan="2">
                    Note that if the <varname>object</varname> is a
                    <link linkend="tlist">tlist</link>
                    or a <link linkend="mlist">mlist</link>, <function>typeof</function>
                    will return the corresponding customized type stored in as a
                    string in the first list entry.
                </td>
            </tr>
            <tr>
                <td colspan="2"></td>
            </tr>
            <tr><td colspan="2">
                    <emphasis role="bold italic">Reserved T-List or M-List types
                        predefined in Scilab:
                    </emphasis>
                </td>
            </tr>
            <tr>
                <td>
                    <emphasis role="bold">dir</emphasis>
                </td>
                <td>
                    <varname>object</varname> is the result of a
                    <link linkend="dir">dir()</link>
                    instruction, with fields <literal>name</literal>, <literal>date</literal>,
                    <literal>bytes</literal>, and <literal>isdir</literal>.
                </td>
            </tr>
            <tr>
                <td>
                    <emphasis role="bold">state-space</emphasis>
                </td>
                <td>
                    <varname>object</varname> is a state-space model
                    (see <link linkend="syslin">syslin</link>).
                </td>
            </tr>
            <tr>
                <td>
                    <emphasis role="bold">program</emphasis>
                </td>
                <td>
                    <varname>object</varname> is a list describing the internal code of a function
                    (see <link linkend="macr2tree">macr2tree</link>).
                </td>
            </tr>
            <tr>
                <td>
                    <emphasis role="bold">cblock</emphasis>
                </td>
                <td>
                    <varname>object</varname> is a block of columns of same
                    heights but of different data types, as returned by
                    <link linkend="mfscanf">mfscanf</link>.
                </td>
            </tr>
            <tr>
                <td>
                    <emphasis role="bold">XMLDoc</emphasis>
                </td>
                <td>
                    <varname>object</varname> is an XML Document created with
                    <link linkend="xmlRead">xmlRead</link>,
                    <link linkend="xmlReadStr">xmlReadStr</link>,
                    <link linkend="htmlRead">htmlRead</link>, or
                    <link linkend="htmlReadStr">htmlReadStr</link>.
                    Additional XML typeof are defined.
                </td>
            </tr>
            <tr>
                <td>
                    <emphasis role="bold">H5Object</emphasis>
                </td>
                <td>
                    <varname>object</varname> is the id of an HDF5 file opened
                    with <link linkend="h5open">h5open</link>.
                    Additional HDF5 typeof are defined:
                    See <link linkend="h5objects">HDF5 Objects</link>.
                </td>
            </tr>
            <tr>
                <td>
                    <emphasis role="bold">uitree</emphasis>
                </td>
                <td>
                    <varname>object</varname> is a tree, a branch or a leaf as created with  a
                    uitree feature. See for instance <link linkend="uiCreateNode">uiCreateNode</link>.
                </td>
            </tr>
            <tr>
                <td colspan="2">
                  <emphasis role="bold italic">Reserved T-list types used in Xcos</emphasis> :
                </td>
            </tr>
            <tr>
                <td>
                  <link linkend="scicos_block"><emphasis role="bold">Block</emphasis></link>
                </td>
                <td><varname>object</varname> is a Xcos block.
              </td>
            </tr>
            <tr>
              <td>
                <link linkend="scicos_cpr"><emphasis role="bold">cpr</emphasis></link>
              </td>
              <td>
                <varname>object</varname> is a tlist containing the compilation results of a Xcos diagram.
              </td>
            </tr>
            <tr>
              <td>
                <link linkend="scicos_diagram"><emphasis role="bold">diagram</emphasis></link>
              </td>
              <td>
                <varname>object</varname> is a tlist defining a Xcos diagram: initial parameters,
                set of blocks, of links between blocks, and of Text labels belonging to the diagram.
              </td>
            </tr>
            <tr>
              <td>
                <link linkend="scicos_graphics"><emphasis role="bold">graphics</emphasis></link>
              </td>
              <td>
                <varname>object</varname> is a tlist assigned to the <literal>.graphics</literal>
                field of a block.
              </td>
            </tr>
            <tr>
              <td>
                <link linkend="scicos_link"><emphasis role="bold">Link</emphasis></link>
              </td>
              <td>
                <varname>object</varname> is a tlist defining and configuring a link between 2 blocks.
              </td>
            </tr>
            <tr>
              <td>
                <link linkend="scicos_model"><emphasis role="bold">model</emphasis></link>
              </td>
              <td>
                <varname>object</varname> is a tlist assigned to the <literal>.model</literal> field
                of a block.
              </td>
            </tr>
            <tr>
              <td>
                <link linkend="scicos_params"><emphasis role="bold">params</emphasis></link>
              </td>
              <td>
                <varname>object</varname> is a tlist containing some configuration parameters of a
                Xcos diagram.
              </td>
            </tr>
            <tr>
              <td>
                <emphasis role="bold">scsopt</emphasis>
              </td>
              <td>
                <varname>object</varname> is a tlist containing the graphical options of the Xcos
                diagram editor.
              </td>
            </tr>
            <tr>
              <td>
                <link linkend="scicos_sim"><emphasis role="bold">scs</emphasis></link>
              </td>
              <td>
                <varname>object</varname> is a tlist containing static results of the compilation of
                a Xcos diagram.
              </td>
            </tr>
            <tr>
              <td>
                <link linkend="scicos_state"><emphasis role="bold">xcs</emphasis></link>
              </td>
              <td>
                <varname>object</varname> is a tlist containing dynamical results during a Xcos
                simulation.
              </td>
            </tr>
            <tr>
              <td>
                <emphasis role="bold">Text</emphasis>
              </td>
              <td>
                <varname>object</varname> is a tlist defining a text label in a Xcos diagram.
              </td>
            </tr>
        </table>
    </refsection>
    <refsection role="examples">
        <title>Exemplos</title>
        <programlisting role="no-scilab-exec"><![CDATA[
// Characters and texts
t = ["a" "Hello"   "à é è ï ô û ñ"
     "1" "Bonjour" "указывает тип объекта"
     ";" "Chao"    "オブジェクトの型"
    ]
typeof(t)

// Booleans
typeof(%t)
typeof("abc"=="def")
hm = grand(2,2,2,"uin",0,9)<5
typeof(hm)

// Encoded integers
[ typeof(uint8(%pi))  typeof(int8(-%pi))
  typeof(uint16(%pi)) typeof(int16(-%pi))
  typeof(uint32(%pi)) typeof(int32(-%pi))
  typeof(uint64(%pi)) typeof(int64(-%pi))
]

// Decimal numbers
n = 1:0.3:2
typeof(n)
hm = grand(2,2,2,"uin",0,9)
typeof(hm)

// Decimal integers
n = 1:7
typeof(n)

// Complex numbers
n = [%i 1-%i %pi - 3*%i]
typeof(n)

// Special "constant"
typeof([])   // empty matrix

// Polynomials
n = [ %z (1-%z)^2]
typeof(n)
n = [ 3*%i + %z (1-%i*%z)^2]
typeof(n)

// Rational fractions
r = [%s/(1-%s) (1+%s)^2/(1-%s)]   // with real coefficients
typeof(r)
r = [%s/(%i-%s) (%i+%s)^2/(1-%s)] // with complex coefficients
typeof(r)

// Sparse matrices
// ---------------
w = sprand(100,100,0.001)
typeof(w)     // sparse
typeof(w==w)  // boolean sparse
//x = mtlb_sparse(sprand(10,10,0.1));
//typeof(x)

// Functions and libraries
// -----------------------
deff('y=f(x)','y=2*x');  // Function in Scilab language
f(%pi)
typeof(f)
typeof(cosd)  // written in Scilab

typeof(corelib) // Library of functions in Scilab language

typeof(sin)     // Built-in function (non-editable)
mysin = sin;
mysin(%pi/2)

// Graphical handles
// -----------------
clf
plot2d()
typeof(gcf())
// The subtype of the handle is in the "type" property:
gcf().type
gca().type
gce().type

close(gcf())

// Containers
// ----------
// Simple list
L = list(%pi, %t, %z, %s/(1-%s), "Bonjour", sin, cosd, list("list_in_list", 432));
typeof(L)

// Cells array
C = {%pi, %t, %z ; %s/(1-%s), "Bonjour", list("list_in_list", 432) }
typeof(C)

// (Array of) Structure
S.num = %pi;
S.b = %t;
S(2).t = "Bonjour"
typeof(S)

// Special generic indexing expressions
// ------------------------------------
typeof($)
typeof(:)    // "eye()" equivalent (all elements)
typeof(3:$)

// Typeof for deletion or undefined elements:
// -----------------------------------------
typeof([])      // empty matrix
typeof(null())
L = list(%pi, ,"hey!")
typeof(L(2))   // undefined element

// Customized typeof of T-Lists:
// ----------------------------
L = tlist(['myLongTypeOf','a','b'], 18, 'Scilab');
typeof(L)

// Reserved T-List typeof
// ----------------------
typeof(dir())        // Files directory
//
c = macr2tree(sind); // Internal code of a Scilab macro
typeof(c)
fieldnames(c)'
c.name
//
doc = xmlReadStr("<root><a att=""foo"">Hello</a></root>");
typeof(doc)
xmlDelete(doc)
//
x = 1;
save(TMPDIR + "/x.sod", "x"); // SOD files are HDF5 ones
a = h5open(TMPDIR + "/x.sod");
typeof(a)
h5close(a)
 ]]></programlisting>
    </refsection>
    <refsection role="see also">
        <title>Ver Também</title>
        <simplelist type="inline">
            <member>
                <link linkend="type">type</link>
            </member>
            <member>
                <link linkend="inttype">inttype</link>
            </member>
            <member>
                <link linkend="overloading">overloading</link>
            </member>
            <member>
                <link linkend="isreal">isreal</link>
            </member>
            <member>
                <link linkend="strings">strings</link>
            </member>
            <member>
                <link linkend="poly">poly</link>
            </member>
            <member>
                <link linkend="rlist">rlist</link>
            </member>
            <member>
                <link linkend="null">null</link>
            </member>
            <member>
                <link linkend="sparse">sparse</link>
            </member>
            <member>
                <link linkend="issparse">issparse</link>
            </member>
            <member>
                <link linkend="mtlb_sparse">mtlb_sparse</link>
            </member>
            <member>
                <link linkend="syslin">syslin</link>
            </member>
            <member>
                <link linkend="dir">dir</link>
            </member>
            <member>
                <link linkend="XMLObjects">XML Objects</link>
            </member>
            <member>
                <link linkend="h5objects">HDF5 Objects</link>
            </member>
        </simplelist>
    </refsection>
    <refsection role="history">
        <title>Histórico</title>
        <revhistory>
            <revision>
                <revnumber>6.0</revnumber>
                <revdescription>
                    <itemizedlist>
                        <listitem>"overload" keyword added. </listitem>
                        <listitem>typeof "uint64" and "int64" added. </listitem>
                        <listitem>typeof "hypermat" removed. Hypermatrices of any homogeneous type are now
                            natively supported.
                        </listitem>
                        <listitem>typeof "listdelete" added (as returned by null()).</listitem>
                        <listitem>typeof() can now be used for any undefined element of a list.
                          It then returns the new "void" typeof.
                        </listitem>
                        <listitem>The typeof of T-lists and M-lists were limited to 8 characters.
                          They may be longer now.
                        </listitem>
                        <listitem>
                            typeof "size implicit" renamed "implicitlist" (<literal>1:$</literal>)
                        </listitem>
                        <listitem>Help page reviewed.</listitem>
                    </itemizedlist>
                </revdescription>
            </revision>
        </revhistory>
    </refsection>
</refentry>
