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


bug #38628: bsxfun slow for complex

Submitted by:  John Hunt <huntj>
Submitted on:  Fri Mar 29 19:17:37 2013  
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)

Sun Nov 20 21:58:41 2016, comment #8:

This (performance) issue is still present in Octave 4.2.0.

Hartmut <hardy>
Tue Oct 13 17:07:58 2015, 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 Oct 13 15:07:36 2015, 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 Oct 13 11:17:01 2015, 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 Oct 13 04:30:11 2015, 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 Oct 9 16:50:09 2015, 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 Apr 4 02:38:11 2013, 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 Apr 3 19:01:30 2013, 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 Mar 29 19:17:37 2013, 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 hardy (Posted a comment)
  • -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 Oct 9 16:50:09 2015ederagAttached File-=>Added octave-4.0.0_trapz.m.patch, #35126
    Wed Apr 3 19:01:30 2013jordighStatusNone=>Confirmed

    Back to the top

    Powered by Savane 3.1-cleanup1