Path: news.mathworks.com!not-for-mail
From: "Bruno Luong" <b.luong@fogale.findmycountry>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Speed up the nested loops (slower than inverse a large matrix)
Date: Sat, 27 Nov 2010 08:25:06 +0000 (UTC)
Organization: FOGALE nanotech
Lines: 18
Message-ID: <icqf92$2i3$1@fred.mathworks.com>
References: <icpphd$cb2$1@fred.mathworks.com> <icpqj3$hu3$1@fred.mathworks.com> <icq218$3ib$1@fred.mathworks.com>
Reply-To: "Bruno Luong" <b.luong@fogale.findmycountry>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1290846306 2627 172.30.248.35 (27 Nov 2010 08:25:06 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 27 Nov 2010 08:25:06 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 390839
Xref: news.mathworks.com comp.soft-sys.matlab:690396

"Ximing xu" <siemenxu@gmail.com> wrote in message <icq218$3ib$1@fred.mathworks.com>...
 
> F is a  k*n matrix ,   R is  a  n*n matrix.  the loop is 
> A=zeros(k,k);
> for i=1:n-1
> for j=i+1:n 
>  A=A+F([i,j],:)'/ R([i,j],[i,j])*F([i,j],:) ;
> end
> end 
> A
> 
> I hope this code is clear (my original complete code is in another computer).  I hope this loop should be faster than inverse  of R, but for n=100 and 1000,  inverse of R is much faster than this loop.  

What you might try is to extract once all the 2x2 submatrices of R and put it on 3D array, and use this FEX to solve the system than sum them back:

http://www.mathworks.com/matlabcentral/fileexchange/27762-small-size-linear-solver

Bruno