Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
e4e6dd9
Structured decompression
gdalle Oct 2, 2024
c3a7242
Store graph in result to allow generic matrices
gdalle Oct 2, 2024
d5837b9
Use `fill!` whenever possible
gdalle Oct 2, 2024
12dcf60
More tests
gdalle Oct 2, 2024
3c1350b
Merge branch 'gd/better_result' into gd/structured
gdalle Oct 2, 2024
0e9adcd
Record useless BipartiteGraph
gdalle Oct 2, 2024
fe178d7
Fix docs
gdalle Oct 2, 2024
3937800
Fix cycling inferrability
gdalle Oct 2, 2024
45b16a3
More tests
gdalle Oct 2, 2024
361e53e
Add BandedMatrices
gdalle Oct 2, 2024
4df06f3
Reactivate lts
gdalle Oct 2, 2024
2d71688
Extras
gdalle Oct 2, 2024
eefd1ee
Fix LTS
gdalle Oct 2, 2024
e088877
Ignore unloaded Requires
gdalle Oct 2, 2024
de4a21a
Add BlockBandedMatrices
gdalle Oct 2, 2024
c743b22
Row coloring
gdalle Oct 2, 2024
4f40758
Fix LTS
gdalle Oct 2, 2024
116691d
No fail fast
gdalle Oct 2, 2024
66acbca
BandedBlockBandedMatrices
gdalle Oct 2, 2024
4c838ff
Infinite width
gdalle Oct 2, 2024
59f4d42
Import
gdalle Oct 2, 2024
f3c3776
Fix
gdalle Oct 2, 2024
f55c09a
Fix version
gdalle Oct 2, 2024
00b1961
Merge branch 'main' into gd/structured
gdalle Oct 2, 2024
ef19b99
Merge branch 'main' into gd/structured
gdalle Oct 2, 2024
df53bde
Merge branch 'main' into gd/structured
gdalle Oct 3, 2024
92a3e2d
Remove optimized structured implementations
gdalle Oct 3, 2024
f8cfd6a
Min diff
gdalle Oct 3, 2024
f3531af
Remove cycle range tests
gdalle Oct 3, 2024
a430140
Optimized implementation for structured
gdalle Oct 3, 2024
61da959
Fix import
gdalle Oct 3, 2024
ee82518
Merge remote-tracking branch 'origin/gd/structured2-test' into gd/str…
gdalle Oct 3, 2024
f2d358f
Merge remote-tracking branch 'origin/main' into gd/structured3
gdalle Oct 6, 2024
692ff43
Fix
gdalle Oct 6, 2024
8621d90
Merge remote-tracking branch 'origin/main' into gd/structured3
gdalle Jul 1, 2025
8e25d9c
Remove Requires
gdalle Jul 1, 2025
d1f0a51
Fix test
gdalle Jul 1, 2025
69c2d96
Define StructuredColoringAlgorithm
gdalle Jul 1, 2025
96f5662
Fix doc lunk
gdalle Jul 1, 2025
b24c181
No optimized decompression
gdalle Jul 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "SparseMatrixColorings"
uuid = "0a514795-09f3-496d-8182-132a7b665d35"
authors = ["Guillaume Dalle", "Alexis Montoison"]
version = "0.4.21"
version = "0.4.22"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand All @@ -12,17 +12,25 @@ Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

[weakdeps]
BandedMatrices = "aae01518-5342-5314-be14-df237901396f"
BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
BlockBandedMatrices = "ffab5731-97b5-5995-9138-79e8c1846df0"
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
CliqueTrees = "60701a23-6482-424a-84db-faee86b9b1f8"
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"

[extensions]
SparseMatrixColoringsBandedMatricesExt = "BandedMatrices"
SparseMatrixColoringsBlockBandedMatricesExt = ["BlockArrays", "BlockBandedMatrices"]
SparseMatrixColoringsCUDAExt = "CUDA"
SparseMatrixColoringsCliqueTreesExt = "CliqueTrees"
SparseMatrixColoringsColorsExt = "Colors"

[compat]
ADTypes = "1.2.1"
BandedMatrices = "1.9.4"
BlockArrays = "1.6.3"
BlockBandedMatrices = "0.13.1"
CUDA = "5.8.2"
CliqueTrees = "1"
Colors = "0.12.11, 0.13"
Expand Down
5 changes: 4 additions & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ using Documenter
using DocumenterInterLinks
using SparseMatrixColorings

links = InterLinks("ADTypes" => "https://sciml.github.io/ADTypes.jl/stable/")
links = InterLinks(
"ADTypes" => "https://sciml.github.io/ADTypes.jl/stable/",
"BandedMatrices" => "https://julialinearalgebra.github.io/BandedMatrices.jl/stable/",
)

cp(joinpath(@__DIR__, "..", "README.md"), joinpath(@__DIR__, "src", "index.md"); force=true)

Expand Down
6 changes: 6 additions & 0 deletions docs/src/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,14 @@ SparseMatrixColorings
coloring
fast_coloring
ColoringProblem
```

## Coloring algorithms

```@docs
GreedyColoringAlgorithm
ConstantColoringAlgorithm
StructuredColoringAlgorithm
```

## Result analysis
Expand Down
6 changes: 6 additions & 0 deletions docs/src/dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,9 @@ SparseMatrixColorings.what_fig_61
SparseMatrixColorings.efficient_fig_1
SparseMatrixColorings.efficient_fig_4
```

## Misc

```@docs
SparseMatrixColorings.cycle_range
```
45 changes: 45 additions & 0 deletions ext/SparseMatrixColoringsBandedMatricesExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
module SparseMatrixColoringsBandedMatricesExt

using BandedMatrices: BandedMatrix, bandrange, bandwidths, colrange, rowrange
using SparseMatrixColorings:
BipartiteGraph,
ColoringProblem,
ColumnColoringResult,
StructuredColoringAlgorithm,
RowColoringResult,
column_colors,
cycle_range,
row_colors
import SparseMatrixColorings as SMC

#=
This code is partly taken from ArrayInterface.jl and FiniteDiff.jl
https://github.com/JuliaArrays/ArrayInterface.jl
https://github.com/JuliaDiff/FiniteDiff.jl
=#

function SMC.coloring(

Check warning on line 21 in ext/SparseMatrixColoringsBandedMatricesExt.jl

View check run for this annotation

Codecov / codecov/patch

ext/SparseMatrixColoringsBandedMatricesExt.jl#L21

Added line #L21 was not covered by tests
A::BandedMatrix,
::ColoringProblem{:nonsymmetric,:column},
::StructuredColoringAlgorithm;
kwargs...,
)
width = length(bandrange(A))
color = cycle_range(width, size(A, 2))
bg = BipartiteGraph(A)
return ColumnColoringResult(A, bg, color)

Check warning on line 30 in ext/SparseMatrixColoringsBandedMatricesExt.jl

View check run for this annotation

Codecov / codecov/patch

ext/SparseMatrixColoringsBandedMatricesExt.jl#L27-L30

Added lines #L27 - L30 were not covered by tests
end

function SMC.coloring(

Check warning on line 33 in ext/SparseMatrixColoringsBandedMatricesExt.jl

View check run for this annotation

Codecov / codecov/patch

ext/SparseMatrixColoringsBandedMatricesExt.jl#L33

Added line #L33 was not covered by tests
A::BandedMatrix,
::ColoringProblem{:nonsymmetric,:row},
::StructuredColoringAlgorithm;
kwargs...,
)
width = length(bandrange(A))
color = cycle_range(width, size(A, 1))
bg = BipartiteGraph(A)
return RowColoringResult(A, bg, color)

Check warning on line 42 in ext/SparseMatrixColoringsBandedMatricesExt.jl

View check run for this annotation

Codecov / codecov/patch

ext/SparseMatrixColoringsBandedMatricesExt.jl#L39-L42

Added lines #L39 - L42 were not covered by tests
end

end
97 changes: 97 additions & 0 deletions ext/SparseMatrixColoringsBlockBandedMatricesExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
module SparseMatrixColoringsBlockBandedMatricesExt

using BlockArrays: blockaxes, blockfirsts, blocklasts, blocksize, blocklengths
using BlockBandedMatrices:
BandedBlockBandedMatrix,
BlockBandedMatrix,
blockbandrange,
blockbandwidths,
blocklengths,
blocksize,
subblockbandwidths
using SparseMatrixColorings:
BipartiteGraph,
ColoringProblem,
ColumnColoringResult,
StructuredColoringAlgorithm,
RowColoringResult,
column_colors,
cycle_range,
row_colors
import SparseMatrixColorings as SMC

#=
This code is partly taken from ArrayInterface.jl and FiniteDiff.jl
https://github.com/JuliaArrays/ArrayInterface.jl
https://github.com/JuliaDiff/FiniteDiff.jl
=#

function subblockbandrange(A::BandedBlockBandedMatrix)
u, l = subblockbandwidths(A)
return (-l):u

Check warning on line 31 in ext/SparseMatrixColoringsBlockBandedMatricesExt.jl

View check run for this annotation

Codecov / codecov/patch

ext/SparseMatrixColoringsBlockBandedMatricesExt.jl#L29-L31

Added lines #L29 - L31 were not covered by tests
end

function blockbanded_coloring(

Check warning on line 34 in ext/SparseMatrixColoringsBlockBandedMatricesExt.jl

View check run for this annotation

Codecov / codecov/patch

ext/SparseMatrixColoringsBlockBandedMatricesExt.jl#L34

Added line #L34 was not covered by tests
A::Union{BlockBandedMatrix,BandedBlockBandedMatrix}, dim::Integer
)
# consider blocks of columns or rows (let's call them vertices) depending on `dim`
nb_blocks = blocksize(A, dim)
nb_in_block = blocklengths(axes(A, dim))
first_in_block = blockfirsts(axes(A, dim))
last_in_block = blocklasts(axes(A, dim))
color = zeros(Int, size(A, dim))

Check warning on line 42 in ext/SparseMatrixColoringsBlockBandedMatricesExt.jl

View check run for this annotation

Codecov / codecov/patch

ext/SparseMatrixColoringsBlockBandedMatricesExt.jl#L38-L42

Added lines #L38 - L42 were not covered by tests

# give a macroscopic color to each block, so that 2 blocks with the same macro color are orthogonal
# same idea as for BandedMatrices
nb_macrocolors = length(blockbandrange(A))
macrocolor = cycle_range(nb_macrocolors, nb_blocks)

Check warning on line 47 in ext/SparseMatrixColoringsBlockBandedMatricesExt.jl

View check run for this annotation

Codecov / codecov/patch

ext/SparseMatrixColoringsBlockBandedMatricesExt.jl#L46-L47

Added lines #L46 - L47 were not covered by tests

width = if A isa BandedBlockBandedMatrix

Check warning on line 49 in ext/SparseMatrixColoringsBlockBandedMatricesExt.jl

View check run for this annotation

Codecov / codecov/patch

ext/SparseMatrixColoringsBlockBandedMatricesExt.jl#L49

Added line #L49 was not covered by tests
# vertices within a block are colored cleverly using bands
length(subblockbandrange(A))

Check warning on line 51 in ext/SparseMatrixColoringsBlockBandedMatricesExt.jl

View check run for this annotation

Codecov / codecov/patch

ext/SparseMatrixColoringsBlockBandedMatricesExt.jl#L51

Added line #L51 was not covered by tests
else
# vertices within a block are colored naively with distinct micro colors (~ infinite band width)
typemax(Int)

Check warning on line 54 in ext/SparseMatrixColoringsBlockBandedMatricesExt.jl

View check run for this annotation

Codecov / codecov/patch

ext/SparseMatrixColoringsBlockBandedMatricesExt.jl#L54

Added line #L54 was not covered by tests
end

# for each macroscopic color, count how many microscopic colors will be needed
nb_colors_in_macrocolor = zeros(Int, nb_macrocolors)
for mc in 1:nb_macrocolors
largest_nb_in_macrocolor = maximum(nb_in_block[mc:nb_macrocolors:nb_blocks]; init=0)
nb_colors_in_macrocolor[mc] = min(width, largest_nb_in_macrocolor)
end
color_shift_in_macrocolor = vcat(0, cumsum(nb_colors_in_macrocolor)[1:(end - 1)])

Check warning on line 63 in ext/SparseMatrixColoringsBlockBandedMatricesExt.jl

View check run for this annotation

Codecov / codecov/patch

ext/SparseMatrixColoringsBlockBandedMatricesExt.jl#L58-L63

Added lines #L58 - L63 were not covered by tests

# assign a microscopic color to each column as a function of its macroscopic color and its position within the block
for b in 1:nb_blocks
block_color = cycle_range(width, nb_in_block[b])
shift = color_shift_in_macrocolor[macrocolor[b]]
color[first_in_block[b]:last_in_block[b]] .= shift .+ block_color
end

Check warning on line 70 in ext/SparseMatrixColoringsBlockBandedMatricesExt.jl

View check run for this annotation

Codecov / codecov/patch

ext/SparseMatrixColoringsBlockBandedMatricesExt.jl#L66-L70

Added lines #L66 - L70 were not covered by tests

return color

Check warning on line 72 in ext/SparseMatrixColoringsBlockBandedMatricesExt.jl

View check run for this annotation

Codecov / codecov/patch

ext/SparseMatrixColoringsBlockBandedMatricesExt.jl#L72

Added line #L72 was not covered by tests
end

function SMC.coloring(

Check warning on line 75 in ext/SparseMatrixColoringsBlockBandedMatricesExt.jl

View check run for this annotation

Codecov / codecov/patch

ext/SparseMatrixColoringsBlockBandedMatricesExt.jl#L75

Added line #L75 was not covered by tests
A::Union{BlockBandedMatrix,BandedBlockBandedMatrix},
::ColoringProblem{:nonsymmetric,:column},
::StructuredColoringAlgorithm;
kwargs...,
)
color = blockbanded_coloring(A, 2)
bg = BipartiteGraph(A)
return ColumnColoringResult(A, bg, color)

Check warning on line 83 in ext/SparseMatrixColoringsBlockBandedMatricesExt.jl

View check run for this annotation

Codecov / codecov/patch

ext/SparseMatrixColoringsBlockBandedMatricesExt.jl#L81-L83

Added lines #L81 - L83 were not covered by tests
end

function SMC.coloring(

Check warning on line 86 in ext/SparseMatrixColoringsBlockBandedMatricesExt.jl

View check run for this annotation

Codecov / codecov/patch

ext/SparseMatrixColoringsBlockBandedMatricesExt.jl#L86

Added line #L86 was not covered by tests
A::Union{BlockBandedMatrix,BandedBlockBandedMatrix},
::ColoringProblem{:nonsymmetric,:row},
::StructuredColoringAlgorithm;
kwargs...,
)
color = blockbanded_coloring(A, 1)
bg = BipartiteGraph(A)
return RowColoringResult(A, bg, color)

Check warning on line 94 in ext/SparseMatrixColoringsBlockBandedMatricesExt.jl

View check run for this annotation

Codecov / codecov/patch

ext/SparseMatrixColoringsBlockBandedMatricesExt.jl#L92-L94

Added lines #L92 - L94 were not covered by tests
end

end
5 changes: 4 additions & 1 deletion src/SparseMatrixColorings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ using Base.Iterators: Iterators
using DocStringExtensions: README, EXPORTS, SIGNATURES, TYPEDEF, TYPEDFIELDS
using LinearAlgebra:
Adjoint,
Bidiagonal,
Diagonal,
Hermitian,
LowerTriangular,
Symmetric,
Transpose,
Tridiagonal,
UpperTriangular,
adjoint,
checksquare,
Expand Down Expand Up @@ -53,6 +55,7 @@ include("interface.jl")
include("constant.jl")
include("adtypes.jl")
include("decompression.jl")
include("structured.jl")
include("check.jl")
include("examples.jl")
include("show_colors.jl")
Expand All @@ -63,7 +66,7 @@ export NaturalOrder, RandomOrder, LargestFirst
export DynamicDegreeBasedOrder, SmallestLast, IncidenceDegree, DynamicLargestFirst
export PerfectEliminationOrder
export ColoringProblem, GreedyColoringAlgorithm, AbstractColoringResult
export ConstantColoringAlgorithm
export ConstantColoringAlgorithm, StructuredColoringAlgorithm
export coloring, fast_coloring
export column_colors, row_colors, ncolors
export column_groups, row_groups
Expand Down
Loading
Loading