Quantize

Trait Quantize 

Source
pub trait Quantize {
    type Type;

    // Required methods
    fn quantize(value: f64) -> Self::Type;
    fn dequantize(quantized: Self::Type) -> f64;
    fn max_error() -> f64;
}
Expand description

Trait for quantizing and dequantizing values.

Required Associated Types§

Source

type Type

The type to store the quantized value in.

Required Methods§

Source

fn quantize(value: f64) -> Self::Type

Quantize a floating point value.

Source

fn dequantize(quantized: Self::Type) -> f64

Restore the floating point value from a quantized value.

Source

fn max_error() -> f64

Calculates the maximum quantization error. The absolute difference between the quantized and original value will not be greater than this, unless it has been clamped because it was out of range.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<L: Linear> Quantize for L
where <L as Linear>::Type: Into<f64> + TryFrom<u64> + Copy,

Source§

type Type = <L as Linear>::Type