mathnet / mathnet-numerics

Math.NET Numerics
http://numerics.mathdotnet.com
MIT License
3.44k stars 891 forks source link

Add method with option to not allow extrapolation. #995

Open Hylke-Atmos opened 1 year ago

Hylke-Atmos commented 1 year ago

Hi @cdrnet

You library is great, however by default the interpolation functions also extrapolate, which is not always desired. Although I know a user is (in most cases) likely able to test possible extrapolation from outside the library, I thought it made a nice addition to the library.

I added a function (to LinearSpline) to which you can provide a flag to indicate whether extrapolation is allowed.

Please let me know if you'd like this addition for the library. It is currently implemented directly in LinearSpline, but I can imagine it might be worth for all interpolation functions. So if you like the idea I can extend it towards the IInterpolation Interface and implement it into all implementations.

Kind Regards, Hylke