SparseMatricesCSR.jl
SparseMatricesCSR.jl copied to clipboard
Convenience functions like `spdiagm`
Would be lovely to have so that one could more easily experiment across CSC/CSR
spdiagm(kv::Pair{<:Integer,<:AbstractVector}...) = _spdiagm(nothing, kv...)
spdiagm(m::Integer, n::Integer, kv::Pair{<:Integer,<:AbstractVector}...) = _spdiagm((Int(m),Int(n)), kv...)
spdiagm(v::AbstractVector) = _spdiagm(nothing, 0 => v)
spdiagm(m::Integer, n::Integer, v::AbstractVector) = _spdiagm((Int(m), Int(n)), 0 => v)
function _spdiagm(size, kv::Pair{<:Integer,<:AbstractVector}...)
I, J, V, mmax, nmax = SparseArrays.spdiagm_internal(kv...)
mnmax = max(mmax, nmax)
m, n = something(size, (mnmax,mnmax))
(m ≥ mmax && n ≥ nmax) || throw(DimensionMismatch("invalid size=$size"))
return sparsecsr(I, J, V, m, n)
end
Seems to be okay