Skip to content

Commit 0ec029b

Browse files
bug fixes
1 parent 1b6f75b commit 0ec029b

File tree

12 files changed

+153
-244
lines changed

12 files changed

+153
-244
lines changed

src/Object_Methods/Free_Objects.jl

Lines changed: 44 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2,57 +2,14 @@
22
GrB_free(object)
33
44
Generic method to free a GraphBLAS object.
5-
6-
# Examples
7-
```jldoctest
8-
julia> using SuiteSparseGraphBLAS
9-
10-
julia> w = GrB_Vector{Int64}()
11-
GrB_Vector{Int64}
12-
13-
julia> I = [0, 2, 4]; X = [10, 20, 30]; n = 3;
14-
15-
julia> GrB_Vector_new(w, GrB_INT64, 5)
16-
GrB_SUCCESS::GrB_Info = 0
17-
18-
julia> GrB_Vector_build(w, I, X, n, GrB_FIRST_INT64)
19-
GrB_SUCCESS::GrB_Info = 0
20-
21-
julia> @GxB_fprint(w, GxB_COMPLETE)
22-
23-
GraphBLAS vector: w
24-
nrows: 5 ncols: 1 max # entries: 3
25-
format: standard CSC vlen: 5 nvec_nonempty: 1 nvec: 1 plen: 1 vdim: 1
26-
hyper_ratio 0.0625
27-
GraphBLAS type: int64_t size: 8
28-
number of entries: 3
29-
column: 0 : 3 entries [0:2]
30-
row 0: int64 10
31-
row 2: int64 20
32-
row 4: int64 30
33-
34-
35-
julia> GrB_free(w)
36-
GrB_SUCCESS::GrB_Info = 0
37-
38-
julia> @GxB_fprint(w, GxB_COMPLETE)
39-
40-
GraphBLAS vector: w NULL
41-
```
425
"""
43-
function GrB_free(object::GrB_Struct)
44-
object_ptr = pointer_from_objref(object)
45-
fn_name = "GrB_" * get_struct_name(object) * "_free"
46-
47-
return GrB_Info(
48-
ccall(
49-
dlsym(graphblas_lib, fn_name),
50-
Cint,
51-
(Ptr{Cvoid}, ),
52-
object_ptr
53-
)
54-
)
55-
end
6+
GrB_free(object::GrB_UnaryOp) = GrB_UnaryOp_free(object)
7+
GrB_free(object::GrB_BinaryOp) = GrB_BinaryOp_free(object)
8+
GrB_free(object::GrB_Monoid) = GrB_Monoid_free(object)
9+
GrB_free(object::GrB_Semiring) = GrB_Semiring_free(object)
10+
GrB_free(object::GrB_Vector) = GrB_Vector_free(object)
11+
GrB_free(object::GrB_Matrix) = GrB_Matrix_free(object)
12+
GrB_free(object::GrB_Descriptor) = GrB_Descriptor_free(object)
5613

5714
"""
5815
GrB_UnaryOp_free(unaryop)
@@ -130,6 +87,43 @@ end
13087
GrB_Vector_free(v)
13188
13289
Free vector.
90+
91+
# Examples
92+
```jldoctest
93+
julia> using SuiteSparseGraphBLAS
94+
95+
julia> w = GrB_Vector{Int64}()
96+
GrB_Vector{Int64}
97+
98+
julia> I = [0, 2, 4]; X = [10, 20, 30]; n = 3;
99+
100+
julia> GrB_Vector_new(w, GrB_INT64, 5)
101+
GrB_SUCCESS::GrB_Info = 0
102+
103+
julia> GrB_Vector_build(w, I, X, n, GrB_FIRST_INT64)
104+
GrB_SUCCESS::GrB_Info = 0
105+
106+
julia> @GxB_fprint(w, GxB_COMPLETE)
107+
108+
GraphBLAS vector: w
109+
nrows: 5 ncols: 1 max # entries: 3
110+
format: standard CSC vlen: 5 nvec_nonempty: 1 nvec: 1 plen: 1 vdim: 1
111+
hyper_ratio 0.0625
112+
GraphBLAS type: int64_t size: 8
113+
number of entries: 3
114+
column: 0 : 3 entries [0:2]
115+
row 0: int64 10
116+
row 2: int64 20
117+
row 4: int64 30
118+
119+
120+
julia> GrB_Vector_free(w)
121+
GrB_SUCCESS::GrB_Info = 0
122+
123+
julia> @GxB_fprint(w, GxB_COMPLETE)
124+
125+
GraphBLAS vector: w NULL
126+
```
133127
"""
134128
function GrB_Vector_free(v::GrB_Vector)
135129
v_ptr = pointer_from_objref(v)

src/Object_Methods/Print_Objects.jl

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,31 @@
1-
function GxB_fprint(A::GrB_Struct, name::String, pr::GxB_Print_Level)
1+
function GxB_fprint(
2+
A::T,
3+
name::String,
4+
pr::GxB_Print_Level
5+
) where T <: Union{GrB_Type, GrB_UnaryOp, GrB_BinaryOp, GrB_Monoid, GrB_Semiring, GrB_Matrix, GrB_Vector, GrB_Descriptor}
6+
27
function f(path, io)
38
FILE = Libc.FILE(io)
49
ccall(dlsym(graphblas_lib, fn_name), Cint, (Ptr{Cvoid}, Ptr{UInt8}, Cint, Ptr{Cvoid}), A.p, pointer(name), pr, FILE)
510
ccall(:fclose, Cint, (Ptr{Cvoid},), FILE)
611
foreach(println, eachline(path))
712
end
8-
s = get_struct_name(A)
13+
14+
s = "Descriptor"
15+
if T <: GrB_UnaryOp
16+
s = "UnaryOp"
17+
elseif T <: GrB_BinaryOp
18+
s = "BinaryOp"
19+
elseif T <: GrB_Monoid
20+
s = "Monoid"
21+
elseif T <: GrB_Semiring
22+
s = "Semiring"
23+
elseif T <: GrB_Vector
24+
s = "Vector"
25+
elseif T <: GrB_Matrix
26+
s = "Matrix"
27+
end
28+
929
fn_name = "GxB_" * s * "_fprint"
1030
mktemp(f)
1131
end

src/Operations/Apply.jl

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,8 @@
33
44
Generic matrix/vector apply.
55
"""
6-
function GrB_apply( # w<mask> = accum (w, op(u))
7-
C::X, # input/output vector for results
8-
Mask::T, # optional mask for w, unused if NULL
9-
accum::U, # optional accum for z=accum(w,t)
10-
op::GrB_UnaryOp, # operator to apply to the entries
11-
A::Y, # first input: vector u
12-
desc::V # descriptor for w and mask
13-
) where {X <: Union{GrB_Vector, GrB_Matrix}, Y <: Union{GrB_Vector, GrB_Matrix}, T <: Union{GrB_Vector, GrB_Matrix, GrB_NULL_Type}, U <: valid_accum_types, V <: valid_desc_types}
14-
15-
fn_name = "GrB_" * get_struct_name(C) * "_apply"
16-
17-
return GrB_Info(
18-
ccall(
19-
dlsym(graphblas_lib, fn_name),
20-
Cint,
21-
(Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}),
22-
C.p, Mask.p, accum.p, op.p, A.p, desc.p
23-
)
24-
)
25-
end
6+
GrB_apply(C::GrB_Vector, Mask, accum, op, A, desc) = GrB_Vector_apply(C, Mask, accum, op, A, desc)
7+
GrB_apply(C::GrB_Matrix, Mask, accum, op, A, desc) = GrB_Matrix_apply(C, Mask, accum, op, A, desc)
268

279
"""
2810
GrB_Vector_apply(w, mask, accum, op, u, desc)

0 commit comments

Comments
 (0)