pub struct FunctionAlgebraElement {
pub values: Vec<f64>,
}Expand description
Represents a function in a function algebra, stored as a lookup table.
This models C(K) – the algebra of continuous functions on a compact set K, approximated by sampling at discrete points.
Fields§
§values: Vec<f64>Sampled function values at equally-spaced points in [0, 1].
Implementations§
Source§impl FunctionAlgebraElement
impl FunctionAlgebraElement
Sourcepub fn from_fn<F: Fn(f64) -> f64>(f: F, n: usize) -> Self
pub fn from_fn<F: Fn(f64) -> f64>(f: F, n: usize) -> Self
Create from a Rust closure, sampling at n equally-spaced points in [0,1].
Sourcepub fn add(&self, other: &FunctionAlgebraElement) -> FunctionAlgebraElement
pub fn add(&self, other: &FunctionAlgebraElement) -> FunctionAlgebraElement
Pointwise addition: (f + g)(x) = f(x) + g(x).
Sourcepub fn multiply(&self, other: &FunctionAlgebraElement) -> FunctionAlgebraElement
pub fn multiply(&self, other: &FunctionAlgebraElement) -> FunctionAlgebraElement
Pointwise multiplication: (f * g)(x) = f(x) * g(x).
Sourcepub fn scale(&self, c: f64) -> FunctionAlgebraElement
pub fn scale(&self, c: f64) -> FunctionAlgebraElement
Scalar multiplication: (c * f)(x) = c * f(x).
Sourcepub fn l2_norm(&self) -> f64
pub fn l2_norm(&self) -> f64
The L2 norm (approximated by the trapezoidal rule on the samples).
Sourcepub fn compose(&self, g: &FunctionAlgebraElement) -> FunctionAlgebraElement
pub fn compose(&self, g: &FunctionAlgebraElement) -> FunctionAlgebraElement
Composition: (f o g)(x) = f(g(x)).
Since we store sampled values, we interpolate g’s output to find f’s value. Clamps g’s output to [0, 1] for lookups.
Trait Implementations§
Source§impl Clone for FunctionAlgebraElement
impl Clone for FunctionAlgebraElement
Source§fn clone(&self) -> FunctionAlgebraElement
fn clone(&self) -> FunctionAlgebraElement
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for FunctionAlgebraElement
impl RefUnwindSafe for FunctionAlgebraElement
impl Send for FunctionAlgebraElement
impl Sync for FunctionAlgebraElement
impl Unpin for FunctionAlgebraElement
impl UnsafeUnpin for FunctionAlgebraElement
impl UnwindSafe for FunctionAlgebraElement
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more