Skip to content

Commit efff99a

Browse files
author
Will Kimmerer
committed
fix GBVector docstrings
1 parent 1e84c10 commit efff99a

File tree

3 files changed

+13
-18
lines changed

3 files changed

+13
-18
lines changed

docs/src/arrays.md

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,19 @@ v = GBVector(sprand(Bool, 100_000_000, 0.001))
3232

3333
```@docs
3434
GBVector
35-
SuiteSparseGraphBLAS.GBVector{T}()
36-
SuiteSparseGraphBLAS.GBVector(::Vector, ::Vector)
37-
SuiteSparseGraphBLAS.GBVector(::SparseVector)
35+
SuiteSparseGraphBLAS.GBVector(::Vector)
36+
SuiteSparseGraphBLAS.GBVector(::AbstractVector{<:Integer}, ::AbstractVector)
3837
```
3938

4039
# Indexing
4140

42-
The usual AbstractArray and SparseArray indexing should work here. Including indexing by scalars, vectors, and ranges.
41+
Normal AbstractArray and SparseArray indexing should work here. Including indexing by scalars, vectors, and ranges.
4342

4443
!!! danger "Indexing Structural Zeros"
4544
When you index a `SparseMatrixCSC` from `SparseArrays` and hit a structural zero (a value within the dimensions of the matrix but not stored) you can expect a `zero(T)`.
4645

4746
When you index a GBArray you will get `nothing` when you hit a structural zero. This is because the zero in GraphBLAS depends not just on the domain of the elements but also on what you are __doing__ with them. For instance with an element type of `Float64` you could want the zero to be `0.0`, `-∞` or `+∞`.
4847

49-
We'll use the small matrix from the Introduction to illustrate the indexing capabilities. We will also use `SparseArrays.SparseMatrixCSC` for the pretty printing functionality, which should be available in this package in `v1.0`.
50-
5148
```@repl mat
5249
A = GBMatrix([1,1,2,2,3,4,4,5,6,7,7,7], [2,4,5,7,6,1,3,6,3,3,4,5], [1:12...])
5350
SparseMatrixCSC(A)
@@ -57,21 +54,18 @@ A[[1,3,5,7], :]
5754
A[1:2:7, :]
5855
A[:,:]
5956
A[:, 5]
60-
SparseMatrixCSC(A[:,:, desc=T0]) #Transpose the first argument
57+
SparseMatrixCSC(A'[:,:]) #Transpose the first argument
6158
```
6259

6360
All of this same functionality exists for vectors in 1-dimension.
6461

6562
# Transpose
66-
The typical lazy Julia `transpose` is available as usual, and the adjoint operator `'` is also
63+
The lazy Julia `transpose` is available, and the adjoint operator `'` is also
6764
overloaded to be equivalent.
6865

6966
`x = A'` will create a `Transpose` wrapper.
7067
When an operation uses this argument it will cause the `desc` to set `INP<0|1> = T_<0|1>`.
7168

72-
!!! warning
73-
Vectors do not support transposition at this time. A matrix with the column or row size set to `1` may be a solution.
74-
7569
# Utilities
7670

7771
```@docs

src/matrix.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ GBMatrix{T}(size::Tuple{Base.OneTo, Base.OneTo}) where {T} =
1414
GBMatrix{T}(size[1].stop, size[2].stop)
1515

1616
"""
17-
GBMatrix(I, J, X; dup = BinaryOps.PLUS, nrows = maximum(I), ncols = maximum(J))
17+
GBMatrix(I, J, X; dup = +, nrows = maximum(I), ncols = maximum(J))
1818
1919
Create an nrows x ncols GBMatrix M such that M[I[k], J[k]] = X[k]. The dup function defaults
2020
to `|` for booleans and `+` for nonbooleans.
2121
"""
2222
function GBMatrix(
2323
I::AbstractVector, J::AbstractVector, X::AbstractVector{T};
24-
dup = BinaryOps.PLUS, nrows = maximum(I), ncols = maximum(J)
24+
dup = +, nrows = maximum(I), ncols = maximum(J)
2525
) where {T}
2626
A = GBMatrix{T}(nrows, ncols)
2727
build(A, I, J, X; dup)
@@ -141,9 +141,9 @@ for T ∈ valid_vec
141141
func = Symbol(prefix, :_Matrix_build_, suffix(T))
142142
@eval begin
143143
function build(A::GBMatrix{$T}, I::AbstractVector, J::AbstractVector, X::Vector{$T};
144-
dup = BinaryOps.PLUS
144+
dup = +
145145
)
146-
dup = getoperator(dup, $T)
146+
dup = getoperator(BinaryOp(dup), $T)
147147
if !(I isa Vector)
148148
I = Vector(I)
149149
end
@@ -373,7 +373,7 @@ function Base.getindex(
373373
return extract(A, i, ALL; mask, accum, desc)
374374
end
375375
function Base.getindex(
376-
A::GBMatrix, ::Colon, ::Colon;
376+
A::GBMatOrTranspose, ::Colon, ::Colon;
377377
mask = nothing, accum = nothing, desc = nothing
378378
)
379379
return extract(A, ALL, ALL; mask, accum, desc)

src/vector.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@ GBVector{T}(dims::Dims{1}) where {T} = GBVector{T}(dims...)
1313
GBVector{T}(nrows::Base.OneTo) where {T} =
1414
GBVector{T}(nrows.stop)
1515
GBVector{T}(nrows::Tuple{Base.OneTo,}) where {T} = GBVector{T}(first(nrows))
16+
1617
"""
17-
GBVector(I::Vector, X::Vector{T})
18+
GBVector(I::AbstractVector, X::AbstractVector{T})
1819
1920
Create a GBVector from a vector of indices `I` and a vector of values `X`.
2021
"""
21-
function GBVector(I::AbstractVector{U}, X::AbstractVector{T}; dup = BinaryOps.PLUS, nrows = maximum(I)) where {U<:Integer, T}
22+
function GBVector(I::AbstractVector{U}, X::AbstractVector{T}; dup = +, nrows = maximum(I)) where {U<:Integer, T}
2223
x = GBVector{T}(nrows)
2324
build(x, I, X, dup = dup)
2425
return x

0 commit comments

Comments
 (0)