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: Nicholas Jankowski
Subject: [Octave-bug-tracker] [bug #33221] subsasgn without LHS should do in-place assignment for performance
Date: Fri, 22 Jul 2022 15:47:41 -0400 (EDT)

Update of bug #33221 (project octave):

                Severity:               2 - Minor => 1 - Wish               
                Priority:              5 - Normal => 3 - Low                
              Item Group:    Matlab Compatibility => Feature Request        

    _______________________________________________________

Follow-up Comment #5:

regarding the primary focus of this report, the comment #0 code no longer runs
in Matlab:

matlab 2022a:

>> r = randn(4,4);
>> subsasgn(r, struct('type', '()', 'subs', {{2, 2}}), 0)
Error using indexing
SUBSASGN must be called with an output.


Not interested in digging through a decade worth or release notes to see if
it's mentioned, but it appears that sometime over the past decade this
undocumented behavior changed. 

Now Octave still allows a subsasgn without an output, and simply puts the
result in ans, leaving r unchanged:


>> r = randn(4,4);
>> subsasgn(r, struct('type', '()', 'subs', {{2, 2}}), 0)
ans =

   1.8659   0.2015  -1.9407   0.1915
   0.3151        0  -0.1796  -0.8894
  -1.1896  -0.5194   1.1625   1.0586
   0.2087  -1.3228  -0.3853  -0.2635

>> who
Variables visible from the current scope:

ans  r

>> ans
ans =

   1.8659   0.2015  -1.9407   0.1915
   0.3151        0  -0.1796  -0.8894
  -1.1896  -0.5194   1.1625   1.0586
   0.2087  -1.3228  -0.3853  -0.2635

>> r
r =

   1.8659   0.2015  -1.9407   0.1915
   0.3151   0.1767  -0.1796  -0.8894
  -1.1896  -0.5194   1.1625   1.0586
   0.2087  -1.3228  -0.3853  -0.2635


of the two speed examples given in comment #0, Matlab no longer allows the
comparison, but both 'slow' versions run almost instantaneously in both Matlab
and Octave. Don't know if this is because both programs have made these
optimizations already, or if things are just faster 11 years later.  

In any case, I'm going to change the category to Wish/Feature request.  It
should probably be closed as Wont Fix unless someone  can verify the code
optimization still needs to be addressed.


    _______________________________________________________

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]