Free Download Scilab 6.0 0

0 views
Skip to first unread message

Candi Ruman

unread,
Aug 3, 2024, 11:57:48 AM8/3/24
to welchchidogkuhn

I habitually use csvRead in scilab to read my data files however I am now faced with one which contains blocks of 200 rows, preceeded by 3 lines of headers, all of which I would like to take into account.

I've tried specifying a range of data following the example on the scilab help website for csvRead (example is right at the bottom of the page) ( _US/csvRead.html) but I always come out with the same error messages :

Otherwise, my data is ordered such that I have my three lines of headers (two lines containing a header over just one or two columns, one line containing a header over all columns), 200 lines of data, and a blank line - this represents data from one image and I have about 500 images in the file, I would like to be able to read and process all of them and keep track of the headers because they state the image number which I need to reference later. Example:

Currently your code raise an error and the end of the file because R1 becomes greater than the number of lines. To solve this, you can specify the maximum number of block or test the value of R1 against the number of lines.

My idea was to read the whole file and store it in a string matrix ( since mgetl as been improved since 6.0.0 ), then use csvTextScan on a submatrix. Doing so also removes the manual writing of the number of block/lines.

I try to create shortcuts when an application are running thanks to the icon that appear on the left side and I do Lock to launcher (which actually impede to take a screen shot). Yet, I did it for Eclipse and even if there is an icon, it doesn't work and for SciLab it would never work.

These .desktop files however assume the application is in $PATH, since the commands in the files to not include an absolute path to the binaries.
There is also an instruction on which commands to run when, in .../scilab-5.5.2/share/applications.

Scilab is a scientific software package for numerical computations providing a powerful open computing environment for engineering and scientific applications that is mostly compatible with MATLAB. More information can be found at www.scilab.org.

Let's see how to use SWIG for Scilab on a small example.
In this example we bind from C a function and a global variable into Scilab. The SWIG interface (stored in a file named example.i), is the following:

Note: we supposed in this example that the path to the Scilab include directory is /usr/local/include/scilab (which is the case in a Debian environment), this should be changed for another environment.

SWIG for Scilab provides only a low-level C interface for Scilab (see Scripting Languages for the general approach to wrapping).This means that functions, structs, classes, variables, etc... are interfaced through C functions. These C functions are mapped as Scilab functions.There are a few exceptions, such as constants and enumerations, which can be wrapped directly as Scilab variables.

In Scilab 5.x, identifier names are composed of 24 characters maximum (this limitation disappears from Scilab 6.0 onwards).
By default, variable, member, and function names longer than 24 characters are truncated, and a warning is produced for each truncation.

This can cause ambiguities, especially when wrapping structs/classes, for which the wrapped function name is composed of the struct/class name and field names.In these cases, the %rename directive can be used to choose a different Scilab name.

In the above example, the function parameter is a primitive type and is marshalled by value.So this function is wrapped without any additional customization.Argument values are converted between C types and Scilab types through type mappings.There are several default type mappings for primitive and complex types, described later in the Scilab typemaps section.

When a parameter is not passed by value, such as a pointer or reference, SWIG does not know if it is an input, output (or both) parameter.The INPUT, OUTPUT, INOUT typemaps defined in the typemaps.i library can be used to specify this.

A C function can have several output parameters. They can all be returned as results of the wrapped function as Scilab supports multiple return values from a functionwhen using the typemaps.i library.If the C function itself returns a result, this is returned first before the parameter outputs.

Global variables are manipulated through generated accessor functions.For example, for a given Foo global variable, SWIG actually generates two functions: Foo_get() to get the value of Foo, and Foo_set() to set the value.These functions are used as following:

It works for variables of primitive type, but also for non-primitive types: arrays, and structs/classes which are described later.For now, an example with two global primitive arrays x and y is shown:

This mode can be enabled/disabled at any time in the interface file with %scilabconst(), whichworks like all the other %feature directives.Use the argument value "1" to enable and "0" to disable this mode.For example in this mode the previous constants:

Also, thanks to the SWIG runtime which stores information about types, pointer types are tracked between exchanges Scilab and the native code. Indeed pointer types are stored alongside the pointer address.A pointer is mapped to a Scilab structure (tlist), which contains as fields the pointer address and the pointer type (in fact a pointer to the type information structure in the SWIG runtime).
Why a native pointer is not mapped to a Scilab pointer (type name: "pointer", type ID: 128) ? The big advantage of mapping to a tlist is that it exposes a new type for the pointer in Scilab, type which can be acessed in Scilab with the typeof function, and manipulated using the overloading mechanism.

Structs exist in Scilab, but C structs are not (at least in this version of SWIG) mapped to Scilab structs.A C structure is wrapped through low-level accessor functions, i.e. functions that give access to the member variables of this structure.In Scilab, a structure is manipulated through a pointer which is passed as an argument to the accessor functions.

Classes do not exist in Scilab. The classes are wrapped the same way as structs.Low-level accessor functions are generated for class members.Also, constructor and destructor functions are generated to create and destroy an instance of the class.

Note: like structs, class pointers are mapped as described in Pointers. Let's give an example which shows that each class pointer type is a new type in Scilab that can be used for example (through overloading) to implement a custom print for the Point class:

This mechanism also applies for accessor functions: they are generated only in the class in which they are defined.But any instance of a derived class can be used as the argument to these accessor functions.

C++ operators are partially supported.Operator overloading exists in Scilab, but a C++ operator is not (in this version) wrapped by SWIG as a Scilab operator, but as a function.It is not automatic, you have to rename each operator (with the instruction %rename) with the suitable wrapper name.

SWIG is aware of C++ namespaces, but does not use it for wrappers.The module is not broken into submodules, nor do namespace appear in functions names.All the namespaces are all flattened in the module.For example with one namespace Foo:

If the function has a throw exception specification, SWIG can automatically map the exception type and set an appropriate Scilab error message.It works for a few primitive types, and also for STL exceptions (the library std_except.i has to be included to get the STL exception support):

Typemaps are available by default for arrays. Primitive type arrays are automatically converted to/from Scilab matrices.Typemaps are also provided to handle members of a struct or class that are arrays.

In input, the matrix is usually one-dimensional (it can be either a row or column vector). But it can also be a two-dimensional matrix.Warning: in Scilab, the values are column-major ordered, unlike in C, which is row-major ordered.

The type mappings used for arrays is the same for primitive types, described earlier.This means that, if needed, a Scilab double vector is converted in input into the related C integer arrayand this C integer array is automatically converted on output into a Scilab double vector.Note that unlike scalars, no control is done for arrays when a double is converted into an integer.

The STL library wraps some containers defined in the STL (Standard Template Library), so that they can be manipulated in Scilab.This library also provides the appropriate typemaps to use the containers in functions and variables.

Then for each container used, the appropriate template must be instantiated, in the std namespace:namespace std %template(IntVector) vector; %template(DoubleVector) vector;Additionally, the module initialization function has to be executed first in Scilab, so that all the types are known to Scilab.See the Module initialization section for more details.

Because in Scilab matrices exist for basic types only, a sequence container of pointers is mapped to a Scilab list.For other item types (double, int, string...) the sequence container is mapped to a Scilab matrix.

The first example below shows how to create a vector (of int) in Scilab, add some values to the vector and pass it as an argument of a function.It also shows, thanks to the typemaps, that we can also pass a Scilab matrix of values directly into the function:

In this mode, used by default, SWIG generates the wrapper sources, which have to be manually compiled and linked.A loader script loader.sce is also produced, this one is executed further in Scilab to load the module.

In this mode, in addition to the wrapper sources, SWIG produces a builder Scilab script (builder.sce), which is executed in Scilab to build the module.In a few words, the Scilab ilib_build() command is used, which produces the shared library file, and the loader script loader.sce (and also a cleaner script cleaner.sce).

c80f0f1006
Reply all
Reply to author
Forward
0 new messages