[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: 'for' loop vectorization
From: |
Hermann Schwarting |
Subject: |
Re: 'for' loop vectorization |
Date: |
Tue, 23 Oct 2007 21:43:00 +0200 |
User-agent: |
KMail/1.9.7 |
Am Dienstag, 23. Oktober 2007 schrieb Alexander Barth:
> What about this:
> i = 2:r;
> j = 2:c;
> D(i, 1) = max(D(i-1, 1), D(i, 1));
> D(1, j) = max(D(1, j-1), D(1, j));
> D(i,j) = max(D(i,j), min( D(i,j-1), min(D(i-1,j-1), D(i-1,j)) ));
>
> I have tested it for a random matrix.
> Does this work for you?
No, sorry. Probably I should have stated the problem with more detail.
The inner for-loop operates in place and the value of one element is
dependent on the previous value left of it and those of the row above
it. So the results are not identical. It may happen by chance that
the value of D(r,c) is the same.
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.
I’ll take the route of putting it in an oct file and see if that works
out.
Alexander, thank you for your time in any case!
Kind regards,
Hermann