Closed prenc closed 2 years ago
The current release is bugged for construction of user-defined monoids and semirings, I apologize. I actually didn't realize this until your issue.
I'm doing my best to make a release tonight or tomorrow, that will include a documented interface to do this.
The main problem with Monoids is that I can't really assume what the identity and terminal of the monoid are. So while you can use a BinaryOp anywhere without forward declaring it, you can't really do so with a monoid right now.
The current syntax would be f(x, y) = x + y; @monoid f Int64 id=>zero
to declare a monoid for Int64. f
can then be used freely where monoids are required (reduce
and mul
). But as mentioned it is missing some method definitions and therefore bugged.
Thank you for a quick answer. Then I'm waiting for the following improvements
Fixed in https://github.com/JuliaSparse/SuiteSparseGraphBLAS.jl/pull/86. New syntax would be *(Monoid((a,b)->a+b, zero), *)(A, A)
since you need to add an identity. This interface will be documented before the next release.
Is it possible to create your own operator, or monoid more specifically? I can't find an example of this anywhere, however, the documentation says:
Currently: