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

Incorrect inverse in some cases #17

Open
oschulz opened this issue Aug 13, 2024 · 0 comments
Open

Incorrect inverse in some cases #17

oschulz opened this issue Aug 13, 2024 · 0 comments
Assignees

Comments

@oschulz
Copy link
Member

oschulz commented Aug 13, 2024

With

using MonotonicSplines

w = [0.0, 0.15, 0.20, 0.45, 0.65, 0.80, 1.0]
h = [0.0, 0.10, 0.25, 0.40, 0.55, 0.70, 1.0]
d = [0.5, 1.3, 0.8, 0.9, 0.7, 1.2, 1.1]
X = collect((0:0.1:1)')
n = length(X)
M = fill(1.0, 1, 1, n)
f = RQSpline(w .* M, h .* M, d .* M)
inv_f = InvRQSpline(w .* M, h .* M, d .* M)

Y = f(X)
X2 = inv_f(Y)

we currently get

julia> X  X2
false

julia> X
1×11 Matrix{Float64}:
 0.0  0.1  0.2  0.3  0.4  0.5  0.6  0.7  0.8  0.9  1.0

julia> X2
1×11 Matrix{Float64}:
 0.0  0.1  0.2  0.3  0.4  0.5  0.6  0.7  0.8  0.85283  1.0

but when adding a spline node at (1.1, 1.1)

w = [0.0, 0.15, 0.20, 0.45, 0.65, 0.80, 1.0, 1.1]
h = [0.0, 0.10, 0.25, 0.40, 0.55, 0.70, 1.0, 1.1]
d = [0.5, 1.3, 0.8, 0.9, 0.7, 1.2, 1.1, 0.9]
X = collect((0:0.1:1.1)')
n = length(X)
M = fill(1.0, 1, 1, n)
f = RQSpline(w .* M, h .* M, d .* M)
inv_f = InvRQSpline(w .* M, h .* M, d .* M)

all is correct:

julia> X  X2
true
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