-
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move JacobianCache into NonlinearSolveBase
- Loading branch information
Showing
23 changed files
with
374 additions
and
317 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
lib/NonlinearSolveBase/ext/NonlinearSolveBaseSparseArraysExt.jl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
module NonlinearSolveBaseSparseArraysExt | ||
|
||
using NonlinearSolveBase: NonlinearSolveBase | ||
using SparseArrays: AbstractSparseMatrixCSC, nonzeros | ||
using SparseArrays: AbstractSparseMatrix, AbstractSparseMatrixCSC, nonzeros | ||
|
||
function NonlinearSolveBase.NAN_CHECK(x::AbstractSparseMatrixCSC) | ||
return any(NonlinearSolveBase.NAN_CHECK, nonzeros(x)) | ||
end | ||
|
||
NonlinearSolveBase.sparse_or_structured_prototype(::AbstractSparseMatrix) = true | ||
|
||
end |
22 changes: 22 additions & 0 deletions
22
lib/NonlinearSolveBase/ext/NonlinearSolveBaseSparseMatrixColoringsExt.jl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module NonlinearSolveBaseSparseMatrixColoringsExt | ||
|
||
using ADTypes: ADTypes, AbstractADType | ||
using NonlinearSolveBase: NonlinearSolveBase, Utils | ||
using SciMLBase: SciMLBase, NonlinearFunction | ||
using SparseMatrixColorings: ConstantColoringAlgorithm, GreedyColoringAlgorithm, | ||
LargestFirst | ||
|
||
Utils.is_extension_loaded(::Val{:SparseMatrixColorings}) = true | ||
|
||
function NonlinearSolveBase.select_fastest_coloring_algorithm(::Val{:SparseMatrixColorings}, | ||
prototype, f::NonlinearFunction, ad::AbstractADType) | ||
prototype === nothing && return GreedyColoringAlgorithm(LargestFirst()) | ||
if SciMLBase.has_colorvec(f) | ||
return ConstantColoringAlgorithm{ifelse( | ||
ADTypes.mode(ad) isa ADTypes.ReverseMode, :row, :column)}( | ||
prototype, f.colorvec) | ||
end | ||
return GreedyColoringAlgorithm(LargestFirst()) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.