Helpers
JaggedArray
PartitionedArrays.GenericJaggedArray
— Typestruct 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)))
.
PartitionedArrays.GenericJaggedArray
— MethodGenericJaggedArray(data,ptrs)
Create a GenericJaggedArray
from the given data
and ptrs
fields. The resulting object stores references to the given vectors.
PartitionedArrays.JaggedArray
— Typestruct 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)))
.
PartitionedArrays.JaggedArray
— MethodJaggedArray(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.
PartitionedArrays.JaggedArray
— MethodJaggedArray(data::Vector,ptrs::Vector)
Create a JaggedArray
from the given data
and ptrs
fields. The resulting object stores references to the given vectors.
PartitionedArrays.getdata
— Methodgetdata(a)
Return a.data
PartitionedArrays.getptrs
— Methodgetptrs(a)
Return a.ptrs
PartitionedArrays.jagged_array
— Methodjagged_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.
PartitionedArrays.length_to_ptrs!
— Methodlength_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.
PartitionedArrays.rewind_ptrs!
— Methodrewind_ptrs(a)!
Sets a[i+1]=a[i]
for i in (length(a)-1):-1:1
and then a[1] = one(eltype(a))
.
Sparse utils
PartitionedArrays.compresscoo
— Functioncompresscoo(T,args...)
Like sparse(args...)
, but generates a sparse matrix of type T
.
PartitionedArrays.indextype
— Functionindextype(a)
Return the element type of the vector used to store the row or column indices in the sparse matrix a
.
PartitionedArrays.nzindex
— Functionnzindex(a,i,j)
Return the position in nonzeros(a)
that stores the non zero value of a
at row i
and column j
.
PartitionedArrays.nziterator
— Functionfor (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
.