Path: news.mathworks.com!not-for-mail
From: "Bruno Luong" <b.luong@fogale.findmycountry>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Vectorizing nested for loops
Date: Tue, 26 May 2009 02:22:01 +0000 (UTC)
Organization: FOGALE nanotech
Lines: 18
Message-ID: <gvfjo9$59q$1@fred.mathworks.com>
References: <gvei09$3hm$1@fred.mathworks.com> <gveme8$cqh$1@fred.mathworks.com> <gvemma$s97$1@fred.mathworks.com> <gvfen2$239$1@fred.mathworks.com>
Reply-To: "Bruno Luong" <b.luong@fogale.findmycountry>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1243304521 5434 172.30.248.37 (26 May 2009 02:22:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 26 May 2009 02:22:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 390839
Xref: news.mathworks.com comp.soft-sys.matlab:542469


"Farhan Rahman" <farban@gmail.com> wrote in message <gvfen2$239$1@fred.mathworks.com>...

> 
>         for i=2:nhx-1
>             for j=2:nhy-1
>                 resid(i,j)= -1/(hx*hx)*(Pc(i+1,j)-2.*Pc(i,j)+Pc(i-1,j))...
>                 -1/(hy*hy)*(Pc(i,j+1)-2.*Pc(i,j)+Pc(i,j-1))...
>                 +1/dt*div(i,j);
>                 Pc(i,j)= (1/(-2/(hx*hx)-2/(hy*hy))*resid(i,j))*relax_pc+Pc(i,j);
>             end
>         end
> 
> I can't seem to separate the loops without getting incorrect answers, which leaves me in a bit of a pickle with regards to vectorization. I think I can eliminate one of these loops but I'm not sure that the performance gain from that alone is worth the change.
> 

It looks a lot like a SOA relaxation to solve a finite difference PDE. No this cannot be vectorized from the best of my knowledge.

Bruno