scilab: fix doc on arrays
This commit is contained in:
parent
e82225608e
commit
3bbdffa833
1 changed files with 23 additions and 21 deletions
|
|
@ -27,7 +27,8 @@
|
||||||
<li><a href="#Scilab_wrapping_identifiers">Identifiers</a>
|
<li><a href="#Scilab_wrapping_identifiers">Identifiers</a>
|
||||||
<li><a href="#Scilab_wrapping_modules">Modules</a>
|
<li><a href="#Scilab_wrapping_modules">Modules</a>
|
||||||
<li><a href="#Scilab_wrapping_functions">Functions</a>
|
<li><a href="#Scilab_wrapping_functions">Functions</a>
|
||||||
<li><a href="#Scilab_wrapping_type_mappings">Default primitive type mappings</a>
|
<li><a href="#Scilab_wrapping_primitive_type_mappings">Default primitive type mappings</a>
|
||||||
|
<li><a href="#Scilab_wrapping_non-primitive_type_mappings">Scilab non-primitive type mappings</a></li>
|
||||||
<li><a href="#Scilab_wrapping_global_variables">Global variables</a>
|
<li><a href="#Scilab_wrapping_global_variables">Global variables</a>
|
||||||
<li><a href="#Scilab_wrapping_constants">Constants</a>
|
<li><a href="#Scilab_wrapping_constants">Constants</a>
|
||||||
<li><a href="#Scilab_wrapping_enums">Enums</a>
|
<li><a href="#Scilab_wrapping_enums">Enums</a>
|
||||||
|
|
@ -382,7 +383,7 @@ In that case, SWIG displays an error when wrapping a function that has long long
|
||||||
<H3><a name="Scilab_wrapping_non-primitive_type_mappings"></a>37.3.5 Default type mappings for non-primitive types</H3>
|
<H3><a name="Scilab_wrapping_non-primitive_type_mappings"></a>37.3.5 Default type mappings for non-primitive types</H3>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
The default mapped type for C/C++ non-primitive types is the Scilab pointer. That is the case for exemple for C structs, C++ classes, ...
|
The default mapped type for C/C++ non-primitive types is the Scilab pointer. That is the case for exemple for C structs, C++ classes, etc...
|
||||||
But there are many type mappings for non-primitive types (such as enums, arrays, STL types, etc...). Each of them is described further in this document.
|
But there are many type mappings for non-primitive types (such as enums, arrays, STL types, etc...). Each of them is described further in this document.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
@ -620,10 +621,13 @@ ans =
|
||||||
|
|
||||||
<H3><a name="Scilab_wrapping_arrays"></a>37.3.11 Arrays</H3>
|
<H3><a name="Scilab_wrapping_arrays"></a>37.3.11 Arrays</H3>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
One-dimensional arrays are supported whether as global variables or functions arguments.
|
||||||
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Arrays are fully supported by SWIG and Scilab. In SWIG, they are handled as pointers.
|
Global arrays are wrapped through accessor functions.
|
||||||
It is easy to deal with arrays too. For example:
|
For example with two global arrays x and y:
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="code"><pre>
|
<div class="code"><pre>
|
||||||
|
|
@ -632,42 +636,40 @@ It is easy to deal with arrays too. For example:
|
||||||
%inline %{
|
%inline %{
|
||||||
int x[10];
|
int x[10];
|
||||||
double y[7];
|
double y[7];
|
||||||
void initArray()
|
|
||||||
{
|
|
||||||
int i, n;
|
|
||||||
|
|
||||||
n = sizeof(x)/sizeof(x[0]);
|
|
||||||
for(i = 0; i > n; i++)
|
|
||||||
x[i] = i;
|
|
||||||
|
|
||||||
n = sizeof(y)/sizeof(y[0]);
|
|
||||||
for(i = 0; i < n; i++)
|
|
||||||
y[i] = ((double) i)/ ((double) n);
|
|
||||||
return;
|
|
||||||
%}
|
%}
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<p> When wrapped, the following functions are generated: x_set(), x_get(), y_set(), y_get(), and _wrap_initArray.
|
<p>Two Scilab functions are generated for each array: a getter _get() and a setter _set(), prefixed by the array name.
|
||||||
They can be used like this:
|
Following is an example of use of these functions:
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="targetlang"><pre>
|
<div class="targetlang"><pre>
|
||||||
--> exec loader.sce
|
--> exec loader.sce
|
||||||
|
|
||||||
--> initArray();
|
--> x_set([0:9]);
|
||||||
--> x_get()
|
--> x_get()
|
||||||
ans =
|
ans =
|
||||||
|
|
||||||
0 1 2 3 4 5 6 7 8 9
|
0 1 2 3 4 5 6 7 8 9
|
||||||
|
|
||||||
|
--> y_set([0:6] / 7);
|
||||||
--> y_get()
|
--> y_get()
|
||||||
|
|
||||||
|
-->
|
||||||
ans =
|
ans =
|
||||||
|
|
||||||
0. 0.1428571 0.2857143 0.4285714 0.5714286 0.7142857 0.8571429
|
0. 0.1428571 0.2857143 0.4285714 0.5714286 0.7142857 0.8571429
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="Scilab_wrapping_matrices"></a>37.3.12 Matrices</H3>
|
<p>
|
||||||
|
The type mappings used for arrays is described in <a href="#Scilab_wrapping_primitive_type_mappings"> 37.3.4</a>.
|
||||||
|
It means that, if needed, a Scilab double vector is converted in input into a C int array.
|
||||||
|
And this C int array is automatically converted in output to a Scilab double vector.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
<H3><a name="Scilab_wrapping_matrices"></a>37.3.12 Matrices</H3>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Scilab uses matrices a lot for numerical mathematics and scientific visualization. Supporting matrices makes Scilab more convenient. For example:
|
Scilab uses matrices a lot for numerical mathematics and scientific visualization. Supporting matrices makes Scilab more convenient. For example:
|
||||||
</p>
|
</p>
|
||||||
|
|
@ -829,7 +831,7 @@ Standard Template Library (STL) is partially supported.
|
||||||
<p>
|
<p>
|
||||||
The following containers are usable:
|
The following containers are usable:
|
||||||
<p>
|
<p>
|
||||||
|
l
|
||||||
<ul>
|
<ul>
|
||||||
<li><tt>std::vector</tt></li>
|
<li><tt>std::vector</tt></li>
|
||||||
<li><tt>std::list</tt></li>
|
<li><tt>std::list</tt></li>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue