mirror of
https://github.com/arnaucube/poulpy.git
synced 2026-02-10 05:06:44 +01:00
streamrepacker wip
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
use itertools::izip;
|
||||
use math::poly::Poly;
|
||||
use math::ring::impl_u64::ring;
|
||||
use math::ring::Ring;
|
||||
|
||||
#[test]
|
||||
@@ -135,3 +134,52 @@ fn test_packing_sparse_u64<const NTT: bool>(ring: &Ring<u64>) {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#[test]
|
||||
fn trace_u64() {
|
||||
let n: usize = 1 << 5;
|
||||
let q_base: u64 = 65537u64;
|
||||
let q_power: usize = 1usize;
|
||||
let ring: Ring<u64> = Ring::new(n, q_base, q_power);
|
||||
|
||||
sub_test("test_trace::<NTT:false>", || {
|
||||
test_trace_u64::<false>(&ring)
|
||||
});
|
||||
sub_test("test_trace::<NTT:true>", || {
|
||||
test_trace_u64::<true>(&ring)
|
||||
});
|
||||
}
|
||||
|
||||
fn test_trace_u64<const NTT: bool>(ring: &Ring<u64>) {
|
||||
let n: usize = ring.n();
|
||||
|
||||
let mut poly: Poly<u64> = ring.new_poly();
|
||||
|
||||
poly.0.iter_mut().enumerate().for_each(|(i, x)|{
|
||||
*x = (i+1) as u64
|
||||
});
|
||||
|
||||
if NTT{
|
||||
ring.ntt_inplace::<false>(&mut poly);
|
||||
}
|
||||
|
||||
let step_start: usize = 2;
|
||||
|
||||
ring.trace_inplace::<NTT>(step_start, &mut poly);
|
||||
|
||||
if NTT{
|
||||
ring.intt_inplace::<false>(&mut poly);
|
||||
}
|
||||
|
||||
let gap: usize = 1<<(ring.log_n() - step_start);
|
||||
|
||||
poly.0.iter().enumerate().for_each(|(i, x)| {
|
||||
if i % gap == 0 {
|
||||
assert_eq!(*x, 1 + i as u64)
|
||||
} else {
|
||||
assert_eq!(*x, 0u64)
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user