Skip to content

Commit 87508b9

Browse files
authored
Add doctest to decompress_single_color! (#82)
* Add doctest to `decompress_single_color!` * Typo
1 parent 8501655 commit 87508b9

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

src/decompression.jl

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,46 @@ Decompress the vector `b` corresponding to color `c` in-place into `A`, given a
198198
!!! warning
199199
This function will only update some coefficients of `A`, without resetting the rest to zero.
200200
201+
# Example
202+
203+
```jldoctest
204+
julia> using SparseMatrixColorings, SparseArrays
205+
206+
julia> A = sparse([
207+
0 0 4 6 0 9
208+
1 0 0 0 7 0
209+
0 2 0 0 8 0
210+
0 3 5 0 0 0
211+
]);
212+
213+
julia> result = coloring(A, ColoringProblem(), GreedyColoringAlgorithm());
214+
215+
julia> column_groups(result)
216+
3-element Vector{Vector{Int64}}:
217+
[1, 2, 4]
218+
[3, 5]
219+
[6]
220+
221+
julia> B = compress(A, result)
222+
4×3 Matrix{Int64}:
223+
6 4 9
224+
1 7 0
225+
2 8 0
226+
3 5 0
227+
228+
julia> A2 = similar(A); A2 .= 0;
229+
230+
julia> decompress_single_color!(A2, B[:, 2], 2, result)
231+
4×6 SparseMatrixCSC{Int64, Int64} with 9 stored entries:
232+
⋅ ⋅ 4 0 ⋅ 0
233+
0 ⋅ ⋅ ⋅ 7 ⋅
234+
⋅ 0 ⋅ ⋅ 8 ⋅
235+
⋅ 0 5 ⋅ ⋅ ⋅
236+
237+
julia> A2[:, [3, 5]] == A[:, [3, 5]]
238+
true
239+
```
240+
201241
# See also
202242
203243
- [`ColoringProblem`](@ref)

0 commit comments

Comments
 (0)