From 57a03da3f71e63ed10e9eaf37415b6c4c5d3e78a Mon Sep 17 00:00:00 2001 From: Bart de Koning Date: Sun, 23 Mar 2025 15:13:46 +0100 Subject: [PATCH 1/3] Add `in_place` to docstrings. --- src/interpolation_caches.jl | 8 +++++++- test/derivative_tests.jl | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/interpolation_caches.jl b/src/interpolation_caches.jl index 2bc29534..a2855bb8 100644 --- a/src/interpolation_caches.jl +++ b/src/interpolation_caches.jl @@ -1393,6 +1393,8 @@ If you want to do this, construct the shape interpolation yourself and use the for the `SmoothArcLengthInterpolation` to be C¹ smooth, the `interpolation_type` must be C¹ smooth as well. - `m`: The number of points at which the shape interpolation is evaluated in each interval between time points. The `SmoothArcLengthInterpolation` converges to the shape interpolation (in shape) as m → ∞. + - `in_place`: Whether the value of the interpolation should be calculated in pre-allocated memory. This saves + allocations, but is not compatible with e.g. ForwardDiff. Defaults to `false`. - `extrapolation`: The extrapolation type applied left and right of the data. Possible options are `ExtrapolationType.None` (default), `ExtrapolationType.Constant`, `ExtrapolationType.Linear` `ExtrapolationType.Extension`, `ExtrapolationType.Periodic` and `ExtrapolationType.Reflective`. @@ -1443,6 +1445,8 @@ Approximate the `shape_itp` with a C¹ unit speed interpolation using line segme - `m`: The number of points at which the shape interpolation is evaluated in each interval between time points. The `SmoothArcLengthInterpolation` converges to the shape interpolation (in shape) as m → ∞. + - `in_place`: Whether the value of the interpolation should be calculated in pre-allocated memory. This saves + allocations, but is not compatible with e.g. ForwardDiff. Defaults to `false`. - `extrapolation`: The extrapolation type applied left and right of the data. Possible options are `ExtrapolationType.None` (default), `ExtrapolationType.Constant`, `ExtrapolationType.Linear` `ExtrapolationType.Extension`, `ExtrapolationType.Periodic` and `ExtrapolationType.Reflective`. @@ -1520,6 +1524,8 @@ segments and circle segments. - `shape_itp`: The interpolation that is being approximated, if one exists. Note that this interpolation is not being used; it is just passed along to keep track of where the shape of the `SmoothArcLengthInterpolation` originated. + - `in_place`: Whether the value of the interpolation should be calculated in pre-allocated memory. This saves + allocations, but is not compatible with e.g. ForwardDiff. Defaults to `false`. - `extrapolation`: The extrapolation type applied left and right of the data. Possible options are `ExtrapolationType.None` (default), `ExtrapolationType.Constant`, `ExtrapolationType.Linear` `ExtrapolationType.Extension`, `ExtrapolationType.Periodic` and `ExtrapolationType.Reflective`. @@ -1618,7 +1624,7 @@ function SmoothArcLengthInterpolation( extrapolation_right::ExtrapolationType.T = ExtrapolationType.None, cache_parameters::Bool = false, assume_linear_t = 1e-2, - in_place::Bool = true) + in_place::Bool = false) N = size(u, 1) n_circle_arcs = size(u, 2) - 1 diff --git a/test/derivative_tests.jl b/test/derivative_tests.jl index 433e600a..c2ffb7ff 100644 --- a/test/derivative_tests.jl +++ b/test/derivative_tests.jl @@ -272,7 +272,7 @@ end SmoothArcLengthInterpolation, args = [u], kwargs = Pair[ :m => 5, :in_place => false], name = "Smooth Arc Length Interpolation") - A = SmoothArcLengthInterpolation(u'; m = 25, in_place = false) + A = SmoothArcLengthInterpolation(u'; m = 25) @test all(t -> norm(derivative(A, t)) ≈ 1, range(0, A.t[end]; length = 100)) @test all( t_ -> derivative(A, prevfloat(t_)) ≈ derivative(A, nextfloat(t_)), A.t[2:(end - 1)]) From 63ab524247c9831cd8665cae3f6137e3051aafc4 Mon Sep 17 00:00:00 2001 From: Bart de Koning Date: Sun, 23 Mar 2025 15:16:32 +0100 Subject: [PATCH 2/3] Add hopefully clarifying word --- docs/src/arclength_interpolation.md | 2 +- test/derivative_tests.jl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/src/arclength_interpolation.md b/docs/src/arclength_interpolation.md index ffc88936..4f9f1d1e 100644 --- a/docs/src/arclength_interpolation.md +++ b/docs/src/arclength_interpolation.md @@ -4,7 +4,7 @@ Arc length interpolation is interpolation between points using a curve that is p ## Usage -`DataInteprolations.jl` offers an arc length interpolation method that approximates an existing non arc length interpolation by circle and line segments. This can be done by providing an interpolation object (the shape interpolation): +`DataInteprolations.jl` offers an arc length interpolation method that approximates an existing non arc length interpolation piecewise by circle and line segments. This can be done by providing an interpolation object (the shape interpolation): ```@example tutorial using DataInterpolations diff --git a/test/derivative_tests.jl b/test/derivative_tests.jl index c2ffb7ff..39909b24 100644 --- a/test/derivative_tests.jl +++ b/test/derivative_tests.jl @@ -270,7 +270,7 @@ end u = [0.3 -1.5 3.1; -0.2 0.2 -1.5; 10.4 -37.2 -5.8] test_derivatives( SmoothArcLengthInterpolation, args = [u], kwargs = Pair[ - :m => 5, :in_place => false], + :m => 5, :in_place], name = "Smooth Arc Length Interpolation") A = SmoothArcLengthInterpolation(u'; m = 25) @test all(t -> norm(derivative(A, t)) ≈ 1, range(0, A.t[end]; length = 100)) From e44c5c248c41b691ee2a396c0c6643200b166651 Mon Sep 17 00:00:00 2001 From: Bart de Koning Date: Sun, 23 Mar 2025 15:35:24 +0100 Subject: [PATCH 3/3] Fix test, add SmoothArcLengthInterpolation to README and docs index --- README.md | 1 + docs/src/index.md | 1 + test/derivative_tests.jl | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index df100c0d..0f6a3682 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,7 @@ corresponding to `(u,t)` pairs. - `CubicHermiteSpline(du, u, t)` - A third order Hermite interpolation, which matches the values and first (`du`) order derivatives in the data points exactly. - `PCHIPInterpolation(u, t)` - a type of `CubicHermiteSpline` where the derivative values `du` are derived from the input data in such a way that the interpolation never overshoots the data. - `QuinticHermiteSpline(ddu, du, u, t)` - A fifth order Hermite interpolation, which matches the values and first (`du`) and second (`ddu`) order derivatives in the data points exactly. + - `SmoothArcLengthInterpolation(u)` create a continuously differentiable interpolation by arc length through the data, by approximating a non-arc length interpolation with line segments and circle segments. See the docs for more details. ## Extension Methods diff --git a/docs/src/index.md b/docs/src/index.md index 1b19d50f..1a2c1851 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -33,6 +33,7 @@ corresponding to `(u,t)` pairs. - `CubicHermiteSpline(du, u, t)` - A third order Hermite interpolation, which matches the values and first (`du`) order derivatives in the data points exactly. - `PCHIPInterpolation(u, t)` - a type of `CubicHermiteSpline` where the derivative values `du` are derived from the input data in such a way that the interpolation never overshoots the data. - `QuinticHermiteSpline(ddu, du, u, t)` - a fifth order Hermite interpolation, which matches the values and first (`du`) and second (`ddu`) order derivatives in the data points exactly. + - `SmoothArcLengthInterpolation(u)` create a continuously differentiable interpolation by arc length through the data, by approximating a non arc length interpolation with line segments and circle segments. See [here](#smooth-arc-length-interpolation) for more details. ## Extension Methods diff --git a/test/derivative_tests.jl b/test/derivative_tests.jl index 39909b24..703e0c98 100644 --- a/test/derivative_tests.jl +++ b/test/derivative_tests.jl @@ -270,7 +270,7 @@ end u = [0.3 -1.5 3.1; -0.2 0.2 -1.5; 10.4 -37.2 -5.8] test_derivatives( SmoothArcLengthInterpolation, args = [u], kwargs = Pair[ - :m => 5, :in_place], + :m => 5], name = "Smooth Arc Length Interpolation") A = SmoothArcLengthInterpolation(u'; m = 25) @test all(t -> norm(derivative(A, t)) ≈ 1, range(0, A.t[end]; length = 100))