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

classic Classic list List threaded Threaded
19 messages Options
Modestas Bunokas Modestas Bunokas
Reply | Threaded
Open this post in threaded view
|

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

If someone will find 2 min of free time, I would be very grateful. I'm somehow getting weird result doing simple operation like:
a=7; b=100; x=[-2:1:2]; y=(5*x)-1;
if y>a then disp(b);
    else disp(y);
end
--> - 11.  - 6.  - 1.    4.    9. 

Last result (9) is wrong, it should be 100 (b). I fully understand that it's because of lack of my knowledge in programming but in few days I could not solve or even could not find any help. Because of that writing here.

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Stefan Du Rietz Stefan Du Rietz
Reply | Threaded
Open this post in threaded view
|

Re: Regarding simple numerical operations result display.

-->y=(5*x)-1
  y  =
   - 11.  - 6.  - 1.    4.    9.

-->y>a
  ans  =
   F F F F T

This is F (the first element)

/Stefan


On 2013-03-17 20:23, Modestas Bunokas wrote:
--------------------

> If someone will find 2 min of free time, I would be very grateful. I'm
> somehow getting weird result doing simple operation like:
>
> a=7;  b=100;  x=[-2:1:2];  y=(5*x)-1;
> if  y>a  then  disp(b);
>      else  disp(y);
> end
>
> --> - 11.  - 6.  - 1.    4.    9.
>
> Last result (9) is wrong, it should be 100 (b). I fully understand
> that it's because of lack of my knowledge in programming but in few
> days I could not solve or even could not find any help. Because of
> that writing here.
>
>
> _______________________________________________
> users mailing list
> [hidden email]
> http://lists.scilab.org/mailman/listinfo/users
>

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Stefan Du Rietz Stefan Du Rietz
Reply | Threaded
Open this post in threaded view
|

Re: Regarding simple numerical operations result display.

Sorry,
I should have written (?):

A multi-element logical array is true (T) only if all elements are T.
-->and(y>a)
  ans  =
   F

/Stefan

On 2013-03-17 20:35, Stefan Du Rietz wrote:
--------------------

> -->y=(5*x)-1
>   y  =
>    - 11.  - 6.  - 1.    4.    9.
>
> -->y>a
>   ans  =
>    F F F F T
>
> This is F (the first element)
>
> /Stefan
>
>
> On 2013-03-17 20:23, Modestas Bunokas wrote:
> --------------------
>> If someone will find 2 min of free time, I would be very grateful. I'm
>> somehow getting weird result doing simple operation like:
>>
>> a=7;  b=100;  x=[-2:1:2];  y=(5*x)-1;
>> if  y>a  then  disp(b);
>>      else  disp(y);
>> end
>>
>> --> - 11.  - 6.  - 1.    4.    9.
>>
>> Last result (9) is wrong, it should be 100 (b). I fully understand
>> that it's because of lack of my knowledge in programming but in few
>> days I could not solve or even could not find any help. Because of
>> that writing here.
>>
>>
>> _______________________________________________
>> users mailing list
>> [hidden email]
>> http://lists.scilab.org/mailman/listinfo/users
>>
>
> _______________________________________________
> users mailing list
> [hidden email]
> http://lists.scilab.org/mailman/listinfo/users
>

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Stefan Du Rietz Stefan Du Rietz
Reply | Threaded
Open this post in threaded view
|

Re: Regarding simple numerical operations result display.

Maybe one of the last two of these four loops was what you wanted:

-->bool2s(y>a)
  ans  =
     0.    0.    0.    0.    1.

-->for k=bool2s(y>a), if k, disp(b), else, disp(y), end, end
   - 11.  - 6.  - 1.    4.    9.
   - 11.  - 6.  - 1.    4.    9.
   - 11.  - 6.  - 1.    4.    9.
   - 11.  - 6.  - 1.    4.    9.
     100.

-->for k=y, if k>a, disp(b), else, disp(y), end, end
   - 11.  - 6.  - 1.    4.    9.
   - 11.  - 6.  - 1.    4.    9.
   - 11.  - 6.  - 1.    4.    9.
   - 11.  - 6.  - 1.    4.    9.
     100.

Here, k takes the value of each element in y:

-->for k=y, if k>a, disp(b), else, disp(k), end, end
   - 11.
   - 6.
   - 1.
     4.
     100.

Or maybe this is easier to follow:

-->for k=1:length(y), if y(k)>a, disp(b), else, disp(y(k)), end, end
   - 11.
   - 6.
   - 1.
     4.
     100.

/Stefan

On 2013-03-17 20:46, Stefan Du Rietz wrote:
--------------------

> Sorry,
> I should have written (?):
>
> A multi-element logical array is true (T) only if all elements are T.
> -->and(y>a)
>   ans  =
>    F
>
> /Stefan
>
> On 2013-03-17 20:35, Stefan Du Rietz wrote:
> --------------------
>> -->y=(5*x)-1
>>   y  =
>>    - 11.  - 6.  - 1.    4.    9.
>>
>> -->y>a
>>   ans  =
>>    F F F F T
>>
>> This is F (the first element)
>>
>> /Stefan
>>
>>
>> On 2013-03-17 20:23, Modestas Bunokas wrote:
>> --------------------
>>> If someone will find 2 min of free time, I would be very grateful. I'm
>>> somehow getting weird result doing simple operation like:
>>>
>>> a=7;  b=100;  x=[-2:1:2];  y=(5*x)-1;
>>> if  y>a  then  disp(b);
>>>      else  disp(y);
>>> end
>>>
>>> --> - 11.  - 6.  - 1.    4.    9.
>>>
>>> Last result (9) is wrong, it should be 100 (b). I fully understand
>>> that it's because of lack of my knowledge in programming but in few
>>> days I could not solve or even could not find any help. Because of
>>> that writing here.
>>>
>>>
>>> _______________________________________________
>>> users mailing list
>>> [hidden email]
>>> http://lists.scilab.org/mailman/listinfo/users
>>>
>>
>> _______________________________________________
>> users mailing list
>> [hidden email]
>> http://lists.scilab.org/mailman/listinfo/users
>>
>
> _______________________________________________
> users mailing list
> [hidden email]
> http://lists.scilab.org/mailman/listinfo/users
>

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Stefan Du Rietz Stefan Du Rietz
Reply | Threaded
Open this post in threaded view
|

Re: Regarding simple numerical operations result display.

But this is the ultimate solution without a loop:

-->bool2s(y>a) .* b + bool2s(~y>a) .* y
  ans  =
   - 11.  - 6.  - 1.    4.    100.

/Stefan

On 2013-03-17 22:05, Stefan Du Rietz wrote:
--------------------

> Maybe one of the last two of these four loops was what you wanted:
>
> -->bool2s(y>a)
>   ans  =
>      0.    0.    0.    0.    1.
>
> -->for k=bool2s(y>a), if k, disp(b), else, disp(y), end, end
>    - 11.  - 6.  - 1.    4.    9.
>    - 11.  - 6.  - 1.    4.    9.
>    - 11.  - 6.  - 1.    4.    9.
>    - 11.  - 6.  - 1.    4.    9.
>      100.
>
> -->for k=y, if k>a, disp(b), else, disp(y), end, end
>    - 11.  - 6.  - 1.    4.    9.
>    - 11.  - 6.  - 1.    4.    9.
>    - 11.  - 6.  - 1.    4.    9.
>    - 11.  - 6.  - 1.    4.    9.
>      100.
>
> Here, k takes the value of each element in y:
>
> -->for k=y, if k>a, disp(b), else, disp(k), end, end
>    - 11.
>    - 6.
>    - 1.
>      4.
>      100.
>
> Or maybe this is easier to follow:
>
> -->for k=1:length(y), if y(k)>a, disp(b), else, disp(y(k)), end, end
>    - 11.
>    - 6.
>    - 1.
>      4.
>      100.
>
> /Stefan
>
> On 2013-03-17 20:46, Stefan Du Rietz wrote:
> --------------------
>> Sorry,
>> I should have written (?):
>>
>> A multi-element logical array is true (T) only if all elements are T.
>> -->and(y>a)
>>   ans  =
>>    F
>>
>> /Stefan
>>
>> On 2013-03-17 20:35, Stefan Du Rietz wrote:
>> --------------------
>>> -->y=(5*x)-1
>>>   y  =
>>>    - 11.  - 6.  - 1.    4.    9.
>>>
>>> -->y>a
>>>   ans  =
>>>    F F F F T
>>>
>>> This is F (the first element)
>>>
>>> /Stefan
>>>
>>>
>>> On 2013-03-17 20:23, Modestas Bunokas wrote:
>>> --------------------
>>>> If someone will find 2 min of free time, I would be very grateful.
>>>> I'm
>>>> somehow getting weird result doing simple operation like:
>>>>
>>>> a=7;  b=100;  x=[-2:1:2];  y=(5*x)-1;
>>>> if  y>a  then  disp(b);
>>>>      else  disp(y);
>>>> end
>>>>
>>>> --> - 11.  - 6.  - 1.    4.    9.
>>>>
>>>> Last result (9) is wrong, it should be 100 (b). I fully understand
>>>> that it's because of lack of my knowledge in programming but in few
>>>> days I could not solve or even could not find any help. Because of
>>>> that writing here.
>>>>
>>>>
>>>> _______________________________________________
>>>> users mailing list
>>>> [hidden email]
>>>> http://lists.scilab.org/mailman/listinfo/users
>>>>
>>>
>>> _______________________________________________
>>> users mailing list
>>> [hidden email]
>>> http://lists.scilab.org/mailman/listinfo/users
>>>
>>
>> _______________________________________________
>> users mailing list
>> [hidden email]
>> http://lists.scilab.org/mailman/listinfo/users
>>
>
> _______________________________________________
> users mailing list
> [hidden email]
> http://lists.scilab.org/mailman/listinfo/users
>

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Rafael Guerra Rafael Guerra
Reply | Threaded
Open this post in threaded view
|

Re: Regarding simple numerical operations result display.

In reply to this post by Stefan Du Rietz
Hi,

The last 'for' loop provided by Stefan is the "correct" simple way of
implementing the basic task requested.

Just for fun, the same result can be obtained by using a single boolean math
command:
--> bool2s(y<=a).*(y-b) + b
 ans  =
  - 11.  - 6.  - 1.    4.    100.  

Rgds
Rafael

-----Original Message-----
From: [hidden email] [mailto:[hidden email]]
On Behalf Of Stefan Du Rietz
Sent: Sunday, March 17, 2013 6:05 PM
To: [hidden email]
Subject: Re: [Scilab-users] Regarding simple numerical operations result
display.

Maybe one of the last two of these four loops was what you wanted:

-->bool2s(y>a)
  ans  =
     0.    0.    0.    0.    1.

-->for k=bool2s(y>a), if k, disp(b), else, disp(y), end, end
   - 11.  - 6.  - 1.    4.    9.
   - 11.  - 6.  - 1.    4.    9.
   - 11.  - 6.  - 1.    4.    9.
   - 11.  - 6.  - 1.    4.    9.
     100.

-->for k=y, if k>a, disp(b), else, disp(y), end, end
   - 11.  - 6.  - 1.    4.    9.
   - 11.  - 6.  - 1.    4.    9.
   - 11.  - 6.  - 1.    4.    9.
   - 11.  - 6.  - 1.    4.    9.
     100.

Here, k takes the value of each element in y:

-->for k=y, if k>a, disp(b), else, disp(k), end, end
   - 11.
   - 6.
   - 1.
     4.
     100.

Or maybe this is easier to follow:

-->for k=1:length(y), if y(k)>a, disp(b), else, disp(y(k)), end, end
   - 11.
   - 6.
   - 1.
     4.
     100.

/Stefan

On 2013-03-17 20:46, Stefan Du Rietz wrote:
--------------------

> Sorry,
> I should have written (?):
>
> A multi-element logical array is true (T) only if all elements are T.
> -->and(y>a)
>   ans  =
>    F
>
> /Stefan
>
> On 2013-03-17 20:35, Stefan Du Rietz wrote:
> --------------------
>> -->y=(5*x)-1
>>   y  =
>>    - 11.  - 6.  - 1.    4.    9.
>>
>> -->y>a
>>   ans  =
>>    F F F F T
>>
>> This is F (the first element)
>>
>> /Stefan
>>
>>
>> On 2013-03-17 20:23, Modestas Bunokas wrote:
>> --------------------
>>> If someone will find 2 min of free time, I would be very grateful.
>>> I'm somehow getting weird result doing simple operation like:
>>>
>>> a=7;  b=100;  x=[-2:1:2];  y=(5*x)-1; if  y>a  then  disp(b);
>>>      else  disp(y);
>>> end
>>>
>>> --> - 11.  - 6.  - 1.    4.    9.
>>>
>>> Last result (9) is wrong, it should be 100 (b). I fully understand
>>> that it's because of lack of my knowledge in programming but in few
>>> days I could not solve or even could not find any help. Because of
>>> that writing here.
>>>
>>>
>>> _______________________________________________
>>> users mailing list
>>> [hidden email]
>>> http://lists.scilab.org/mailman/listinfo/users
>>>
>>
>> _______________________________________________
>> users mailing list
>> [hidden email]
>> http://lists.scilab.org/mailman/listinfo/users
>>
>
> _______________________________________________
> users mailing list
> [hidden email]
> http://lists.scilab.org/mailman/listinfo/users
>

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Berns Buenaobra Berns Buenaobra
Reply | Threaded
Open this post in threaded view
|

Re: Regarding simple numerical operations result display.

In reply to this post by Stefan Du Rietz
Hi Stefan:

Maybe I should like to get some insight how to do this.

What I have is two columns (or 2 column vectors) and they need to go in pairs say magnitude y and a position in x say P(x,y). Now what I wanted is to be able to detect peaks from a set threshold value - I would like to keep 10 values above it in memory and discard the rest. I I repeat the same action until I only get the highest of all these column vector magnitudes at the last threshold value. There is a uniform delta for each of the threshold value I use going from bottom up.

Problem: I can detect the peaks alright but how does one ensure that it sticks to its position pair? Since indexing the magnitude seemed to a sequential location in memory and not its position?

Thanks for any help.

Regards,
Berns B.
USC Physics




On Mon, Mar 18, 2013 at 5:24 AM, Stefan Du Rietz <[hidden email]> wrote:
But this is the ultimate solution without a loop:

-->bool2s(y>a) .* b + bool2s(~y>a) .* y
 ans  =
  - 11.  - 6.  - 1.    4.    100.

/Stefan


On 2013-03-17 22:05, Stefan Du Rietz wrote:
--------------------
Maybe one of the last two of these four loops was what you wanted:

-->bool2s(y>a)
  ans  =
     0.    0.    0.    0.    1.

-->for k=bool2s(y>a), if k, disp(b), else, disp(y), end, end
   - 11.  - 6.  - 1.    4.    9.
   - 11.  - 6.  - 1.    4.    9.
   - 11.  - 6.  - 1.    4.    9.
   - 11.  - 6.  - 1.    4.    9.
     100.

-->for k=y, if k>a, disp(b), else, disp(y), end, end
   - 11.  - 6.  - 1.    4.    9.
   - 11.  - 6.  - 1.    4.    9.
   - 11.  - 6.  - 1.    4.    9.
   - 11.  - 6.  - 1.    4.    9.
     100.

Here, k takes the value of each element in y:

-->for k=y, if k>a, disp(b), else, disp(k), end, end
   - 11.
   - 6.
   - 1.
     4.
     100.

Or maybe this is easier to follow:

-->for k=1:length(y), if y(k)>a, disp(b), else, disp(y(k)), end, end
   - 11.
   - 6.
   - 1.
     4.
     100.

/Stefan

On 2013-03-17 20:46, Stefan Du Rietz wrote:
--------------------
Sorry,
I should have written (?):

A multi-element logical array is true (T) only if all elements are T.
-->and(y>a)
  ans  =
   F

/Stefan

On 2013-03-17 20:35, Stefan Du Rietz wrote:
--------------------
-->y=(5*x)-1
  y  =
   - 11.  - 6.  - 1.    4.    9.

-->y>a
  ans  =
   F F F F T

This is F (the first element)

/Stefan


On 2013-03-17 20:23, Modestas Bunokas wrote:
--------------------
If someone will find 2 min of free time, I would be very grateful.
I'm
somehow getting weird result doing simple operation like:

a=7;  b=100;  x=[-2:1:2];  y=(5*x)-1;
if  y>a  then  disp(b);
     else  disp(y);
end

--> - 11.  - 6.  - 1.    4.    9.

Last result (9) is wrong, it should be 100 (b). I fully understand
that it's because of lack of my knowledge in programming but in few
days I could not solve or even could not find any help. Because of
that writing here.


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Modestas Bunokas Modestas Bunokas
Reply | Threaded
Open this post in threaded view
|

Re: Regarding simple numerical operations result display.

This post was updated on .
Stefan and Rafael, thank you for your kind help, as it was really ultimate solution in one single line. If for real did not expected so much help here.
Thank you again,
Stefan Du Rietz Stefan Du Rietz
Reply | Threaded
Open this post in threaded view
|

Re: Regarding simple numerical operations result display.

In reply to this post by Berns Buenaobra
Hi Berns,
I am not sure if I understand exactly what you mean.

Perhaps something like this simplified example (to keep the 5 pairs
with the largest y-values)?

x = (1:10)';
y = [1:5; 6:10]; y = y(:);
data = [x, y];
th = 1:10;   // threshold values

data // display the original data
for k=1:length(th)
   index = data(:, 2) > th(k);
   if sum(index) < 5  // too few data values left
     break
   end
   data = data(index, :)  // display this result
end

Output from the run:
  data  =
     1.     1.
     2.     6.
     3.     2.
     4.     7.
     5.     3.
     6.     8.
     7.     4.
     8.     9.
     9.     5.
     10.    10.
  data  =
     2.     6.
     3.     2.
     4.     7.
     5.     3.
     6.     8.
     7.     4.
     8.     9.
     9.     5.
     10.    10.
  data  =
     2.     6.
     4.     7.
     5.     3.
     6.     8.
     7.     4.
     8.     9.
     9.     5.
     10.    10.
  data  =
     2.     6.
     4.     7.
     6.     8.
     7.     4.
     8.     9.
     9.     5.
     10.    10.
  data  =
     2.     6.
     4.     7.
     6.     8.
     8.     9.
     9.     5.
     10.    10.
  data  =
     2.     6.
     4.     7.
     6.     8.
     8.     9.
     10.    10.

Regards
Stefan


On 2013-03-18 01:25, Berns Buenaobra wrote:
--------------------

> Hi Stefan:
>
> Maybe I should like to get some insight how to do this.
>
> What I have is two columns (or 2 column vectors) and they need to go
> in pairs say magnitude y and a position in x say P(x,y). Now what I
> wanted is to be able to detect peaks from a set threshold value - I
> would like to keep 10 values above it in memory and discard the rest.
> I I repeat the same action until I only get the highest of all these
> column vector magnitudes at the last threshold value. There is a
> uniform delta for each of the threshold value I use going from bottom up.
>
> Problem: I can detect the peaks alright but how does one ensure that
> it sticks to its position pair? Since indexing the magnitude seemed to
> a sequential location in memory and not its position?
>
> Thanks for any help.
>
> Regards,
> Berns B.
> USC Physics
>
>
>
>
> On Mon, Mar 18, 2013 at 5:24 AM, Stefan Du Rietz <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     But this is the ultimate solution without a loop:
>
>     -->bool2s(y>a) .* b + bool2s(~y>a) .* y
>       ans  =
>        - 11.  - 6.  - 1.    4.    100.
>
>     /Stefan
>
>
>     On 2013-03-17 22:05, Stefan Du Rietz wrote:
>     --------------------
>
>         Maybe one of the last two of these four loops was what you wanted:
>
>         -->bool2s(y>a)
>            ans  =
>               0.    0.    0.    0.    1.
>
>         -->for k=bool2s(y>a), if k, disp(b), else, disp(y), end, end
>             - 11.  - 6.  - 1.    4.    9.
>             - 11.  - 6.  - 1.    4.    9.
>             - 11.  - 6.  - 1.    4.    9.
>             - 11.  - 6.  - 1.    4.    9.
>               100.
>
>         -->for k=y, if k>a, disp(b), else, disp(y), end, end
>             - 11.  - 6.  - 1.    4.    9.
>             - 11.  - 6.  - 1.    4.    9.
>             - 11.  - 6.  - 1.    4.    9.
>             - 11.  - 6.  - 1.    4.    9.
>               100.
>
>         Here, k takes the value of each element in y:
>
>         -->for k=y, if k>a, disp(b), else, disp(k), end, end
>             - 11.
>             - 6.
>             - 1.
>               4.
>               100.
>
>         Or maybe this is easier to follow:
>
>         -->for k=1:length(y), if y(k)>a, disp(b), else, disp(y(k)),
>         end, end
>             - 11.
>             - 6.
>             - 1.
>               4.
>               100.
>
>         /Stefan
>
>         On 2013-03-17 20:46, Stefan Du Rietz wrote:
>         --------------------
>
>             Sorry,
>             I should have written (?):
>
>             A multi-element logical array is true (T) only if all
>             elements are T.
>             -->and(y>a)
>                ans  =
>                 F
>
>             /Stefan
>
>             On 2013-03-17 20:35, Stefan Du Rietz wrote:
>             --------------------
>
>                 -->y=(5*x)-1
>                    y  =
>                     - 11.  - 6.  - 1.    4.    9.
>
>                 -->y>a
>                    ans  =
>                     F F F F T
>
>                 This is F (the first element)
>
>                 /Stefan
>
>
>                 On 2013-03-17 20:23, Modestas Bunokas wrote:
>                 --------------------
>
>                     If someone will find 2 min of free time, I would
>                     be very grateful.
>                     I'm
>                     somehow getting weird result doing simple
>                     operation like:
>
>                     a=7;  b=100;  x=[-2:1:2];  y=(5*x)-1;
>                     if  y>a  then  disp(b);
>                           else  disp(y);
>                     end
>
>                     --> - 11.  - 6.  - 1.    4.    9.
>
>                     Last result (9) is wrong, it should be 100 (b). I
>                     fully understand
>                     that it's because of lack of my knowledge in
>                     programming but in few
>                     days I could not solve or even could not find any
>                     help. Because of
>                     that writing here.
>
>
>                     _________________________________________________
>                     users mailing list
>                     [hidden email] <mailto:[hidden email]>
>                     http://lists.scilab.org/__mailman/listinfo/users
>                     <http://lists.scilab.org/mailman/listinfo/users>
>
>
>                 _________________________________________________
>                 users mailing list
>                 [hidden email] <mailto:[hidden email]>
>                 http://lists.scilab.org/__mailman/listinfo/users
>                 <http://lists.scilab.org/mailman/listinfo/users>
>
>
>             _________________________________________________
>             users mailing list
>             [hidden email] <mailto:[hidden email]>
>             http://lists.scilab.org/__mailman/listinfo/users
>             <http://lists.scilab.org/mailman/listinfo/users>
>
>
>         _________________________________________________
>         users mailing list
>         [hidden email] <mailto:[hidden email]>
>         http://lists.scilab.org/__mailman/listinfo/users
>         <http://lists.scilab.org/mailman/listinfo/users>
>
>
>     _________________________________________________
>     users mailing list
>     [hidden email] <mailto:[hidden email]>
>     http://lists.scilab.org/__mailman/listinfo/users
>     <http://lists.scilab.org/mailman/listinfo/users>
>
>
>
>
> _______________________________________________
> users mailing list
> [hidden email]
> http://lists.scilab.org/mailman/listinfo/users
>

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Stefan Du Rietz Stefan Du Rietz
Reply | Threaded
Open this post in threaded view
|

Re: Regarding simple numerical operations result display.

But as usual there is a better (faster, simpler) solution without a loop!

// sort in reverse order and get indices
[ysort, k] = gsort(data(:, 2));
// take indices of the 5 largest values
k = k(1:5);
// keep those data
data = [data(k, :)];

Regards
Stefan


On 2013-03-18 13:09, Stefan Du Rietz wrote:
--------------------

> Hi Berns,
> I am not sure if I understand exactly what you mean.
>
> Perhaps something like this simplified example (to keep the 5 pairs
> with the largest y-values)?
>
> x = (1:10)';
> y = [1:5; 6:10]; y = y(:);
> data = [x, y];
> th = 1:10;   // threshold values
>
> data // display the original data
> for k=1:length(th)
>    index = data(:, 2) > th(k);
>    if sum(index) < 5  // too few data values left
>      break
>    end
>    data = data(index, :)  // display this result
> end
>
> Output from the run:
>   data  =
>      1.     1.
>      2.     6.
>      3.     2.
>      4.     7.
>      5.     3.
>      6.     8.
>      7.     4.
>      8.     9.
>      9.     5.
>      10.    10.
>   data  =
>      2.     6.
>      3.     2.
>      4.     7.
>      5.     3.
>      6.     8.
>      7.     4.
>      8.     9.
>      9.     5.
>      10.    10.
>   data  =
>      2.     6.
>      4.     7.
>      5.     3.
>      6.     8.
>      7.     4.
>      8.     9.
>      9.     5.
>      10.    10.
>   data  =
>      2.     6.
>      4.     7.
>      6.     8.
>      7.     4.
>      8.     9.
>      9.     5.
>      10.    10.
>   data  =
>      2.     6.
>      4.     7.
>      6.     8.
>      8.     9.
>      9.     5.
>      10.    10.
>   data  =
>      2.     6.
>      4.     7.
>      6.     8.
>      8.     9.
>      10.    10.
>
> Regards
> Stefan
>
>
> On 2013-03-18 01:25, Berns Buenaobra wrote:
> --------------------
>> Hi Stefan:
>>
>> Maybe I should like to get some insight how to do this.
>>
>> What I have is two columns (or 2 column vectors) and they need to go
>> in pairs say magnitude y and a position in x say P(x,y). Now what I
>> wanted is to be able to detect peaks from a set threshold value - I
>> would like to keep 10 values above it in memory and discard the rest.
>> I I repeat the same action until I only get the highest of all these
>> column vector magnitudes at the last threshold value. There is a
>> uniform delta for each of the threshold value I use going from
>> bottom up.
>>
>> Problem: I can detect the peaks alright but how does one ensure that
>> it sticks to its position pair? Since indexing the magnitude seemed to
>> a sequential location in memory and not its position?
>>
>> Thanks for any help.
>>
>> Regards,
>> Berns B.
>> USC Physics
>>
>>
>>
>>
>> On Mon, Mar 18, 2013 at 5:24 AM, Stefan Du Rietz <[hidden email]
>> <mailto:[hidden email]>> wrote:
>>
>>     But this is the ultimate solution without a loop:
>>
>>     -->bool2s(y>a) .* b + bool2s(~y>a) .* y
>>       ans  =
>>        - 11.  - 6.  - 1.    4.    100.
>>
>>     /Stefan
>>
>>
>>     On 2013-03-17 22:05, Stefan Du Rietz wrote:
>>     --------------------
>>
>>         Maybe one of the last two of these four loops was what you
>> wanted:
>>
>>         -->bool2s(y>a)
>>            ans  =
>>               0.    0.    0.    0.    1.
>>
>>         -->for k=bool2s(y>a), if k, disp(b), else, disp(y), end, end
>>             - 11.  - 6.  - 1.    4.    9.
>>             - 11.  - 6.  - 1.    4.    9.
>>             - 11.  - 6.  - 1.    4.    9.
>>             - 11.  - 6.  - 1.    4.    9.
>>               100.
>>
>>         -->for k=y, if k>a, disp(b), else, disp(y), end, end
>>             - 11.  - 6.  - 1.    4.    9.
>>             - 11.  - 6.  - 1.    4.    9.
>>             - 11.  - 6.  - 1.    4.    9.
>>             - 11.  - 6.  - 1.    4.    9.
>>               100.
>>
>>         Here, k takes the value of each element in y:
>>
>>         -->for k=y, if k>a, disp(b), else, disp(k), end, end
>>             - 11.
>>             - 6.
>>             - 1.
>>               4.
>>               100.
>>
>>         Or maybe this is easier to follow:
>>
>>         -->for k=1:length(y), if y(k)>a, disp(b), else, disp(y(k)),
>>         end, end
>>             - 11.
>>             - 6.
>>             - 1.
>>               4.
>>               100.
>>
>>         /Stefan
>>
>>         On 2013-03-17 20:46, Stefan Du Rietz wrote:
>>         --------------------
>>
>>             Sorry,
>>             I should have written (?):
>>
>>             A multi-element logical array is true (T) only if all
>>             elements are T.
>>             -->and(y>a)
>>                ans  =
>>                 F
>>
>>             /Stefan
>>
>>             On 2013-03-17 20:35, Stefan Du Rietz wrote:
>>             --------------------
>>
>>                 -->y=(5*x)-1
>>                    y  =
>>                     - 11.  - 6.  - 1.    4.    9.
>>
>>                 -->y>a
>>                    ans  =
>>                     F F F F T
>>
>>                 This is F (the first element)
>>
>>                 /Stefan
>>
>>
>>                 On 2013-03-17 20:23, Modestas Bunokas wrote:
>>                 --------------------
>>
>>                     If someone will find 2 min of free time, I would
>>                     be very grateful.
>>                     I'm
>>                     somehow getting weird result doing simple
>>                     operation like:
>>
>>                     a=7;  b=100;  x=[-2:1:2];  y=(5*x)-1;
>>                     if  y>a  then  disp(b);
>>                           else  disp(y);
>>                     end
>>
>>                     --> - 11.  - 6.  - 1.    4.    9.
>>
>>                     Last result (9) is wrong, it should be 100 (b). I
>>                     fully understand
>>                     that it's because of lack of my knowledge in
>>                     programming but in few
>>                     days I could not solve or even could not find any
>>                     help. Because of
>>                     that writing here.
>>
>>
>>                     _________________________________________________
>>                     users mailing list
>>                     [hidden email]
>> <mailto:[hidden email]>
>>                     http://lists.scilab.org/__mailman/listinfo/users
>>                     <http://lists.scilab.org/mailman/listinfo/users>
>>
>>
>>                 _________________________________________________
>>                 users mailing list
>>                 [hidden email] <mailto:[hidden email]>
>>                 http://lists.scilab.org/__mailman/listinfo/users
>>                 <http://lists.scilab.org/mailman/listinfo/users>
>>
>>
>>             _________________________________________________
>>             users mailing list
>>             [hidden email] <mailto:[hidden email]>
>>             http://lists.scilab.org/__mailman/listinfo/users
>>             <http://lists.scilab.org/mailman/listinfo/users>
>>
>>
>>         _________________________________________________
>>         users mailing list
>>         [hidden email] <mailto:[hidden email]>
>>         http://lists.scilab.org/__mailman/listinfo/users
>>         <http://lists.scilab.org/mailman/listinfo/users>
>>
>>
>>     _________________________________________________
>>     users mailing list
>>     [hidden email] <mailto:[hidden email]>
>>     http://lists.scilab.org/__mailman/listinfo/users
>>     <http://lists.scilab.org/mailman/listinfo/users>
>>
>>
>>
>>
>> _______________________________________________
>> users mailing list
>> [hidden email]
>> http://lists.scilab.org/mailman/listinfo/users
>>
>
> _______________________________________________
> users mailing list
> [hidden email]
> http://lists.scilab.org/mailman/listinfo/users
>

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Berns Buenaobra Berns Buenaobra
Reply | Threaded
Open this post in threaded view
|

Re: Regarding simple numerical operations result display.

Outstanding!

Thanks Stefan,

Berns B.


On Tue, Mar 19, 2013 at 12:23 AM, Stefan Du Rietz <[hidden email]> wrote:
But as usual there is a better (faster, simpler) solution without a loop!

// sort in reverse order and get indices
[ysort, k] = gsort(data(:, 2));
// take indices of the 5 largest values
k = k(1:5);
// keep those data
data = [data(k, :)];

Regards
Stefan



On 2013-03-18 13:09, Stefan Du Rietz wrote:
--------------------
Hi Berns,
I am not sure if I understand exactly what you mean.

Perhaps something like this simplified example (to keep the 5 pairs
with the largest y-values)?

x = (1:10)';
y = [1:5; 6:10]; y = y(:);
data = [x, y];
th = 1:10;   // threshold values

data // display the original data
for k=1:length(th)
   index = data(:, 2) > th(k);
   if sum(index) < 5  // too few data values left
     break
   end
   data = data(index, :)  // display this result
end

Output from the run:
  data  =
     1.     1.
     2.     6.
     3.     2.
     4.     7.
     5.     3.
     6.     8.
     7.     4.
     8.     9.
     9.     5.
     10.    10.
  data  =
     2.     6.
     3.     2.
     4.     7.
     5.     3.
     6.     8.
     7.     4.
     8.     9.
     9.     5.
     10.    10.
  data  =
     2.     6.
     4.     7.
     5.     3.
     6.     8.
     7.     4.
     8.     9.
     9.     5.
     10.    10.
  data  =
     2.     6.
     4.     7.
     6.     8.
     7.     4.
     8.     9.
     9.     5.
     10.    10.
  data  =
     2.     6.
     4.     7.
     6.     8.
     8.     9.
     9.     5.
     10.    10.
  data  =
     2.     6.
     4.     7.
     6.     8.
     8.     9.
     10.    10.

Regards
Stefan


On 2013-03-18 01:25, Berns Buenaobra wrote:
--------------------
Hi Stefan:

Maybe I should like to get some insight how to do this.

What I have is two columns (or 2 column vectors) and they need to go
in pairs say magnitude y and a position in x say P(x,y). Now what I
wanted is to be able to detect peaks from a set threshold value - I
would like to keep 10 values above it in memory and discard the rest.
I I repeat the same action until I only get the highest of all these
column vector magnitudes at the last threshold value. There is a
uniform delta for each of the threshold value I use going from
bottom up.

Problem: I can detect the peaks alright but how does one ensure that
it sticks to its position pair? Since indexing the magnitude seemed to
a sequential location in memory and not its position?

Thanks for any help.

Regards,
Berns B.
USC Physics




On Mon, Mar 18, 2013 at 5:24 AM, Stefan Du Rietz <[hidden email]
<mailto:[hidden email]>> wrote:

    But this is the ultimate solution without a loop:

    -->bool2s(y>a) .* b + bool2s(~y>a) .* y
      ans  =
       - 11.  - 6.  - 1.    4.    100.

    /Stefan


    On 2013-03-17 22:05, Stefan Du Rietz wrote:
    --------------------

        Maybe one of the last two of these four loops was what you
wanted:

        -->bool2s(y>a)
           ans  =
              0.    0.    0.    0.    1.

        -->for k=bool2s(y>a), if k, disp(b), else, disp(y), end, end
            - 11.  - 6.  - 1.    4.    9.
            - 11.  - 6.  - 1.    4.    9.
            - 11.  - 6.  - 1.    4.    9.
            - 11.  - 6.  - 1.    4.    9.
              100.

        -->for k=y, if k>a, disp(b), else, disp(y), end, end
            - 11.  - 6.  - 1.    4.    9.
            - 11.  - 6.  - 1.    4.    9.
            - 11.  - 6.  - 1.    4.    9.
            - 11.  - 6.  - 1.    4.    9.
              100.

        Here, k takes the value of each element in y:

        -->for k=y, if k>a, disp(b), else, disp(k), end, end
            - 11.
            - 6.
            - 1.
              4.
              100.

        Or maybe this is easier to follow:

        -->for k=1:length(y), if y(k)>a, disp(b), else, disp(y(k)),
        end, end
            - 11.
            - 6.
            - 1.
              4.
              100.

        /Stefan

        On 2013-03-17 20:46, Stefan Du Rietz wrote:
        --------------------

            Sorry,
            I should have written (?):

            A multi-element logical array is true (T) only if all
            elements are T.
            -->and(y>a)
               ans  =
                F

            /Stefan

            On 2013-03-17 20:35, Stefan Du Rietz wrote:
            --------------------

                -->y=(5*x)-1
                   y  =
                    - 11.  - 6.  - 1.    4.    9.

                -->y>a
                   ans  =
                    F F F F T

                This is F (the first element)

                /Stefan


                On 2013-03-17 20:23, Modestas Bunokas wrote:
                --------------------

                    If someone will find 2 min of free time, I would
                    be very grateful.
                    I'm
                    somehow getting weird result doing simple
                    operation like:

                    a=7;  b=100;  x=[-2:1:2];  y=(5*x)-1;
                    if  y>a  then  disp(b);
                          else  disp(y);
                    end

                    --> - 11.  - 6.  - 1.    4.    9.

                    Last result (9) is wrong, it should be 100 (b). I
                    fully understand
                    that it's because of lack of my knowledge in
                    programming but in few
                    days I could not solve or even could not find any
                    help. Because of
                    that writing here.


                    _________________________________________________
                    users mailing list
                    [hidden email]
<mailto:[hidden email]>
                    http://lists.scilab.org/__mailman/listinfo/users
                    <http://lists.scilab.org/mailman/listinfo/users>


                _________________________________________________
                users mailing list
                [hidden email] <mailto:[hidden email]>
                http://lists.scilab.org/__mailman/listinfo/users
                <http://lists.scilab.org/mailman/listinfo/users>


            _________________________________________________
            users mailing list
            [hidden email] <mailto:[hidden email]>
            http://lists.scilab.org/__mailman/listinfo/users
            <http://lists.scilab.org/mailman/listinfo/users>


        _________________________________________________
        users mailing list
        [hidden email] <mailto:[hidden email]>
        http://lists.scilab.org/__mailman/listinfo/users
        <http://lists.scilab.org/mailman/listinfo/users>


    _________________________________________________
    users mailing list
    [hidden email] <mailto:[hidden email]>
    http://lists.scilab.org/__mailman/listinfo/users
    <http://lists.scilab.org/mailman/listinfo/users>




_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Christophe Dang Ngoc Chan Christophe Dang Ngoc Chan
Reply | Threaded
Open this post in threaded view
|

Re: Regarding simple numerical operations result display.

In reply to this post by Stefan Du Rietz
Hello,

De la part de Stefan Du Rietz
Envoyé : lundi 18 mars 2013 17:23

> But as usual there is a better (faster, simpler) solution without a
> loop!
>
> // sort in reverse order and get indices
> [ysort, k] = gsort(data(:, 2));

Well, there are loops, hidden in gsort(), which is a quicksort.

I think it is faster because you perform the loops only once.

For optimisation in finding the highest -- or lowest -- values,
you might find some ideas there:

http://en.wikipedia.org/wiki/Selection_algorithm

Best regards

--
Christophe Dang Ngoc Chan
Mechanical calculation engineer

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error), please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
--
Christophe Dang Ngoc Chan
Mechanical calculation engineer
Stefan Du Rietz Stefan Du Rietz
Reply | Threaded
Open this post in threaded view
|

Re: Regarding simple numerical operations result display.

On 2013-03-19 09:26, Dang, Christophe wrote:
--------------------

> Hello,
>
> De la part de Stefan Du Rietz
> Envoyé : lundi 18 mars 2013 17:23
>
>> But as usual there is a better (faster, simpler) solution without a
>> loop!
>>
>> // sort in reverse order and get indices
>> [ysort, k] = gsort(data(:, 2));
>
> Well, there are loops, hidden in gsort(), which is a quicksort.
>
> I think it is faster because you perform the loops only once.
>
> For optimisation in finding the highest -- or lowest -- values,
> you might find some ideas there:
>
> http://en.wikipedia.org/wiki/Selection_algorithm
>
> Best regards
>
But gsort is a built-in function (and very efficient):

-->typeof(gsort)
  ans  =
  fptr

I cite from your linked Wikipedia article:

"Selection can be reduced to sorting by sorting the list and then
extracting the desired element. This method is efficient ..."

You should avoid code with loops because all lines in a loop are
re-interpreted by Scilab in every round-trip -- it is therefore very
slow. This is of course not the case with built-in functions.

I once used the datenum function in Scilab 4, which was not
vectorized. It took many minutes to convert my large datevec matrix
into a datenum vector. After my vectorization, it took a fractional
second!

Regards
Stefan




_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Christophe Dang Ngoc Chan Christophe Dang Ngoc Chan
Reply | Threaded
Open this post in threaded view
|

Re: Regarding simple numerical operations result display.

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().

It can be interesting to do so in specific cases:
a specific implementation might be faster than a general one.

--
Christophe Dang Ngoc Chan
Mechanical calculation engineer
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error), please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
--
Christophe Dang Ngoc Chan
Mechanical calculation engineer
Serge Steer-3 Serge Steer-3
Reply | Threaded
Open this post in threaded view
|

Re: Regarding simple numerical operations result display.

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.


>
> It can be interesting to do so in specific cases:
> a specific implementation might be faster than a general one.
>

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Christophe Dang Ngoc Chan Christophe Dang Ngoc Chan
Reply | Threaded
Open this post in threaded view
|

Re: Regarding simple numerical operations result display.

De la part de Serge Steer
Envoyé : mardi 19 mars 2013 11:44

> Note that comp [...] only generate a pre-interpreted code not a
> processor binary code

Thanks for the information.

--
Christophe Dang Ngoc Chan
Mechanical calculation engineer
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error), please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
--
Christophe Dang Ngoc Chan
Mechanical calculation engineer
Stefan Du Rietz Stefan Du Rietz
Reply | Threaded
Open this post in threaded view
|

Re: Regarding simple numerical operations result display.

In reply to this post by Serge Steer-3
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?

Best regards
Stefan



_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Serge Steer-3 Serge Steer-3
Reply | Threaded
Open this post in threaded view
|

Re: Regarding simple numerical operations result display.

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
>
>
>
>

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Stefan Du Rietz Stefan Du Rietz
Reply | Threaded
Open this post in threaded view
|

Re: Regarding simple numerical operations result display.

On 2013-03-20 14:38, Serge Steer wrote:
--------------------

> 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
>
Very good! I have not found this information elsewhere.

Thank you very much!

>> Best regards
>> Stefan
>>
>>
>>
>>
>
>


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users