PackedVectorsOfVectors

PackedVectorsOfVectors.PackedVectorOfVectorsType
PackedVectorOfVectors{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.

source
PackedVectorsOfVectors.allocate_packedMethod
allocate_packed(T, init, n) -> PackedVectorOfVectors

Allocate a packed vector of vectors with nested element type T such that the kth 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]
source
PackedVectorsOfVectors.packMethod
pack([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]
source
PackedVectorsOfVectors.packed_indicesMethod
packed_indices(n) -> pv::PackedVectorOfVectors

Packed vector of vectors such that the kth nested vector has length nth(n,k) and pv[k][i] is the index in the flattened vector of the ith element in the kth nested vector.

Examples

julia> packed_indices([2,3])
2-element pack(::Vector{Vector{Int64}}):
 1:2
 3:5
source
Base.transposeMethod
transpose(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]
source