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

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

[Octave-bug-tracker] [bug #52668] Anonymous function locks in an unexpec


From: Joseph Young
Subject: [Octave-bug-tracker] [bug #52668] Anonymous function locks in an unexpected type for the arguments in its closure
Date: Thu, 14 Dec 2017 17:24:27 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:57.0) Gecko/20100101 Firefox/57.0

URL:
  <http://savannah.gnu.org/bugs/?52668>

                 Summary: Anonymous function locks in an unexpected type for
the arguments in its closure
                 Project: GNU Octave
            Submitted by: josyoun
            Submitted on: Thu 14 Dec 2017 10:24:26 PM UTC
                Category: Interpreter
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: None
                  Status: None
             Assigned to: None
         Originator Name: josyoun
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 4.2.1
        Operating System: GNU/Linux

    _______________________________________________________

Details:

It appears as though an anonymous function is locking in an unexpected type
for one of its arguments.  Consider the following code:


octave:1> I=eye(5);
octave:2> ei=@(i)I(:,i);
octave:3> ei(3)
error: can't perform indexing operations for diagonal matrix type
octave:3> I(:,3)
ans =

   0
   0
   1
   0
   0


Basically, the closure appears to be locking in I as a diagonal matrix whereas
if we access it directly the interpreter allows it to change types.  This also
appears unique to Octave.  From MATLAB:


>> I=eye(5);
>> ei=@(i)I(:,i);
>> ei(3)

ans =

     0
     0
     1
     0
     0


That said, we can force the correct type by:


octave:1> I=full(eye(5));
octave:2> ei=@(i)I(:,i);
octave:3> ei(3)
ans =

   0
   0
   1
   0
   0


Anyway, I'm not sure if Octave is supposed to be dynamically changing the type
in the closure or not.  It would appear that it should, but it's not.




    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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