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

Zero on start X value #1

Closed
Ensase opened this issue Aug 24, 2019 · 5 comments
Closed

Zero on start X value #1

Ensase opened this issue Aug 24, 2019 · 5 comments

Comments

@Ensase
Copy link

Ensase commented Aug 24, 2019

Hello!
I've tried to run simple example before using in project:

f := piecewiselinear.Function{Y: []float64{100, 105, 120}}
f.X = piecewiselinear.Span(10, 16, len(f.Y))
fmt.Println(f.X)
fmt.Println(f.Y)
fmt.Println(
f.At(10), // f.At(x) evaluates f at x
f.At(11),
f.At(12),
f.At(13),
f.At(14),
f.At(15),
f.At(16),
)

And I've got the output:
[10 13 16]
[100 105 120]
0 101.66666666666667 103.33333333333334 105 110.00000000000001 115 120

Everything is fine except zero on defined X value.

Thank you

@sgreben
Copy link
Owner

sgreben commented Aug 24, 2019

Good catch, thanks! I've just pushed a fix and a test that should catch this case :) Tagged as release 2.0.4 now.

@sgreben sgreben closed this as completed Aug 24, 2019
@sgreben
Copy link
Owner

sgreben commented Aug 24, 2019

I've also double-checked the output of the fixed code for your specific example:

Screen Shot 2019-08-25 at 00 28 08

@sgreben
Copy link
Owner

sgreben commented Aug 24, 2019

For convenience, here's the link to the release with the fix: https://github.com/sgreben/piecewiselinear/releases/tag/2.0.4 :)

@Ensase
Copy link
Author

Ensase commented Aug 24, 2019

All works fine.
Thanks a lot!

@sgreben
Copy link
Owner

sgreben commented Aug 24, 2019

You're welcome! Thanks for finding the bug 👍

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