[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: very very very slow computing
From: |
Ivan Sutoris |
Subject: |
Re: very very very slow computing |
Date: |
Fri, 6 Feb 2009 18:53:18 +0100 |
On Fri, Feb 6, 2009 at 5:04 PM, Depo <address@hidden> wrote:
>
> 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
Hi
I guess your problem is missing semicolon in line
new_sign_difference(k,i)=sign_difference(k,i)
which means that whole matrix is printed in every cycle . After I
removed output to screen by adding semicolon and removing both disp()
commands, the assignment takes about 2.5 secs on my computer (for
10*3000 matrix).
Regards
Ivan Sutoris