I was studying the type stability of my code (I’m still very bad at it) and I bumped into this weird behavior with SparseArrays.blockdiag()
:
julia> using SparseArrays
julia> A = [sprand(100, 100, .1) for i = 1: 15]; @code_warntype blockdiag(A...);
Body::SparseMatrixCSC{Float64,Int64}
...
But if I make a 16-element array (or bigger)
julia> A = [sprand(100, 100, .1) for i = 1: 16]; @code_warntype blockdiag(A...);
Body::SparseMatrixCSC{_1,_2} where _2 where _1
...
I’m omitting the complete output of @code_warntype, but you can easily get it on your computer.
The size of the sparse matrices doesn’t seem to affect the behavior.
What is going on here?