[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
fastest way to test a logical vector
From: |
Dupuis |
Subject: |
fastest way to test a logical vector |
Date: |
Wed, 20 Jan 2010 03:42:21 -0800 (PST) |
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
--
View this message in context:
http://old.nabble.com/fastest-way-to-test-a-logical-vector-tp27240403p27240403.html
Sent from the Octave - General mailing list archive at Nabble.com.
- fastest way to test a logical vector,
Dupuis <=
Re: fastest way to test a logical vector, Jaroslav Hajek, 2010/01/20