Sparse Tensors
GCPDecompositions.SparseArrayCOOs.SparseArrayCOO — TypeSparseArrayCOO{Tv,Ti<:Integer,N} <: AbstractArray{Tv,N}N-dimensional sparse array stored in the COOrdinate format. Elements are stored as a vector of indices (using type Ti) and a vector of values (of type Tv). Values for duplicate indices are summed.
Fields:
dims::Dims{N}: tuple of dimensionsinds::Vector{NTuple{N,Ti}}: vector of indicesvals::Vector{Tv}: vector of values
GCPDecompositions.SparseArrayCOOs.SparseArrayCOO — MethodSparseArrayCOO([Ti=Int], A::AbstractArray)Convert an AbstractArray A into a SparseArrayCOO with indices using type Ti.
Examples
julia> A = SparseArrayCOO(Int8, Float16[1.1 0.0 0.0; 2.1 0.0 2.3])
2×3 SparseArrayCOO{Float16, Int8, 2} with 3 stored entries:
[1, 1] = 1.1
[2, 1] = 2.1
[2, 3] = 2.3
julia> B = SparseArrayCOO(Int16, Float16[1.1 0.0 0.0; 2.1 0.0 2.3])
2×3 SparseArrayCOO{Float16, Int16, 2} with 3 stored entries:
[1, 1] = 1.1
[2, 1] = 2.1
[2, 3] = 2.3
julia> C = SparseArrayCOO(Float16[1.1 0.0 0.0; 2.1 0.0 2.3])
2×3 SparseArrayCOO{Float16, Int64, 2} with 3 stored entries:
[1, 1] = 1.1
[2, 1] = 2.1
[2, 3] = 2.3GCPDecompositions.SparseArrayCOOs.SparseArrayCOO — MethodSparseArrayCOO{Tv,Ti<:Integer}(undef, dims)
SparseArrayCOO{Tv,Ti<:Integer,N}(undef, dims)Construct an uninitialized N-dimensional SparseArrayCOO with indices using type Ti and elements of type Tv. Here uninitialized means it has no stored entries.
Here undef is the UndefInitializer. If N is supplied, then it must match the length of dims.
Examples
julia> A = SparseArrayCOO{Float64, Int8, 3}(undef, (2, 3, 4)) # N given explicitly
2×3×4 SparseArrayCOO{Float64, Int8, 3} with 0 stored entries
julia> B = SparseArrayCOO{Float64, Int8}(undef, (4,)) # N determined by the input
4-element SparseArrayCOO{Float64, Int8, 1} with 0 stored entries
julia> similar(B, 2, 4, 1) # use typeof(B), and the given size
2×4×1 SparseArrayCOO{Float64, Int8, 3} with 0 stored entriesGCPDecompositions.SparseArrayCOOs.check_Ti — Methodcheck_Ti(dims, Ti)Check that the dims tuple and Ti index type are valid:
dimsare nonnegative and fit inTi(0 ≤ dims[k] ≤ typemax(Ti))- corresponding length fits in
Int(prod(dims) ≤ typemax(Int))
If not, throw an ArgumentError.
GCPDecompositions.SparseArrayCOOs.check_coo_buffers — Methodcheck_coo_buffers(inds, vals)Check that the inds and vals buffers are valid:
- their lengths match (
length(inds) == length(vals))
If not, throw an ArgumentError.
GCPDecompositions.SparseArrayCOOs.check_coo_inds — Methodcheck_coo_inds(dims, inds)Check that the indices in inds are valid:
- each index is in bounds (
1 ≤ inds[ptr][k] ≤ dims[k])
If not, throw an ArgumentError.
GCPDecompositions.SparseArrayCOOs.checkbounds_dims — Methodcheckbounds_dims(dims, I...)Throw an error if the specified indices I are not in bounds for an array with the given dimensions dims. Useful for checking the inputs to constructors.
GCPDecompositions.SparseArrayCOOs.checkbounds_dims — Methodcheckbounds_dims(Bool, dims, I...)Return true if the specified indices I are in bounds for an array with the given dimensions dims. Useful for checking the inputs to constructors.
GCPDecompositions.SparseArrayCOOs.numstored — Methodnumstored(A::SparseArrayCOO{Tv,Ti,N})Return the number of stored entries. Includes any stored numerical zeros and duplicates; use count(!iszero,A) to count the number of nonzeros.