JuliaDiff / SparseDiffTools.jl

Fast jacobian computation through sparsity exploitation and matrix coloring
MIT License
237 stars 41 forks source link

matrix_colors can overwrite input (remove stored zeros) #144

Closed sjdaines closed 3 years ago

sjdaines commented 3 years ago

The culprit would appear to be:

 function matrix2graph(sparse_matrix::SparseMatrixCSC{<:Number, Int}, partition_by_rows::Bool=true)

    dropzeros!(sparse_matrix)

Not sure what the correct fix is. Perhaps two reasonable options ?

  1. test for stored zeros, and error if present, or
  2. treat stored zeros as structural nonzeros

However silently calling dropzeros! and modifying the input is surely wrong...

ChrisRackauckas commented 3 years ago

Oh, that dropzeros! is just wrong. Thanks for finding it. We should remove that. Coloring should only be w.r.t. structural zeros.

ChrisRackauckas commented 3 years ago

Thanks a lot. This is a good find.