You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Normal AbstractArray and SparseArray indexing should work here. Including indexing by scalars, vectors, and ranges.
41
+
The usual AbstractArray and SparseArray indexing capabilities are available. Including indexing by scalars, vectors, and ranges.
42
42
43
43
!!! danger "Indexing Structural Zeros"
44
-
When indexing a `SparseMatrixCSC` from `SparseArrays` a structural, or implicit, zero will be returned as `zero(T)` where `T` is the elemtn type of the matrix.
44
+
When indexing a `SparseMatrixCSC` from `SparseArrays` a structural, or implicit, zero will be returned as `zero(T)` where `T` is the element type of the matrix.
45
45
46
-
When indexing a GBArray a structural zero is instead returned as `nothing`. While this is a significant departure from the `SparseMatrixCSC` it more closely matches the GraphBLAS spec, and enables the consuming method to determine the value of implicit zeros.
46
+
When indexing a GBArray structural zeros are instead returned as `nothing`.
47
+
While this is a significant departure from the `SparseMatrixCSC` it more closely matches the GraphBLAS spec,
48
+
and enables the consuming method to determine the value of implicit zeros.
47
49
48
50
For instance with an element type of `Float64` you may want the zero to be `0.0`, `-∞` or `+∞` depending on your algorithm. In addition, for graph algorithms there may be a distinction between an implicit zero, indicating the lack of an edge between two vertices in an adjacency matrix, and an explicit zero where the edge exists but has a `0` weight.
49
51
52
+
Better compatibility with `SparseMatrixCSC` and the ability to specify the value of implicit zeros is provided
53
+
by `SuiteSparseGraphBLAS.SparseArrayCompat.SparseMatrixGB` array type.
54
+
50
55
```@repl mat
51
56
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...])
52
57
SparseMatrixCSC(A)
@@ -65,6 +70,11 @@ The functionality illustrated above extends to `GBVector` as well.
65
70
The lazy Julia `transpose` is available, and the adjoint operator `'` is also
66
71
overloaded to be equivalent.
67
72
73
+
!!! danger "Adjoint vs Transpose"
74
+
The adjoint operator `'` currently transposes matrices rather than performing the
75
+
conjugate transposition. In the future this will change to the complex conjugate
76
+
for complex types, but currently you must do `map(conj, A')` to achieve this.
Copy file name to clipboardExpand all lines: docs/src/binaryops.md
+15-5Lines changed: 15 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,11 +5,21 @@ However, the vast majority of binary operators are defined on a single domain.
5
5
6
6
## Built-Ins
7
7
8
-
All built-in binary oeprators can be found in the `BinaryOps` submodule.
8
+
All built-in binary operators can be found in the `BinaryOps` submodule.
9
9
10
-
The documentation below uses `T` to refer to any of the valid primitive types listed in [Supported Types](@ref), `ℤ` to refer to integers (signed and unsigned), `F` to refer to floating point types, `ℝ` to refer to real numbers (non-complex numbers).
10
+
```@eval
11
+
using Pkg
12
+
Pkg.activate("..")
13
+
cd("..")
14
+
using SuiteSparseGraphBLAS
15
+
using Latexify
16
+
head = ["UnaryOp", "Function Form", "Types"]
17
+
v1 = filter((x) -> getproperty(BinaryOps, x) isa SuiteSparseGraphBLAS.AbstractBinaryOp, names(BinaryOps))
The SuiteSparse:GraphBLAS binary is installed automatically as `SSGraphBLAS_jll`.
22
22
23
+
Then in the REPL or script `using SuiteSparseGraphBLAS` will import the package.
23
24
# Introduction
24
25
25
26
GraphBLAS harnesses the well-understood duality between graphs and matrices.
26
-
Specifically a graph can be represented by its [adjacency matrix](https://en.wikipedia.org/wiki/Adjacency_matrix), [incidence matrix](https://en.wikipedia.org/wiki/Incidence_matrix), or the many variations on those formats.
27
+
Specifically a graph can be represented by its [adjacency matrix](https://en.wikipedia.org/wiki/Adjacency_matrix), [incidence matrix](https://en.wikipedia.org/wiki/Incidence_matrix), or one of the many variations on those formats.
27
28
With this matrix representation in hand we have a method to operate on the graph using linear algebra operations on the matrix.
28
29
29
30
Below is an example of the adjacency matrix of a directed graph, and finding the neighbors of a single vertex using basic matrix-vector multiplication on the arithemtic semiring.
Copy file name to clipboardExpand all lines: docs/src/operations.md
+21-19Lines changed: 21 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,6 +26,10 @@ where ``\bf M`` is a `GBArray` mask, ``\odot`` is a binary operator for accumula
26
26
!!! note "assign vs subassign"
27
27
`subassign` is equivalent to `assign` except that the mask in `subassign` has the dimensions of ``\bf C(I,J)`` vs the dimensions of ``C`` for `assign`, and elements outside of the mask will never be modified by `subassign`. See the [GraphBLAS User Guide](https://github.com/DrTimothyAldenDavis/GraphBLAS/blob/stable/Doc/GraphBLAS_UserGuide.pdf) for more details.
28
28
29
+
## Operation Documentation
30
+
31
+
All non-mutating operations below support a mutating form by adding an output array as the first argument as well as the `!` function suffix.
32
+
29
33
### `mul`
30
34
```@docs
31
35
mul
@@ -45,37 +49,41 @@ LinearAlgebra.kron
45
49
46
50
## Common arguments
47
51
48
-
The operations above have often accept most or all of the following arguments.
52
+
The operations typically accept one of the following types in the `op` argument.
49
53
50
54
### `op` - `UnaryOp`, `BinaryOp`, `Monoid`, `Semiring`, or `SelectOp`:
51
55
52
-
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`.
53
-
Most operations are restricted to one type of operator.
56
+
This argument determines ``\oplus``, ``\otimes``, or ``f`` in the table above as well as the semiring used in `mul`. They typically have synonymous functions in Julia, so `conj` can be used in place of `UnaryOps.CONJ` for instance.
54
57
55
58
!!! tip "Built-Ins"
56
59
The built-in operators can be found in the submodules: `UnaryOps`, `BinaryOps`, `Monoids`, and `Semirings`.
57
60
61
+
See the [Operators](@ref) section for more information.
62
+
58
63
### `desc` - `Descriptor`:
59
64
60
65
The descriptor argument allows the user to modify the operation in some fashion. The most common options are:
Copy file name to clipboardExpand all lines: docs/src/operators.md
+14-15Lines changed: 14 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,37 +3,35 @@
3
3
There are five operator types in SuiteSparseGraphBLAS. Four are defined for all GraphBLAS implementations: `UnaryOp`, `BinaryOp`, `Monoid`, and `Semiring`.
4
4
One is an extension to the `v1.3` specification: `SelectOp`.
5
5
6
-
!!! note "Operator vs Algebraic Object"
7
-
While we will refer to anything in the list above as an operator, semirings and monoids are technically not operators so much as algebraic objects.
8
-
9
6
!!! danger "Note"
10
-
Operators are **not** callable objects like functions. They **do** behave like functions as arguments to higher-order functions (operations in the language of GraphBLAS).
7
+
Operators are **not** callable objects like functions. They **do** behave like functions as arguments to higher-order functions (operations in the language of GraphBLAS). However `BinaryOp` and `UnaryOp` operators
8
+
typically have a synonymous julia function, which can be found using `juliaop(op)`.
11
9
12
10
Typically operators are positional arguments in one of two places.
13
11
For operations with a clear default operator they appear as the last positional argument:
Each operator is defined on a specific domain. For some this is the typical primitive datatypes like booleans, floats, and signed and unsigned integers of the typical sizes. A few also accept complex numbers, while most are restricted to some subset of these types.
26
+
Each operator is defined on a specific domain. For some this is the usual primitive datatypes like booleans, floats, and signed and unsigned integers of the typical sizes.
29
27
30
-
Each operator is represented as its own concrete type.
28
+
Each operator is represented as its own concrete type for dispatch purposes.
31
29
For instance `BinaryOps.PLUS <: AbstractBinaryOp <: AbstractOp`.
32
30
Operators are effectively dictionaries containing the type-specific operators indexed by the `DataType` of their arguments.
33
31
34
32
### Supported Types
35
33
36
-
GraphBLAS supports the following types:
34
+
SuiteSparseGraphBLAS.jl natively supports the following types:
37
35
38
36
- Booleans
39
37
- Integers with sizes 8, 16, 32, 64
@@ -46,11 +44,12 @@ The supported types can be found as in the example below:
46
44
using SuiteSparseGraphBLAS
47
45
```
48
46
```@repl operators
47
+
Semiring(max, +)
49
48
Semirings.MAX_PLUS
50
49
Semirings.MAX_PLUS[Float64]
51
50
```
52
51
53
-
Either form may be passed to all operations, the function will take care of selecting the proper typed operator.
52
+
All operations will accept the function/tuple form, the `DataType` form, or the `TypedSemiring` form.
54
53
Unless you need to specifically cast the arguments to a specific type there is no need to specify the operator type.
55
54
56
55
You can determine the available types for an operator and the input and output types of a type-specific operator with the functions below:
0 commit comments