help-octave
[Top][All Lists]
Advanced

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

Re: 'for' loop vectorization


From: Jordi Gutiérrez Hermoso
Subject: Re: 'for' loop vectorization
Date: Tue, 23 Oct 2007 16:24:30 -0500

On 23/10/2007, John W. Eaton <address@hidden> wrote:
> On 23-Oct-2007, Jordi Gutiérrez Hermoso wrote:
>
> | On 23/10/2007, Hermann Schwarting <address@hidden> wrote:
> | > The more I think about it, it looks like I can't vectorize this. It's
> | > a bit similar to a cumulative maximum, which can't be vectorized
> | > either, I think.
> |
> | It can be, but my vectorisation runs slower than the unvectorised code. :-(
> |
> |      a = max(triu(repmat(a(:),1,length(a))))
> |
> | The triu call is the bottleneck, it seems, which mystifies me.
>
> The triu function is a .m file with a for loop.

Yeah, I just realised. That should be fixed, eh? I also see that it's
very old and uses a weird construct instead of calling zeros(nr,nc).

I'm trying to think of a way to avoiding the for-loops in tril and
triu, but perhaps they should just be compiled in. What do you think?

- Jordi G. H.



reply via email to

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