
You’re only as good as your weakest link adaptability of your strongest skill.
Nay loops
, Yay MATLAB bsxfun
/NumPy Broadcasting
Interesting Indulgences:
6D Permute
:MATLAB
,NumPy
Kill recursions by tracing.
Exciting MATLAB:
- Vectorized computations on ragged pattern data (including cell arrays) with bsxfun's masking capability.
- Sum over blocks : [1], [2], [3], [4].
- Dump
meshgrid/ndgrid
forbsxfun
: [1] [2] [3] - Avoid anonymous functions, even with bsxfun : [1] runtime numbers.
- Index into diagonal elements efficiently with bsxfun: [1]
- Function-inline for insane speedups:[1].
- Avoid
sub2ind
with its raw version for a noticeable speedup! [1] - Replace
repmat
withbsxfun
: [1] [2] [3] [4] - Even
tic/toc
need warming up before benchmarking - Efficient euclidean distances calculation: Original source, Explanation
- Dump kron for bsxfun!
- Alternatives to
nchoosek(1:N,2)
Accumarray
on 2D matrix
Exciting NumPy:
Heavy
Broadcasting
based vectorizationFaster alternative to
np.any
innp.einsum
Top Questions