Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gdalle committed May 18, 2024
1 parent 83864e7 commit 8ed7b49
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions src/colpackcoloring.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ The users needs to specify a coloring `method` and an `order` on the vertices.
- [`ColoringOrder`](@ref)
"""
mutable struct ColPackColoring
refColPack::Vector{Ptr{Cvoid}}
refColPack::Base.RefValue{Ptr{Cvoid}}
coloring::Vector{Cint}
method::ColoringMethod
order::ColoringOrder
csr::Union{Vector{Ptr{Cuint}},Nothing}
end

function free_coloring(g::ColPackColoring)
ccall((:free_coloring, libcolpack), Cvoid, (Ptr{Cvoid},), g.refColPack)
@ccall libcolpack.free_coloring(g.refColPack::Ptr{Cvoid})::Cvoid
return nothing
end

Expand All @@ -65,7 +65,7 @@ function ColPackColoring(
error("ColPack coloring failed.")
end

g = ColPackColoring(refColPack, zeros(Int, reflen[1]), method, order, nothing)
g = ColPackColoring(refColPack, zeros(Int, reflen[]), method, order, nothing)
finalizer(free_coloring, g)
return g
end
Expand All @@ -91,7 +91,7 @@ function ColPackColoring(
end
nrows = size(M, 2)
reflen = Ref{Cint}(0)
refColPack = Vector{Ptr{Cvoid}}([C_NULL])
refColPack = Ref{Ptr{Cvoid}}(C_NULL)
ret = @ccall libcolpack.build_coloring_from_csr(
refColPack::Ptr{Cvoid},
reflen::Ptr{Cint},
Expand All @@ -105,7 +105,7 @@ function ColPackColoring(
error("ColPack coloring failed.")
end

g = ColPackColoring(refColPack, zeros(Int, reflen[1]), method, order, csr)
g = ColPackColoring(refColPack, zeros(Int, reflen[]), method, order, csr)
finalizer(free_coloring, g)
return g
end
Expand All @@ -116,15 +116,12 @@ end
Retrieve the colors from a [`ColPackColoring`](@ref) as a vector of integers.
"""
function get_colors(coloring::ColPackColoring; verbose=false)
ccall(
(:get_colors, libcolpack),
Cvoid,
(Ptr{Cvoid}, Ptr{Cdouble}, Cstring, Cint),
coloring.refColPack[1],
coloring.coloring,
coloring.method.method,
Cint(verbose),
)
@ccall libcolpack.get_colors(
coloring.refColPack[]::Ptr{Cvoid},
coloring.coloring::Ptr{Cdouble}, # TODO: should this be Cint?
coloring.method.method::Cstring,
verbose::Cint,
)::Cvoid
# Julia colorings should be base 1
return coloring.coloring .+ 1
end

0 comments on commit 8ed7b49

Please sign in to comment.