-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f33b028
Showing
3 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
name = "ColPack" | ||
uuid = "ffa27691-3a59-46ab-a8d4-551f45b8d401" | ||
authors = ["Michel Schanen <[email protected]>"] | ||
version = "0.1.0" | ||
|
||
[deps] | ||
MatrixMarket = "4d4711f2-db25-561a-b6b3-d35e7d4047d3" | ||
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using ColPack | ||
|
||
verbose = 1 | ||
A = sprand(100, 100, 0.1) | ||
MatrixMarket.mmwrite(filename, A) | ||
ccall((:hello, libcolpack), Cvoid, ()) | ||
|
||
coloring = ColPack(filename, ColPack.d1, "RANDOM", verbose) | ||
colors = get_colors(coloring) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
module ColPack | ||
|
||
using SparseArrays | ||
using MatrixMarket | ||
|
||
const libcolpack = "/home/michel/git/ColPack.jl/ColPack/build/automake/build/lib/libColPack" | ||
|
||
const filename = "mat.mtx" | ||
const d1 = "DISTANCE_ONE" | ||
const d2 = "DISTANCE_TWO" | ||
const acyclic = "ACYCLIC", | ||
const star = "STAR", | ||
|
||
struct ColPack | ||
refColPack::Vector{Ptr{Cvoid}} | ||
coloring::Vector{Cint} | ||
method::AbstractString | ||
order::AbstractString | ||
end | ||
|
||
function ColPack(filename::AbstractString, method::AbstractString, order::AbstractString, verbose::Int) | ||
reflen = Vector{Cint}([Cint(0)]) | ||
refColPack = Vector{Ptr{Cvoid}}([C_NULL]) | ||
ret = ccall( | ||
(:build_coloring, libcolpack), | ||
Cint, (Ptr{Cvoid}, Ptr{Cint}, Cstring, Cstring, Cstring, Cint), | ||
refColPack, reflen, filename, method, order, verbose, | ||
) | ||
if ret == 0 | ||
error("ColPack coloring failed.") | ||
end | ||
|
||
println("Coloring length $(reflen[1])") | ||
return ColPack(refColPack, zeros(Int, reflen[1]), method, order) | ||
end | ||
|
||
function get_colors(coloring::ColPack) | ||
ccall( | ||
(:get_colors, libcolpack), | ||
Cvoid, (Ptr{Cvoid}, Ptr{Cdouble}, Cstring), | ||
coloring.refColPack[1], coloring.coloring, coloring.method, | ||
) | ||
@show coloring.coloring | ||
end | ||
|
||
@show length(get_colors(coloring)) | ||
@show unique(colors) | ||
@show length(unique(colors)) | ||
end #module | ||
|