-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #102 from JuliaDynamics/add_tests
- Loading branch information
Showing
10 changed files
with
99 additions
and
195 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
diagonal_cov(l) = Diagonal(ones(l)) | ||
|
||
""" | ||
$(TYPEDSIGNATURES) | ||
Translates the stochastic process specified in `sys` into the language required by the | ||
`SDEProblem` of `DynamicalSystems.jl`. | ||
""" | ||
function noise_process(sys::CoupledSDEs) | ||
return sys.integ.W | ||
end | ||
|
||
""" | ||
$(TYPEDSIGNATURES) | ||
Gives the covariance matrix specified in `sys`. | ||
""" | ||
function covariance_matrix(sys::CoupledSDEs) | ||
noise = noise_process(sys) | ||
covariance = isnothing(noise) ? nothing : noise.covariance | ||
if isnothing(noise) || isnothing(covariance) | ||
return diagonal_cov(dimension(sys)) | ||
else | ||
return covariance | ||
end | ||
end | ||
|
||
""" | ||
$(TYPEDSIGNATURES) | ||
Gives the noise strength specified in `sys`. | ||
""" | ||
function noise_strength(sys::CoupledSDEs) | ||
return sys.noise_strength | ||
end | ||
|
||
""" | ||
$(TYPEDSIGNATURES) | ||
Returns the drift field ``b(x)`` of the CoupledSDEs `sys` at the state vector `x`. | ||
""" | ||
function drift(sys::CoupledSDEs{IIP}, x) where {IIP} | ||
# assumes the drift is time independent | ||
f = dynamic_rule(sys) | ||
if IIP | ||
dx = similar(x) | ||
f(dx, x, sys.p0, 0) | ||
return dx | ||
else | ||
return f(x, sys.p0, 0) | ||
end | ||
end | ||
|
||
""" | ||
$(TYPEDSIGNATURES) | ||
Computes the divergence of the drift field `sys.f` at the given point `x`. | ||
""" | ||
function div_drift(sys::CoupledSDEs, x) | ||
b(x) = drift(sys, x) | ||
return tr(ForwardDiff.jacobian(b, x)) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1 @@ | ||
diagonal_cov(l) = Diagonal(ones(l)) | ||
|
||
""" | ||
$(TYPEDSIGNATURES) | ||
Translates the stochastic process specified in `sys` into the language required by the | ||
`SDEProblem` of `DynamicalSystems.jl`. | ||
""" | ||
function noise_process(sys::CoupledSDEs) | ||
return sys.integ.W | ||
end | ||
|
||
""" | ||
$(TYPEDSIGNATURES) | ||
Gives the covariance matrix specified in `sys`. | ||
""" | ||
function covariance_matrix(sys::CoupledSDEs) | ||
noise = noise_process(sys) | ||
covariance = isnothing(noise) ? nothing : noise.covariance | ||
if isnothing(noise) || isnothing(covariance) | ||
return diagonal_cov(dimension(sys)) | ||
else | ||
return covariance | ||
end | ||
end | ||
|
||
""" | ||
$(TYPEDSIGNATURES) | ||
Gives the noise strength specified in `sys`. | ||
""" | ||
function noise_strength(sys::CoupledSDEs) | ||
return sys.noise_strength | ||
end | ||
|
||
""" | ||
$(TYPEDSIGNATURES) | ||
Returns the drift field ``b(x)`` of the CoupledSDEs `sys` at the state vector `x`. | ||
""" | ||
function drift(sys::CoupledSDEs{IIP}, x) where {IIP} | ||
# assumes the drift is time independent | ||
f = dynamic_rule(sys) | ||
if IIP | ||
dx = similar(x) | ||
f(dx, x, sys.p0, 0) | ||
return dx | ||
else | ||
return f(x, sys.p0, 0) | ||
end | ||
end | ||
|
||
""" | ||
$(TYPEDSIGNATURES) | ||
Computes the divergence of the drift field `sys.f` at the given point `x`. | ||
""" | ||
function div_drift(sys::CoupledSDEs, x) | ||
b(x) = drift(sys, x) | ||
return tr(ForwardDiff.jacobian(b, x)) | ||
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
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.