summaryrefslogtreecommitdiff
path: root/modules/m2sci/help/en_US/m2scideclare.xml
blob: bf4d90d126d63702ea4a813803327cc6975900b9 (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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
<?xml version="1.0" encoding="UTF-8"?>
<!--
    * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
    * Copyright (C) 2002-2004 - INRIA - Vincent COUVERT 
    * 
    * 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.1-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" xmlns:scilab="http://www.scilab.org" xml:lang="en" xml:id="m2scideclare">
    <refnamediv>
        <refname>m2scideclare</refname>
        <refpurpose>Giving tips to help M2SCI...</refpurpose>
    </refnamediv>
    <refsection>
        <title>Description</title>
        <para>
            The main difficulty for M2SCI (<literal>mfile2sci</literal>) is to find what variables are: dimensions, type...  
        </para>
        <para>
            To help this tool, just add comments beginning with <literal>%m2scideclare</literal> in the M-file to convert, 
            (<literal>%m2sciassume</literal> was used in previous Scilab versions and is now obsolete).
        </para>
        <para>
            The syntax of this command is:
        </para>
        <para>
            <literal>%m2scideclare variable_name|dimensions|data_type|property</literal>
        </para>
        <para>
            with :
        </para>
        <itemizedlist>
            <listitem>
                <itemizedlist>
                    <listitem>
                        <para>
                            variable_name: name of the variable declared. It can be a Struct field (e.g. <literal>x(1,2).name</literal>)
                            or describe the contents of a Cell using syntax
                            <literal>x(1,2).entries</literal>. NOTE that for Cells and Structs,
                            <literal>*</literal> can be used as an index (see examples below).
                        </para>
                    </listitem>
                    <listitem>
                        <para>
                            dimensions: dimensions of the variable declared separated by blanks, if a dimension is unknown,
                            replace it by <literal>?</literal>. NOTE that String dimensions must be similar to Matlab ones
                            e.g. <literal>1 6</literal> for character string 'string'.
                        </para>
                    </listitem>
                    <listitem>
                        <para>
                            data_type: data type of the variable which can be:
                        </para>
                        <informaltable border="1">
                            <tr>
                                <td>m2scideclare data type</td>
                                <td>Scilab "equivalent" type</td>
                            </tr>
                            <tr>
                                <td>Double</td>
                                <td>1</td>
                            </tr>
                            <tr>
                                <td>Boolean</td>
                                <td>4</td>
                            </tr>
                            <tr>
                                <td>Sparse</td>
                                <td>5</td>
                            </tr>
                            <tr>
                                <td>Int</td>
                                <td>8</td>
                            </tr>
                            <tr>
                                <td>Handle</td>
                                <td>9</td>
                            </tr>
                            <tr>
                                <td>String</td>
                                <td>10</td>
                            </tr>
                            <tr>
                                <td>Struct</td>
                                <td>Matlab struct (16)</td>
                            </tr>
                            <tr>
                                <td>Cell</td>
                                <td>Matlab cell (17)</td>
                            </tr>
                            <tr>
                                <td>Void</td>
                                <td>No type (0)</td>
                            </tr>
                            <tr>
                                <td>?</td>
                                <td>Unknown type</td>
                            </tr>
                        </informaltable>
                    </listitem>
                    <listitem>
                        <para>
                            property: property of the variable which can be:
                        </para>
                        <informaltable border="1">
                            <tr>
                                <td>m2scideclare property</td>
                                <td>Scilab "equivalent"</td>
                            </tr>
                            <tr>
                                <td>Real</td>
                                <td>Real data</td>
                            </tr>
                            <tr>
                                <td>Complex</td>
                                <td>Complex data</td>
                            </tr>
                            <tr>
                                <td>?</td>
                                <td>Unknown property</td>
                            </tr>
                        </informaltable>
                        <para>
                            This field is ignored for following datatypes: <literal>Cell</literal>,
                            <literal>Struct</literal>, <literal>String</literal> and <literal>Boolean</literal>.
                        </para>
                    </listitem>
                </itemizedlist>
            </listitem>
        </itemizedlist>
        <para>
            All data given by <literal>m2scideclare</literal> are compared with infered data,
            in case of conflict, infered data are kept and a warning message is displayed.
            If you are sure about your data, report a bug.
        </para>
        <para>Some examples are given below:</para>
        <itemizedlist>
            <listitem>
                <itemizedlist>
                    <listitem>
                        <para>
                            <literal>%m2scideclare var1|2 3|Double|Real</literal>var1 is declared as a 2x3 Double matrix containing real data
                        </para>
                    </listitem>
                    <listitem>
                        <para>
                            <literal>%m2scideclare var2|2 3 10|Double|Complex</literal>var2 is declared as a 2x3x10 Double hypermatrix containing complex data
                        </para>
                    </listitem>
                    <listitem>
                        <para>
                            <literal>%m2scideclare var3(1,2).name|1 10|String|?</literal>var3 is declared as a Struct array containing a 1x10 character string
                            in field 'name' of struct at index (1,2) 
                        </para>
                    </listitem>
                    <listitem>
                        <para>
                            <literal>%m2scideclare var4(1,5).entries|1 ?|Boolean|?</literal>var4 is declared as a Cell containing a row boolean vector at index (1,5)
                        </para>
                    </listitem>
                    <listitem>
                        <para>
                            <literal>%m2scideclare var4(1,6).entries|? ?|Int|?</literal>var4 is declared as a Cell containing a row boolean vector at index (1,5) 
                            and integer data at index (1,6)
                        </para>
                    </listitem>
                    <listitem>
                        <para>
                            <literal>%m2scideclare var5(*,*).name|1 ?|String|?</literal>var5 is declared as a Struct array containing a 1xn character string
                            in all fields 'name'
                        </para>
                    </listitem>
                    <listitem>
                        <para>
                            <literal>%m2scideclare var6(2,*).entries|1 3|Double|Real</literal>var6 is declared as a Cell array containing a 1x3 double vector
                            in each element of its second row
                        </para>
                    </listitem>
                </itemizedlist>
            </listitem>
        </itemizedlist>
    </refsection>
</refentry>