@@ -19,7 +19,6 @@ use crate::{
1919} ;
2020use flint_sys:: {
2121 fmpq_poly:: fmpq_poly_sub, fmpz_mod_poly:: fmpz_mod_poly_sub, fmpz_poly:: fmpz_poly_sub,
22- fq:: fq_sub,
2322} ;
2423use std:: ops:: { Sub , SubAssign } ;
2524
@@ -148,15 +147,8 @@ impl Sub<&PolynomialRingZq> for &PolyOverZ {
148147 /// let c: PolynomialRingZq = &b - &a;
149148 /// ```
150149 fn sub ( self , other : & PolynomialRingZq ) -> Self :: Output {
151- let mut out = PolynomialRingZq :: from ( ( & PolyOverZ :: default ( ) , & other. modulus ) ) ;
152- unsafe {
153- fq_sub (
154- & mut out. poly . poly ,
155- & self . poly ,
156- & other. poly . poly ,
157- other. modulus . get_fq_ctx ( ) ,
158- ) ;
159- }
150+ let mut out = PolynomialRingZq :: from ( ( self , & other. modulus ) ) ;
151+ out -= other;
160152 out
161153 }
162154}
@@ -352,10 +344,10 @@ mod test_sub_poly_ring_zq {
352344 #[ test]
353345 fn borrowed_correctness ( ) {
354346 let poly_1 =
355- PolynomialRingZq :: from_str ( & format ! ( "2 2 {} / 4 1 2 3 4 mod {}" , i64 :: MAX , u64 :: MAX ) )
347+ PolynomialRingZq :: from_str ( & format ! ( "2 2 {} / 4 1 2 3 1 mod {}" , i64 :: MAX , u64 :: MAX ) )
356348 . unwrap ( ) ;
357349 let poly_2 = PolynomialRingZq :: from_str ( & format ! (
358- "2 -1 -{} / 4 1 2 3 4 mod {}" ,
350+ "2 -1 -{} / 4 1 2 3 1 mod {}" ,
359351 i64 :: MAX as u64 - 2 ,
360352 u64 :: MAX
361353 ) )
@@ -370,7 +362,7 @@ mod test_sub_poly_ring_zq {
370362 /// Checks if subtraction works fine for different types
371363 #[ test]
372364 fn availability ( ) {
373- let poly = PolynomialRingZq :: from_str ( "3 1 2 3 / 4 1 2 3 4 mod 17" ) . unwrap ( ) ;
365+ let poly = PolynomialRingZq :: from_str ( "3 1 2 3 / 4 1 2 3 1 mod 17" ) . unwrap ( ) ;
374366 let z = PolyOverZ :: from ( 2 ) ;
375367
376368 _ = z. clone ( ) - poly. clone ( ) ;
0 commit comments