Speed is tantamount for me right now because I am running repeated neural 
simulations, so would looping still be the fasted way?

On Thursday, July 31, 2014 2:45:25 AM UTC-4, Gunnar Farnebäck wrote:
>
> This is not the most efficient way, neither the clearest, but it's 
> compact. In a language like Matlab it would be the preferred approach.
>
> sum((outputarray[1:end-1] .< 0) & (outputarray[2:end] .>= 0))
>
> Den onsdagen den 30:e juli 2014 kl. 22:03:32 UTC+2 skrev 
> yaois...@gmail.com:
>>
>> Hi guys,
>>
>> I asked this in a previous thread, but because that diverged off-topic 
>> from my existing question, I decided to create a new thread.
>>
>> Anyhow, say I have an array
>>
>> outputarray = 
>> Float64[-1.23423,-3.23423,-2.34234,-2.12342,1.23234,2.23423,-2.23432,5.2341,0.01111,1.23423]
>>
>> This array lists the output of some function. I want to count the number 
>> of times that the function passes by or equals 0 while emerging from a 
>> negative f(x). 
>>
>> In pseudocode, I want to do:
>>
>> function counter(outputarray)
>>     count = 0
>>     for i in Int64[1:len(outputarray)]
>>         if outputarray[i] >= 0 && outputarray[i-1] < 0
>>             count += 1
>>         end
>>     end
>>     return count
>> end
>>
>> What would be the most efficient way of doing this in Julia?
>>
>> Thanks,
>> Wally 
>>
>

Reply via email to