@@ -10,16 +10,18 @@ julia> using SuiteSparseGraphBLAS
10
10
julia> GrB_init(GrB_NONBLOCKING)
11
11
GrB_SUCCESS::GrB_Info = 0
12
12
13
- julia> MAT = GrB_Matrix()
14
- GrB_Matrix
13
+ julia> MAT = GrB_Matrix{Int8} ()
14
+ GrB_Matrix{Int8}
15
15
16
16
julia> GrB_Matrix_new(MAT, GrB_INT8, 4, 4)
17
17
GrB_SUCCESS::GrB_Info = 0
18
18
```
19
19
"""
20
- function GrB_Matrix_new (A:: GrB_Matrix , type:: GrB_Type , nrows:: T , ncols:: T ) where T <: GrB_Index
20
+ function GrB_Matrix_new (A:: GrB_Matrix{T} , type:: GrB_Type , nrows:: U , ncols:: U ) where {U <: GrB_Index , T <: valid_types }
21
21
A_ptr = pointer_from_objref (A)
22
-
22
+ if jl_type (type) != T
23
+ error (" Given domain and matrix type do not match" )
24
+ end
23
25
return GrB_Info (
24
26
ccall (
25
27
dlsym (graphblas_lib, " GrB_Matrix_new" ),
@@ -42,8 +44,8 @@ julia> using SuiteSparseGraphBLAS
42
44
julia> GrB_init(GrB_NONBLOCKING)
43
45
GrB_SUCCESS::GrB_Info = 0
44
46
45
- julia> MAT = GrB_Matrix()
46
- GrB_Matrix
47
+ julia> MAT = GrB_Matrix{Int8} ()
48
+ GrB_Matrix{Int8}
47
49
48
50
julia> GrB_Matrix_new(MAT, GrB_INT8, 4, 4)
49
51
GrB_SUCCESS::GrB_Info = 0
@@ -73,11 +75,11 @@ row: 3 : 1 entries [4:4]
73
75
74
76
```
75
77
"""
76
- function GrB_Matrix_build (C:: GrB_Matrix , I:: Vector{U} , J:: Vector{U} , X:: Vector{T} , nvals:: U , dup:: GrB_BinaryOp ) where {U <: GrB_Index , T <: valid_types }
78
+ function GrB_Matrix_build (C:: GrB_Matrix{T} , I:: Vector{U} , J:: Vector{U} , X:: Vector{T} , nvals:: U , dup:: GrB_BinaryOp ) where {U <: GrB_Index , T <: valid_types }
77
79
I_ptr = pointer (I)
78
80
J_ptr = pointer (J)
79
81
X_ptr = pointer (X)
80
- fn_name = " GrB_Matrix_build_" * get_suffix (T)
82
+ fn_name = " GrB_Matrix_build_" * suffix (T)
81
83
return GrB_Info (
82
84
ccall (
83
85
dlsym (graphblas_lib, fn_name),
@@ -101,8 +103,8 @@ julia> using SuiteSparseGraphBLAS
101
103
julia> GrB_init(GrB_NONBLOCKING)
102
104
GrB_SUCCESS::GrB_Info = 0
103
105
104
- julia> MAT = GrB_Matrix()
105
- GrB_Matrix
106
+ julia> MAT = GrB_Matrix{Int8} ()
107
+ GrB_Matrix{Int8}
106
108
107
109
julia> GrB_Matrix_new(MAT, GrB_INT8, 4, 4)
108
110
GrB_SUCCESS::GrB_Info = 0
@@ -138,8 +140,8 @@ julia> using SuiteSparseGraphBLAS
138
140
julia> GrB_init(GrB_NONBLOCKING)
139
141
GrB_SUCCESS::GrB_Info = 0
140
142
141
- julia> MAT = GrB_Matrix()
142
- GrB_Matrix
143
+ julia> MAT = GrB_Matrix{Int8} ()
144
+ GrB_Matrix{Int8}
143
145
144
146
julia> GrB_Matrix_new(MAT, GrB_INT8, 4, 4)
145
147
GrB_SUCCESS::GrB_Info = 0
@@ -175,8 +177,8 @@ julia> using SuiteSparseGraphBLAS
175
177
julia> GrB_init(GrB_NONBLOCKING)
176
178
GrB_SUCCESS::GrB_Info = 0
177
179
178
- julia> MAT = GrB_Matrix()
179
- GrB_Matrix
180
+ julia> MAT = GrB_Matrix{Int8} ()
181
+ GrB_Matrix{Int8}
180
182
181
183
julia> GrB_Matrix_new(MAT, GrB_INT8, 4, 4)
182
184
GrB_SUCCESS::GrB_Info = 0
@@ -216,8 +218,8 @@ julia> using SuiteSparseGraphBLAS
216
218
julia> GrB_init(GrB_NONBLOCKING)
217
219
GrB_SUCCESS::GrB_Info = 0
218
220
219
- julia> MAT = GrB_Matrix()
220
- GrB_Matrix
221
+ julia> MAT = GrB_Matrix{Int8} ()
222
+ GrB_Matrix{Int8}
221
223
222
224
julia> GrB_Matrix_new(MAT, GrB_INT8, 4, 4)
223
225
GrB_SUCCESS::GrB_Info = 0
@@ -227,8 +229,8 @@ julia> I = [1, 2, 2, 2, 3]; J = [1, 2, 1, 3, 3]; X = Int8[2, 3, 4, 5, 6]; n = 5;
227
229
julia> GrB_Matrix_build(MAT, I, J, X, n, GrB_FIRST_INT8)
228
230
GrB_SUCCESS::GrB_Info = 0
229
231
230
- julia> B = GrB_Matrix()
231
- GrB_Matrix
232
+ julia> B = GrB_Matrix{Int8} ()
233
+ GrB_Matrix{Int8}
232
234
233
235
julia> GrB_Matrix_dup(B, MAT)
234
236
GrB_SUCCESS::GrB_Info = 0
@@ -252,7 +254,7 @@ row: 3 : 1 entries [4:4]
252
254
253
255
```
254
256
"""
255
- function GrB_Matrix_dup (C:: GrB_Matrix , A:: GrB_Matrix )
257
+ function GrB_Matrix_dup (C:: GrB_Matrix{T} , A:: GrB_Matrix{T} ) where T <: valid_types
256
258
C_ptr = pointer_from_objref (C)
257
259
258
260
return GrB_Info (
@@ -277,8 +279,8 @@ julia> using SuiteSparseGraphBLAS
277
279
julia> GrB_init(GrB_NONBLOCKING)
278
280
GrB_SUCCESS::GrB_Info = 0
279
281
280
- julia> MAT = GrB_Matrix()
281
- GrB_Matrix
282
+ julia> MAT = GrB_Matrix{Int8} ()
283
+ GrB_Matrix{Int8}
282
284
283
285
julia> GrB_Matrix_new(MAT, GrB_INT8, 4, 4)
284
286
GrB_SUCCESS::GrB_Info = 0
@@ -321,8 +323,8 @@ julia> using SuiteSparseGraphBLAS
321
323
julia> GrB_init(GrB_NONBLOCKING)
322
324
GrB_SUCCESS::GrB_Info = 0
323
325
324
- julia> MAT = GrB_Matrix()
325
- GrB_Matrix
326
+ julia> MAT = GrB_Matrix{Int8} ()
327
+ GrB_Matrix{Int8}
326
328
327
329
julia> GrB_Matrix_new(MAT, GrB_INT8, 4, 4)
328
330
GrB_SUCCESS::GrB_Info = 0
@@ -343,8 +345,8 @@ julia> GrB_Matrix_extractElement(MAT, 1, 1)
343
345
7
344
346
```
345
347
"""
346
- function GrB_Matrix_setElement (C:: GrB_Matrix , X:: T , I:: U , J:: U ) where {U <: GrB_Index , T <: valid_int_types }
347
- fn_name = " GrB_Matrix_setElement_" * get_suffix (T)
348
+ function GrB_Matrix_setElement (C:: GrB_Matrix{T} , X:: T , I:: U , J:: U ) where {U <: GrB_Index , T <: valid_int_types }
349
+ fn_name = " GrB_Matrix_setElement_" * suffix (T)
348
350
return GrB_Info (
349
351
ccall (
350
352
dlsym (graphblas_lib, fn_name),
@@ -355,7 +357,7 @@ function GrB_Matrix_setElement(C::GrB_Matrix, X::T, I::U, J::U) where {U <: GrB_
355
357
)
356
358
end
357
359
358
- function GrB_Matrix_setElement (C:: GrB_Matrix , X:: Float32 , I:: U , J:: U ) where U <: GrB_Index
360
+ function GrB_Matrix_setElement (C:: GrB_Matrix{Float32} , X:: Float32 , I:: U , J:: U ) where U <: GrB_Index
359
361
fn_name = " GrB_Matrix_setElement_FP32"
360
362
return GrB_Info (
361
363
ccall (
@@ -367,7 +369,7 @@ function GrB_Matrix_setElement(C::GrB_Matrix, X::Float32, I::U, J::U) where U <:
367
369
)
368
370
end
369
371
370
- function GrB_Matrix_setElement (C:: GrB_Matrix , X:: Float64 , I:: U , J:: U ) where U <: GrB_Index
372
+ function GrB_Matrix_setElement (C:: GrB_Matrix{Float64} , X:: Float64 , I:: U , J:: U ) where U <: GrB_Index
371
373
fn_name = " GrB_Matrix_setElement_FP64"
372
374
return GrB_Info (
373
375
ccall (
@@ -392,8 +394,8 @@ julia> using SuiteSparseGraphBLAS
392
394
julia> GrB_init(GrB_NONBLOCKING)
393
395
GrB_SUCCESS::GrB_Info = 0
394
396
395
- julia> MAT = GrB_Matrix()
396
- GrB_Matrix
397
+ julia> MAT = GrB_Matrix{Int8} ()
398
+ GrB_Matrix{Int8}
397
399
398
400
julia> GrB_Matrix_new(MAT, GrB_INT8, 4, 4)
399
401
GrB_SUCCESS::GrB_Info = 0
@@ -407,11 +409,8 @@ julia> GrB_Matrix_extractElement(MAT, 1, 1)
407
409
2
408
410
```
409
411
"""
410
- function GrB_Matrix_extractElement (A:: GrB_Matrix , row_index:: U , col_index:: U ) where U <: GrB_Index
411
- res, A_type = GxB_Matrix_type (A)
412
- res != GrB_SUCCESS && return res
413
- suffix, T = get_suffix_and_type (A_type)
414
- fn_name = " GrB_Matrix_extractElement_" * suffix
412
+ function GrB_Matrix_extractElement (A:: GrB_Matrix{T} , row_index:: U , col_index:: U ) where {U <: GrB_Index , T <: valid_types }
413
+ fn_name = " GrB_Matrix_extractElement_" * suffix (T)
415
414
416
415
element = Ref (T (0 ))
417
416
result = GrB_Info (
@@ -438,8 +437,8 @@ julia> using SuiteSparseGraphBLAS
438
437
julia> GrB_init(GrB_NONBLOCKING)
439
438
GrB_SUCCESS::GrB_Info = 0
440
439
441
- julia> MAT = GrB_Matrix()
442
- GrB_Matrix
440
+ julia> MAT = GrB_Matrix{Int8} ()
441
+ GrB_Matrix{Int8}
443
442
444
443
julia> GrB_Matrix_new(MAT, GrB_INT8, 4, 4)
445
444
GrB_SUCCESS::GrB_Info = 0
@@ -453,18 +452,15 @@ julia> GrB_Matrix_extractTuples(MAT)
453
452
([1, 2, 2, 2, 3], [1, 1, 2, 3, 3], Int8[2, 4, 3, 5, 6])
454
453
```
455
454
"""
456
- function GrB_Matrix_extractTuples (A:: GrB_Matrix )
457
- res, A_type = GxB_Matrix_type (A)
458
- res != GrB_SUCCESS && return res
459
- suffix, T = get_suffix_and_type (A_type)
455
+ function GrB_Matrix_extractTuples (A:: GrB_Matrix{T} ) where T <: valid_types
460
456
nvals = GrB_Matrix_nvals (A)
461
457
U = typeof (nvals)
462
458
row_indices = Vector {U} (undef, nvals)
463
459
col_indices = Vector {U} (undef, nvals)
464
460
vals = Vector {T} (undef, nvals)
465
461
n = Ref (UInt64 (nvals))
466
462
467
- fn_name = " GrB_Matrix_extractTuples_" * suffix
463
+ fn_name = " GrB_Matrix_extractTuples_" * suffix (T)
468
464
result = GrB_Info (
469
465
ccall (
470
466
dlsym (graphblas_lib, fn_name),
0 commit comments