arnaucube
arnaucube/poulpyPublic Self-hosted repository
poulpy/poulpy-hal/src/reference/fft64/reim/conversion.rs
poulpy-hal/src/reference/fft64/reim/conversion.rsRaw
 1#[inline(always)]
 2pub fn reim_from_znx_i64_ref(res: &mut [f64], a: &[i64]) {
 3    #[cfg(debug_assertions)]
 4    {
 5        assert_eq!(res.len(), a.len())
 6    }
 7
 8    for i in 0..res.len() {
 9        res[i] = a[i] as f64
10    }
11}
12
13#[inline(always)]
14pub fn reim_to_znx_i64_ref(res: &mut [i64], divisor: f64, a: &[f64]) {
15    #[cfg(debug_assertions)]
16    {
17        assert_eq!(res.len(), a.len())
18    }
19    let inv_div = 1. / divisor;
20    for i in 0..res.len() {
21        res[i] = (a[i] * inv_div).round() as i64
22    }
23}
24
25#[inline(always)]
26pub fn reim_to_znx_i64_inplace_ref(res: &mut [f64], divisor: f64) {
27    let inv_div = 1. / divisor;
28    for ri in res {
29        *ri = f64::from_bits(((*ri * inv_div).round() as i64) as u64)
30    }
31}