bugGNU Octave - Bugs: bug #47510, arrayfun errors on indexing...

 
 

bug #47510: arrayfun errors on indexing diagonal matrix

Submitter:  CarnĂ« Draug <carandraug>
Submitted:  Wed 23 Mar 2016 05:23:03 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  None
Status:  Confirmed Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 24 Mar 2016 04:33:10 AM UTC, comment #4: 

Actually, I see your point.  I must have been mistaken in my test script.

Rik <rik5>
Group administrator
Thu 24 Mar 2016 04:05:26 AM UTC, comment #3: 

I think my original suggestion is correct, at least it works for me without sub2ind.

From the specification, only one column in each row has a 1 in it.  Therefore I created indices (i,j) where i runs over the rows (1:N) and the j index is provided by the vector Y.

Rik <rik5>
Group administrator
Thu 24 Mar 2016 02:50:24 AM UTC, comment #2: 

@Rik: I think you meant:


x = zeros(N, 10);
x(sub2ind(size(x), 1:N, Y)) = 1;


not that it matters here :)

Amro <amro_octave>
Wed 23 Mar 2016 08:34:25 PM UTC, comment #1: 

Confirmed, although the code is really poorly written to do the job stated by the author on StackOverflow.  I think the code below is clearer.


x = zeros (N, 10);
x(1:N, Y) = 1;


To help narrow it down, it is possible to index diagonal arrays either on the command line or in a function (m-file).  A little use of grep shows that the message "can't perform indexing operations" is only in libinterp/octave-value/ov-base.cc for either subsref or do_index_op.

I set some breakpoints and tried the code and I got the following backtrace.


#0  octave_base_value::do_multi_index_op (this=0x7fffd41bf7d0)
    at libinterp/octave-value/ov-base.cc:200
#1  0x00007ffff6bb6fa7 in octave_base_value::do_multi_index_op (
    this=0x7fffd41bf7d0, nargout=0, idx=...)
    at libinterp/octave-value/ov-base.cc:209
#2  0x00007ffff6cd734b in octave_value::do_multi_index_op (
    this=0x7fffd41af9d8, nargout=0, idx=..., lvalue_list=0x0)
    at libinterp/octave-value/ov.cc:1286
#3  0x00007ffff6c5ed2c in octave_fcn_binder::do_multi_index_op (
    this=0x7fffd41af850, nargout=0, args=..., lvalue_list=0x0)
    at libinterp/octave-value/ov-fcn-handle.cc:2094
#4  0x00007ffff6c5eb9b in octave_fcn_binder::do_multi_index_op (
    this=0x7fffd41af850, nargout=0, args=...)
    at libinterp/octave-value/ov-fcn-handle.cc:2072
#5  0x00007ffff6cd72d9 in octave_value::do_multi_index_op (
    this=0x7fffd8a80400, nargout=0, idx=...)
    at libinterp/octave-value/ov.cc:1279
#6  0x00007ffff6df5d23 in get_output_list (count=0, nargout=0, inputlist=...,
    func=..., error_handler=...) at libinterp/corefcn/cellfun.cc:79
#7  0x00007ffff6df95ee in Farrayfun (args=..., nargout=0)
    at libinterp/corefcn/cellfun.cc:1345
#8  0x00007ffff6bcfc12 in octave_builtin::do_multi_index_op (
    this=0x7fffd404b7e0, nargout=0, args=..., lvalue_list=0x0)
    at libinterp/octave-value/ov-builtin.cc:125
#9  0x00007ffff6bcf8e3 in octave_builtin::subsref (this=0x7fffd404b7e0,
    type=..., idx=..., nargout=0, lvalue_list=0x0)
    at libinterp/octave-value/ov-builtin.cc:63
#10 0x00007ffff6bcf7a7 in octave_builtin::subsref (this=0x7fffd404b7e0,
    type=..., idx=..., nargout=0) at libinterp/octave-value/ov-builtin.cc:46
#11 0x00007ffff6cd6b4c in octave_value::subsref (this=0x7fffd8a80c10,
    type=..., idx=..., nargout=0) at libinterp/octave-value/ov.cc:1197
#12 0x00007ffff6cd6c0e in octave_value::subsref (this=0x7fffd8a80c10,
    type=..., idx=..., nargout=0, lvalue_list=0x0)
    at libinterp/octave-value/ov.cc:1208
#13 0x00007ffff6d8b25d in tree_index_expression::rvalue (this=0x7fffd466afc0,
    nargout=0, lvalue_list=0x0) at libinterp/parse-tree/pt-idx.cc:428
#14 0x00007ffff6d8a6be in tree_index_expression::rvalue (this=0x7fffd466afc0,
    nargout=0) at libinterp/parse-tree/pt-idx.cc:269
#15 0x00007ffff6d8b6ae in tree_index_expression::rvalue1 (this=0x7fffd466afc0,
    nargout=0) at libinterp/parse-tree/pt-idx.cc:461
#16 0x00007ffff6d838cc in tree_evaluator::visit_statement (
    this=0x7ffff7833d60 <std_evaluator>, stmt=...)
    at libinterp/parse-tree/pt-eval.cc:708
#17 0x00007ffff6da5420 in tree_statement::accept (this=0x7fffd466b0f0, tw=...)
    at libinterp/parse-tree/pt-stmt.cc:187
#18 0x00007ffff6d83a71 in tree_evaluator::visit_statement_list (
    this=0x7ffff7833d60 <std_evaluator>, lst=...)
    at libinterp/parse-tree/pt-eval.cc:750
#19 0x00007ffff6da5e6e in tree_statement_list::accept (this=0x7fffd459e2a0,
    tw=...) at libinterp/parse-tree/pt-stmt.cc:327
#20 0x00007ffff6cc81d3 in octave_user_script::do_multi_index_op (
    this=0x7fffd466b180, nargout=0, args=...)
    at libinterp/octave-value/ov-usr-fcn.cc:149
#21 0x00007ffff6cd72d9 in octave_value::do_multi_index_op (
    this=0x7fffd8a812b0, nargout=0, idx=...)
    at libinterp/octave-value/ov.cc:1279
#22 0x00007ffff6d887b3 in tree_identifier::rvalue (this=0x7fffd45ebb90,
    nargout=0, lvalue_list=0x0) at libinterp/parse-tree/pt-id.cc:90
#23 0x00007ffff6d68f92 in tree_identifier::rvalue (this=0x7fffd45ebb90,
    nargout=0) at libinterp/parse-tree/pt-id.h:111
#24 0x00007ffff6d889f0 in tree_identifier::rvalue1 (this=0x7fffd45ebb90,
    nargout=0) at libinterp/parse-tree/pt-id.cc:116
#25 0x00007ffff6d838cc in tree_evaluator::visit_statement (
    this=0x7ffff7833d60 <std_evaluator>, stmt=...)
    at libinterp/parse-tree/pt-eval.cc:708
#26 0x00007ffff6da5420 in tree_statement::accept (this=0x7fffd45ebbd0, tw=...)
    at libinterp/parse-tree/pt-stmt.cc:187
#27 0x00007ffff6d83a71 in tree_evaluator::visit_statement_list (
    this=0x7ffff7833d60 <std_evaluator>, lst=...)
    at libinterp/parse-tree/pt-eval.cc:750
#28 0x00007ffff6da5e6e in tree_statement_list::accept (this=0x7fffd44a6090,
    tw=...) at libinterp/parse-tree/pt-stmt.cc:327
#29 0x00007ffff71e2e4f in main_loop () at libinterp/corefcn/toplev.cc:707
#30 0x00007ffff67ff5af in octave_execute_interpreter ()
    at libinterp/octave.cc:995
#31 0x00007ffff7a2620a in octave_interpreter::execute (this=0x73cd30)
    at libgui/src/octave-interpreter.cc:48
#32 0x00007ffff7a81573 in octave_interpreter::qt_static_metacall (_o=0x73cd30,
    _c=QMetaObject::InvokeMetaMethod, _id=1, _a=0x734ab0)
    at libgui/src/moc-octave-interpreter.cc:57
#33 0x00007ffff2c1ed01 in QObject::event(QEvent*) ()
   from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#34 0x00007ffff3130cdc in QApplicationPrivate::notify_helper(QObject*, QEvent*)
    () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#35 0x00007ffff3137c16 in QApplication::notify(QObject*, QEvent*) ()
   from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#36 0x00007ffff2c0485d in QCoreApplication::notifyInternal(QObject*, QEvent*)
    () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#37 0x00007ffff2c08316 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#38 0x00007ffff2c3507e in ?? () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#39 0x00007fffec48bff7 in g_main_context_dispatch ()
   from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#40 0x00007fffec48c250 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#41 0x00007fffec48c2fc in g_main_context_iteration ()
   from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#42 0x00007ffff2c3520e in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#43 0x00007ffff2c030d1 in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#44 0x00007ffff2c03445 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#45 0x00007ffff2af24f9 in QThread::exec() ()
   from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#46 0x00007ffff2af4d1c in ?? () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#47 0x00007ffff46846aa in start_thread (arg=0x7fffd8a82700)
    at pthread_create.c:333
#48 0x00007ffff43b9e9d in clone ()
    at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109



Rik <rik5>
Group administrator
Wed 23 Mar 2016 05:23:03 PM UTC, original submission:  

Reported on stackoverflow https://stackoverflow.com/questions/36182328/why-this-octave-code-wont-work


octave> theEye = eye(10);
octave> Y = vec(1:10);
octave> arrayfun(@(x)theEye(x,:), Y, 'UniformOutput', false)
error: can't perform indexing operations for diagonal matrix type


Carnë Draug <carandraug>
Group Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by amro_octave (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by carandraug (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-03-23 rik5 StatusNone Confirmed

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code