Skip to content

Commit dd78000

Browse files
committed
improve complement handling, fix structural + complement handling
1 parent ba702df commit dd78000

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

src/descriptors.jl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ function GxB_Desc_set(d, field, value)
9292
end
9393
end
9494

95+
Base.:+(a::LibGraphBLAS.GrB_Desc_Value, b::LibGraphBLAS.GrB_Desc_Value) =
96+
Integer(a) + Integer(b)
97+
98+
9599
function Base.getproperty(d::Descriptor, s::Symbol)
96100
if s === :p
97101
return getfield(d, s)
@@ -104,7 +108,7 @@ function Base.getproperty(d::Descriptor, s::Symbol)
104108
end
105109
elseif s === :complement_mask
106110
x = GxB_Desc_get(d, LibGraphBLAS.GrB_MASK)
107-
if x == LibGraphBLAS.GrB_COMP || x == LibGraphBLAS.GrB_STRUCT_COMP
111+
if x == LibGraphBLAS.GrB_COMP || x == LibGraphBLAS.GrB_STRUCTURE + LibGraphBLAS.GrB_COMP
108112
return true
109113
else
110114
return false
@@ -173,7 +177,11 @@ function Base.setproperty!(d::Descriptor, s::Symbol, x)
173177
GxB_Desc_set(d, LibGraphBLAS.GrB_MASK, LibGraphBLAS.GxB_DEFAULT)
174178
end
175179
else
176-
GxB_Desc_set(d, LibGraphBLAS.GrB_MASK, LibGraphBLAS.GrB_COMP)
180+
if d.structural_mask
181+
GxB_Desc_set(d, LibGraphBLAS.GrB_MASK, LibGraphBLAS.GrB_STRUCTURE + LibGraphBLAS.GrB_COMP)
182+
else
183+
GxB_Desc_set(d, LibGraphBLAS.GrB_MASK, LibGraphBLAS.GrB_COMP)
184+
end
177185
end
178186
elseif s === :structural_mask
179187
if x == false

src/operations/operationutils.jl

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,16 @@ struct Complement{T}
1818
parent::T
1919
end
2020

21-
Complement(A::T) where {T<:GBArrayOrTranspose}= Complement{T}(A)
22-
Base.:~(A::T) where {T<:GBArrayOrTranspose} = Complement(A)
21+
Complement(A::T) where {
22+
T<:Union{GBArrayOrTranspose,
23+
Structural{<:GBArrayOrTranspose},
24+
Complement{<:GBArrayOrTranspose}}
25+
} = Complement{T}(A)
26+
Base.:~(A::T) where {
27+
T<:Union{GBArrayOrTranspose,
28+
Structural{<:GBArrayOrTranspose},
29+
Complement}
30+
} = Complement(A)
2331
Base.parent(C::Complement) = C.parent
2432

2533
struct Structural{T}
@@ -37,7 +45,7 @@ function _handlemask!(desc, mask)
3745
mask = copy(mask)
3846
elseif mask isa Complement
3947
mask = parent(mask)
40-
desc.complement_mask = true
48+
desc.complement_mask = ~desc.complement_mask
4149
elseif mask isa Structural
4250
mask = parent(mask)
4351
desc.structural_mask = true

0 commit comments

Comments
 (0)