Skip to content

Potentially fix dropped values in DI sparse diff#2655

Closed
ChrisRackauckas wants to merge 1 commit intomasterfrom
ChrisRackauckas-patch-2
Closed

Potentially fix dropped values in DI sparse diff#2655
ChrisRackauckas wants to merge 1 commit intomasterfrom
ChrisRackauckas-patch-2

Conversation

@ChrisRackauckas
Copy link
Copy Markdown
Member

No description provided.

!isnothing(jac_config) ?
convert.(
eltype(u), SparseMatrixColorings.sparsity_pattern(jac_config[1])) :
eltype(u), SparseMatrixColorings.sparsity_pattern(abs.(jac_config[1]) .+ abs.(f.mass_matrix)):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
eltype(u), SparseMatrixColorings.sparsity_pattern(abs.(jac_config[1]) .+ abs.(f.mass_matrix)):
eltype(u), SparseMatrixColorings.sparsity_pattern(abs.(jac_config[1]) .+ abs.(f.mass_matrix))):
ERROR: LoadError: ParseError:
# Error @ OrdinaryDiffEqDifferentiation\vCvMi\src\derivative_utils.jl:771:17
                    spzeros(eltype(u), length(u), length(u))
                elseif eltype(f.sparsity) == Bool
#               └ ── Expected `)`


if isnothing(f.sparsity)
!isnothing(jac_config) ? convert.(eltype(u), SparseMatrixColorings.sparsity_pattern(jac_config[1])) :
!isnothing(jac_config) ? convert.(eltype(u), SparseMatrixColorings.sparsity_pattern(abs.(jac_config[1]) .+ abs.(f.mass_matrix)) :
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
!isnothing(jac_config) ? convert.(eltype(u), SparseMatrixColorings.sparsity_pattern(abs.(jac_config[1]) .+ abs.(f.mass_matrix)) :
!isnothing(jac_config) ? convert.(eltype(u), SparseMatrixColorings.sparsity_pattern(abs.(jac_config[1]) .+ abs.(f.mass_matrix))) :

@gdalle
Copy link
Copy Markdown
Contributor

gdalle commented Apr 2, 2025

This fix won't work, the key is to give the right sparsity pattern to DI from the start so that it is reflected in jac_config, not to modify what's there a posteriori. I'm still thinking

@ChrisRackauckas ChrisRackauckas deleted the ChrisRackauckas-patch-2 branch April 3, 2025 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants