Skip to content

Commit c74d773

Browse files
authored
Merge pull request #178 from SciML/finite_diff_update
Update for use with finite differences v0.11
2 parents 4e8ec46 + 99a72e1 commit c74d773

File tree

4 files changed

+5
-8
lines changed

4 files changed

+5
-8
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ DSP = "0.6"
2424
DataInterpolations = "3.1"
2525
DiffEqBase = "6.45"
2626
DocStringExtensions = "0.7, 0.8"
27-
FiniteDifferences = "0.9.6, 0.10"
27+
FiniteDifferences = "0.11"
2828
ModelingToolkit = "4.0.8"
2929
ProximalOperators = "0.11, 0.12, 0.13"
3030
QuadGK = "2.4"

src/koopman/dmdc.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ end
8989
function gDMDc(t::AbstractVector, X::AbstractArray, U::AbstractArray; dt::Real = 0.0, B::AbstractArray = [], alg::DataDrivenDiffEq.AbstractKoopmanAlgorithm = DMDPINV(), fdm::FiniteDifferences.FiniteDifferenceMethod = backward_fdm(5, 1), itp = CubicSpline, itp_u = LinearInterpolation)
9090
@assert size(X, 2) == length(t) "Sample size must match."
9191
@assert test_comp = begin
92-
9392
if itp [LinearInterpolation, QuadraticInterpolation] && !isa(fdm, FiniteDifferences.Backward{typeof(fdm.grid), typeof(fdm.coefs)})
9493
false
9594
else
@@ -104,7 +103,7 @@ function gDMDc(t::AbstractVector, X::AbstractArray, U::AbstractArray; dt::Real =
104103
Y = similar(X̂)
105104
for (i, xi) in enumerate(eachrow(X))
106105
itp_ = itp(xi, t)
107-
dx(t) = FiniteDifferences.fdm(fdm, itp_, t)
106+
dx(t) = fdm(x->itp_(x), t)
108107
X̂[i, :] .= itp_.(t̂)
109108
Y[i, :] .= dx.(t̂)
110109
end

src/koopman/exact_dmd.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ end
6161
function gDMD(t::AbstractVector, X::AbstractArray ; dt::Real = 0.0, alg::DataDrivenDiffEq.AbstractKoopmanAlgorithm = DMDPINV(), fdm::FiniteDifferences.FiniteDifferenceMethod = backward_fdm(5, 1), itp = CubicSpline)
6262
@assert size(X, 2) == length(t) "Sample size must match."
6363
@assert test_comp = begin
64-
6564
if itp [LinearInterpolation, QuadraticInterpolation] && !isa(fdm, FiniteDifferences.Backward{typeof(fdm.grid), typeof(fdm.coefs)})
6665
false
6766
else
@@ -76,7 +75,7 @@ function gDMD(t::AbstractVector, X::AbstractArray ; dt::Real = 0.0, alg::DataDri
7675
Y = similar(X̂)
7776
for (i, xi) in enumerate(eachrow(X))
7877
itp_ = itp(xi, t)
79-
dx(t) = FiniteDifferences.fdm(fdm, itp_, t)
78+
dx(t) = fdm(x->itp_(x), t)
8079
X̂[i, :] .= itp_.(t̂)
8180
Y[i, :] .= dx.(t̂)
8281
end

src/koopman/extended_dmd.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ function gEDMD(X::AbstractArray, DX::AbstractArray, Ψ::Basis; p::AbstractArray
5656
N,M = size(X)
5757

5858
# Compute the transformed data
59-
59+
6060
# Compute the transformed data
6161
Ψ₀ = zeros(eltype(X), length(Ψ), size(X, 2))
6262
Ψ(Ψ₀, X, p, t)
@@ -104,7 +104,6 @@ koopman = gEDMD(t, X, basis, fdm = fdm, itp = itp)
104104
function gEDMD(t::AbstractVector, X::AbstractArray, Ψ::Basis; dt::Real = 0.0, p::AbstractArray = [], C::AbstractArray = [], alg::DataDrivenDiffEq.AbstractKoopmanAlgorithm = DMDPINV(), fdm::FiniteDifferences.FiniteDifferenceMethod = backward_fdm(5, 1), itp = CubicSpline)
105105
@assert size(X, 2) == length(t) "Sample size must match."
106106
@assert test_comp = begin
107-
108107
if itp [LinearInterpolation, QuadraticInterpolation, QuadraticSpline] && !isa(fdm, FiniteDifferences.Backward{typeof(fdm.grid), typeof(fdm.coefs)})
109108
false
110109
else
@@ -119,7 +118,7 @@ function gEDMD(t::AbstractVector, X::AbstractArray, Ψ::Basis; dt::Real = 0.0, p
119118
Y = similar(X̂)
120119
for (i, xi) in enumerate(eachrow(X))
121120
itp_ = itp(xi, t)
122-
dx(t) = FiniteDifferences.fdm(fdm, itp_, t)
121+
dx(t) = fdm(x->itp_(x), t)
123122
X̂[i, :] .= itp_.(t̂)
124123
Y[i, :] .= dx.(t̂)
125124
end

0 commit comments

Comments
 (0)