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$>
References: <icpphd$cb2$> <icpqj3$hu3$> <icq218$3ib$>
Reply-To: "Bruno Luong" <b.luong@fogale.findmycountry>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1290846306 2627 (27 Nov 2010 08:25:06 GMT)
NNTP-Posting-Date: Sat, 27 Nov 2010 08:25:06 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 390839
Xref: comp.soft-sys.matlab:690396

"Ximing xu" <> wrote in message <icq218$3ib$>...
> 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: