rsdiff_math/linalg/
fields.rs

1/*
2    Appellation: fields <module>
3    Contrib: FL03 <jo3mccain@icloud.com>
4*/
5use core::marker::PhantomData;
6use num::complex::Complex;
7use num::traits::real::Real;
8/// A field is a set of elements with two binary operations, addition and multiplication, that satisfy the following axioms:
9/// - Associativity of addition and multiplication
10/// - Commutativity of addition and multiplication
11pub trait Field {
12    const RANK: Option<usize> = None;
13    type Elem: ?Sized;
14
15    fn kind(&self) -> Fields;
16    /// The rank of the field; i.e the number of dimensions.
17    fn rank(&self) -> usize;
18    /// The number of elements in the field.
19    fn size(&self) -> usize;
20}
21
22pub enum Fields {
23    Real(R),
24    Complex(C),
25}
26
27pub struct R<T = f64>
28where
29    T: Real,
30{
31    _elem: PhantomData<T>,
32}
33
34pub struct C<T = f64>
35where
36    T: Real,
37{
38    _elem: PhantomData<Complex<T>>,
39}
40
41pub trait ComplexField {
42    type DType;
43}
44
45pub trait Scalar {
46    type Complex: ComplexField<DType = Self::Real>;
47    type Real: Scalar<Real = Self::Real>;
48}
49
50#[cfg(test)]
51mod tests {}