summaryrefslogtreecommitdiffstats
path: root/scilab/modules/data_structures/help/en_US/tlist.xml
blob: d54e0ee947501e582a868c697eebf13b4530cbfd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<?xml version="1.0" encoding="UTF-8"?>
<!--
 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 * Copyright (C) 2006-2008 - INRIA
 *
 * This file must be used under the terms of the CeCILL.
 * This source file is licensed as described in the file COPYING, which
 * you should have received as part of this distribution.  The terms
 * are also available at
 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
 *
 -->
<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" version="5.0-subset Scilab" xml:lang="en" xml:id="tlist">
  <info>
    <pubdate>$LastChangedDate$</pubdate>
  </info>
  <refnamediv>
    <refname>tlist</refname>
    <refpurpose> Scilab object and typed list definition.  </refpurpose>
  </refnamediv>
  <refsynopsisdiv>
    <title>Calling Sequence</title>
    <synopsis>tlist(typ,a1,....an )</synopsis>
  </refsynopsisdiv>
  <refsection>
    <title>Parameters</title>
    <variablelist>
      <varlistentry>
        <term>typ</term>
        <listitem>
          <para>Character string or vector of character strings</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term>ai</term>
        <listitem>
          <para>Any Scilab object (<literal>matrix, list,string...</literal>).</para>
        </listitem>
      </varlistentry>
    </variablelist>
  </refsection>
  <refsection>
    <title>Description</title>
    <para>
    Creates a <literal>typed-list</literal> with elements <literal>ai</literal>'s. The <literal>typ</literal>
    argument specifies the list type. Such <literal>typed-list</literal> allow 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).</para>
    <para><literal>typ(1)</literal> specifies the list type (character string used to define
    soft coded operations)</para>
    <para>
    if specified <literal>typ(i)</literal> may give the <literal>i+1</literal>th element formal name</para>
    <para>
    Standard Operations on <literal>list</literal> work similarly for <literal>typed-list</literal>:</para>
    <para>
     extraction
    : <literal>[x,y,z...]=l(v)</literal> where <literal>v</literal> is a vector of indices;
    <literal>[x,y,z]=l(:)</literal> extracts all the elements.</para>
    <para>
      insertion
    : <literal>l(i)=a</literal></para>
    <para>
     deletion : <literal>l(i)=null()</literal> removes the i-th
     element of the <literal>tlist l</literal>. Note that the
     semantics of <literal>l.x=null()</literal> is undefined, but a
     definition can be given through the <link
     linkend="overloading">overloading</link> mechanism.</para>
    <para>
     display</para>
    <para>
    Moreover if <literal>typ(2:n+1)</literal> are specified, user may point elements by
    their names</para>
    <para>
    We give below examples where tlist are used.</para>
    <para>
    Linear systems are represented by specific <literal>typed-list</literal> e.g. a
    linear system <literal>[A,B,C,D]</literal> is represented by the tlist
    <literal>Sys=tlist(['lss';'A';'B';'C';'D';'X0';'dt'],A,B,C,D,x0,'c')</literal>
    and this specific list may be created by the function <literal>syslin</literal>.</para>
    <para>
    Sys(2), Sys('A') or Sys.A is the state-matrix and Sys('dt') or Sys.dt is the time domain</para>
    <para>
    A rational matrix <literal>H</literal> is represented by the <literal>typed-list</literal>
    <literal>H=tlist(['r';'num';'den';'dt'],Num,Den,[])</literal> where <literal>Num</literal> and <literal>Den</literal> are two
    polynomial matrices and a  (e.g. continuous time) linear system with
    transfer matrix <literal>H</literal> maybe created by <literal>syslin('c',H)</literal>.</para>
    <para>
    H(2), H('num') or H.num is the transfer matrix numerator</para>
  </refsection>
  <refsection>
    <title>Examples</title>
    <programlisting role="example"><![CDATA[
// tlist creation
t = tlist(["listtype","field1","field2"], [], []);
t.field1(1) = 10;
t.field1(2) = 20;
t.field2(1) = "Scilab";
t.field2(2) = "tlist";
t.field2(3) = "example";

// Fields contents display
disp(t.field1)
disp(t.field2)

// Generic tlist display
disp(t)

// Overloading display for this type of tlist
function %listtype_p(mytlist)
  f = fieldnames(mytlist);

  // typeof(mytlist) <=> f(1)
  mprintf("Displaying a tlist of type: %s\n", typeof(mytlist));

  mprintf("\n");

  mprintf("-- Field ''%s'' --\n", f(1));
  mprintf("Contents: %s\n", sci2exp(mytlist(f(1))));

  mprintf("\n");

  mprintf("-- Field ''%s'' --\n", f(2));
  mprintf("Contents: %s\n", sci2exp(mytlist(f(2))));
endfunction

// Display using overloading function
disp(t)
 ]]></programlisting>
  </refsection>
  <refsection>
    <title>See Also</title>
    <simplelist type="inline">
      <member>
        <link linkend="percent">percent</link>
      </member>
      <member>
        <link linkend="syslin">syslin</link>
      </member>
      <member>
        <link linkend="list">list</link>
      </member>
    </simplelist>
  </refsection>
</refentry>