Expand description
Algebra traits for the tenferro workspace.
This crate provides the minimal algebra foundation:
Scalar: Minimum requirements for tensor element types (Copy + Send + Sync + Add + Mul + Zero + One + PartialEq).Conjugate: Complex conjugation (identity for real types).HasAlgebra: Maps a scalar typeTto its default algebraA. Enables automatic inference:Tensor<f64>→Standard,Tensor<MaxPlus<f64>>→MaxPlus(in external crate).Semiring: Defines zero, one, add, mul for algebra-generic operations.Standard: Standard arithmetic algebra (add =+, mul =*).
§Extensibility
External crates define new algebras by implementing HasAlgebra for their
scalar types and TensorPrims<MyAlgebra> for CpuBackend (orphan rule
compatible). For example, tenferro-tropical defines MaxPlus<T>.
§Examples
use tenferro_algebra::{HasAlgebra, Scalar, Standard};
// f64 maps to Standard algebra automatically
fn check_algebra<T: HasAlgebra<Algebra = Standard>>() {}
check_algebra::<f64>();
check_algebra::<f32>();
// Scalar is automatically implemented for numeric types
fn needs_scalar<T: Scalar>() {}
needs_scalar::<f64>();
needs_scalar::<f32>();Structs§
- Standard
- Standard arithmetic algebra (add =
+, mul =*).
Traits§
- Conjugate
- Complex conjugation for tensor element types.
- HasAlgebra
- Maps a scalar type
Tto its default algebraA. - Scalar
- Scalar element type for tensors.
- Semiring
- Semiring trait for algebra-generic operations.