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

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

[Octave-bug-tracker] [bug #33221] subsasgn without LHS should do in-plac


From: Daniel Molina García
Subject: [Octave-bug-tracker] [bug #33221] subsasgn without LHS should do in-place assignment for performance
Date: Tue, 26 May 2020 07:55:58 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0

Follow-up Comment #3, bug #33221 (project octave):

It is not only a Matlab compatibility issue, but apparently an inconsistency
with Octave documentation.


octave:1> help subsasgn
[...]
          val = magic (3);
          idx.type = "()";
          idx.subs = {":", 1:2};
          subsasgn (val, idx, 0)
               =>  [ 0   0   6
                     0   0   7
                     0   0   2 ]

     Note that this is the same as writing 'val(:, 1:2) = 0'.


However, last sentence is not correct (val is not assigned after subsasgn
call). Example that shows it:


octave:1> val = magic (3);
octave:2> idx.type = "()";
octave:3> idx.subs = {":", 1:2};
octave:4> 
octave:4> subsasgn (val, idx, 0)
ans =

   0   0   6
   0   0   7
   0   0   2

octave:5> val
val =

   8   1   6
   3   5   7
   4   9   2

octave:6> val(:, 1:2) = 0
val =

   0   0   6
   0   0   7
   0   0   2

octave:7> val
val =

   0   0   6
   0   0   7
   0   0   2



If I understand it correctly, documentation should be modified/clarified or
subsasgn implementation modified.

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?33221>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

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