Skip to content

Commit

Permalink
handle combination of static and nonstatic in Rk4
Browse files Browse the repository at this point in the history
  • Loading branch information
baggepinnen committed Oct 6, 2023
1 parent b50a1f9 commit 24d6bed
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "SeeToDee"
uuid = "1c904df7-48cd-41e7-921b-d889ed9a470c"
authors = ["Fredrik Bagge Carlson"]
version = "1.1.1"
version = "1.1.2"

[deps]
FastGaussQuadrature = "442a2c76-b920-505d-bb47-c5924d526838"
Expand Down
4 changes: 3 additions & 1 deletion src/SeeToDee.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function _inner_rk4(integ::Rk4{F}, f1, x, u, p, t; Ts=integ.Ts, supersample=inte
f4 = f(xi, u, p, t + Ts2)
xi .= (Ts2 / 6) .* (f1 .+ 2 .* f2 .+ 2 .* f3 .+ f4)
# This gymnastics with changing the name to y is to ensure type stability when x + add is not the same type as x. The compiler is smart enough to figure out the type of y
y = x + xi
y = _mutable(x + xi) # If x is non-static but xi isn't, we get a static array and adding to y won't work
for i in 2:supersample
f1 = f(y, u, p, t)
xi = y .+ (Ts2 / 2) .* f1
Expand All @@ -93,6 +93,8 @@ function _inner_rk4(integ::Rk4{F}, f1, x, u, p, t; Ts=integ.Ts, supersample=inte
return y
end

_mutable(x::StaticArray) = Array(x)
_mutable(x::AbstractArray) = x

# ==============================================================================

Expand Down

2 comments on commit 24d6bed

@baggepinnen
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/92928

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.1.2 -m "<description of version>" 24d6bede1161933f7c2cab47b4bb6b46a61f7672
git push origin v1.1.2

Please sign in to comment.