use bytemuck::Pod;
use num_complex::{Complex32, Complex64};
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Precision {
F32,
F64,
}
pub trait Scalar: Pod + Send + Sync + 'static {
const BYTES: usize = core::mem::size_of::<Self>();
const IS_COMPLEX: bool;
const PRECISION: Precision;
}
pub trait Real: Scalar {
type Complex: Complex<Real = Self>;
}
pub trait Complex: Scalar {
type Real: Real<Complex = Self>;
}
impl Scalar for f32 {
const IS_COMPLEX: bool = false;
const PRECISION: Precision = Precision::F32;
}
impl Scalar for f64 {
const IS_COMPLEX: bool = false;
const PRECISION: Precision = Precision::F64;
}
impl Scalar for Complex32 {
const IS_COMPLEX: bool = true;
const PRECISION: Precision = Precision::F32;
}
impl Scalar for Complex64 {
const IS_COMPLEX: bool = true;
const PRECISION: Precision = Precision::F64;
}
impl Real for f32 {
type Complex = Complex32;
}
impl Real for f64 {
type Complex = Complex64;
}
impl Complex for Complex32 {
type Real = f32;
}
impl Complex for Complex64 {
type Real = f64;
}