help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fastest way to test a logical vector


From: Carlo de Falco
Subject: Re: fastest way to test a logical vector
Date: Wed, 20 Jan 2010 12:52:18 +0100


On 20 Jan 2010, at 12:42, Dupuis wrote:

Hello,

I'm analysing a signal where outliers are not uncommon. So the main loop
contains a number of test like

sum(x(indi-(1:4)) >= 0) >= 2 && sum(x(indi+(1:4)) <= 2) >= 2,

I tried to optimise x and indi as int16, so the types are
x(indi-(1:4)) vector of int16
x(indi-(1:4)) >= 0 vector of logical
sum(x(indi-(1:4)) >= 0) double

Is there a way to avoid, in the last operation, the logical -> double
conversion ? any() doesn't fit the requirement, as it test for one value. I
thinked about
sort(x(indi-(1:4)) >= 0))(3) == 1
But this implies to call sort at each test. Does someone see a faster
solution ? I'm working with octave3.2

Regards

Pascal

you could use

numel (find (x(indi-(1:4)))) >= 2

c.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]