Module for rudimentary support of manipulation with piecewise-linear functions (which are usually interpolations of higher-order functions, whence the module name). Interpolation is always given as two lists of the same length, where the x-list must be increasing.
Periodicity is supported by supposing that the interpolation can wrap from the last x-value to the first x-value (which should be 0 for meaningful results).
Non-periodic interpolation can be converted to periodic one by padding the interpolation with constant head and tail using the sanitizeInterpolation function.
There is a c++ template function for interpolating on such sequences in pkg/common/Engine/PartialEngine/LinearInterpolate.hpp (stateful, therefore fast for sequential reads).
TODO: Interpolating from within python is not (yet) supported.
- woo.linterpolation.integral(x, y)¶
Return integral of piecewise-linear function given by points x0,x1,… and y0,y1,…
- woo.linterpolation.revIntegrateLinear(I, x0, y0, x1, y1)¶
Helper function, returns value of integral variable x for linear function f passing through (x0,y0),(x1,y1) such that 1. x∈[x0,x1] 2. ∫_x0^x f dx=I and raise exception if such number doesn’t exist or the solution is not unique (possible?)
- woo.linterpolation.sanitizeInterpolation(x, y, x0, x1)¶
Extends piecewise-linear function in such way that it spans at least the x0…x1 interval, by adding constant padding at the beginning (using y0) and/or at the end (using y1) or not at all.
- woo.linterpolation.xFractionalFromIntegral(integral, x, y)¶
Return x within range x0…xn such that ∫_x0^x f dx==integral. Raises error if the integral value is not reached within the x-range.
- woo.linterpolation.xFromIntegral(integralValue, x, y)¶
Return x such that ∫_x0^x f dx==integral. x wraps around at xn. For meaningful results, therefore, x0 should == 0
Report issues or inclarities to github.