sim_lib_discrete_spectral/error.rs
1//! Error type for the discrete spectral atlas.
2
3/// Errors raised by FWHT, convolution, and Walsh-domain operations.
4#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
5pub enum SpectralError {
6 /// A transform was given input whose length is not a power of two.
7 #[error("length {len} is not a power of two")]
8 NonPowerOfTwoLength {
9 /// The offending length.
10 len: usize,
11 },
12 /// An integer inverse with `DivideByLength` hit a non-divisible coefficient.
13 #[error("inverse not divisible by length {len}")]
14 NonDivisibleInverse {
15 /// The transform length the coefficients must divide by.
16 len: usize,
17 },
18 /// A normalization mode is not valid for this element type.
19 #[error("invalid normalization: {0}")]
20 InvalidNormalization(String),
21 /// A length computation would overflow.
22 #[error("length overflow for input of size {len}")]
23 LengthOverflow {
24 /// The offending input length.
25 len: usize,
26 },
27 /// Operand shapes are incompatible for the requested operation.
28 #[error("shape mismatch: {0}")]
29 ShapeMismatch(String),
30 /// An explicit size limit was exceeded (for example, materializing a view).
31 #[error("limit exceeded: {0}")]
32 LimitExceeded(String),
33 /// An exact integer transform overflowed `i64` and would lose precision.
34 #[error("integer overflow in exact transform")]
35 Overflow,
36}