Crates.io | pcw_fn |
lib.rs | pcw_fn |
version | 0.2.1 |
source | src |
created_at | 2023-01-22 12:07:30.99747 |
updated_at | 2023-01-23 14:36:53.152263 |
description | Generic piecewise function trait and impls. |
homepage | |
repository | https://github.com/SV-97/pcw_fn/ |
max_upload_size | |
id | 764959 |
size | 57,406 |
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
.