@@ -19,32 +19,35 @@ The library provides C-compatible API, written in the GraphBLAS style.
19
19
cuBool library C API. This package exports library features and primitives
20
20
in high-level format with automated resources management and fancy syntax sugar.
21
21
22
- ** The primary library primitive ** is a sparse boolean matrix. The library provides
23
- the most popular operations for matrix manipulation, such as construction from
24
- values, transpose, sub-matrix extraction, matrix-to-vector reduce, matrix-matrix
25
- element-wise addition, matrix-matrix multiplication and Kronecker product.
22
+ ** The primary library primitives ** are sparse matrix and sparse vector of boolean values.
23
+ The library provides the most popular operations for matrix manipulation,
24
+ such as construction from values, transpose, sub-matrix/sub-vector extraction, matrix-to-vector reduce,
25
+ element-wise addition, matrix-matrix, matrix-vector, vector-matrix multiplication, and Kronecker product.
26
26
27
27
** As a fallback** library provides sequential backend for mentioned above operations
28
28
for computations on CPU side only. This backend is selected automatically
29
29
if Cuda compatible device is not presented in the system. This can be quite handy for
30
30
prototyping algorithms on a local computer for later running on a powerful server.
31
31
32
- ## Features
32
+ ### Features
33
33
34
34
- C API for performance-critical computations
35
35
- Python package for every-day tasks
36
36
- Cuda backend for computations
37
37
- Cpu backend for computations
38
- - Matrix creation (empty, from data, with random data)
38
+ - Matrix/vector creation (empty, from data, with random data)
39
39
- Matrix-matrix operations (multiplication, element-wise addition, kronecker product)
40
+ - Matrix-vector operations (matrix-vector and vector-matrix multiplication)
41
+ - Vector-vector operations (element-wise addition)
40
42
- Matrix operations (equality, transpose, reduce to vector, extract sub-matrix)
41
- - Matrix data extraction (as lists, as list of pairs)
42
- - Matrix syntax sugar (pretty string printing, slicing, iterating through non-zero values)
43
+ - Vector operations (equality, reduce to value, extract sub-vector)
44
+ - Matrix/vector data extraction (as lists, as list of pairs)
45
+ - Matrix/vector syntax sugar (pretty string printing, slicing, iterating through non-zero values)
43
46
- IO (import/export matrix from/to ` .mtx ` file format)
44
47
- GraphViz (export single matrix or set of matrices as a graph with custom color and label settings)
45
48
- Debug (matrix string debug markers, logging)
46
49
47
- ## Simple example
50
+ ### Simple example
48
51
49
52
Create sparse matrices, compute matrix-matrix product and print the result to the output:
50
53
@@ -64,7 +67,31 @@ b[2, 1] = True
64
67
print (a, b, a.mxm(b), sep = " \n " )
65
68
```
66
69
67
- ## Transitive closure example
70
+ ### Vector example
71
+
72
+ Create sparse matrix and vector, compute matrix-vector and vector-matrix products and print the result:
73
+
74
+ ``` python
75
+ import pycubool as cb
76
+
77
+ m = cb.Matrix.empty(shape = (3 , 4 ))
78
+ m[0 , 1 ] = True
79
+ m[1 , 0 ] = True
80
+ m[1 , 3 ] = True
81
+ m[2 , 2 ] = True
82
+
83
+ v = cb.Vector.empty(nrows = 4 )
84
+ v[0 ] = True
85
+ v[2 ] = True
86
+
87
+ t = cb.Vector.empty(nrows = 3 )
88
+ t[0 ] = True
89
+ t[2 ] = True
90
+
91
+ print (m.mxv(v), t.vxm(m), sep = " \n " )
92
+ ```
93
+
94
+ ### Transitive closure example
68
95
69
96
Compute the transitive closure problem for the directed graph and print the result:
70
97
@@ -88,7 +115,7 @@ while total != t.nvals:
88
115
print (a, t, sep = " \n " )
89
116
```
90
117
91
- ## GraphViz example
118
+ ### GraphViz example
92
119
93
120
Generate GraphViz graph script for a graph stored as a set of adjacency matrices:
94
121
0 commit comments