Few questions were asked before on comparisons between bsxfun
and repmat
for performance.
- One of them was:
Matlab - bsxfun no longer faster than repmat?
. This one tried to investigate performance comparisons betweenrepmat
andbsxfun
, specific to performing subtraction of an input array's mean along the columns from the input array itself and as such would explore only the@minus
part ofbsxfun
against itsrepmat
equivalent. - Another was :
In Matlab, when is it optimal to use bsxfun?
. That one tried to do the same operation of subtraction by the mean along columns and didn't expand onto other built-in operations either.
With this post, I am trying to investigate the performance numbers between bsxfun
and repmat
to cover all the bsxfun
built-ins to sort of give it a wider perspective as both of these present good vectorized solutions.
Specifically, my questions with this post are:
How do the various built-in operations with
bsxfun
perform againstrepmat
equivalents?bsxfun
supports floating point operations like@plus
,@minus
,@times
, etc. and also relational and logical operations like@ge
,@and
, etc. So, are there specific built-ins that would give me noticeable speedups withbsxfun
than using theirrepmat
equivalents?Loren in her
blog post
has benchmarkedrepmat
againstbsxfun
with timing@() A - repmat(mean(A),size(A,1),1)
against@() bsxfun(@minus,A,mean(A))
respectively. If I need to cover benchmarking for all the built-ins, can I use some other comparison model that would work with floating point, relational and logical operations?