-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpoly_over_zq.rs
67 lines (63 loc) · 1.86 KB
/
poly_over_zq.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright © 2023 Marvin Beckmann
//
// This file is part of qFALL-math.
//
// qFALL-math is free software: you can redistribute it and/or modify it under
// the terms of the Mozilla Public License Version 2.0 as published by the
// Mozilla Foundation. See <https://mozilla.org/en-US/MPL/2.0/>.
//! [`PolyOverZq`] is a type of polynomial with arbitrarily many coefficients of type
//! [`Zq`](crate::integer_mod_q::Zq).
//! This implementation uses the [FLINT](https://flintlib.org/) library.
//!
//! For **DEVELOPERS**: Many functions assume that the [`PolyOverZq`] instances are reduced.
//! To avoid unnecessary checks and reductions, always return canonical/reduced
//! values. The end-user should be unable to obtain a non-reduced value.
use super::modulus::Modulus;
use flint_sys::fmpz_mod_poly::fmpz_mod_poly_struct;
mod arithmetic;
mod cmp;
mod coefficient_embedding;
mod dot_product;
mod evaluate;
mod from;
mod get;
mod norm;
mod ownership;
mod properties;
mod sample;
mod serialize;
mod set;
mod to_string;
/// [`PolyOverZq`] is a type of polynomial with arbitrarily many coefficients of type
/// [`Zq`](crate::integer_mod_q::Zq).
///
// Attributes:
// - `poly`: holds the content of the polynomial
// - `modulus`: holds the value of the modulus
//
/// # Examples
/// ```
/// use qfall_math::integer::Z;
/// use qfall_math::integer_mod_q::PolyOverZq;
/// use qfall_math::traits::*;
/// use std::str::FromStr;
///
/// // instantiations
/// let poly_1 = PolyOverZq::from_str("4 0 1 2 3 mod 42").unwrap();
/// let poly_2 = poly_1.clone();
///
/// // evaluate function
/// let value = Z::from(3);
/// let res = poly_1.evaluate(&value);
///
/// // properties
/// let reducibility: bool = poly_1.is_irreducible();
///
/// // comparison
/// assert_eq!(poly_1, poly_2);
/// ```
#[derive(Debug)]
pub struct PolyOverZq {
pub(crate) poly: fmpz_mod_poly_struct,
pub(crate) modulus: Modulus,
}