[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: implement a SOR like routine efficiently
From: |
Ganesh Bikshandi |
Subject: |
Re: implement a SOR like routine efficiently |
Date: |
Wed, 17 Nov 2004 13:55:24 -0600 |
Thanks for the solutions. But I am not sure if they will work. I will
try them, anyways.
Ganesh
On Tue, 16 Nov 2004 10:40:17 -0500 (EST), Przemek Klosowski
<address@hidden> wrote:
>
>
>
> I need to implement the following loop efficiently:
>
> for i = 2:n-1
> for j = 2:n-1
> a(i,j) = a(i-1,j) + a(i+1,j) + a(i,j+1) + a(i,j-1)
> end
> end
>
> The loop is not vectorizable, as it has a carried dependence. If I run
> this loop as it is, it is very slow ( in my program n is 256 and
>
> Well, as written, the loop is not vectorizable; but the expression is
> suspiciously close to an 'averaging' kernel. I just wanted you to
> confirm that a convolution of a and [0 1 0; 1 0 1; 0 1 0] would not be
> an acceptable solution:
>
> a(2:n-1,2:n-1) = conv2(a, [0 1 0; 1 0 1; 0 1 0],'valid');
>
>
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------