1 <?xml version="1.0" encoding="UTF-8"?>
3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4 * Copyright (C) 2006-2008 - INRIA
6 * This file must be used under the terms of the CeCILL.
7 * This source file is licensed as described in the file COPYING, which
8 * you should have received as part of this distribution. The terms
9 * are also available at
10 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
13 <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="en" xml:id="tlist">
15 <refname>tlist</refname>
16 <refpurpose>Scilab object and typed list definition. </refpurpose>
19 <title>Calling Sequence</title>
20 <synopsis>tlist(typ, a1, ..., an)</synopsis>
23 <title>Arguments</title>
28 <para>a character string or vector of character strings.</para>
35 any Scilab object (<literal>matrix</literal>, <literal>list</literal>,
36 <literal>string</literal>, ...).
43 <title>Description</title>
45 <literal>tlist(typ, a1, ..., an)</literal> creates a <literal>typed-list</literal> with elements <varname>ai</varname>'s. The <varname>typ</varname> argument specifies the list type. Such <literal>typed-list</literal> allows the user to define new operations working on these object through Scilab functions. The only difference between <literal>typed-list</literal> and <literal>list</literal> is the value of the type (16 instead of 15).
48 <code>typ(1)</code> specifies the list type (character string used to define soft coded operations).
51 If specified <code>typ(i)</code> may give the <literal>(i+1)</literal>-th element formal name.
54 Standard Operations on <literal>list</literal> work similarly for <literal>typed-list</literal>:
60 <literal>[x, y, z, ...]=l(v)</literal> where <literal>v</literal> is a vector of indices;
61 <literal>[x, y, z]=l(:)</literal> extracts all the elements.
67 <literal>l(i)=a</literal>
73 <code>l(i)=null()</code> removes the <literal>i</literal>-th
74 element of the <literal>tlist</literal> <literal>l</literal>.
76 Note that the semantics of <code>l.x=null()</code> is undefined, but a definition can be given through the <link linkend="overloading">overloading</link> mechanism.
83 Moreover if <code>typ(2:n+1)</code> are specified, user may
84 point elements by their names.
87 We give below examples where <literal>tlist</literal> are used.
90 Linear systems are represented by specific <literal>typed-list</literal> e.g. a
91 linear system <literal>[A,B,C,D]</literal> is represented by the <literal>tlist</literal>
92 <code>Sys=tlist(['lss';'A';'B';'C';'D';'X0';'dt'],A,B,C,D,x0,'c')</code>
93 and this specific list may be created by the function <function>syslin</function>.
96 <code>Sys(2)</code>, <code>Sys('A')</code> or <code>Sys.A</code> is the state-matrix and <code>Sys('dt')</code> or <code>Sys.dt</code> is the time domain.
99 A rational matrix <literal>H</literal> is represented by the <literal>typed-list</literal>
100 <code>H=rlist(Num,Den,[])</code> where <literal>Num</literal> and <literal>Den</literal> are two
101 polynomial matrices and a continuous time linear system with
102 transfer matrix <literal>H</literal> may be created by <code>syslin('c',H)</code>.
105 <code>H(2)</code>, <code>H('num')</code> or <code>H.num</code> is the transfer matrix numerator.
109 <title>Examples</title>
110 <programlisting role="example"><![CDATA[
112 t = tlist(["listtype","field1","field2"], [], []);
115 t.field2(1) = "Scilab";
116 t.field2(2) = "tlist";
117 t.field2(3) = "example";
119 // Fields contents display
123 // Generic tlist display
126 // Overloading display for this type of tlist
127 function %listtype_p(mytlist)
128 f = fieldnames(mytlist);
130 // typeof(mytlist) <=> f(1)
131 mprintf("Displaying a tlist of type: %s\n", typeof(mytlist));
135 mprintf("-- Field ''%s'' --\n", f(1));
136 mprintf("Contents: %s\n", sci2exp(mytlist(f(1))));
140 mprintf("-- Field ''%s'' --\n", f(2));
141 mprintf("Contents: %s\n", sci2exp(mytlist(f(2))));
144 // Display using overloading function
148 <refsection role="see also">
149 <title>See Also</title>
150 <simplelist type="inline">
152 <link linkend="percent">percent</link>
155 <link linkend="syslin">syslin</link>
158 <link linkend="list">list</link>
161 <link linkend="mlist">mlist</link>