help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: very very very slow computing


From: Schirmacher, Rolf
Subject: RE: very very very slow computing
Date: Fri, 6 Feb 2009 19:03:58 +0100


> -----Original Message-----
> From: Depo [mailto:address@hidden
> Sent: Friday, February 06, 2009 5:05 PM
> To: address@hidden
> Subject: very very very slow computing
> 
> 
> 
> Hi everybody,
> 
> I was just trying making some simple operations on a large 
> matrix (10, 3000)
> and I faced off o very slow computational time comparing to the simple
> operation I was attempting to do. Looking for the problem I 
> saw that even
> copying same values to a new matrix was a computationally huge
> operation!!!!!!!!!!!!!
> 
> That is the code:
> 
> clear new_sign_difference;                                    
>     #to ensure
> it is emty
> i=1; k=1;
> while (k <= n_rows)                                           
>        #I have
> used while statement instead of for because some says it is faster... 
> while (i <= n_cols) 
> new_sign_difference(k,i)=sign_difference(k,i)           #reassign same
> values to a new matrix
> disp(i);
> disp(k);
> i++;
> endwhile
> k++; i=1;
> endwhile  
> 
> the matrix sign_difference has size 10x3'000, so this is a 
> 30'000-operation
> loop. It takes up to 10
> minutes!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
> 
> If I only visualize on screen matrix' values it takes 1
> second............................., here is the code:
> 
> 
> clear new_sign_difference; 
> i=1; k=1;
> while (k <= n_rows) 
> while (i <= n_cols) 
> sign_difference(k,i)                #only to screen, without 
> writing on a
> new matrix
> disp(i);
> disp(k);
> i++;
> endwhile
> k++; i=1;
> endwhile  
> 
> 
> How is it possible?????????????????????????????????????
> Please help me, I'm getting crazy and I can't work at all at these
> conditions..........................
> 
> 
> Tanks everybody 
> -- 
> View this message in context: 
> http://www.nabble.com/very-very-very-slow-computing-tp21875383
p21875383.html
Sent from the Octave - General mailing list archive at Nabble.com.

The way you set up your code, there are 30000 times where the new matrix
requires to allocate new memory and get resized. Please try to allocate one
chunk of memory before you enter the loops, e.g. by 

new_sign_difference=zeros(size(sign_difference));

Should help you a lot ;-)

Rolf


reply via email to

[Prev in Thread] Current Thread [Next in Thread]