Helpers

JaggedArray

PartitionedArrays.GenericJaggedArrayType
struct GenericJaggedArray{V,A,B}

Generalization of JaggedArray, where the fields data and ptrs are allowed to be any array-like object.

Properties

data::A
ptrs::B

Supertype hierarchy

GenericJaggedArray{V,A,B} <: AbstractVector{V}

Given a::GenericJaggedArray, V is typeof(view(a.data,a.ptrs[i]:(a.ptrs[i+1]-1))).

source
PartitionedArrays.JaggedArrayType
struct JaggedArray{T,Ti}

Efficient implementation of a vector of vectors. The inner vectors are stored one after the other in consecutive memory locations using an auxiliary vector data. The range of indices corresponding to each inner vector are encoded using a vector of integers ptrs.

Properties

data::Vector{T}
ptrs::Vector{Ti}

Given a::JaggedArray, a.data contains the inner vectors. The i-th inner vector is stored in the range a.ptrs[i]:(a.ptrs[i+1]-1). The number of inner vectors (i.e. length(a)) is length(a.ptrs)-1. a[i] returns a view of a.data restricted to the range a.ptrs[i]:(a.ptrs[i+1]-1).

Supertype hierarchy

JaggedArray{T,Ti} <: AbstractVector{V}

Given a::JaggedArray, V is typeof(view(a.data,a.ptrs[i]:(a.ptrs[i+1]-1))).

source
PartitionedArrays.JaggedArrayMethod
JaggedArray(a)

Create a JaggedArray object from the vector of vectors a. If a::JaggedArray, then a is returned. Otherwise, the contents of a are copied.

source
PartitionedArrays.JaggedArrayMethod
JaggedArray(data::Vector,ptrs::Vector)

Create a JaggedArray from the given data and ptrs fields. The resulting object stores references to the given vectors.

source
PartitionedArrays.jagged_arrayMethod
jagged_array(data,ptrs)

Create a JaggedArray or a GenericJaggedArray object depending on the type of data and ptrs. The returned object stores references to the given inputs.

source
PartitionedArrays.length_to_ptrs!Method
length_to_ptrs!(ptrs)

Compute the field ptrs of a JaggedArray. length(ptrs) should be the number of sub-vectors in the jagged array plus one. At input, ptrs[i+1] is the length of the i-th sub-vector. At output, ptrs[i]:(ptrs[i+1]-1) contains the range where the i-th sub-vector is stored in the data field of the jagged array.

source

Sparse utils

PartitionedArrays.nziteratorFunction
for (i,j,v) in nziterator(a)
...
end

Iterate over the non zero entries of a returning the corresponding row i, column j and value v.

source