amari_core/
error.rs

1//! Error types for core geometric algebra operations
2
3use thiserror::Error;
4
5/// Error types for core geometric algebra operations
6#[derive(Error, Debug, Clone, PartialEq)]
7pub enum CoreError {
8    /// Invalid dimension for operation
9    #[error("Invalid dimension: expected {expected}, got {actual}")]
10    InvalidDimension { expected: usize, actual: usize },
11
12    /// Division by zero
13    #[error("Division by zero")]
14    DivisionByZero,
15
16    /// Numerical instability detected
17    #[error("Numerical instability detected")]
18    NumericalInstability,
19
20    /// Invalid basis vector index
21    #[error("Invalid basis vector index: {0} (max: {1})")]
22    InvalidBasisIndex(usize, usize),
23
24    /// Matrix is singular (non-invertible)
25    #[error("Matrix is singular and cannot be inverted")]
26    SingularMatrix,
27
28    /// Invalid metric signature
29    #[error("Invalid metric signature: positive {positive} + negative {negative} + zero {zero} != dimension {dimension}")]
30    InvalidSignature {
31        positive: usize,
32        negative: usize,
33        zero: usize,
34        dimension: usize,
35    },
36}
37
38/// Result type for core operations
39pub type CoreResult<T> = Result<T, CoreError>;