strided_traits/scalar.rs
1//! Scalar type bounds for strided operations and einsum.
2
3/// Shared trait bounds for all element types usable with einsum, independent
4/// of GEMM backend.
5///
6/// Unlike the previous design, `ScalarBase` does **not** require
7/// `ElementOpApply`. This allows custom scalar types (e.g., tropical
8/// semiring types) to satisfy einsum bounds without implementing
9/// conj/transpose/adjoint.
10pub trait ScalarBase:
11 Copy
12 + Send
13 + Sync
14 + 'static
15 + std::ops::Mul<Output = Self>
16 + std::ops::Add<Output = Self>
17 + num_traits::Zero
18 + num_traits::One
19 + PartialEq
20{
21}
22
23impl<T> ScalarBase for T where
24 T: Copy
25 + Send
26 + Sync
27 + 'static
28 + std::ops::Mul<Output = T>
29 + std::ops::Add<Output = T>
30 + num_traits::Zero
31 + num_traits::One
32 + PartialEq
33{
34}
35
36#[cfg(test)]
37mod tests;