Skip to content

Commit

Permalink
Merge a983a38 into b4fa3f6
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCap23 committed Feb 18, 2020
2 parents b4fa3f6 + a983a38 commit cc912cf
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/dmdc.jl
Expand Up @@ -7,7 +7,8 @@ mutable struct DMDc{K, B, Q, P} <: abstractKoopmanOperator
end


function DMDc(X::AbstractArray, Y::AbstractArray, U::AbstractArray; B::AbstractArray = [], dt::Float64 = 0.0)
function DMDc(X::AbstractArray, Y::AbstractArray, U::AbstractArray; B::AbstractArray = [], dt::T = 0.0) where T <: Real
@assert dt >= zero(dt)
@assert all(size(X) .== size(Y))
@assert size(X)[2] .== size(U)[2]

Expand Down Expand Up @@ -44,7 +45,7 @@ function DMDc(X::AbstractArray, Y::AbstractArray, U::AbstractArray; B::AbstractA
end


function DMDc(X::AbstractArray, U::AbstractArray; B::AbstractArray = [], dt::Float64 = 0.0)
function DMDc(X::AbstractArray, U::AbstractArray; B::AbstractArray = [], dt::T = 0.0) where T <: Real
@assert size(X)[2]-1 == size(U)[2] "Provide consistent input data."
return DMDc(X[:, 1:end-1], X[:, 2:end], U, B = B, dt = dt)
end
Expand Down
4 changes: 2 additions & 2 deletions src/extended_dmd.jl
Expand Up @@ -12,11 +12,11 @@ LinearAlgebra.eigen(m::ExtendedDMD) = eigen(m.koopman)
LinearAlgebra.eigvals(m::ExtendedDMD) = eigvals(m.koopman)
LinearAlgebra.eigvecs(m::ExtendedDMD) = eigvecs(m.koopman)

function ExtendedDMD(X::AbstractArray, Ψ::abstractBasis; p::AbstractArray = [], B::AbstractArray = reshape([], 0,0), dt::T = 1.0) where T <: Real
function ExtendedDMD(X::AbstractArray, Ψ::abstractBasis; p::AbstractArray = [], B::AbstractArray = reshape([], 0,0), dt::T = 0.0) where T <: Real
return ExtendedDMD(X[:, 1:end-1], X[:, 2:end], Ψ, p = p, B = B, dt = dt)
end

function ExtendedDMD(X::AbstractArray, Y::AbstractArray, Ψ::abstractBasis; p::AbstractArray = [], B::AbstractArray = reshape([], 0,0), dt::T = 1.0) where T <: Real
function ExtendedDMD(X::AbstractArray, Y::AbstractArray, Ψ::abstractBasis; p::AbstractArray = [], B::AbstractArray = reshape([], 0,0), dt::T = 0.0) where T <: Real
@assert dt >= zero(typeof(dt)) "Provide positive dt"
@assert size(X)[2] .== size(Y)[2] "Provide consistent dimensions for data"
@assert size(Y)[1] .<= size(Y)[2] "Provide consistent dimensions for data"
Expand Down
1 change: 1 addition & 0 deletions src/isindy.jl
Expand Up @@ -5,6 +5,7 @@

# TODO preallocation
function ISInDy(X::AbstractArray, Ẋ::AbstractArray, Ψ::Basis; maxiter::Int64 = 10, rtol::Float64 = 0.99, p::AbstractArray = [], opt::T = ADM()) where T <: DataDrivenDiffEq.Optimise.AbstractSubspaceOptimiser
@assert size(X)[end] == size(Ẋ)[end]
nb = length.basis)

# Compute the library and the corresponding nullspace
Expand Down
4 changes: 2 additions & 2 deletions src/sindy.jl
Expand Up @@ -35,7 +35,7 @@ end

# Returns a basis for the differential state
function SInDy(X::AbstractArray, Ẋ::AbstractArray, Ψ::Basis; p::AbstractArray = [], maxiter::Int64 = 10, opt::T = Optimise.STRRidge()) where T <: Optimise.AbstractOptimiser
@assert size(X) == size(Ẋ)
@assert size(X)[end] == size(Ẋ)[end]
nx, nm = size(X)

Ξ = zeros(eltype(X), length(Ψ), nx)
Expand All @@ -50,7 +50,7 @@ end

# Returns an array of basis for all values of lambda
function SInDy(X::AbstractArray, Ẋ::AbstractArray, Ψ::Basis, thresholds::AbstractArray ; p::AbstractArray = [], maxiter::Int64 = 10, opt::T = Optimise.STRRidge()) where T <: Optimise.AbstractOptimiser
@assert size(X) == size(Ẋ)
@assert size(X)[end] == size(Ẋ)[end]
nx, nm = size(X)

θ = Ψ(X, p = p)
Expand Down

0 comments on commit cc912cf

Please sign in to comment.