SuiteSparseGraphBLAS.from_listsMethod
from_lists(I, J, V; m = nothing, n = nothing, type = nothing, combine = Binaryop.FIRST)

Create a new GBMatrix from the given lists of row indices, column indices and values. If m and n are not provided, they are computed from the max values of the row and column indices lists, respectively. 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 row indices.
  • J: the list of column indices.
  • V: the list of values.
  • [m]: the number of rows.
  • [n]: the number of columns.
  • [type]: the type of the elements of the matrix.
  • [combine]: the BinaryOperator which assembles any duplicate entries with identical indices.

Examples

julia> from_lists([1,1,2,3], [1,2,2,2], [5,2,7,4])
3x2 GBMatrix{Int64} with 4 stored entries:
  [1, 1] = 5
  [1, 2] = 2
  [2, 2] = 7
  [3, 2] = 4

julia> from_lists([1,1,2,3], [1,2,2,2], [5,2,7,4], type=Float64)
3x2 GBMatrix{Float64} with 4 stored entries:
  [1, 1] = 5.0
  [1, 2] = 2.0
  [2, 2] = 7.0
  [3, 2] = 4.0

julia> from_lists([1,1,2,3], [1,2,2,2], [5,2,7,4], m=10, n=4)
10x4 GBMatrix{Int64} with 4 stored entries:
  [1, 1] = 5
  [1, 2] = 2
  [2, 2] = 7
  [3, 2] = 4

julia> A = from_lists([1,1,2,3], [1,1,2,2], [5,2,7,4], combine=Binaryop.PLUS)
3x2 GBMatrix{Int64} with 3 stored entries:
  [1, 1] = 7
  [2, 2] = 7
  [3, 2] = 4
source
SuiteSparseGraphBLAS.from_matrixFunction
from_matrix(m)

Create a GBMatrix from the given Matrix m.

Examples

julia> from_matrix([1 0 2; 0 0 3; 0 1 0])
3x3 GBMatrix{Int64} with 4 stored entries:
  [1, 1] = 1
  [1, 3] = 2
  [2, 3] = 3
  [3, 2] = 1
source
Base.identityFunction
identity(type, n)

Create an identity GBMatrix of size n×n with the given type type.

Examples

julia> identity(Bool, 4)
4x4 GBMatrix{Bool} with 4 stored entries:
  [1, 1] = true
  [2, 2] = true
  [3, 3] = true
  [4, 4] = true
source
Base.MatrixMethod
Matrix(A::GBMatrix{T}) -> Matrix{T}

Construct a Matrix{T} from a GBMatrix{T} A.

source
SuiteSparseGraphBLAS.squareFunction
square(m::GBMatrix)

Return true if m is a square matrix.

Examples

julia> A = from_matrix([1 2; 4 5]);

julia> square(A)
true
source
Base.sizeMethod
size(m::GBMatrix, [dim])

Return a tuple containing the dimensions of m. Optionally you can specify a dimension to just get the length of that dimension.

Examples

julia> A = from_matrix([1 2 3; 4 5 6]);

julia> size(A)
(2, 3)

julia> size(A, 1)
2
source
SuiteSparseGraphBLAS.findnzMethod
findnz(m::GBMatrix)

Return a tuple (I, J, V) where I and J are the row and column lists of the "non-zero" values in m, and V is a list of "non-zero" values.

Examples

julia> A = from_matrix([1 2 0; 0 0 1]);

julia> findnz(A)
([1, 1, 2], [1, 2, 3], [1, 2, 1])
source
Base.:==Method
==(A, B)

Check if two matrices A and B are equal.

source
SuiteSparseGraphBLAS.nnzMethod
nnz(m::GBMatrix)

Return the number of entries in a matrix m.

Examples

julia> A = from_matrix([1 2 0; 0 0 1]);

julia> nnz(A)
3
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
Base.lastindexMethod
lastindex(m::GBMatrix, [d])

Return the last index of a matrix m. If d is given, return the last index of m along dimension d.

Examples

julia> A = from_matrix([1 2 0; 0 0 1]);

julia> lastindex(A)
(2, 3)

julia> lastindex(A, 2)
3
source
SuiteSparseGraphBLAS.mxmFunction
mxm(A::GBMatrix, B::GBMatrix; kwargs...)

Multiply two sparse matrix A and B using the semiring. If a semiring is not provided, it uses the default semiring.

Arguments

  • A: the first matrix.
  • B: the second matrix.
  • [out]: the output matrix for result.
  • [semiring]: the semiring to use.
  • [accum]: optional accumulator.
  • [mask]: optional mask.
  • [desc]: descriptor for out, mask, A and B.

Examples

julia> A = from_matrix([1 2; 3 4]);

julia> B = copy(A);

julia> mxm(A, B, semiring = Semirings.PLUS_TIMES)
2x2 GBMatrix{Int64} with 4 stored entries:
  [1, 1] = 7
  [1, 2] = 10
  [2, 1] = 15
  [2, 2] = 22
source
SuiteSparseGraphBLAS.mxvFunction
mxv(A::GBMatrix, u::GBVector; kwargs...) -> GBVector

Multiply a sparse matrix A times a column vector u.

Arguments

  • A: the sparse matrix.
  • u: the column vector.
  • [out]: the output vector for result.
  • [semiring]: the semiring to use.
  • [accum]: optional accumulator.
  • [mask]: optional mask.
  • [desc]: descriptor for out, mask, A and B.

Examples

julia> A = from_matrix([1 2; 3 4]);

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

julia> mxv(A, u, semiring = Semirings.PLUS_TIMES)
2-element GBVector{Int64} with 2 stored entries:
  [1] = 5
  [2] = 11
source
SuiteSparseGraphBLAS.emultMethod
emult(A::GBMatrix, B::GBMatrix; kwargs...)

Compute the element-wise "multiplication" of two matrices A and B, 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

  • A: the first matrix.
  • B: the second matrix.
  • [out]: the output matrix for result.
  • [operator]: the operator to use. Can be either a Binary Operator, or a Monoid or a Semiring.
  • [accum]: optional accumulator.
  • [mask]: optional mask.
  • [desc]: descriptor for out, mask, A and B.

Examples

julia> A = from_matrix([1 2; 3 4]);

julia> B = copy(A);

julia> emult(A, B, operator = Binaryop.PLUS)
2x2 GBMatrix{Int64} with 4 stored entries:
  [1, 1] = 2
  [1, 2] = 4
  [2, 1] = 6
  [2, 2] = 8
source
SuiteSparseGraphBLAS.eaddMethod
eadd(A::GBMatrix, B::GBMatrix; kwargs...)

Compute the element-wise "addition" of two matrices A and B, 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

  • A: the first matrix.
  • B: the second matrix.
  • [out]: the output matrix for result.
  • [operator]: the operator to use. Can be either a Binary Operator, or a Monoid or a Semiring.
  • [accum]: optional accumulator.
  • [mask]: optional mask.
  • [desc]: descriptor for out, mask, A and B.

Examples

julia> A = from_matrix([1 2; 3 4]);

julia> B = copy(A);

julia> eadd(A, B, operator = Binaryop.TIMES)
2x2 GBMatrix{Int64} with 4 stored entries:
  [1, 1] = 1
  [1, 2] = 4
  [2, 1] = 9
  [2, 2] = 16
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 matrix A.

Arguments

  • A: the sparse matrix.
  • [unaryop]: the Unary Operator to use.
  • [accum]: optional accumulator.
  • [mask]: optional mask.
  • [desc]: descriptor for maskandA`.

Examples

julia> A = from_matrix([-1 2; -3 -4]);

julia> apply!(A, unaryop = Unaryop.ABS);

julia> A
2x2 GBMatrix{Int64} with 4 stored entries:
  [1, 1] = 1
  [1, 2] = 2
  [2, 1] = 3
  [2, 2] = 4
source
SuiteSparseGraphBLAS.selectMethod
select(A::GBMatrix, op::SelectOperator; kwargs...)

Apply a Select Operator to the entries of a matrix A.

Arguments

  • A: the sparse matrix.
  • op: the Select Operator to use.
  • [out]: the output matrix for result.
  • [thunk]: optional input for the Select Operator.
  • [accum]: optional accumulator.
  • [mask]: optional mask.
  • [desc]: descriptor for out, mask and A.

Examples

julia> A = from_matrix([1 2; 3 4]);

# TODO: insert example
source
SuiteSparseGraphBLAS.reduce_vectorFunction
reduce_vector(A::GBMatrix; kwargs...)

Reduce a matrix A to a column vector using an operator. Normally the operator is a Binary Operator, in which all the three domains must be the same. It can be used a Monoid as an operator. In both cases the reduction operator must be commutative and associative.

Arguments

  • A: the sparse matrix.
  • [out]: the output matrix for result.
  • [operator]: reduce operator.
  • [accum]: optional accumulator.
  • [mask]: optional mask.
  • [desc]: descriptor for out, mask and A.

Examples

julia> A = from_matrix([1 2; 3 4]);

julia> reduce_vector(A, operator = Binaryop.PLUS)
2-element GBVector{Int64} with 2 stored entries:
  [1] = 3
  [2] = 7
source
SuiteSparseGraphBLAS.reduce_scalarFunction
reduce_scalar(A::GBMatrix{T}; kwargs...) -> T

Reduce a matrix A to a scalar, using the given Monoid.

Arguments

  • A: the sparse matrix to reduce.
  • [monoid]: monoid to do the reduction.
  • [accum]: optional accumulator.
  • [desc]: descriptor for A.

Examples

julia> A = from_matrix([1 2; 3 4]);

julia> reduce_scalar(A, monoid = Monoids.PLUS)
10
source
Base.transposeFunction
transpose(A::GBMatrix; kwargs...)

Transpose a matrix A.

Arguments

  • A: the sparse matrix to transpose.
  • [out]: the output matrix for result.
  • [mask]: optional mask.
  • [accum]: optional accumulator.
  • [desc]: descriptor for out, mask and A.

Examples

julia> A = from_matrix([1 2 3; 4 5 6]);

julia> transpose(A)
3x2 GBMatrix{Int64} with 6 stored entries:
  [1, 1] = 1
  [1, 2] = 4
  [2, 1] = 2
  [2, 2] = 5
  [3, 1] = 3
  [3, 2] = 6
source
Base.kronFunction
kron(A::GBMatrix, B::GBMatrix; kwargs...)

Compute the Kronecker product, using the given Binary Operator.

Arguments

  • A: the first matrix.
  • B: the second matrix.
  • [out]: the output matrix for result.
  • [binaryop]: the Binary Operator to use.
  • [mask]: optional mask.
  • [accum]: optional accumulator.
  • [desc]: descriptor for out, mask and A.

Examples

julia> A = from_matrix[1 2; 3 4]);

julia> B = copy(A)

julia> Matrix(kron(A, B, binaryop = Binaryop.TIMES))
4×4 Array{Int64,2}:
 1   2   2   4
 3   4   6   8
 3   6   4   8
 9  12  12  16
source