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: John W. Eaton
Subject: [Octave-bug-tracker] [bug #48686] Copy of columns of the matrix
Date: Wed, 8 Mar 2017 12:31:53 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0

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

I think this bug report is related to bug #42118.

When you do


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


the variable B is a reference to a slice of A.  It is only when you do


a(1:2) = [1 2]';


that a copy is made.  At this point, however, Octave doesn't know that it
could just copy the two elements referenced by B and decrement the reference
count for A.  So instead, it copies all the data of A and then modifies the
copy.  This is indeed wasteful.  It doesn't happen when working with rows of a
matrix because Octave uses column-major storage so you can't create a slice
using a row.

Maybe some smarter slice management could fix this problem so that Octave
could know about the slice B when looking at A.  But I'm not sure it's worth
the extra complexity.  Or, as I think we've discussed in the other bug report,
we could make copies instead of slices when the slice size is small (for some
definition of "small").

    _______________________________________________________

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]