<p dir="auto">Broadcasting a unitary operation like <code class="notranslate">exp</code> against a <code class="notranslate">Symmetric</code> matrix should be almost 2x faster since it only needs to process 1/2 the elements.<br>
But instead is is  almost 2x slower.<br>
(So like 4x slower than expected)</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="julia&gt; using LinearAlgebra

julia&gt; using BenchmarkTools

julia&gt; const data = Matrix(Symmetric(randn(2_000, 2_000)));

julia&gt; @benchmark exp.($data)
BenchmarkTools.Trial:
  memory estimate:  30.52 MiB
  allocs estimate:  2
  --------------
  minimum time:     23.570 ms (0.00% GC)
  median time:      24.860 ms (0.00% GC)
  mean time:        27.109 ms (9.95% GC)
  maximum time:     98.043 ms (70.41% GC)
  --------------
  samples:          185
  evals/sample:     1

julia&gt; @benchmark exp.($(Symmetric(data)))
BenchmarkTools.Trial:
  memory estimate:  30.52 MiB
  allocs estimate:  2
  --------------
  minimum time:     37.712 ms (0.00% GC)
  median time:      38.774 ms (0.00% GC)
  mean time:        41.895 ms (7.72% GC)
  maximum time:     115.427 ms (59.57% GC)
  --------------
  samples:          120
  evals/sample:     1"><pre class="notranslate">julia<span class="pl-k">&gt;</span> <span class="pl-k">using</span> LinearAlgebra

julia<span class="pl-k">&gt;</span> <span class="pl-k">using</span> BenchmarkTools

julia<span class="pl-k">&gt;</span> <span class="pl-k">const</span> data <span class="pl-k">=</span> <span class="pl-c1">Matrix</span>(<span class="pl-c1">Symmetric</span>(<span class="pl-c1">randn</span>(<span class="pl-c1">2_000</span>, <span class="pl-c1">2_000</span>)));

julia<span class="pl-k">&gt;</span> <span class="pl-c1">@benchmark</span> <span class="pl-c1">exp</span>.(<span class="pl-k">$</span>data)
BenchmarkTools<span class="pl-k">.</span>Trial<span class="pl-k">:</span>
  memory estimate<span class="pl-k">:</span>  <span class="pl-c1">30.52</span> MiB
  allocs estimate<span class="pl-k">:</span>  <span class="pl-c1">2</span>
  <span class="pl-k">--------------</span>
  minimum time<span class="pl-k">:</span>     <span class="pl-c1">23.570</span> ms (<span class="pl-c1">0.00</span><span class="pl-k">%</span> GC)
  median time<span class="pl-k">:</span>      <span class="pl-c1">24.860</span> ms (<span class="pl-c1">0.00</span><span class="pl-k">%</span> GC)
  mean time<span class="pl-k">:</span>        <span class="pl-c1">27.109</span> ms (<span class="pl-c1">9.95</span><span class="pl-k">%</span> GC)
  maximum time<span class="pl-k">:</span>     <span class="pl-c1">98.043</span> ms (<span class="pl-c1">70.41</span><span class="pl-k">%</span> GC)
  <span class="pl-k">--------------</span>
  samples<span class="pl-k">:</span>          <span class="pl-c1">185</span>
  evals<span class="pl-k">/</span>sample<span class="pl-k">:</span>     <span class="pl-c1">1</span>

julia<span class="pl-k">&gt;</span> <span class="pl-c1">@benchmark</span> <span class="pl-c1">exp</span>.(<span class="pl-k">$</span>(<span class="pl-c1">Symmetric</span>(data)))
BenchmarkTools<span class="pl-k">.</span>Trial<span class="pl-k">:</span>
  memory estimate<span class="pl-k">:</span>  <span class="pl-c1">30.52</span> MiB
  allocs estimate<span class="pl-k">:</span>  <span class="pl-c1">2</span>
  <span class="pl-k">--------------</span>
  minimum time<span class="pl-k">:</span>     <span class="pl-c1">37.712</span> ms (<span class="pl-c1">0.00</span><span class="pl-k">%</span> GC)
  median time<span class="pl-k">:</span>      <span class="pl-c1">38.774</span> ms (<span class="pl-c1">0.00</span><span class="pl-k">%</span> GC)
  mean time<span class="pl-k">:</span>        <span class="pl-c1">41.895</span> ms (<span class="pl-c1">7.72</span><span class="pl-k">%</span> GC)
  maximum time<span class="pl-k">:</span>     <span class="pl-c1">115.427</span> ms (<span class="pl-c1">59.57</span><span class="pl-k">%</span> GC)
  <span class="pl-k">--------------</span>
  samples<span class="pl-k">:</span>          <span class="pl-c1">120</span>
  evals<span class="pl-k">/</span>sample<span class="pl-k">:</span>     <span class="pl-c1">1</span></pre></div>
<p dir="auto">Currently, <code class="notranslate">map</code> and <code class="notranslate">broadcast</code> on <code class="notranslate">Symmetric</code> arguments don’t take advantage of the fact that you only have to compute <code class="notranslate">n*(n+1)/2</code> elements of the output matrix instead of <code class="notranslate">n^2</code>elements. For big matrices, this can leave a lot of performance on the table.</p>