bugGNU Octave - Bugs: bug #38628, bsxfun slow for complex


bug #38628: bsxfun slow for complex

Submitted by:  John Hunt <huntj>
Submitted on:  Fri 29 Mar 2013 07:17:37 PM UTC  
Category: InterpreterSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Performance
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)

Tue 13 Oct 2015 05:07:58 PM UTC, comment #7:

As a follow-up to comment #2, I think the reason it is slower is that bsxfun doesn't have any special optimizations in place for mixed-type operations.

John W. Eaton <jwe>
Project Administrator
Tue 13 Oct 2015 03:07:36 PM UTC, comment #6:

@Jordi: Did you write the automatic broadcasting code? I haven't followed this much, but having two different code paths does seem problematic. Certainly we need to keep bsxfun to be Matlab-compatible, but maybe it should call to the automatic broadcasting code since it seems to be faster.

Rik <rik5>
Project Administrator
Tue 13 Oct 2015 11:17:01 AM UTC, comment #5:

The broadcast warning is gone, but it was just replaced by a different warning tag (that change is the subject of another bug report).

Also, since @times is handled as a special case in bsxfun, why is it slow for complex?

I was looking at bsxfun last night to see why it is slow for @bitxor, and I got a bit lost. It seems quite complicated. Also bad that we now have two ways of doing these operations. I thought that broadcasting operators were just syntactic sugar for bsxfun, but it seems there are actually two different code paths for the same thing?

John W. Eaton <jwe>
Project Administrator
Tue 13 Oct 2015 04:30:11 AM UTC, comment #4:

I replaced bsxfun in all cases in Octave core where there might be complex inputs. See this cset (http://hg.savannah.gnu.org/hgweb/octave/rev/a3b9ee5c040a)

Rik <rik5>
Project Administrator
Fri 09 Oct 2015 04:50:09 PM UTC, comment #3:

The bug is still there in 4.0.0.

Anyway, now that the "Octave:broadcast" warning is gone, trapz could use broadcasting ? (patch attached for trapz).

(file #35126)

ederag <ederag>
Thu 04 Apr 2013 02:38:11 AM UTC, comment #2:

Exceedingly strange. This is, perhaps, a clue. If dx is promoted to a complex matrix (with 0 for the imaginary part) then the bsxfun call goes back to being extremely fast.

Rik <rik5>
Project Administrator
Wed 03 Apr 2013 07:01:30 PM UTC, comment #1:

Hm, this is quite bizarre. I'll try to remember to look into this later.

Jordi GutiƩrrez Hermoso <jordigh>
Project Administrator
Fri 29 Mar 2013 07:17:37 PM UTC, original submission:

bsxfun is slow for complex array. Much slower than broadcasting.
trapz which uses bsxfun is impacted for instance.

these outputs are from dev
hg id -in
a695ee2dc17e+ 16392+

but it holds also for 3.6.3 and 3.6.4

John Hunt <huntj>


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

Attach File(s):

Attached Files
file #35126:  octave-4.0.0_trapz.m.patch added by ederag (456B - text/x-patch)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by jwe (Posted a comment)
  • -unavailable- added by ederag (Updated the item)
  • -unavailable- added by rik5 (Posted a comment)
  • -unavailable- added by jordigh (Posted a comment)
  • -unavailable- added by huntj (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 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 09 Oct 2015 04:50:09 PM UTCederagAttached File-=>Added octave-4.0.0_trapz.m.patch, #35126
    Wed 03 Apr 2013 07:01:30 PM UTCjordighStatusNone=>Confirmed

    Back to the top

    Powered by Savane 3.1-cleanup