Skip to content

Commit 5692964

Browse files
author
Wimmerer
committed
udo docs
1 parent d62ad5e commit 5692964

File tree

7 files changed

+46
-8
lines changed

7 files changed

+46
-8
lines changed

docs/make.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ makedocs(
1515
"binaryops.md",
1616
"monoids.md",
1717
"semirings.md",
18-
"selectops.md"
18+
"selectops.md",
19+
"udfs.md"
1920
]
2021
]
2122
)

docs/src/arrays.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,16 @@ SparseMatrixCSC(A[:,:, desc=Descriptors.T0]) #Transpose the first argument
6767

6868
All of this same functionality exists for vectors in 1-dimension.
6969

70+
# Transpose
71+
The typical lazy Julia `transpose` is available as usual, and the adjoint operator `'` is also
72+
overloaded to be equivalent.
73+
74+
`x = A'` will create a `Transpose` wrapper.
75+
When an operation uses this argument it will cause the `desc` to set `INP<0|1> = T_<0|1>`.
76+
77+
!!! warning
78+
Vectors do not support transposition at this time. A matrix with the column or row size set to `1` may be a solution.
79+
7080
# Utilities
7181

7282
```@docs

docs/src/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ It aims to provide a Julian wrapper over Tim Davis' SuiteSparse reference implem
66
# Roadmap
77

88
!!! note
9-
This library is still very WIP, if you are missing any functionality, or find any incorrectly implemented functions from those interfaces please open an issue or PR!
9+
This library is still a WIP, if you are missing any functionality, find any incorrectly implemented functions, or need further/better documentation please open an issue, PR, or ask in the [#GraphBLAS channel on the Julia Zulip](https://julialang.zulipchat.com/#narrow/stream/289264-GraphBLAS) (preferred) or the [#graphblas channel on the Julia Slack](https://julialang.slack.com/archives/C023B0WGMHR)!
1010

1111
While the core library is mostly complete, and all GraphBLAS functionality is present, there are still quite a few features being worked on for v1.0:
1212

docs/src/operations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ The operations above have often accept most or all of the following arguments.
3232

3333
### `op` - `UnaryOp`, `BinaryOp`, `Monoid`, `Semiring`, or `SelectOp`:
3434

35-
This is the most important argument for most of these operations. It determines ``\oplus``, ``\otimes``, or ``f`` in the table above as well as the semiring used in `mul`.
35+
This is the most important argument for most of the GraphBLAS operations. It determines ``\oplus``, ``\otimes``, or ``f`` in the table above as well as the semiring used in `mul`.
3636
Most operations are restricted to one type of operator.
3737

3838
!!! tip "Built-Ins"

docs/src/udfs.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# User Defined Operators
2+
3+
!!! warning "Experimental"
4+
This is still a work in progress, and subject to change. Please open an issue if you find any problems!
5+
6+
GraphBLAS supports users to supply functions as operators. Constructors exported are:
7+
8+
- `UnaryOp(name::String, fn::Function, [type | types | ztype, xtype | ztypes, xtypes])`
9+
- `BinaryOp(name::String, fn::Function, [type | types | ztype, xtype | ztypes, xtypes])`
10+
- `Monoid(name::String, binop::Union{AbstractBinaryOp, GrB_BinaryOp}, id::T, terminal::T = nothing)`: all types must be the same.
11+
- `Semiring(name::String, add::[GrB_Monoid | AbstractMonoid], mul::[GrB_BinaryOp | AbstractBinaryOp])`
12+
13+
`GrB_` prefixed arguments are typed operators, such as the result of `UnaryOps.COS[Float64]`.
14+
Type arguments may be single types or vectors of types.
15+
If no type is supplied to `UnaryOp` or `BinaryOp` they will default to constructing typed operators for all the built-in primitive types.
16+
17+
The `fn` arguments to `UnaryOp` and `BinaryOp` must have one or two arguments respectively.
18+
19+
!!! danger "Performance"
20+
Due to the nature of the underlying C library user-defined operators may be significantly slower than their built-in counterparts.
21+
When possible use the built-in operators, or combinations of them.
22+
23+
!!! note "Where to Find User-Defined Operators"
24+
The constructors for an operator add that operator to the submodule for that operator type.
25+
For instance `UnaryOp(minus, -, Int64, Int64)` will add `UnaryOps.minus`.
26+

src/operators/unaryops.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ end
123123

124124
#UnaryOp constructors
125125
#####################
126+
function UnaryOp end
126127
function UnaryOp(name::String, fn::Function, ztype, xtype)
127128
op = UnaryOp(name)
128129
_addunaryop(op, fn, toGBType(ztype), toGBType(xtype))

test/operations.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
n = GBMatrix([1,2,3,2], [1,2,2,1], [1,2,3,4])
55
#eadd correctness
66
@test eadd(m, n) == GBMatrix([1,1,2,2,3,3], [1,2,1,2,1,2], [2,4,6,7,3,9])
7-
@test eadd(m, n; op = BinaryOps.GT)[1, 1] == 0
7+
@test eadd(m, n, BinaryOps.GT)[1, 1] == 0
88
#check that the (+) op is being picked up from the semiring.
9-
@test eadd(m, n; op = Semirings.PLUS_MAX) == eadd(m, n; op = BinaryOps.PLUS)
9+
@test eadd(m, n, Semirings.PLUS_MAX) == eadd(m, n, BinaryOps.PLUS)
1010
#emul correctness
11-
@test emul(m, n; op = BinaryOps.POW)[3, 2] == m[3,2] ^ n[3,2]
11+
@test emul(m, n, BinaryOps.POW)[3, 2] == m[3,2] ^ n[3,2]
1212
#check that the (*) op is being picked up from the semiring
13-
@test emul(m, n; op = Semirings.MAX_PLUS) == emul(m, n; op = BinaryOps.PLUS)
13+
@test emul(m, n, Semirings.MAX_PLUS) == emul(m, n, BinaryOps.PLUS)
1414
end
1515
@testset "kron" begin
1616
m1 = GBMatrix(UInt64[1, 2, 3, 5], UInt64[1, 3, 1, 2], Int8[1, 2, 3, 5])
@@ -68,7 +68,7 @@
6868
m = GBMatrix([[1,2,3] [4,5,6] [7,8,9]])
6969
s = select(SelectOps.TRIL, m)
7070
@test s[1,2] === nothing && s[3,1] == 3
71-
s = select(SelectOps.LT_THUNK, m, 6)
71+
s = select(SelectOps.LT, m, 6)
7272
@test s[2,2] == 5 && s[3,3] === nothing
7373
end
7474
@testset "transpose" begin

0 commit comments

Comments
 (0)