Matlab and broadcasting

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Matlab and broadcasting

Rik-4
I wasn't following things, but apparently since 2016B broadcasting is now a part of Matlab (Octave was here first!).  For example, in the documentation for bsxfun, there is now this

"In MATLAB® R2016b and later, you can directly use operators instead of bsxfun, since the operators independently support implicit expansion of arrays with compatible sizes."

Seems like a good project might be to review Octave's m-file scripts to see if there are places where we are unnecessarily using repmat or ones() in order to create correct dimensions when broadcasting would take care of this and not involve the creation of potentially large temporary variables.

Unfortunately, I see that broadcasting is still not as good as bsxfun for all implementations.  There is this comment in center.m

## FIXME: Use bsxfun, rather than broadcasting, until broadcasting
##        supports diagonal and sparse matrices (Bugs #41441, #35787).

--Rik




Reply | Threaded
Open this post in threaded view
|

Re: Matlab and broadcasting

NJank
On Aug 30, 2017 5:47 PM, "Rik" <[hidden email]> wrote:
I wasn't following things, but apparently since 2016B broadcasting is now a part of Matlab (Octave was here first!).  For example, in the documentation for bsxfun, there is now this

"In MATLAB® R2016b and later, you can directly use operators instead of bsxfun, since the operators independently support implicit expansion of arrays with compatible sizes."

Seems like a good project might be to review Octave's m-file scripts to see if there are places where we are unnecessarily using repmat or ones() in order to create correct dimensions when broadcasting would take care of this and not involve the creation of potentially large temporary variables.

Unfortunately, I see that broadcasting is still not as good as bsxfun for all implementations.  There is this comment in center.m

There was a bit of a discussion on it when it came out. 


how much of an overhead penalty does the ones() trick create? I think I used it a couple times in repelem.