Skip to content

Commit

Permalink
Integrals POC
Browse files Browse the repository at this point in the history
  • Loading branch information
SouthEndMusic committed Nov 22, 2024
1 parent 0c3b360 commit d547e32
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/integrals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,25 @@ function _extrapolate_integral_down(A, t)
(first(A.u) - slope * Δt / 2) * Δt
elseif extrapolation_left == ExtrapolationType.extension
_integral(A, 1, t, first(A.t))
elseif extrapolation_left == ExtrapolationType.periodic
t_, n = transformation_periodic(A, t)
out = -integral(A, t_)
if !iszero(n)
out -= n * integral(A, first(A.t), last(A.t))
end
out
else
# extrapolation_left == ExtrapolationType.reflective
t_, n = transformation_reflective(A, t)
out = if isodd(n)
-integral(A, t_, last(A.t))
else
-integral(A, t_)
end
if !iszero(n)
out -= n * integral(A, first(A.t), last(A.t))
end
out
end
end

Expand All @@ -89,6 +108,25 @@ function _extrapolate_integral_up(A, t)
(last(A.u) + slope * Δt / 2) * Δt
elseif extrapolation_right == ExtrapolationType.extension
_integral(A, length(A.t) - 1, last(A.t), t)
elseif extrapolation_right == ExtrapolationType.periodic
t_, n = transformation_periodic(A, t)
out = integral(A, first(A.t), t_)
if !iszero(n)
out += n * integral(A, first(A.t), last(A.t))
end
out
else
# extrapolation_right == ExtrapolationType.reflective
t_, n = transformation_reflective(A, t)
out = if iseven(n)
integral(A, t_, last(A.t))
else
integral(A, t_)
end
if !iszero(n)
out += n * integral(A, first(A.t), last(A.t))
end
out
end
end

Expand Down
2 changes: 2 additions & 0 deletions src/interpolation_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -316,12 +316,14 @@ function transformation_periodic(A, t)
Δt = last(A.t) - first(A.t)
n, t_ = fldmod(t - first(A.t), Δt)
t_ += first(A.t)
(n > 0) && (n -= 1)
t_, n
end

function transformation_reflective(A, t)
Δt = last(A.t) - first(A.t)
n, t_ = fldmod(t - first(A.t), Δt)
t_ = isodd(n) ? last(A.t) - t_ : first(A.t) + t_
(n > 0) && (n -= 1)
t_, n
end

0 comments on commit d547e32

Please sign in to comment.