GithubHelp home page GithubHelp logo

sgreben / piecewiselinear Goto Github PK

View Code? Open in Web Editor NEW
26.0 6.0 3.0 19 KB

tiny linear interpolation library for go

Home Page: https://pkg.go.dev/github.com/sgreben/piecewiselinear

License: MIT License

Go 100.00%
linear-interpolation golang piecewise linear tiny

piecewiselinear's People

Contributors

chmorgan avatar sgreben avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

piecewiselinear's Issues

Way to indicate out of range?

Would a pull request to modify At() to return (float64, error) be accepted? In my use case I'd prefer not to rely on a magic value of 0 to indicate not found but would propose instead we returned something like 0, fmt.Errorf("value out of range") so the user could decide how to handle those cases?

Zero on start X value

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.