pub struct ScalarField<const P: usize, const Q: usize, const R: usize> { /* private fields */ }Expand description
A scalar field f: ℝⁿ → ℝ
Represents a function that maps points in n-dimensional space to scalar values.
§Examples
use amari_calculus::ScalarField;
// Define f(x, y) = x² + y²
let f = ScalarField::<3, 0, 0>::new(|coords| {
coords[0].powi(2) + coords[1].powi(2)
});
// Evaluate at (3, 4)
let value = f.evaluate(&[3.0, 4.0, 0.0]);
assert!((value - 25.0).abs() < 1e-10);Implementations§
Source§impl<const P: usize, const Q: usize, const R: usize> ScalarField<P, Q, R>
impl<const P: usize, const Q: usize, const R: usize> ScalarField<P, Q, R>
Sourcepub fn with_dimension(function: fn(&[f64]) -> f64, dim: usize) -> Self
pub fn with_dimension(function: fn(&[f64]) -> f64, dim: usize) -> Self
Create a scalar field with explicit dimension
Useful when the field dimension doesn’t match the algebra dimension.
Sourcepub fn partial_derivative(
&self,
coords: &[f64],
axis: usize,
h: f64,
) -> CalculusResult<f64>
pub fn partial_derivative( &self, coords: &[f64], axis: usize, h: f64, ) -> CalculusResult<f64>
Compute numerical derivative along coordinate axis
Uses centered difference: f’(x) ≈ (f(x+h) - f(x-h)) / (2h)
§Arguments
coords- Point at which to compute derivativeaxis- Coordinate axis index (0 = x, 1 = y, etc.)h- Step size (default: 1e-5)
Trait Implementations§
Auto Trait Implementations§
impl<const P: usize, const Q: usize, const R: usize> Freeze for ScalarField<P, Q, R>
impl<const P: usize, const Q: usize, const R: usize> RefUnwindSafe for ScalarField<P, Q, R>
impl<const P: usize, const Q: usize, const R: usize> Send for ScalarField<P, Q, R>
impl<const P: usize, const Q: usize, const R: usize> Sync for ScalarField<P, Q, R>
impl<const P: usize, const Q: usize, const R: usize> Unpin for ScalarField<P, Q, R>
impl<const P: usize, const Q: usize, const R: usize> UnwindSafe for ScalarField<P, Q, R>
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