@@ -676,7 +676,7 @@ impl MilnorAlgebra {
676
676
if self . generic {
677
677
let m1f = self . multiply_qpart ( m1, m2. q_part ) ;
678
678
for ( cc, basis) in m1f {
679
- let mut multiplier = PPartMultiplier :: new ( self . prime ( ) , & ( basis. p_part ) , & ( m2. p_part ) , false ) ;
679
+ let mut multiplier = PPartMultiplier :: < false > :: new ( self . prime ( ) , & ( basis. p_part ) , & ( m2. p_part ) ) ;
680
680
let mut new = MilnorBasisElement {
681
681
degree : target_dim,
682
682
q_part : basis. q_part ,
@@ -688,7 +688,7 @@ impl MilnorAlgebra {
688
688
}
689
689
}
690
690
} else {
691
- let mut multiplier = PPartMultiplier :: new ( self . prime ( ) , & ( m1. p_part ) , & ( m2. p_part ) , false ) ;
691
+ let mut multiplier = PPartMultiplier :: < false > :: new ( self . prime ( ) , & ( m1. p_part ) , & ( m2. p_part ) ) ;
692
692
let mut new = MilnorBasisElement {
693
693
degree : target_dim,
694
694
q_part : 0 ,
@@ -732,11 +732,10 @@ impl std::ops::IndexMut<usize> for Matrix2D {
732
732
}
733
733
734
734
#[ allow( non_snake_case) ]
735
- pub struct PPartMultiplier < ' a > {
735
+ pub struct PPartMultiplier < ' a , const MOD4 : bool > {
736
736
p : ValidPrime ,
737
737
M : Matrix2D ,
738
738
r : & ' a PPart ,
739
- mod_4 : bool ,
740
739
rows : usize ,
741
740
cols : usize ,
742
741
diag_num : usize ,
@@ -745,14 +744,14 @@ pub struct PPartMultiplier<'a> {
745
744
}
746
745
747
746
#[ allow( non_snake_case) ]
748
- impl < ' a > PPartMultiplier < ' a > {
747
+ impl < ' a , const MOD4 : bool > PPartMultiplier < ' a , MOD4 > {
749
748
fn prime ( & self ) -> ValidPrime {
750
749
self . p
751
750
}
752
751
753
752
#[ allow( clippy:: ptr_arg) ]
754
- pub fn new ( p : ValidPrime , r : & ' a PPart , s : & ' a PPart , mod_4 : bool ) -> PPartMultiplier < ' a > {
755
- if mod_4 {
753
+ pub fn new ( p : ValidPrime , r : & ' a PPart , s : & ' a PPart ) -> Self {
754
+ if MOD4 {
756
755
assert_eq ! ( * p, 2 ) ;
757
756
}
758
757
let rows = r. len ( ) + 1 ;
@@ -767,7 +766,7 @@ impl<'a> PPartMultiplier<'a> {
767
766
}
768
767
M [ 0 ] [ 1 ..cols] . clone_from_slice ( & s[ 0 ..( cols - 1 ) ] ) ;
769
768
770
- PPartMultiplier { p, M , r, rows, cols, diag_num, diagonal, init : true , mod_4 }
769
+ PPartMultiplier { p, M , r, rows, cols, diag_num, diagonal, init : true }
771
770
}
772
771
773
772
fn update ( & mut self ) -> bool {
@@ -817,7 +816,7 @@ impl<'a> PPartMultiplier<'a> {
817
816
if self . init {
818
817
self . init = false ;
819
818
for i in 1 .. std:: cmp:: min ( self . cols , self . rows ) {
820
- if self . mod_4 {
819
+ if MOD4 {
821
820
coef *= fp:: prime:: binomial4 ( self . M [ i] [ 0 ] + self . M [ 0 ] [ i] , self . M [ 0 ] [ i] ) ;
822
821
} else {
823
822
coef *= fp:: prime:: binomial ( self . prime ( ) , ( self . M [ i] [ 0 ] + self . M [ 0 ] [ i] ) as i32 , self . M [ 0 ] [ i] as i32 ) ;
@@ -852,7 +851,7 @@ impl<'a> PPartMultiplier<'a> {
852
851
if sum == 0 {
853
852
continue ;
854
853
}
855
- if self . mod_4 {
854
+ if MOD4 {
856
855
if coef == 2 {
857
856
coef *= fp:: prime:: multinomial2 ( & self . diagonal ) ;
858
857
} else {
0 commit comments