Skip to content

Commit

Permalink
Remove nnz_colors in sparsity_pattern.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
amontoison committed Sep 25, 2024
1 parent 1a5dd72 commit 881d145
Showing 1 changed file with 0 additions and 34 deletions.
34 changes: 0 additions & 34 deletions src/sparsity_pattern.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,37 +51,3 @@ function compute_hessian_sparsity(
S = ADTypes.hessian_sparsity(lagrangian, x0, detector)
return S
end

"""
dcolors = nnz_colors(trilH, star_set, colors, ncolors)
Determine the coefficients in `trilH` that will be computed by a given color.
Arguments:
- `trilH::SparseMatrixCSC`: The lower triangular part of a symmetric matrix in CSC format.
- `star_set::StarSet`: A structure `StarSet` returned by the function `symmetric_coloring_detailed` of SparseMatrixColorings.jl.
- `colors::Vector{Int}`: A vector where the i-th entry represents the color assigned to the i-th column of the matrix.
- `ncolors::Int`: The number of distinct colors used in the coloring.
Output:
- `dcolors::Dict{Int, Vector{Tuple{Int, Int}}}`: A dictionary where the keys are the color indices (from 1 to `ncolors`),
and the values are vectors of tuples. Each tuple contains two integers: the first integer is the row index, and the
second integer is the index in `trilH.nzval` where the non-zero coefficient can be found.
"""
function nnz_colors(trilH, star_set, colors, ncolors)
# We want to determine the coefficients in `trilH` that will be computed by a given color.
# Because we exploit the symmetry, we also need to store the row index for a given coefficient
# in the "compressed column".
dcolors = Dict(i => Tuple{Int, Int}[] for i = 1:ncolors)

n = LinearAlgebra.checksquare(trilH)
for j = 1:n
for k = trilH.colptr[j]:(trilH.colptr[j + 1] - 1)
i = trilH.rowval[k]
l, c = symmetric_coefficient(i, j, colors, star_set)
push!(dcolors[c], (l, k))
end
end

return dcolors
end

0 comments on commit 881d145

Please sign in to comment.