Skip to content

Parametric smoothing interpolation #397

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
yakir12 opened this issue Feb 20, 2025 · 2 comments
Open

Parametric smoothing interpolation #397

yakir12 opened this issue Feb 20, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@yakir12
Copy link

yakir12 commented Feb 20, 2025

Describe the bug 🐞

Interpolating a smoothing B-spline on parametric data errors.

Expected behavior

I had expected it to work just as interpolating a parametric data set works for non smoothing interpolation.

Minimal Reproducible Example 👇

using StaticArrays, DataInterpolations
n = 10
t = Float64.(1:n)
u = rand(SVector{2, Float64}, n)
LinearInterpolation(u, t) # works!

BSplineApprox(u, t, 2, 3, :Uniform, :Uniform) # errors!

Error & Stacktrace ⚠️

ERROR: MethodError: no method matching ^(::SVector{2, Float64}, ::Int64)
The function `^` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  ^(::Irrational{:ℯ}, ::Integer)
   @ Base mathconstants.jl:139
  ^(::ForwardDiff.Dual{Tx}, ::Integer) where Tx
   @ ForwardDiff ~/.julia/packages/ForwardDiff/UBbGT/src/dual.jl:148
  ^(::Float32, ::Integer)
   @ Base math.jl:1228
  ...

Stacktrace:
 [1] literal_pow
   @ ./intfuncs.jl:389 [inlined]
 [2] BSplineApprox(u::Vector{…}, t::Vector{…}, d::Int64, h::Int64, pVecType::Symbol, knotVecType::Symbol; extrapolation::DataInterpolations.ExtrapolationType.T, extrapolation_left::DataInterpolations.ExtrapolationType.T, extrapolation_right::DataInterpolations.ExtrapolationType.T, assume_linear_t::Float64)
   @ DataInterpolations ~/.julia/packages/DataInterpolations/r3oVa/src/interpolation_caches.jl:989
 [3] BSplineApprox(u::Vector{SVector{2, Float64}}, t::Vector{Float64}, d::Int64, h::Int64, pVecType::Symbol, knotVecType::Symbol)
   @ DataInterpolations ~/.julia/packages/DataInterpolations/r3oVa/src/interpolation_caches.jl:971
 [4] top-level scope
   @ REPL[13]:1
Some type information was truncated. Use `show(err)` to see complete types.

Environment (please complete the following information):

  • Output of using Pkg; Pkg.status()
Status `/tmp/jl_HwR3uf/Project.toml`
  [82cc6244] DataInterpolations v7.2.0
  [90137ffa] StaticArrays v1.9.12
  • Output of using Pkg; Pkg.status(; mode = PKGMODE_MANIFEST)
Status `/tmp/jl_HwR3uf/Manifest.toml`
  [bbf7d656] CommonSubexpressions v0.3.1
  [a8cc5b0e] Crayons v4.1.1
  [9a962f9c] DataAPI v1.16.0
  [82cc6244] DataInterpolations v7.2.0
  [e2d170a0] DataValueInterfaces v1.0.0
  [163ba53b] DiffResults v1.1.0
  [b552c78f] DiffRules v1.15.1
  [ffbed154] DocStringExtensions v0.9.3
  [4e289a0a] EnumX v1.0.4
  [64ca27bc] FindFirstFunctions v1.4.1
  [f6369f11] ForwardDiff v0.10.38
  [92d709cd] IrrationalConstants v0.2.4
  [82899510] IteratorInterfaceExtensions v1.0.0
  [692b3bcd] JLLWrappers v1.7.0
  [b964fa9f] LaTeXStrings v1.4.0
  [2ab3a3ac] LogExpFunctions v0.3.29
  [1914dd2f] MacroTools v0.5.15
  [77ba4419] NaNMath v1.1.2
  [bac558e1] OrderedCollections v1.8.0
  [aea7be01] PrecompileTools v1.2.1
  [21216c6a] Preferences v1.4.3
  [08abe8d2] PrettyTables v2.4.0
  [3cdcf5f2] RecipesBase v1.3.4
  [189a3867] Reexport v1.2.2
  [276daf66] SpecialFunctions v2.5.0
  [90137ffa] StaticArrays v1.9.12
  [1e83bf80] StaticArraysCore v1.4.3
  [892a3eda] StringManipulation v0.4.1
  [3783bdb8] TableTraits v1.0.1
  [bd369af6] Tables v1.12.0
  [efe28fd5] OpenSpecFun_jll v0.5.6+0
  [56f22d72] Artifacts v1.11.0
  [2a0f44e3] Base64 v1.11.0
  [ade2ca70] Dates v1.11.0
  [76f85450] LibGit2 v1.11.0
  [8f399da3] Libdl v1.11.0
  [37e2e46d] LinearAlgebra v1.11.0
  [d6f4376e] Markdown v1.11.0
  [ca575930] NetworkOptions v1.2.0
  [de0858da] Printf v1.11.0
  [9a3f8284] Random v1.11.0
  [ea8e919c] SHA v0.7.0
  [fa267f1f] TOML v1.0.3
  [4ec0a83e] Unicode v1.11.0
  [e66e0078] CompilerSupportLibraries_jll v1.1.1+0
  [e37daf67] LibGit2_jll v1.7.2+0
  [29816b5a] LibSSH2_jll v1.11.0+1
  [c8ffd9c3] MbedTLS_jll v2.28.6+0
  [4536629a] OpenBLAS_jll v0.3.27+1
  [05823500] OpenLibm_jll v0.8.1+2
  [8e850b90] libblastrampoline_jll v5.11.0+0
  • Output of versioninfo()
Julia Version 1.11.3
Commit d63adeda50d (2025-01-21 19:42 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 32 × AMD Ryzen Threadripper 2950X 16-Core Processor
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, znver1)
Threads: 32 default, 0 interactive, 16 GC (on 32 virtual cores)

Additional context

None.

@yakir12 yakir12 added the bug Something isn't working label Feb 20, 2025
@SouthEndMusic
Copy link
Member

Interesting. As far as I'm aware, we treat the elements of u as vectors (in the mathematical sense), i.e. we only assume that addition and scalar multiplication are defined for these elements. Here that's not the case. The erroring expression can probably be replaced by norm(u[i] - u[i - 1])^2.

@sathvikbhagavan
Copy link
Member

BSplines does not support Vector of Vectors but LinearInterpolation does. There is an open PR for it #351 which should fix it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants