[Scilab-users] Regarding simple numerical operations result display.

Serge Steer Serge.Steer at inria.fr
Wed Mar 20 14:38:22 CET 2013


Le 19/03/2013 13:32, Stefan Du Rietz a écrit :
> On 2013-03-19 11:43, Serge Steer wrote:
> --------------------
>> Le 19/03/2013 11:26, Dang, Christophe a écrit :
>>> De la part de Stefan Du Rietz
>>> Envoyé : mardi 19 mars 2013 11:10
>>>
>>>> But gsort is a built-in function (and very efficient):
>>> I just wonder if it can be as efficient if you write your own function
>>> and then compile it with comp().
>> Note that comp is now made automatically when you define a Scilab
>> function, but comp only generate a pre-interpreted code not a
>> processor binary code so gsort which is a built-in (processor binary
>> code) will be in any case much more efficient.
>>
> Serge, can you please also tell us what "pre-interpreted" implies 
> regarding loops?
Nothing special is done for loops. The pre-interpretation  just parses 
the original code, checks its syntactical correctness and transforms it 
into a reverse polish notation more appropriate for stack automaton.

Most of the time spent in execution of Scilab code is used for handling 
type and dimension checking and the decision tree relative to the types 
and dimensions with select the final piece of code that will realise the 
computation.

Example: imagine the A+B Scilab instruction,  it implies the following 
set of tests and routing:

Get location of A in the memory
Get location of B in the memory
What is the type of A  (1, 2, ...) -->assume 1
What is the type of B  (1, 2, ...) -->assume 1
What is the dimension of A (empty, scalar, array) -->assume array
What is the dimension of B (empty, scalar, array) -->assume scalar
Is A real or complex --> assume real
Is B real or complex --> assume real
Is there enough memory to store the result  -->assume yes
Finally call the code that adds a double scalar to each entries of an 
array ou doubles

So at least 10 operations to select the proper leaf of the tree. It is 
neglectible if A is a big array, but significative if A is just a 1 by 2 
array


Serge

>
> Best regards
> Stefan
>
>
>
>




More information about the users mailing list