octave-maintainers
[Top][All Lists]
Advanced

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

Fwd: 'for' loop vectorization


From: John W. Eaton
Subject: Fwd: 'for' loop vectorization
Date: Wed, 24 Oct 2007 02:21:00 -0400

On 23-Oct-2007, Jordi Gutiérrez Hermoso wrote:

| Forwarding this discussion to the dev list per jwe's suggestion...
| 
| ---------- Forwarded message ----------
| From: Jordi Gutiérrez Hermoso <address@hidden>
| Date: 23 Oct 2007 16:24
| Subject: Re: 'for' loop vectorization
| To: "John W. Eaton" <address@hidden>
| Cc: Octave Help <address@hidden>
| 
| 
| 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).

Ask David Bateman about that.  And is it really that old?  The
copyright line has 2005, 2006, 2007, so there have been changes in
each of the last two years.

| 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?

The nice thing about triu being a script is that it is generic and
should work for any data type.  It might be more work to do that in
C++ for all data types.

Anyway, I now seem to remember discussing this once before, and we
decided to leave it a script then.  But maybe there is something new
now that would convince us otherwise?

jwe



reply via email to

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