Page 1 of 1

comparing elements in array

Posted: Thu Mar 27, 2014 10:11 pm
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.

Re: comparing elements in array

Posted: Thu Mar 27, 2014 11:37 pm
by KG_is_back
It is called local maximum. No ruby needed...

Re: comparing elements in array

Posted: Fri Mar 28, 2014 12:37 am
by tester
Thanks, I did not knew that it's possible that way.