On Tuesday, February 24, 2015 at 3:47:12 PM UTC-6, Seth wrote:
>
> I was surprised to find that there is no method on sizehint! for sparse
> matrices:
>
> ERROR: MethodError: `sizehint!` has no method matching sizehint!(::Base.
> SparseMatrix.SparseMatrixCSC{Int64,Int64}, ::Int64)
>
>
> Is this intentional? I noticed that insert performance on sparse matrices (
> setindex! in particular) is the bottleneck in my code, and I was hoping
> to optimize a bit more.
>
sizehint! could be applied to the .rowval and .nzval fields but it will
only make things easier if you then add elements to the last columns. Even
if the vectors don't need to be resized, adding a non-zero value to an
interior column of a sparse matrix requires inserting in the middle of a
vector.
If it makes sense in your application you are better off using nonzeros to
get the triplet representation, pushing values onto the end of those
vectors and, when you are finished, using sparse to convert back to
SparseMatrixCSC.