<p dir="auto">I thought this was worth a separate issue.</p>
<p dir="auto">In <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="105096485" data-permission-text="Title is private" data-url="https://github.com/JuliaLang/julia/issues/12981" data-hovercard-type="issue" data-hovercard-url="/JuliaLang/julia/issues/12981/hovercard" href="https://github.com/JuliaLang/julia/issues/12981">#12981</a> <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/mb1234/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/mb1234">@mb1234</a> posted a short comparison script to benchmark few methods on sparse matrices between Julia, Octave and Matlab. The script to perform the table below can be seen in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="105096485" data-permission-text="Title is private" data-url="https://github.com/JuliaLang/julia/issues/12981" data-hovercard-type="issue" data-hovercard-url="/JuliaLang/julia/issues/12981/hovercard?comment_id=138122760&amp;comment_type=issue_comment" href="https://github.com/JuliaLang/julia/issues/12981#issuecomment-138122760">#12981 (comment)</a> except I added an explicit call to <code class="notranslate">gc()</code> between method invocations. The average of 5 runs is shown with the standard deviation in parenthesis.</p>
<table role="table">
<thead>
<tr>
<th>Func</th>
<th align="center">Julia</th>
<th align="center">Octave</th>
<th align="center">Matlab (single thread)</th>
</tr>
</thead>
<tbody>
<tr>
<td>sparse:</td>
<td align="center">2.478101 (0.161879)</td>
<td align="center">1.233007 (0.098839)</td>
<td align="center">2.678221 (0.104867)</td>
</tr>
<tr>
<td>2*A   :</td>
<td align="center">0.052062 (0.000805)</td>
<td align="center">0.120093 (0.042131)</td>
<td align="center">0.070358 (0.001547)</td>
</tr>
<tr>
<td>A'    :</td>
<td align="center">1.131908 (0.010331)</td>
<td align="center">0.810197 (0.075346)</td>
<td align="center">1.159815 (0.246967)</td>
</tr>
<tr>
<td>A+B   :</td>
<td align="center">0.246413 (0.001277)</td>
<td align="center">0.487021 (0.088988)</td>
<td align="center">0.202465 (0.000276)</td>
</tr>
<tr>
<td>A*x   :</td>
<td align="center">0.169672 (0.003784)</td>
<td align="center">0.340456 (0.009046)</td>
<td align="center">0.162381 (0.016590)</td>
</tr>
<tr>
<td>A'*x  :</td>
<td align="center">0.146576 (0.003835)</td>
<td align="center">1.191680 (0.099767)</td>
<td align="center">0.135291 (0.003267)</td>
</tr>
</tbody>
</table>
<p dir="auto">In general, we are doing really well! However, we can see that for <code class="notranslate">sparse</code> and <code class="notranslate">transpose</code> we have a bit to go to match Octave. Right now, for <code class="notranslate">sparse</code> we are making a CSR-matrix and transposing it in the end. It should be possible to directly construct the CSC-matrix and avoid the transpose.</p>
<p dir="auto">For <code class="notranslate">transpose</code> I looked at <a href="https://github.com/JuliaLang/julia/blob/f51873ab0578c7562cca9c1f84e6499b45c69201/base/sparse/csparse.jl#L135">the code</a> and I am not sure what could be done. Anyone have any ideas here?</p>
<p dir="auto">This can be done for arguments whose types can be inferred. It will make things more convenient in general, but the cost is that it won't be easy to predict when an explicit conversion needs to be written. At the very least it will improve the situation with literals, so you don't need to write <code class="notranslate">int32(0)</code>.</p>