octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #48686] Copy of columns of the matrix


From: anonymous
Subject: [Octave-bug-tracker] [bug #48686] Copy of columns of the matrix
Date: Wed, 8 Mar 2017 11:49:15 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:40.0) Gecko/20100101 Firefox/40.0

Follow-up Comment #4, bug #48686 (project octave):

I made a few further test (see attached script), and it seems to be a quite
fundamental problem, not only related to row assignments or even matrices. It
can easily be demonstrated like this:

a=rand(100000000,1);
tic;a(1:2)=[1 2]';toc
tic;b=a(1:2);toc
tic;a(1:2)=[1 2]';toc

The second assignment (and further, all assignments that directly follow a
read) take (at my computer) 0.3 seconds. That is an assignment of two scalar
values! The test script shows that this has to be a side effect of using
ranges. For some reason, it seems that in the assignments of these two
elements of a in the code above the whole vector a is copied, because if I do


tic;b=a;toc
tic;b(1)=1;toc

the first assignment of b goes fast due to lazy copying, and only when b is
changed it takes exactly the 0.3 seconds seen also above. I think this is
quite a severe bug. 

(file #39943)
    _______________________________________________________

Additional Item Attachment:

File name: test_range_copy.m              Size:1 KB


    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?48686>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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