Skip to content
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

Support for custom types? #23

Open
juliohm opened this issue Sep 17, 2024 · 1 comment
Open

Support for custom types? #23

juliohm opened this issue Sep 17, 2024 · 1 comment

Comments

@juliohm
Copy link

juliohm commented Sep 17, 2024

Can this package handle custom types in a Hilbert space?

import Base: +, *

struct Foo
  x::Float64
  y::Float64
end

+(f1::Foo, f2::Foo) = Foo(f1.x + f2.x, f1.y + f2.y)
*(a::Real, f::Foo) = Foo(a * f.x, a * f.y)

g(x) = Foo(x[1], x[2])
lb, ub = [1,3], [2, 4]
x = chebpoints((10,20), lb, ub)
c = chebinterp(g.(x), lb, ub)
ERROR: MethodError: no method matching zero(::Type{Any})
@stevengj
Copy link
Member

stevengj commented Sep 17, 2024

No, not currently. For example, it currently uses FFTs to compute the coefficients quickly, but I don't have an FFT method for arbitrary vector spaces.

Right now you'll need to first define a mapping/isomorphism of your vector space to/from ℝⁿ or ℂⁿ (ideally to SVector{n} so it is allocation-free), and then use this mapping before calling chebinterp, and use the inverse mapping on the result of interpolation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants