Skip to content

Commit 42a9697

Browse files
committed
remove potentially colliding exports, improve safety of as, mul => * overload
1 parent 58abe48 commit 42a9697

File tree

20 files changed

+168
-184
lines changed

20 files changed

+168
-184
lines changed

benchmarks/benchmarks.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ function AxB_allbyrow(S, G, nthreads, sizerhs)
9898
gbset(:nthreads, n)
9999
#print burble for checking
100100
gbset(:burble, true)
101-
mul(G, m2)
101+
*(G, m2)
102102
gbset(:burble, false)
103-
B = @benchmark mul($G, $m2)
103+
B = @benchmark *($G, $m2)
104104
show(stdout, MIME("text/plain"), B)
105105
tratio = ratio(median(A), median(B))
106106
color = tratio.time >= 1.0 ? :green : :red
@@ -129,9 +129,9 @@ function AxB_ColxRow(S, G, nthreads, sizerhs)
129129
gbset(:nthreads, n)
130130
#print burble for checking
131131
gbset(:burble, true)
132-
mul(G, m2)
132+
*(G, m2)
133133
gbset(:burble, false)
134-
B = @benchmark mul($G, $m2)
134+
B = @benchmark *($G, $m2)
135135
show(stdout, MIME("text/plain"), B)
136136
tratio = ratio(median(A), median(B))
137137
color = tratio.time >= 1.0 ? :green : :red

benchmarks/benchmarks2.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function mxm(A::SuiteSparseGraphBLAS.GBArray, B::SuiteSparseGraphBLAS.GBArray; a
5858
if !accumdenseoutput
5959
printstyled(stdout, "\nC::GBArray = A::GBArray($Ao, $(size(A))) * B::GBArray($Bo, $(size(B)))\n")
6060
flush(stdout)
61-
result = @gbbench mul(A, B)
61+
result = @gbbench *(A, B)
6262
else
6363
printstyled(stdout, "\nC::GBArray += A::GBArray($Ao, $(size(A))) * B::GBArray($Bo, $(size(B)))\n")
6464
C = GBMatrix(zeros(eltype(A), size(A, 1), size(B, 2)))

docs/src/index.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ GraphBLAS operations are, where possible, methods of existing Julia functions li
100100

101101
| GraphBLAS | Operation | Julia |
102102
|:--------------------|:----------------------------------------: |----------: |
103-
|`mxm`, `mxv`, `vxm` |``\bf C \langle M \rangle = C \odot AB`` |`mul[!]` or `*` |
103+
|`mxm`, `mxv`, `vxm` |``\bf C \langle M \rangle = C \odot AB`` |`mul!` or `*` |
104104
|`eWiseMult` |``\bf C \langle M \rangle = C \odot (A \otimes B)`` |`emul[!]` or `.` broadcasting |
105105
|`eWiseAdd` |``\bf C \langle M \rangle = C \odot (A \oplus B)`` |`eadd[!]` |
106106
|`extract` |``\bf C \langle M \rangle = C \odot A(I,J)`` |`extract[!]`, `getindex` |
@@ -138,7 +138,7 @@ map(sin, A)
138138
Broadcasting functionality is also supported, `A .^ A` will lower to `emul(A, A, ^)`, and `sin.(A)` will lower to `map(sin, A)`.
139139

140140
Matrix multiplication, which accepts a semiring, can be called with either `*(max, +)(A, B)` or
141-
`mul(A, B, (max, +))`.
141+
`*(A, B, (max, +))`.
142142

143143
We can also use functions that are not already built into SuiteSparseGraphBLAS.jl:
144144

@@ -168,15 +168,16 @@ Input `A` must be a square, symmetric matrix with any element type.
168168
We'll test it using the matrix from the GBArray section above, which has two triangles in its undirected form.
169169

170170
```@repl intro
171+
using SuiteSparseGraphBLAS: pair
171172
function cohen(A)
172173
U = select(triu, A)
173174
L = select(tril, A)
174-
return reduce(+, mul(L, U, (+, pair); mask=A)) ÷ 2
175+
return reduce(+, *(L, U, (+, pair); mask=A)) ÷ 2
175176
end
176177
177178
function sandia(A)
178179
L = select(tril, A)
179-
return reduce(+, mul(L, L, (+, pair); mask=L))
180+
return reduce(+, *(L, L, (+, pair); mask=L))
180181
end
181182
182183
M = eadd(A, A', +) #Make undirected/symmetric

docs/src/monoids.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Monoids
22

33
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$.
4-
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`.
4+
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!`.
55

66
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$.
77

8-
Monoids are used primarily in the `reduce`(@ref) operation. Their other use is as a component of semirings in the [`mul`](@ref) operation.
8+
Monoids are used primarily in the `reduce`(@ref) operation. Their other use is as a component of semirings in the [`mul!`](@ref) operation.
99

1010
## Built-Ins
1111

docs/src/operations.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ GraphBLAS operations cover most of the typical linear algebra operations on arra
55
## Correspondence of GraphBLAS C functions and Julia functions
66
| GraphBLAS | Operation | Julia |
77
|:--------------------|:---------------------------------------------------------------: |----------------------------------------: |
8-
|`mxm`, `mxv`, `vxm` |``\bf C \langle M \rangle = C \odot AB`` |`mul[!]` or `*` |
8+
|`mxm`, `mxv`, `vxm` |``\bf C \langle M \rangle = C \odot AB`` |`mul!` or `*` |
99
|`eWiseMult` |``\bf C \langle M \rangle = C \odot (A \otimes B)`` |`emul[!]` or `.` broadcasting |
1010
|`eWiseAdd` |``\bf C \langle M \rangle = C \odot (A \oplus B)`` |`eadd[!]` |
1111
|`extract` |``\bf C \langle M \rangle = C \odot A(I,J)`` |`extract[!]`, `getindex` |
@@ -73,7 +73,7 @@ The mask may also be complemented. These options are controlled by the `desc` ar
7373
All non-mutating operations below support a mutating form by adding an output array as the first argument as well as the `!` function suffix.
7474

7575
```@docs
76-
mul
76+
*
7777
emul
7878
emul!
7979
eadd

docs/src/operators.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ For operations with a clear default operator they appear as the last positional
1414
- [`emul(A, B, op::Union{BinaryOp, Function})`](@ref emul)
1515
- [`eadd(A, B, op::Union{BinaryOp, Function})`](@ref eadd)
1616
- [`kron(A, B, op::Union{BinaryOp, Function})`](@ref kron)
17-
- [`mul(A, B, op::Union{Semiring, Tuple{Function, Function}})`](@ref mul)
17+
- [`*(A, B, op::Union{Semiring, Tuple{Function, Function}})`](@ref *)
1818

1919
For other operations without a clear default operator they appear as the first argument:
2020

docs/src/semirings.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ The second, $\otimes$ or "multiply", is a binary operator defined on $D_1 \times
88

99
A semiring is denoted by a tuple $(D_1, D_2, D_3, \oplus, \otimes, \mathbb{0})$. However in the vast majority of cases $D_1 = D_2 = D_3$ so this is often shortened to $(\oplus, \otimes)$.
1010

11-
Semirings are used in a single GraphBLAS operation, [`mul[!]`](@ref mul).
11+
Semirings are used in a single GraphBLAS operation, [`mul!`](@ref).
1212

1313
## Passing to Functions
1414

15-
`mul[!]` is the only function which accepts semirings, and the best method to do so is a tuple of binary functions like `mul(A, B, (max, +))`. An operator form is also available as `*(min, +)(A, B)`.
15+
`mul!` and `*` are the only functions which accept semirings, and the best method to do so is a tuple of binary functions like `*(A, B, (max, +))`. An operator form is also available as `*(min, +)(A, B)`.
1616

1717
Semiring objects may be constructed in a similar fashion: `Semiring(max, +)`.

docs/src/utilities.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ mask!
66
gbset
77
Descriptor
88
SuiteSparseGraphBLAS.set_lib!
9-
clear!
9+
empty!
1010
```

examples/triangle_centrality.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
using SuiteSparseGraphBLAS
2+
using SuiteSparseGraphBLAS: pair
23
function triangle_centrality1(A)
3-
T = mul(A, A', (+, *), mask=A)
4+
T = *(A, A', (+, *), mask=A)
45
y = reduce(+, T, dims=2)
56
k = reduce(+, y)
6-
return (3 * mul(A, y) - 2 * mul(T, y) .+ y) ./ k
7+
return (3 * *(A, y) - 2 * *(T, y) .+ y) ./ k
78
end
89

910
function triangle_centrality(A)
10-
T = mul(A, A', (+, pair), mask=A, Descriptor(structural_mask=true))
11+
T = *(A, A', (+, pair), mask=A, Descriptor(structural_mask=true))
1112
y = reduce(+, T, dims=2)
1213
k = reduce(+, y)
13-
return (3.0 * mul(A, y) .- (2.0 * mul(T, y, (+, second))) .+ y) ./ k
14+
return (3.0 * *(A, y) .- (2.0 * *(T, y, (+, second))) .+ y) ./ k
1415
end

src/SuiteSparseGraphBLAS.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,17 @@ export lgamma, gamma, erf, erfc #reexport of SpecialFunctions.
114114
#UnaryOps not found in Julia/stdlibs.
115115
export frexpe, frexpx, positioni, positionj
116116
#BinaryOps not found in Julia/stdlibs.
117-
export second, rminus, pair, , , lxor, fmod, firsti,
118-
firstj, secondi, secondj
117+
export firsti, firstj, secondi, secondj
118+
# unexported but important BinaryOps:
119+
# export second, rminus, pair, ∨, ∧, lxor, fmod
120+
119121
#SelectOps not found in Julia/stdlibs
120122
export offdiag
121123

122-
export clear!, extract, extract!, subassign!, assign!, hvcat! #array functions
124+
export extract, extract!, subassign!, assign!, hvcat! #array functions
123125

124126
#operations
125-
export mul, select, select!, eadd, eadd!, emul, emul!, map, map!, gbtranspose, gbtranspose!,
127+
export select, select!, eadd, eadd!, emul, emul!, gbtranspose, gbtranspose!,
126128
gbrand, eunion, eunion!, mask, mask!, apply, apply!, setfill, setfill!
127129
# Reexports from LinAlg
128130
export diag, diagm, mul!, kron, kron!, transpose, reduce, tril, triu

0 commit comments

Comments
 (0)