1use core::ops::{Div, Mul};
2use num_traits::real::Real;
3
4use super::{len, sdiv};
5
6#[inline]
13pub fn norm<'out, T>(out: &'out mut [T; 2], b: &[T; 2]) -> T
14where
15 T: Real,
16 for<'a, 'b> &'a T: Mul<&'b T, Output = T> + Div<&'b T, Output = T>,
17{
18 let s = len(b);
19 sdiv(out, b, &s);
20 s
21}
22
23#[inline]
30pub fn norm_mut<'out, T>(out: &'out mut [T; 2]) -> T
31where
32 T: Real,
33 for<'a, 'b> &'a T: Mul<&'b T, Output = T> + Div<&'b T, Output = T>,
34{
35 let tmp = out.clone();
36 norm(out, &tmp)
37}