Skip to main content

Module value

Module value 

Source
Expand description

Numeric types and iteration utilities for polynomial curves.

This module defines the Value trait, which abstracts the numeric types that can be used in polynomial fitting and evaluation, ensuring compatibility with nalgebra, floating-point operations, and formatting.

§Traits

  • Value: Extends Float, Scalar, and ComplexField to provide:
    • A canonical two() constant.
    • try_cast for safe type conversion with error handling.
    • powi for integer exponentiation.

§Iterators

  • SteppedValues: A floating-point range iterator with a specified step, useful for generating evaluation points for polynomials.

§Example

use polyfit::value::{Value, SteppedValues};

// Create a range of f64 values from 0.0 to 1.0 in steps of 0.1
let range = SteppedValues::new(0.0..=1.0, 0.1);
for x in range {
    println!("{x}");
}

// Using Value trait methods
let two = f64::two();
let squared = two.powi(2);

Structs§

SteppedValues
Iterator over a range of floating-point values with a specified step.

Traits§

CoordExt
Extension trait for accessing the x and y coordinates of a type.
FloatClampedCast
Trait for infallible floating-point casting with clamping.
IntClampedCast
Trait for infallible integer casting with clamping.
Value
Numeric type for curves