1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
use num_traits::float;
use num_traits::identities::Zero;
use num_traits::cast::FromPrimitive;
use std::fmt::Debug;
use std::ops::{Add, Sub, Mul, Div};
pub trait Float: float::Float + FromPrimitive + Debug {}
impl<F> Float for F where F: float::Float + FromPrimitive + Debug {}
pub trait PVOps<F>:
Add<Self, Output = Self> +
Sub<Self, Output = Self> +
Mul<F, Output = Self> +
Div<F, Output = Self> +
Zero
where Self: Sized,
F: Float {}
pub trait Point<F>:
Into<<Self as Point<F>>::Vector> +
Clone +
Copy +
PVOps<F>
where Self: Sized,
F: Float {
type Vector: Vector<F>;
}
pub trait Vector<F: Float>:
Clone +
Copy +
PVOps<F> {}
impl PVOps<f32> for f32 {}
impl Point<f32> for f32 {
type Vector = f32;
}
impl Vector<f32> for f32 {}
impl PVOps<f64> for f64 {}
impl Point<f64> for f64 {
type Vector = f64;
}
impl Vector<f64> for f64 {}