working on adding sin_cos_pi
[vector-math.git] / src / scalar.rs
1 use crate::traits::{Context, Make};
2
3 #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, Default)]
4 pub struct Scalar;
5
6 macro_rules! impl_context {
7 (
8 impl Context for Scalar {
9 $(type $name:ident = $ty:ty;)*
10 #[vec]
11 $(type $vec_name:ident = $vec_ty:ty;)*
12 }
13 ) => {
14 impl Context for Scalar {
15 $(type $name = $ty;)*
16 $(type $vec_name = $vec_ty;)*
17 }
18
19 $(
20 impl Make for $ty {
21 type Prim = $ty;
22 type Context = Scalar;
23 fn ctx(self) -> Self::Context {
24 Scalar
25 }
26 fn make(_ctx: Self::Context, v: Self::Prim) -> Self {
27 v
28 }
29 }
30 )*
31 };
32 }
33
34 impl_context! {
35 impl Context for Scalar {
36 type Bool = bool;
37 type U8 = u8;
38 type I8 = i8;
39 type U16 = u16;
40 type I16 = i16;
41 type F16 = crate::f16::F16;
42 type U32 = u32;
43 type I32 = i32;
44 type F32 = f32;
45 type U64 = u64;
46 type I64 = i64;
47 type F64 = f64;
48 #[vec]
49 type VecBool8 = bool;
50 type VecU8 = u8;
51 type VecI8 = i8;
52 type VecBool16 = bool;
53 type VecU16 = u16;
54 type VecI16 = i16;
55 type VecF16 = crate::f16::F16;
56 type VecBool32 = bool;
57 type VecU32 = u32;
58 type VecI32 = i32;
59 type VecF32 = f32;
60 type VecBool64 = bool;
61 type VecU64 = u64;
62 type VecI64 = i64;
63 type VecF64 = f64;
64 }
65 }