SuiteSparseGraphBLAS.from_type — Methodfrom_type(type, n)Create an empty GBVector of size n from the given type type.
SuiteSparseGraphBLAS.from_lists — Methodfrom_lists(I, V; n = nothing, type = nothing, combine = Binaryop.FIRST)Create a new GBVector from the given lists of indices and values. If n is not provided, it is computed from the max value of the indices list. If type is not provided, it is inferred from the values list. A combiner Binary Operator can be provided to manage duplicates values. If it is not provided, the default BinaryOp.FIRST is used.
Arguments
I: the list of indices.V: the list of values.[n]: the size of the vector.[type]: the type of the elements of the vector.combine: theBinaryOperatorwhich assembles any duplicate entries with identical indices.
Examples
julia> from_lists([1,2,5], [1,4,2])
5-element GBVector{Int64} with 3 stored entries:
[1] = 1
[2] = 4
[5] = 2
julia> from_lists([1,2,5], [1,4,2], type=Float32)
5-element GBVector{Float32} with 3 stored entries:
[1] = 1.0
[2] = 4.0
[5] = 2.0
julia> from_lists([1,2,5], [1,4,2], n=10)
10-element GBVector{Int64} with 3 stored entries:
[1] = 1
[2] = 4
[5] = 2
julia> from_lists([1,2,1,2,5], [1,4,2,4,2], combine=Binaryop.PLUS)
5-element GBVector{Int64} with 3 stored entries:
[1] = 3
[2] = 8
[5] = 2SuiteSparseGraphBLAS.from_vector — Functionfrom_vector(V)Create a GBVector from the given Vector m.
julia> from_vector([1, 0, 0, 1, 2, 0])
6-element GBVector{Int64} with 3 stored entries:
[1] = 1
[4] = 1
[5] = 2Base.size — Methodsize(v::GBVector)Return the dimension of v. Optionally you can specify a dimension to just get the length of that dimension.
Examples
julia> v = from_vector([1, 2, 3]);
julia> size(v)
3Base.:== — Method==(u, v) -> BoolCheck if two vectors u and v are equal.
Base.copy — Methodcopy(v::GBVector)Create a copy of v.
Examples
julia> v = from_vector([1, 0, 0, 1, 2, 0]);
julia> u = copy(v)
6-element GBVector{Int64} with 3 stored entries:
[1] = 1
[4] = 1
[5] = 2
julia> u == v
true
julia> u === v
falsecopy(m::GBMatrix)Create a copy of m.
Examples
julia> A = from_matrix([1 0 1; 0 0 2; 2 0 1]);
julia> B = copy(A)
3x3 GBMatrix{Int64} with 5 stored entries:
[1, 1] = 1
[1, 3] = 1
[2, 3] = 2
[3, 1] = 2
[3, 3] = 1
julia> A == B
true
julia> A === B
falseSuiteSparseGraphBLAS.nnz — Methodnnz(v::GBVector)Return the number of entries in a vector v.
Examples
julia> v = from_vector([1, 2, 0]);
julia> nnz(v)
2SuiteSparseGraphBLAS.findnz — Methodfindnz(v::GBVector)Return a tuple (I, V) where I is the indices lists of the "non-zero" values in m, and V is a list of "non-zero" values.
Examples
julia> v = from_vector([1, 2, 0, 0, 0, 1]);
julia> findnz(v)
([1, 2, 6], [1, 2, 1])SuiteSparseGraphBLAS.clear! — Methodclear!(v::GBVector)Clear all entries from a vector v.
Base.Vector — MethodVector(A::GBVector{T}) -> Vector{T}Construct a Vector{T} from a GBVector{T} A.
Base.lastindex — Methodlastindex(v::GBVector)Return the last index of a vector v.
Examples
julia> v = from_vector([1, 2, 0, 0, 0, 1]);
julia> lastindex(v)
6SuiteSparseGraphBLAS.emult — Methodemult(u::GBVector, v::GBVector; kwargs...)Compute the element-wise "multiplication" of two vector u and v, using a Binary Operator, a Monoid or a Semiring. If given a Monoid, the additive operator of the monoid is used as the multiply binary operator. If given a Semiring, the multiply operator of the semiring is used as the multiply binary operator.
Arguments
u: the first vector.v: the second vector.[out]: the output vector for result.[operator]: the operator to use. Can be either a Binary Operator, a Monoid or a Semiring.[accum]: optional accumulator.[mask]: optional mask.[desc]: descriptor forout,mask,uandv.
Examples
julia> u = from_vector([1, 2, 3, 4]);
julia> v = copy(u);
julia> emult(u, v, operator = Binaryop.PLUS)
4-element GBVector{Int64} with 4 stored entries:
[1] = 2
[2] = 4
[3] = 6
[4] = 8SuiteSparseGraphBLAS.eadd — Methodeadd(u::GBVector, v::GBVector; kwargs...)Compute the element-wise "addition" of two vectors u and v, using a Binary Operator, a Monoid or a Semiring. If given a Monoid, the additive operator of the monoid is used as the add binary operator. If given a Semiring, the additive operator of the semiring is used as the add binary operator.
Arguments
u: the first vector.v: the second vector.[out]: the output vector for result.[operator]: the operator to use. Can be either a Binary Operator, a Monoid or a Semiring.[accum]: optional accumulator.[mask]: optional mask.[desc]: descriptor forout,mask,uandv.
Examples
julia> u = from_vector([1, 2, 3, 4]);
julia> v = copy(u);
julia> eadd(u, v, operator = Binaryop.TIMES)
4-element GBVector{Int64} with 4 stored entries:
[1] = 1
[2] = 4
[3] = 9
[4] = 16SuiteSparseGraphBLAS.vxm — Functionvxm(u::GBVector, A::GBMatrix; kwargs...) -> GBVectorMultiply a row vector u times a matrix A.
Arguments
u: the row vector.A: the sparse matrix.[out]: the output vector for result.[semiring]: the semiring to use.[accum]: optional accumulator.[mask]: optional mask.[desc]: descriptor forout,maskandA.
Examples
julia> u = from_vector([1, 2]);
julia> A = from_matrix([1 2; 3 4]);
julia> vxm(u, A, semiring = Semirings.PLUS_TIMES)
2-element GBVector{Int64} with 2 stored entries:
[1] = 7
[2] = 10SuiteSparseGraphBLAS.apply — Methodapply(u::GBVector; kwargs...) -> GBVectorApply a Unary Operator to the entries of a vector u, creating a new vector.
Arguments
u: the sparse vector.[out]: the output vector for result.[unaryop]: the unary operator to use.[accum]: optional accumulator.[mask]: optional mask.[desc]: descriptor foroutandmask.
Examples
julia> u = from_vector([-1, 2, -3]);
julia> apply(u, unaryop = Unaryop.ABS)
3-element GBVector{Int64} with 3 stored entries:
[1] = 1
[2] = 2
[3] = 3apply(A::GBMatrix; kwargs...)Apply a Unary Operator to the entries of a matrix A, creating a new matrix.
Arguments
A: the sparse matrix.[out]: the output matrix for result.[unaryop]: the Unary Operator to use.[accum]: optional accumulator.[mask]: optional mask.[desc]: descriptor forout,maskandA.
Examples
julia> A = from_matrix([-1 2; -3 -4]);
julia> apply(A, unaryop = Unaryop.ABS)
2x2 GBMatrix{Int64} with 4 stored entries:
[1, 1] = 1
[1, 2] = 2
[2, 1] = 3
[2, 2] = 4SuiteSparseGraphBLAS.apply! — Methodapply!(A::GBMatrix; kwargs...)Apply a Unary Operator to the entries of a vector u.
Arguments
u: the sparse vector.[unaryop]: the unary operator to use.[accum]: optional accumulator.[mask]: optional mask.[desc]: descriptor foroutandmask.
Examples
julia> u = from_vector([-1, 2, -3]);
julia> apply!(u, unaryop = Unaryop.ABS);
julia> u
3-element GBVector{Int64} with 3 stored entries:
[1] = 1
[2] = 2
[3] = 3Base.reduce — Functionreduce(u::GBVector{T}; kwargs...) -> TReduce a vector u to a scalar, using the given Monoid.
Arguments
u: the sparse vector to reduce.[monoid]: monoid to do the reduction.[accum]: optional accumulator.
Examples
julia> u = from_vector([1, 2, 3, 4]);
julia> reduce(u, monoid = Monoids.PLUS)
10