Operators
Operators are one of the basic objects of GraphBLAS. In Julia, however, users must only interact directly with operators on rare occasions, and should instead pass functions to GraphBLAS operations.
There are five operator types in SuiteSparseGraphBLAS: UnaryOp
, IndexUnaryOp
, BinaryOp
, Monoid
, and Semiring
.
Operators are not callable objects like functions. They do behave like functions when used as arguments to higher-order functions (Operations in the language of GraphBLAS).
Operators are no longer first class objects in SuiteSparseGraphBLAS.jl v0.8. Only Monoids and possibly IndexOp
require direct user interaction.
Typically operators are positional arguments in one of two places. For operations with a clear default operator they appear as the last positional argument:
emul(A, B, op::Function)
eadd(A, B, op::Function)
kron(A, B, op::Function)
*(A, B, op::Tuple{Function, Function})
For other operations without a clear default operator they appear as the first argument:
apply(op::Function, A)
reduce(op::Union{Monoid, Function}, A)
select(op::Union{SelectOp, Function}, A)
GraphBLAS supports both built-in and user-defined operators. Built-in operators are precompiled C functions, while user-defined operators are function pointers to Julia functions.
Built-in operators are typically much faster than user-defined ones. See the page for the particular operator type (unary, binary, select, etc.) for more information.
Due to Julia limitations on the aarch64
and ppc64
architectures it is not possible to use closure functions, or callable objects as operators in SuiteSparseGraphBLAS.jl
UnaryOps, IndexUnaryOps, BinaryOps, Monoids, and Semirings
Each operator is defined on a specific domain. For some this is the usual primitive datatypes like booleans, floats, and signed and unsigned integers of the typical sizes.
Natively Supported Types
SuiteSparseGraphBLAS.jl natively supports the following types:
- Booleans
- Integers with sizes 8, 16, 32, 64
- Unsigned Integers with sizes 8, 16, 32, 64
- Float32 and Float64
- ComplexF32 and ComplexF64
Users may freely use non-native isbitstypes
as well, although they will incur a performance penalty.