bugGNU Octave - Bugs: bug #50796, calling find on diagonal matrix is...

 
 

bug #50796: calling find on diagonal matrix is slower than full matrix

Submitted by:  Carnë Draug <carandraug>
Submitted on:  Thu Apr 13 13:19:14 2017  
 
Category: PerformanceSeverity: 3 - Normal
Priority: 5 - NormalItem Group: None
Status: ConfirmedAssigned to: None
Originator Name: Open/Closed: Open
Release: devOperating System: GNU/Linux

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

Thu Apr 27 19:39:09 2017, comment #7:

What do you think of the included patch? I modified find_nonzero_elem_idx in find.cc in order to manage the DiagArray2 case. Please, revise carefully since these are my first experiments with C++.

(file #40522)

Marco Caliari <caliari>
Project Member
Thu Apr 27 00:24:55 2017, comment #6:

The script shows that that is not always true, it depends on the types of elements of the matrix (compared bool vs double).

Also the complexities do not seem to differ that much.

What I meant is that finding on a diagonal matrices is just finding on the vector of its diagonal, so the "overload" is just calling find on the diag vector, i.e. find (diag(A),...)

Juan Pablo Carbajal <juanpi>
Wed Apr 26 23:01:48 2017, comment #5:

I don't think so. Since there is no overload it appears that find converts the matrix to full, and then calls find on that. However, there is something else going on since

is a relatively quick operation.

Rik <rik5>
Project Administrator
Wed Apr 26 22:12:16 2017, comment #4:

Isn't the find of diagMatrix A just find(diag(A),...)?

Juan Pablo Carbajal <juanpi>
Wed Apr 26 20:57:57 2017, comment #3:

Confirmed. The trouble seems to be that there is no overload of the find function for DiagMatrix. I think any change needs to start in liboctave/array/. But it might also require changes to libinterp/corefcn/find.cc.

Rik <rik5>
Project Administrator
Sat Apr 15 14:02:14 2017, comment #2:

I forgot to mention that this was identified on this

stackoverflow question http://stackoverflow.com/a/43393446/1609556

where I mention that find has special cases for several data types and it is missing diagonal matrices. It's just weird that it takes so much more time so maybe there is something else going on.

Carnë Draug <carandraug>
Project Member
Thu Apr 13 14:14:23 2017, comment #1:

The attached script produces (using function speed)

So it seems the problem is with doubles, as booleans are close to the optimal. I am puzzled by the negative order of the boolean full case.

(file #40391)

Juan Pablo Carbajal <juanpi>
Thu Apr 13 13:19:14 2017, original submission:

I though this was because find converts a diagonal to a full matrix internally, but even if calling full ourselves before find, it's still much faster so I am no longer sure:

Carnë Draug <carandraug>
Project Member

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #40522:  find.patch added by caliari (4kB - text/x-patch)
file #40391:  find_timeit.m added by juanpi (829B - text/x-objcsrc)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by caliari (Updated the item)
  • -unavailable- added by rik5 (Posted a comment)
  • -unavailable- added by juanpi (Updated the item)
  • -unavailable- added by carandraug (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu Apr 27 19:39:09 2017caliariAttached File-=>Added find.patch, #40522
    Wed Apr 26 20:57:57 2017rik5StatusNone=>Confirmed
    Thu Apr 13 14:14:23 2017juanpiAttached File-=>Added find_timeit.m, #40391

    Back to the top


    Powered by Savane 3.1-cleanup1