-
-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: DataInterpolations doesn't need to be a main dep
- Loading branch information
Showing
6 changed files
with
32 additions
and
18 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
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,19 @@ | ||
module DiffEqFluxDataInterpolationsExt | ||
|
||
using DataInterpolations: DataInterpolations | ||
using DiffEqFlux: DiffEqFlux | ||
|
||
@views function DiffEqFlux.collocate_data( | ||
data::AbstractMatrix{T}, tpoints::AbstractVector{T}, | ||
tpoints_sample::AbstractVector{T}, interp, args...) where {T} | ||
u = zeros(T, size(data, 1), length(tpoints_sample)) | ||
du = zeros(T, size(data, 1), length(tpoints_sample)) | ||
for d1 in axes(data, 1) | ||
interpolation = interp(data[d1, :], tpoints, args...) | ||
u[d1, :] .= interpolation.(tpoints_sample) | ||
du[d1, :] .= DataInterpolations.derivative.((interpolation,), tpoints_sample) | ||
end | ||
return du, u | ||
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