From aad60819ea5627d724529276b69f58fb046ea77f Mon Sep 17 00:00:00 2001 From: Bart de Koning Date: Mon, 25 Nov 2024 19:52:45 +0100 Subject: [PATCH] Add to docs --- README.md | 2 +- docs/src/index.md | 2 +- docs/src/manual.md | 1 + docs/src/methods.md | 18 ++++++++++++++++++ src/interpolation_caches.jl | 4 ++-- 5 files changed, 23 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index df100c0d..0dd6635d 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ In all cases, `u` an `AbstractVector` of values and `t` is an `AbstractVector` o corresponding to `(u,t)` pairs. - `ConstantInterpolation(u,t)` - A piecewise constant interpolation. - + - `SmoothedConstantInterpolation(u,t)` - An integral preserving continuously differentiable approximation of constant interpolation. - `LinearInterpolation(u,t)` - A linear interpolation. - `QuadraticInterpolation(u,t)` - A quadratic interpolation. - `LagrangeInterpolation(u,t,n)` - A Lagrange interpolation of order `n`. diff --git a/docs/src/index.md b/docs/src/index.md index 1b19d50f..e74bbd8b 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -17,7 +17,7 @@ In all cases, `u` an `AbstractVector` of values and `t` is an `AbstractVector` o corresponding to `(u,t)` pairs. - `ConstantInterpolation(u,t)` - A piecewise constant interpolation. - + - `SmoothedConstantInterpolation(u,t)` - An integral preserving continuously differentiable approximation of constant interpolation. - `LinearInterpolation(u,t)` - A linear interpolation. - `QuadraticInterpolation(u,t)` - A quadratic interpolation. - `LagrangeInterpolation(u,t,n)` - A Lagrange interpolation of order `n`. diff --git a/docs/src/manual.md b/docs/src/manual.md index 3818a9e3..e599fad9 100644 --- a/docs/src/manual.md +++ b/docs/src/manual.md @@ -6,6 +6,7 @@ QuadraticInterpolation LagrangeInterpolation AkimaInterpolation ConstantInterpolation +SmoothedConstantInterpolation QuadraticSpline CubicSpline BSplineInterpolation diff --git a/docs/src/methods.md b/docs/src/methods.md index 648131eb..ae2e17d3 100644 --- a/docs/src/methods.md +++ b/docs/src/methods.md @@ -77,6 +77,24 @@ A = ConstantInterpolation(u, t, dir = :right) plot(A) ``` +## Smoothed Constant Interpolation + +This function is much like the constant interpolation above, but the transition +between consecutive values is smoothed out so that the function is continuously +differentiable. The smoothing is done in such a way that the integral of this function +is never much off from the same integral of constant interpolation without smoothing (because of the symmetry of the smoothing sections). +The maximum smoothing distance in the `t` direction from the data points can be set +with the keyword argument `d_max`. + +```@example tutorial +A = ConstantInterpolation(u, t) +plot(A) +A = SmoothedConstantInterpolation(u, t; d_max = 10) +plot!(A) +``` + +Note that `u[end]` is ignored. + ## Quadratic Spline This is the quadratic spline. It is a continuously differentiable interpolation diff --git a/src/interpolation_caches.jl b/src/interpolation_caches.jl index cb2bb0aa..7f0f8126 100644 --- a/src/interpolation_caches.jl +++ b/src/interpolation_caches.jl @@ -290,8 +290,8 @@ end cache_parameters = false, assume_linear_t = 1e-2) It is a method for interpolating constantly with forward fill, with smoothing around the -value transitions to make the curve C1 smooth while the integral never drifts far from -the integral of constant interpolation. +value transitions to make the curve continuously differentiable while the integral never +drifts far from the integral of constant interpolation. In this interpolation type u[end] is ignored. ## Arguments