use crate::cyclotomic::IsRing;
pub(crate) fn norm2_f<T: IsRing>(v: &T) -> f64 {
let (x, y) = v.xy();
x * x + y * y
}
pub(crate) fn norm_f<T: IsRing>(v: &T) -> f64 {
norm2_f(v).sqrt()
}
pub(crate) fn area_f<T: IsRing>(poly: &[T]) -> f64 {
let mut a = 0.0;
let n = poly.len();
for i in 0..n {
let (x1, y1) = poly[i].xy();
let (x2, y2) = poly[(i + 1) % n].xy();
a += x1 * y2 - x2 * y1;
}
a.abs() / 2.0
}
pub(crate) fn cross_f<T: IsRing>(a: &T, b: &T) -> f64 {
let (ax, ay) = a.xy();
let (bx, by) = b.xy();
ax * by - ay * bx
}