SuiteSparseGraphBLAS.from_listsMethod
from_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: the BinaryOperator which 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] = 2
source
SuiteSparseGraphBLAS.from_vectorFunction
from_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] = 2
source
Base.sizeMethod
size(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)
3
source
Base.:==Method
==(u, v) -> Bool

Check if two vectors u and v are equal.

source
Base.copyMethod
copy(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
false
source
copy(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
false
source
SuiteSparseGraphBLAS.nnzMethod
nnz(v::GBVector)

Return the number of entries in a vector v.

Examples

julia> v = from_vector([1, 2, 0]);

julia> nnz(v)
2
source
SuiteSparseGraphBLAS.findnzMethod
findnz(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])
source
Base.VectorMethod
Vector(A::GBVector{T}) -> Vector{T}

Construct a Vector{T} from a GBVector{T} A.

source
Base.lastindexMethod
lastindex(v::GBVector)

Return the last index of a vector v.

Examples

julia> v = from_vector([1, 2, 0, 0, 0, 1]);

julia> lastindex(v)
6
source
SuiteSparseGraphBLAS.emultMethod
emult(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 for out, mask, u and v.

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] = 8
source
SuiteSparseGraphBLAS.eaddMethod
eadd(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 for out, mask, u and v.

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] = 16
source
SuiteSparseGraphBLAS.vxmFunction
vxm(u::GBVector, A::GBMatrix; kwargs...) -> GBVector

Multiply 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 for out, mask and A.

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] = 10
source
SuiteSparseGraphBLAS.applyMethod
apply(u::GBVector; kwargs...) -> GBVector

Apply 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 for out and mask.

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] = 3
source
apply(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 for out, mask and A.

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] = 4
source
SuiteSparseGraphBLAS.apply!Method
apply!(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 for out and mask.

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] = 3
source
Base.reduceFunction
reduce(u::GBVector{T}; kwargs...) -> T

Reduce 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
source