Skip to main content

symjit/
types.rs

1use num_complex::Complex;
2use wide::{f64x2, f64x4};
3
4#[derive(Clone, Debug)]
5pub enum ElemType {
6    RealF64(f64),
7    ComplexF64(Complex<f64>),
8    RealF64x2(f64x2),
9    ComplexF64x2(Complex<f64x2>),
10    RealF64x4(f64x4),
11    ComplexF64x4(Complex<f64x4>),
12}
13
14pub trait Element: Default {
15    fn get_type(x: Self) -> ElemType;
16}
17
18impl Element for f64 {
19    fn get_type(x: Self) -> ElemType {
20        ElemType::RealF64(x)
21    }
22}
23
24impl Element for Complex<f64> {
25    fn get_type(x: Self) -> ElemType {
26        ElemType::ComplexF64(x)
27    }
28}
29
30impl Element for f64x2 {
31    fn get_type(x: Self) -> ElemType {
32        ElemType::RealF64x2(x)
33    }
34}
35
36impl Element for Complex<f64x2> {
37    fn get_type(x: Self) -> ElemType {
38        ElemType::ComplexF64x2(x)
39    }
40}
41
42impl Element for f64x4 {
43    fn get_type(x: Self) -> ElemType {
44        ElemType::RealF64x4(x)
45    }
46}
47
48impl Element for Complex<f64x4> {
49    fn get_type(x: Self) -> ElemType {
50        ElemType::ComplexF64x4(x)
51    }
52}