arnaucube
arnaucube/poulpyPublic Self-hosted repository
poulpy/base2k/src/infos.rs
base2k/src/infos.rsRaw
 1#[derive(Copy, Clone)]
 2#[repr(C)]
 3pub struct LAYOUT{
 4    /// Ring degree.
 5    n: usize,
 6    /// Number of logical rows in the layout.
 7    rows: usize,
 8    /// Number of polynomials per row.
 9    cols: usize,
10    /// Number of limbs per polynomial.
11    size: usize,
12    /// Whether limbs are interleaved inside a row.
13    ///
14    /// For example, for (rows, cols, size) = (2, 2, 3):
15    /// 
16    /// - `true`: layout is ((a0, b0, a1, b1, a2, b2), (c0, d0, c1, d1, c2, d2))
17    /// - `false`: layout is ((a0, a1, a2, b0, b1, b2), (c0, c1, c2, d0, d1, d2))
18    interleaved : bool,
19}
20
21pub trait Infos {
22
23    /// Returns the full layout.
24    fn layout(&self) -> LAYOUT;
25
26    /// Returns the ring degree of the polynomials.
27    fn n(&self) -> usize;
28
29    /// Returns the base two logarithm of the ring dimension of the polynomials.
30    fn log_n(&self) -> usize;
31
32    /// Returns the number of rows.
33    fn rows(&self) -> usize;
34
35    /// Returns the number of polynomials in each row.
36    fn cols(&self) -> usize;
37
38    /// Returns the number of limbs per polynomial.
39    fn size(&self) -> usize;
40
41    /// Whether limbs are interleaved across rows.
42    fn interleaved(&self) -> bool;
43}