Monoids

A monoid is made up of a set or domain $T$ and a binary operator $z = f(x, y)$ operating on the same domain, $T \times T \rightarrow T$. This binary operator must be associative, that is $f(a, f(b, c)) = f(f(a, b), c)$ is always true. Associativity is important for operations like reduce and the multiplication step of mul!.

The operator is also be equipped with an identity such that $f(x, 0) = f(0, x) = x$. Some monoids are equipped with a terminal or annihilator such that $z = f(z, x) \forall x$.

Monoids are used primarily in the reduce operation. Their other use is as a component of semirings in the mul! operation.

Built-Ins

Julia FunctionGraphBLAS NameNotes
maxMAX_MONOIDidentity: typemax, terminal: typemin
minMIN_MONOIDidentity: typemin, terminal: typemax
+PLUS_MONOIDidentity: zero
*TIMES_MONOIDidentity: one, terminal: zero (terminal only for non-Float types)
anyANY_MONOIDidentity, terminal: any value in domain
&BAND_MONOIDidentity: typemax, terminal: zero
|BOR_MONOIDidentity: zero, terminal: typemax
BXOR_MONOIDidentity: zero
lxorLXOR_MONOIDidentity: false
==LXNOR_MONOIDidentity: true
LOR_MONOIDidentity: false, term: true
LAND_MONOIDidentity: true, term: false
SuiteSparseGraphBLAS.Monoids.MonoidType
Monoid{F, I, T}

A Monoid is a binary function fn along with an identity and an optional terminal value.

The identity and terminal should be functions of a type, or nothing for the terminal. For instance Monoid(*, one, zero) would be the Monoid for scalar multiplication.

Monoids are translated into TypedMonoids before calling into GraphBLAS itself.

source