Skip to content

Commit

Permalink
Update documentation and docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
SouthEndMusic committed Jul 6, 2024
1 parent 1466240 commit 947aefb
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 10 deletions.
8 changes: 4 additions & 4 deletions docs/src/inverting_integrals.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# Inverting integrals

Solving implicit integral problems of the form:
Solving implicit integral problems of the following form is supported:

```math
\begin{equation}
\text{find $t$ such that } \int_{t_1}^t f(\tau)\text{d}\tau = V \ge 0
\text{find $t$ such that } \int_{t_1}^t f(\tau)\text{d}\tau = V \ge 0,
\end{equation}
```

is supported for interpolations $f$ that are strictly positive and of one of these types:
where $t_1$ is given by `first(A.t)`. This is supported for interpolations $f$ that are strictly positive and of one of these types:

- `ConstantInterpolation`
- `LinearInterpolation`

This is done by creating an 'integral inverse' interpolation object which can efficiently compute $t$ for a given value of $V$, see the example below.
This is achieved by creating an 'integral inverse' interpolation object which can efficiently compute $t$ for a given value of $V$, see the example below.

```@example inverting_integrals
using Random #hide
Expand Down
32 changes: 26 additions & 6 deletions src/integral_inverses.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ abstract type AbstractIntegralInverseInterpolation{T} <: AbstractInterpolation{T
Creates the inverted integral interpolation object from the given interpolation. Conditions:
- The range of `A` must be strictly positive
- There must be an ordering defined on the data type of `A.u`
- This is currently only supported for ConstantInterpolation and LinearInterpolation
- `A.u` must be a number type (on which an ordering is defined)
- This is currently only supported for `ConstantInterpolation` and `LinearInterpolation`
## Arguments
Expand All @@ -22,7 +22,16 @@ function _derivative(A::AbstractIntegralInverseInterpolation, t::Number, iguess)
end

"""
some stuff
LinearInterpolationIntInv(u, t, A)
It is the interpolation of the inverse of the integral of a `LinearInterpolation`.
Can be easily constructed with `invert_integral(A::LinearInterpolation{<:AbstractVector{<:Number}})`
## Arguments
- `u` : Given by `A.t`
- `t` : Given by `A.I` (the cumulative integral of `A`)
- `A` : The `LinearInterpolation` object
"""
struct LinearInterpolationIntInv{uType, tType, itpType, T} <:
AbstractIntegralInverseInterpolation{T}
Expand All @@ -31,9 +40,10 @@ struct LinearInterpolationIntInv{uType, tType, itpType, T} <:
extrapolate::Bool
idx_prev::Base.RefValue{Int}
itp::itpType
safetycopy::Bool
function LinearInterpolationIntInv(u, t, A)
new{typeof(u), typeof(t), typeof(A), eltype(u)}(
u, t, A.extrapolate, Ref(1), A)
u, t, A.extrapolate, Ref(1), A, A.safetycopy)
end
end

Expand All @@ -56,7 +66,16 @@ function _interpolate(
end

"""
some stuff
ConstantInterpolationIntInv(u, t, A)
It is the interpolation of the inverse of the integral of a `ConstantInterpolation`.
Can be easily constructed with `invert_integral(A::ConstantInterpolation{<:AbstractVector{<:Number}})`
## Arguments
- `u` : Given by `A.t`
- `t` : Given by `A.I` (the cumulative integral of `A`)
- `A` : The `ConstantInterpolation` object
"""
struct ConstantInterpolationIntInv{uType, tType, itpType, T} <:
AbstractIntegralInverseInterpolation{T}
Expand All @@ -65,9 +84,10 @@ struct ConstantInterpolationIntInv{uType, tType, itpType, T} <:
extrapolate::Bool
idx_prev::Base.RefValue{Int}
itp::itpType
safetycopy::Bool
function ConstantInterpolationIntInv(u, t, A)
new{typeof(u), typeof(t), typeof(A), eltype(u)}(
u, t, A.extrapolate, Ref(1), A
u, t, A.extrapolate, Ref(1), A, A.safetycopy
)
end
end
Expand Down

0 comments on commit 947aefb

Please sign in to comment.