Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove nnz_colors in sparsity_pattern.jl #304

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Changes from all commits
Commits
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
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
Loading