typeof was refering to xmlobjects instead of XMLObjects
[scilab.git] / scilab / modules / data_structures / help / en_US / typeof.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
5  * Copyright (C) 2015 - 2016 - Samuel GOUGEON
6  * Copyright (C) 2012 - 2016 - Scilab Enterprises
7  *
8  * This file is hereby licensed under the terms of the GNU GPL v2.0,
9  * pursuant to article 5.3.4 of the CeCILL v.2.1.
10  * This file was originally licensed under the terms of the CeCILL v2.1,
11  * and continues to be available under such terms.
12  * For more information, see the COPYING file which you should have received
13  * along with this program.
14  *
15  -->
16 <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="typeof" xml:lang="en">
17     <refnamediv>
18         <refname>typeof</refname>
19         <refpurpose>Human-readable type or overloading code of an object</refpurpose>
20     </refnamediv>
21     <refsynopsisdiv>
22         <title>Syntax</title>
23         <synopsis>
24             t  = typeof(object)
25             oc = typeof(object, "overload")
26         </synopsis>
27     </refsynopsisdiv>
28     <refsection role="parameters">
29         <title>Arguments</title>
30         <variablelist>
31             <varlistentry>
32                 <term>object</term>
33                 <listitem>
34                     <para>a Scilab object</para>
35                 </listitem>
36             </varlistentry>
37             <varlistentry>
38                 <term>t</term>
39                 <listitem>
40                     <para>
41                         a string (may have spaces): the name of the type of <varname>object</varname>
42                     </para>
43                 </listitem>
44             </varlistentry>
45             <varlistentry>
46                 <term>oc</term>
47                 <listitem>
48                     <para>a string (without spaces): the name of the overloading code for the
49                         <varname>object</varname>.
50                     </para>
51                 </listitem>
52             </varlistentry>
53         </variablelist>
54     </refsection>
55     <refsection role="description">
56         <title>Description</title>
57         <para>
58             <code>t = typeof(object)</code> returns one of the following strings:
59         </para>
60         <table>
61             <tr>
62                 <td>
63                     <emphasis role="bold">string</emphasis>
64                 </td>
65                 <td>
66                     <varname>object</varname> is a matrix or hypermatrix made of
67                     <link linkend="strings">characters</link> and texts.
68                 </td>
69             </tr>
70             <tr>
71                 <td>
72                     <emphasis role="bold">boolean</emphasis>
73                 </td>
74                 <td>
75                     <varname>object</varname> is a
76                     <link linkend="matrices">boolean matrix or hypermatrix</link>.
77                 </td>
78             </tr>
79             <tr>
80                 <td colspan="2">
81                     <emphasis role="bold">int8</emphasis> or
82                     <emphasis role="bold">int16</emphasis> or
83                     <emphasis role="bold">int32</emphasis> or
84                     <emphasis role="bold">int64</emphasis> or
85                     <emphasis role="bold">uint8</emphasis> or
86                     <emphasis role="bold">uint16</emphasis> or
87                     <emphasis role="bold">uint32</emphasis> or
88                     <emphasis role="bold">uint64</emphasis>
89                 </td>
90             </tr>
91             <tr>
92                 <td> </td>
93                 <td>
94                     <varname>object</varname> is a matrix or hypermatrix of [unsigned]
95                     integers stored
96                     on 8, 16, 32 or 64 bits. (see <link linkend="inttype">inttype</link>)
97                 </td>
98             </tr>
99             <tr>
100                 <td>
101                     <emphasis role="bold">constant</emphasis>
102                 </td>
103                 <td>
104                     <varname>object</varname> is matrix or hypermatrix of
105                     decimal or complex numbers.
106                 </td>
107             </tr>
108             <tr>
109                 <td>
110                     <emphasis role="bold">polynomial</emphasis>
111                 </td>
112                 <td>
113                     <varname>object</varname> is a matrix or hypermatrix of
114                     <link linkend="poly">polynomials</link>
115                     with decimal or complex coefficients.
116                 </td>
117             </tr>
118             <tr>
119                 <td>
120                     <emphasis role="bold">rational</emphasis>
121                 </td>
122                 <td>
123                     <varname>object</varname> is a matrix or hypermatrix of
124                     <link linkend="rational">rational</link>
125                     fractions (e.g. transfer matrix), with decimal or complex coefficients.
126                 </td>
127             </tr>
128             <tr>
129                 <td>
130                     <emphasis role="bold">handle</emphasis>
131                 </td>
132                 <td>
133                     <varname>object</varname> is a graphics
134                     <link linkend="graphics_entities">handle</link>.
135                     The subtype of graphics handles (Figure, Axes, Polyline,
136                     Compound, etc) is available in their <literal>.type</literal>
137                     property. See examples below.
138                 </td>
139             </tr>
140             <tr>
141                 <td>
142                     <emphasis role="bold">list</emphasis>
143                 </td>
144                 <td>
145                     <varname>object</varname> is a <link linkend="list">list</link>.
146                 </td>
147             </tr>
148             <tr>
149                 <td>
150                     <emphasis role="bold">st</emphasis>
151                 </td>
152                 <td>
153                     <varname>object</varname> is a
154                     <link linkend="struct">structure</link>
155                     or a nD-array of structures.
156                 </td>
157             </tr>
158             <tr>
159                 <td>
160                     <emphasis role="bold">ce</emphasis>
161                 </td>
162                 <td>
163                     <varname>object</varname> is a
164                     <link linkend="cell">cell</link> or a nD-array of cells.
165                 </td>
166             </tr>
167             <tr>
168                 <td>
169                     <emphasis role="bold">boolean sparse</emphasis>
170                 </td>
171                 <td>
172                     <varname>object</varname> is a
173                     <link linkend="sparse">boolean sparse matrix</link>.
174                     <warning>Sparse boolean hypermatrices are not supported.</warning>
175                 </td>
176             </tr>
177             <tr>
178                 <td>
179                     <emphasis role="bold">sparse</emphasis>
180                 </td>
181                 <td>
182                     <varname>object</varname> is a
183                     <link linkend="sparse">sparse matrix</link>
184                     of decimal or complex numbers.
185                     <warning>Sparse numerical hypermatrices are not supported.</warning>
186                 </td>
187             </tr>
188             <tr>
189                 <td>
190                     <emphasis role="bold">"Matlab sparse"</emphasis>
191                 </td>
192                 <td>
193                     <varname>object</varname> is a Matlab-like-encoded sparse
194                     matrix (see <link linkend="mtlb_sparse">mtlb_sparse()</link>).
195                 </td>
196             </tr>
197             <tr>
198                 <td>
199                     <emphasis role="bold">fptr</emphasis>
200                 </td>
201                 <td>
202                     <varname>object</varname> is a built-in Scilab function,
203                     called also <emphasis role="italic">gateway</emphasis>
204                     (C, C++ or Fortran code), a.k.a. a primitive.
205                 </td>
206             </tr>
207             <tr>
208                 <td>
209                     <emphasis role="bold">function</emphasis>
210                 </td>
211                 <td>
212                     <varname>object</varname> is a <link linkend="function">function</link>
213                     (Scilab code). See also <link linkend="deff">deff</link>.
214                 </td>
215             </tr>
216             <tr>
217                 <td>
218                     <emphasis role="bold">library</emphasis>
219                 </td>
220                 <td>
221                     <varname>object</varname> is a
222                     <link linkend="library">library</link>
223                     of functions in Scilab language.
224                 </td>
225             </tr>
226             <tr>
227                 <td>
228                     <emphasis role="bold">pointer</emphasis>
229                 </td>
230                 <td>
231                     <varname>object</varname> is a pointer. See a use case:
232                     <link linkend="lufact">lufact</link>.
233                 </td>
234             </tr>
235             <tr>
236                 <td>
237                     <emphasis role="bold">implicitlist</emphasis>
238                 </td>
239                 <td>
240                     <varname>object</varname> is an implicit list using a
241                     polynomial as formal index, for indexing.
242                     See  <link linkend="dollar">n:$</link>
243                     <link linkend="colon">: (colon)</link>
244                 </td>
245             </tr>
246             <tr>
247                 <td>
248                     <emphasis role="bold">listdelete</emphasis>
249                 </td>
250                 <td>
251                     is returned by 
252                     <function>
253                         typeof(<literal>null()</literal>)
254                     </function>
255                     .
256                     See  <link linkend="null">null()</link>.
257                 </td>
258             </tr>
259             <tr>
260                 <td>
261                     <emphasis role="bold">void</emphasis>
262                 </td>
263                 <td>is the typeof undefined elements in lists.</td>
264             </tr>
265             <tr>
266                 <td colspan="2"></td>
267             </tr>
268             <tr>
269                 <td colspan="2">
270                     <emphasis role="bold italic">Typed T-Lists or M-Lists:</emphasis>
271                 </td>
272             </tr>
273             <tr>
274                 <td colspan="2">
275                     Note that if the <varname>object</varname> is a
276                     <link linkend="tlist">tlist</link>
277                     or a <link linkend="mlist">mlist</link>, <function>typeof</function>
278                     will return the corresponding customized type stored in as a
279                     string in the first list entry.
280                 </td>
281             </tr>
282             <tr>
283                 <td colspan="2"></td>
284             </tr>
285             <tr>
286                 <td colspan="2">
287                     <emphasis role="bold italic">Reserved T-List or M-List types
288                         predefined in Scilab:
289                     </emphasis>
290                 </td>
291             </tr>
292             <tr>
293                 <td>
294                     <emphasis role="bold">dir</emphasis>
295                 </td>
296                 <td>
297                     <varname>object</varname> is the result of a
298                     <link linkend="dir">dir()</link>
299                     instruction, with fields <literal>name</literal>, <literal>date</literal>,
300                     <literal>bytes</literal>, and <literal>isdir</literal>.
301                 </td>
302             </tr>
303             <tr>
304                 <td>
305                     <emphasis role="bold">state-space</emphasis>
306                 </td>
307                 <td>
308                     <varname>object</varname> is a state-space model
309                     (see <link linkend="syslin">syslin</link>).
310                 </td>
311             </tr>
312             <tr>
313                 <td>
314                     <emphasis role="bold">XMLDoc</emphasis>
315                 </td>
316                 <td>
317                     <varname>object</varname> is an XML Document created with
318                     <link linkend="xmlRead">xmlRead</link>,
319                     <link linkend="xmlReadStr">xmlReadStr</link>,
320                     <link linkend="htmlRead">htmlRead</link>, or
321                     <link linkend="htmlReadStr">htmlReadStr</link>.
322                     Additional XML typeof are defined.
323                 </td>
324             </tr>
325             <tr>
326                 <td>
327                     <emphasis role="bold">H5Object</emphasis>
328                 </td>
329                 <td>
330                     <varname>object</varname> is the id of an HDF5 file opened
331                     with <link linkend="h5open">h5open</link>.
332                     Additional HDF5 typeof are defined:
333                     See <link linkend="h5objects">HDF5 Objects</link>.
334                 </td>
335             </tr>
336             <tr>
337                 <td>
338                     <emphasis role="bold">uitree</emphasis>
339                 </td>
340                 <td>
341                     <varname>object</varname> is a tree, a branch or a leaf as created with  a
342                     uitree feature. See for instance <link linkend="uiCreateNode">uiCreateNode</link>.
343                 </td>
344             </tr>
345         </table>
346     </refsection>
347     <refsection role="examples">
348         <title>Examples</title>
349         <programlisting role="no-scilab-exec"><![CDATA[
350 // Characters and texts
351 t = ["a" "Hello"   "à é è ï ô û ñ"
352      "1" "Bonjour" "указывает тип объекта"
353      ";" "Chao"    "オブジェクトの型"
354     ]
355 typeof(t)
356
357 // Booleans
358 typeof(%t)
359 typeof("abc"=="def")
360 hm = grand(2,2,2,"uin",0,9)<5
361 typeof(hm)
362
363 // Encoded integers
364 [ typeof(uint8(%pi))  typeof(int8(-%pi))
365   typeof(uint16(%pi)) typeof(int16(-%pi))
366   typeof(uint32(%pi)) typeof(int32(-%pi))
367   typeof(uint64(%pi)) typeof(int64(-%pi))
368 ]
369
370 // Decimal numbers
371 n = 1:0.3:2
372 typeof(n)
373 hm = grand(2,2,2,"uin",0,9)
374 typeof(hm)
375
376 // Decimal integers
377 n = 1:7
378 typeof(n)
379
380 // Complex numbers
381 n = [%i 1-%i %pi - 3*%i]
382 typeof(n)
383
384 // Special "constant"
385 typeof([])   // empty matrix
386
387 // Polynomials
388 n = [ %z (1-%z)^2]
389 typeof(n)
390 n = [ 3*%i + %z (1-%i*%z)^2]
391 typeof(n)
392
393 // Rational fractions
394 r = [%s/(1-%s) (1+%s)^2/(1-%s)]   // with real coefficients
395 typeof(r)
396 r = [%s/(%i-%s) (%i+%s)^2/(1-%s)] // with complex coefficients
397 typeof(r)
398
399 // Sparse matrices
400 // ---------------
401 w = sprand(100,100,0.001)
402 typeof(w)     // sparse
403 typeof(w==w)  // boolean sparse
404 //x = mtlb_sparse(sprand(10,10,0.1));
405 //typeof(x)
406
407 // Functions and libraries
408 // -----------------------
409 deff('y=f(x)','y=2*x');  // Function in Scilab language
410 f(%pi)
411 typeof(f)
412 typeof(cosd)  // written in Scilab
413
414 typeof(corelib) // Library of functions in Scilab language
415
416 typeof(sin)     // Built-in function (non-editable)
417 mysin = sin;
418 mysin(%pi/2)
419
420 // Graphical handles
421 // -----------------
422 clf
423 plot2d()
424 typeof(gcf())
425 // The subtype of the handle is in the "type" property:
426 gcf().type
427 gca().type
428 gce().type
429
430 close(gcf())
431
432 // Containers
433 // ----------
434 // Simple list
435 L = list(%pi, %t, %z, %s/(1-%s), "Bonjour", sin, cosd, list("list_in_list", 432));
436 typeof(L)
437
438 // Cells array
439 C = {%pi, %t, %z ; %s/(1-%s), "Bonjour", list("list_in_list", 432) }
440 typeof(C)
441
442 // (Array of) Structure
443 S.num = %pi;
444 S.b = %t;
445 S(2).t = "Bonjour"
446 typeof(S)
447
448 // Special generic indexing expressions
449 // ------------------------------------
450 typeof($)
451 typeof(:)    // "eye()" equivalent (all elements)
452 typeof(3:$)
453
454 // Typeof for deletion or undefined elements:
455 // -----------------------------------------
456 typeof([])      // empty matrix
457 typeof(null())
458 L = list(%pi, ,"hey!")
459 typeof(L(2))   // undefined element
460
461 // Customized typeof of T-Lists:
462 // ----------------------------
463 L = tlist(['myLongTypeOf','a','b'], 18, 'Scilab');
464 typeof(L)
465
466 // Reserved T-List typeof
467 // ----------------------
468 typeof(dir())  // files directory
469
470 doc = xmlReadStr("<root><a att=""foo"">Hello</a></root>");
471 typeof(doc)
472 xmlDelete(doc)
473
474 x = 1;
475 save(TMPDIR + "/x.sod", "x"); // SOD files are HDF5 ones
476 a = h5open(TMPDIR + "/x.sod");
477 typeof(a)
478 h5close(a)
479  ]]></programlisting>
480     </refsection>
481     <refsection role="see also">
482         <title>See Also</title>
483         <simplelist type="inline">
484             <member>
485                 <link linkend="type">type</link>
486             </member>
487             <member>
488                 <link linkend="inttype">inttype</link>
489             </member>
490             <member>
491                 <link linkend="overloading">overloading</link>
492             </member>
493             <member>
494                 <link linkend="isreal">isreal</link>
495             </member>
496             <member>
497                 <link linkend="strings">strings</link>
498             </member>
499             <member>
500                 <link linkend="poly">poly</link>
501             </member>
502             <member>
503                 <link linkend="rlist">rlist</link>
504             </member>
505             <member>
506                 <link linkend="null">null</link>
507             </member>
508             <member>
509                 <link linkend="sparse">sparse</link>
510             </member>
511             <member>
512                 <link linkend="issparse">issparse</link>
513             </member>
514             <member>
515                 <link linkend="mtlb_sparse">mtlb_sparse</link>
516             </member>
517             <member>
518                 <link linkend="syslin">syslin</link>
519             </member>
520             <member>
521                 <link linkend="dir">dir</link>
522             </member>
523             <member>
524                 <link linkend="XMLObjects">XML Objects</link>
525             </member>
526             <member>
527                 <link linkend="h5objects">HDF5 Objects</link>
528             </member>
529         </simplelist>
530     </refsection>
531     <refsection role="history">
532         <title>History</title>
533         <revhistory>
534             <revision>
535                 <revnumber>6.0</revnumber>
536                 <revdescription>
537                     <itemizedlist>
538                         <listitem>"overload" keyword added. </listitem>
539                         <listitem>typeof "uint64" and "int64" added. </listitem>
540                         <listitem>
541                             typeof "hypermat" removed. Hypermatrices of any homogeneous type are now
542                             natively supported.
543                         </listitem>
544                         <listitem>typeof "listdelete" and "void" added.</listitem>
545                         <listitem>
546                             typeof(:) was "constant" and becomes "implicitlist". typeof(1:$) was
547                             "size implicit" and become "implicitlist".
548                         </listitem>
549                         <listitem>
550                             The typeof of T-lists and M-lists were limited to 8 characters. They may
551                             be longer now.
552                         </listitem>
553                         <listitem>
554                             typeof "size implicit" renamed "implicitlist" (<literal>1:$</literal>)
555                         </listitem>
556                         <listitem>Help page reviewed.</listitem>
557                     </itemizedlist>
558                 </revdescription>
559             </revision>
560         </revhistory>
561     </refsection>
562 </refentry>