comparing elements in array

For general discussion related FlowStone
Post Reply
tester
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

comparing elements in array

Post by tester »

I'm looking for an efficent solution for finding a single "peak" value within a small array (less than 50 elements). While I could do this with greens - at 25fps and some other stuff going on - I think ruby may be faster on that. Here it is what I exactly look for.

Let say that I have an array of floats, like this:

121
90
77
66
51
30
37
43
51
43
36
22
10

In above example - the peak is at index 8.

Concept:

- peak is a value at index N, greater than values at N-1 and N+1 indexes
- there will be only a one single peak in such array
- border values (lowest and highest) are never a peak values
- peak value does not have to be "max" in array (otherwise - it would be simple)

- it has to be efficient calculation (25fps or more), thus parsing the whole array per each comparison should not be done by greens, rather ruby.
Last edited by tester on Fri Mar 28, 2014 12:39 am, edited 1 time in total.
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
KG_is_back
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: comparing elements in array

Post by KG_is_back »

It is called local maximum. No ruby needed...
Attachments
local maximum.fsm
(878 Bytes) Downloaded 854 times
tester
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

Re: comparing elements in array

Post by tester »

Thanks, I did not knew that it's possible that way.
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
Post Reply