mirror of
https://github.com/arnaucube/poulpy.git
synced 2026-02-10 21:26:41 +01:00
added from_bytes to vec_znx_[dft/big]
This commit is contained in:
@@ -5,6 +5,16 @@ use crate::{Infos, Module, VecZnx, VecZnxDft};
|
||||
pub struct VecZnxBig(pub *mut vec_znx_big::vec_znx_bigcoeff_t, pub usize);
|
||||
|
||||
impl VecZnxBig {
|
||||
/// Casts a contiguous array of [u8] into as a [VecZnxDft].
|
||||
/// User must ensure that data is properly alligned and that
|
||||
/// the size of data is at least equal to [Module::bytes_of_vec_znx_big].
|
||||
pub fn from_bytes(&self, limbs: usize, data: &mut [u8]) -> VecZnxBig {
|
||||
VecZnxBig(
|
||||
data.as_mut_ptr() as *mut vec_znx_big::vec_znx_bigcoeff_t,
|
||||
limbs,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn as_vec_znx_dft(&mut self) -> VecZnxDft {
|
||||
VecZnxDft(self.0 as *mut vec_znx_dft::vec_znx_dft_t, self.1)
|
||||
}
|
||||
@@ -19,6 +29,10 @@ impl Module {
|
||||
unsafe { VecZnxBig(vec_znx_big::new_vec_znx_big(self.0, limbs as u64), limbs) }
|
||||
}
|
||||
|
||||
pub fn bytes_of_vec_znx_big(&self, limbs: usize) -> usize {
|
||||
unsafe { vec_znx_big::bytes_of_vec_znx_big(self.0, limbs as u64) as usize }
|
||||
}
|
||||
|
||||
// b <- b - a
|
||||
pub fn vec_znx_big_sub_small_a_inplace(&self, b: &mut VecZnxBig, a: &VecZnx) {
|
||||
let limbs: usize = a.limbs();
|
||||
|
||||
Reference in New Issue
Block a user