diff --git a/docs/src/inverting_integrals.md b/docs/src/inverting_integrals.md index 8cbfcc3e..4f0380d4 100644 --- a/docs/src/inverting_integrals.md +++ b/docs/src/inverting_integrals.md @@ -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 diff --git a/src/integral_inverses.jl b/src/integral_inverses.jl index 1e2ca581..4437726e 100644 --- a/src/integral_inverses.jl +++ b/src/integral_inverses.jl @@ -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 @@ -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} @@ -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 @@ -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} @@ -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