11using ADTypes: column_coloring, row_coloring, symmetric_coloring
22using Compat
3+ using LinearAlgebra
34using SparseArrays
45using SparseMatrixColorings
5- using SparseMatrixColorings: color_groups, decompress_columns, decompress_rows
6+ using SparseMatrixColorings:
7+ color_groups,
8+ decompress_columns,
9+ decompress_columns!,
10+ decompress_rows,
11+ decompress_rows!,
12+ same_sparsity_pattern
613using StableRNGs
714using Test
815
916rng = StableRNG (63 )
1017
1118algo = GreedyColoringAlgorithm ()
1219
20+ @testset " Sparsity pattern comparison" begin
21+ A = [
22+ 1 1
23+ 0 1
24+ 0 0
25+ ]
26+ B1 = [
27+ 1 1
28+ 0 1
29+ 1 0
30+ ]
31+ B2 = [
32+ 1 1
33+ 0 0
34+ 0 1
35+ ]
36+ C = [
37+ 1 1 0
38+ 0 1 0
39+ 0 0 0
40+ ]
41+
42+ @test same_sparsity_pattern (sparse (A), sparse (A))
43+ @test ! same_sparsity_pattern (sparse (A), sparse (B1))
44+ @test_broken ! same_sparsity_pattern (sparse (A), sparse (B2))
45+ @test ! same_sparsity_pattern (sparse (A), sparse (C))
46+
47+ @test same_sparsity_pattern (transpose (sparse (A)), transpose (sparse (A)))
48+ @test ! same_sparsity_pattern (transpose (sparse (A)), transpose (sparse (B1)))
49+ @test_broken ! same_sparsity_pattern (transpose (sparse (A)), transpose (sparse (B2)))
50+ @test ! same_sparsity_pattern (transpose (sparse (A)), transpose (sparse (C)))
51+ end ;
52+
1353@testset " Column decompression" begin
1454 @testset " Small" begin
1555 A0 = [
@@ -33,6 +73,11 @@ algo = GreedyColoringAlgorithm()
3373 (sparse (A0), sparse (S0)),
3474 ]
3575 @test decompress_columns (S, C, colors) == A
76+ if A isa SparseMatrixCSC
77+ @test_throws DimensionMismatch decompress_columns! (
78+ similar (A), false .* S, C, colors
79+ )
80+ end
3681 end
3782 end
3883 @testset " Medium" begin
76121 (transpose (sparse (transpose (A0))), transpose (sparse (transpose (S0)))),
77122 ]
78123 @test decompress_rows (S, C, colors) == A
124+ if A isa Transpose{<: Any ,<: SparseMatrixCSC }
125+ @test_throws DimensionMismatch decompress_rows! (
126+ transpose (similar (parent (A))), transpose (false .* parent (S)), C, colors
127+ )
128+ end
79129 end
80130 end
81131 @testset " Medium" begin
0 commit comments