#piecewise #numeric #func #num

pcw_fn

Generic piecewise function trait and impls

5 releases

0.2.1 Jan 23, 2023
0.2.0 Jan 23, 2023
0.1.2 Jan 23, 2023
0.1.1 Jan 22, 2023
0.1.0 Jan 22, 2023

#759 in Math

40 downloads per month
Used in pcw_regrs

MIT/Apache

47KB
949 lines

Generic piecewise function trait and impls

pcw_fn is a library for handling piecewise defined functions (or other "piecewise data") generically.

Currently the PcwFn trait the library is built around is implemented for a single type: VecPcwFn. This type represents a piecewise function f given by a collection of jump positions and functions such that

       ╭ f₁(x)   if      x < x₀
       │ f₂(x)   if x₀ ≤ x < x₁
f(x) = ┤ f₃(x)   if x₁ ≤ x < x₂
       │  ⋮               ⋮
       ╰ fₙ(x)   if xₙ ≤ x

for all x ∈ X where f₁,...,fₙ : X -> Y, and x₀ < x₁ < ... < xₙ from some strictly totally ordered set X (so X is Ord). Note that for most functionality it's not required that the funcs actually behave like a function so the type can be used very well for "non-functional" funcs.

It's trivial to add impls backed by other types like SmallVec or StaticVec.

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~520–800KB
~16K SLoC