PackedVectorsOfVectors
PackedVectorsOfVectors.PackedVectorOfVectors
— TypePackedVectorOfVectors{P,V,E} <: AbstractVector{E}
Vector of vectors, stored as a single long vector v::V
and a vector of pointers p::P
indicating the subvector boundaries.
PackedVectorOfVectors
is roughly equivalent to SparseMatrixCSC
without the rowval
vector.
PackedVectorsOfVectors.allocate_packed
— Methodallocate_packed(T, init, n) -> PackedVectorOfVectors
Allocate a packed vector of vectors with nested element type T
such that the k
th nested vector has length nth(n,k)
. See the documentation of Vector{T}(init,n)
regarding the meaning of init
.
Examples
julia> allocate_packed(Ref{Int}, undef, [1,2,3])
3-element pack(::Vector{Vector{Ref{Int64}}}):
[#undef]
[#undef, #undef]
[#undef, #undef, #undef]
PackedVectorsOfVectors.pack
— Methodpack([T,] vv) -> PackedVectorOfVectors
Convert the vector of vectors vv
to its packed representation. If T
is provided, then the elements of the nested vector are converted to this type.
Example
julia> pack([[1,2],[3]])
2-element pack(::Vector{Vector{Int64}}):
[1, 2]
[3]
julia> pack(Float64, [[1,2],[3]])
2-element pack(::Vector{Vector{Float64}}):
[1.0, 2.0]
[3.0]
PackedVectorsOfVectors.packed_fill
— Methodpacked_fill(x,n) -> pv::PackedVectorOfVectors
Create a packed vector of vectors such that pv[k] == fill(x, nth(n,k))
.
PackedVectorsOfVectors.packed_indices
— Methodpacked_indices(n) -> pv::PackedVectorOfVectors
Packed vector of vectors such that the k
th nested vector has length nth(n,k)
and pv[k][i]
is the index in the flattened vector of the i
th element in the k
th nested vector.
Examples
julia> packed_indices([2,3])
2-element pack(::Vector{Vector{Int64}}):
1:2
3:5
PackedVectorsOfVectors.packed_ones
— Methodpacked_ones([T=Float64,] n) -> pv::PackedVectorOfVectors
Create a packed vector of vectors such that pv[k] == ones(T, nth(n,k))
.
PackedVectorsOfVectors.packed_zeros
— Methodpacked_zeros([T=Float64,] n) -> pv::PackedVectorOfVectors
Create a packed vector of vectors such that pv[k] == zeros(T, nth(n,k))
.
Base.transpose
— Methodtranspose(pv::PackedVectorOfVectors[, n = maximum(maximum.(pv))) -> PackedVectorOfVectors
Interpret pv
as the sparsity pattern of a sparse matrix and compute the sparsity pattern of its transpose.
The nested eltype of pv
must be Int
.
Examples
julia> transpose(pack([[1,2],[2]]))
2-element pack(::Vector{Vector{Int64}}):
[1]
[1, 2]