While I cannot not agree with this ;), I'd like to state that:
1) High level functions might leverage clever algorithms faster than plain 
loops (best example comming to mind: dot).
2) Vectorized code is always easier to understand, write, fix and maintain 
because the intent is clear from the start. You equation is written just as it 
was on paper and not burried within nested loops among many explicit indices.
Moreover, Julia will get better at devectorizing and at avoiding temporaries.

Therefore I would recommand using explicit loops only when *proved* to provide 
a necessary speedup or a memory gain.

In this case diagm is working just as intended and saving 20ns on matrix 
construction just seem silly. I perfectly understand your point though but 
explicit loops have downsides too.

Profile first, optimize later... Comment now!  ;)

Reply via email to