Speedup/Refaktoring loop? Extended...

David Bateman David.Bateman at motorola.com
Wed Aug 27 09:58:01 CDT 2008


Andreas Romeyke wrote:
> Hello,
>
>   
>>     a=transpose(U) * X;
>>     b=transpose(U) * U * V;
>>     V=V .* a ./ b;
>>     a=X * transpose(V);
>>     b=U * V * transpose(V);
>>     U=U .* a ./ b;
>>     
>
> BTW, could anyone describe why Matlab 7.3 runs 4 times faster than
> Octave 3.02 in this piece of code? AFAIK both programs uses the
> Altlas/Lapack libraries. And the code is fully vectorized here.
>
> Could you explain the difference?
>
> Bye Andreas
>
>   
>
Could you give a complete example to test against? Three possible 
reasons are that the above explicitly transposes U and Octave in 3.1.51+ 
now has faster transpose code. If you wrote the above instead as

a=U.' * X;
b=U.' * U * V;
V=V .* a ./ b;
a=X * V.';
b=U * V * V.';
U=U .* a ./ b;

then Octave 3.1.51+, and presumably Matlab, will never explicitly form 
the transpose matrix but call the underlying lapack code with the 
transpose flagged. A final reason might be that the matlab solver for 
over/under determined matrices uses a QR decomposition rather than the 
xGELSD function as Octave does. The reason Octave doesn't want to change 
is discussed in the thread

 http://www.nabble.com/Behavior-of-mldivide-in-Octave-relative-to-Matlab-to16561235.html

Matlab gets a significant speed increase for their solution at the cost 
of a solution that is not invariant with column permutations. I suspect 
this third issue is the reason for the speed difference Marco pointed 
out how to duplicate Matlab's behavior for this, and presumably their 
speed, with 4 lines of code.

D.

-- 
David Bateman                                David.Bateman at motorola.com
Motorola Labs - Paris                        +33 1 69 35 48 04 (Ph) 
Parc Les Algorithmes, Commune de St Aubin    +33 6 72 01 06 33 (Mob) 
91193 Gif-Sur-Yvette FRANCE                  +33 1 69 35 77 01 (Fax) 

The information contained in this communication has been classified as: 

[x] General Business Information 
[ ] Motorola Internal Use Only 
[ ] Motorola Confidential Proprietary



More information about the Help-octave mailing list