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: Jaroslav Hajek
Subject: Re: fastest way to test a logical vector
Date: Wed, 20 Jan 2010 21:36:27 +0100

On Wed, Jan 20, 2010 at 6:20 PM, Dupuis <address@hidden> wrote:
>
>
> Carlo de Falco-2 wrote:
>>
>>
>>
>>> Regards
>>>
>>> Pascal
>>
>> you could use
>>
>> numel (find (x(indi-(1:4)))) >= 2
>>
>> c.
>> _______________________________________________
>> Help-octave mailing list
>> address@hidden
>> https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
>>
>>
>
> Hello,
> I tried to implement most of the logic I needed in the simple, enclosed
> file. The results clearly show that replacing 'for' loops by direct work on
> vectors is way faster.
> http://old.nabble.com/file/p27245361/speedtest.m speedtest.m
>

Yes, this is quite expectable.

> Now my problem is that I'm implementing a kind of state machine. I can write
> state(2) as a function of state(1) and so on, but state(1) depends on the
> latest state, so direct work on vector would not work. Any idea on how to
> solve this ?

This kind of problems is quite difficult to vectorize, admittedly. It
heavily depends on the problem at hand. In general, the "filter"
function can be of use (for difference equations), as well as the
cumulative reductions (cumsum etc).
For other options, see the signal package:
http://octave.sourceforge.net/signal/index.html

-- 
RNDr. Jaroslav Hajek, PhD
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz


reply via email to

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