[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: unexpected copying
From: |
John W. Eaton |
Subject: |
Re: unexpected copying |
Date: |
Tue, 13 Jun 2006 14:03:19 -0400 |
On 13-Jun-2006, Paul Kienzle wrote:
| Thanks! Your workaround works in 2.1.72 as well:
|
| A = reshape(A,newshape);
| 1; # Drop extra reference to A (Octave 2.9.6 and below)
| A(1,1) = 2;
OK, I also made this change to the 2.1.x sources in case we decide to
make a 2.1.74 snapshot.
| Here's another one which I suspect will be harder to avoid:
|
| function t = set1(A), tic; A(1,1)=2; t=toc; end
| S=T=[100:100:3000];
| for i=1:length(S); T(i) = set1(rand(S(i))); end
| plot(S,T);
|
| I'm guessing the argument list is holding onto a reference
| to the temporary rand(S(i)) until the function call returns.
|
| It's probably not worth your time addressing this since
| it won't help the common case:
|
| function t = set1(A), tic; A(1,1)=2; t=toc; end
| S=T=[100:100:3000];
| for i=1:length(S); A=rand(S(i)); T(i) = set1(A); end
| plot(S,T);
Right, I don't see how to avoid these copies without rewriting much of
Octave.
jwe