spatialrust_math/
scalar.rs1pub trait Scalar:
3 Copy
4 + Clone
5 + Default
6 + PartialEq
7 + PartialOrd
8 + core::fmt::Debug
9 + core::ops::Add<Output = Self>
10 + core::ops::Sub<Output = Self>
11 + core::ops::Mul<Output = Self>
12 + core::ops::Div<Output = Self>
13 + core::ops::Neg<Output = Self>
14{
15}
16
17impl Scalar for f32 {}
18impl Scalar for f64 {}
19
20pub trait Real: Scalar {
22 fn abs(self) -> Self;
24
25 fn sqrt(self) -> Self;
27}
28
29impl Real for f32 {
30 fn abs(self) -> Self {
31 f32::abs(self)
32 }
33
34 fn sqrt(self) -> Self {
35 f32::sqrt(self)
36 }
37}
38
39impl Real for f64 {
40 fn abs(self) -> Self {
41 f64::abs(self)
42 }
43
44 fn sqrt(self) -> Self {
45 f64::sqrt(self)
46 }
47}