File tree Expand file tree Collapse file tree 1 file changed +20
-6
lines changed Expand file tree Collapse file tree 1 file changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -416,19 +416,33 @@ trait InternalImplementations: ModIntBase {
416416 Self :: raw ( val)
417417 }
418418
419- #[ inline]
420- fn mul_impl ( lhs : Self , rhs : Self ) -> Self {
421- let modulus = Self :: modulus ( ) ;
422- Self :: raw ( ( u64:: from ( lhs. val ( ) ) * u64:: from ( rhs. val ( ) ) % u64:: from ( modulus) ) as u32 )
423- }
419+ fn mul_impl ( lhs : Self , rhs : Self ) -> Self ;
424420
425421 #[ inline]
426422 fn div_impl ( lhs : Self , rhs : Self ) -> Self {
427423 Self :: mul_impl ( lhs, rhs. inv ( ) )
428424 }
429425}
430426
431- impl < Z : ModIntBase > InternalImplementations for Z { }
427+ impl < M : Modulus > InternalImplementations for StaticModInt < M > {
428+ #[ inline]
429+ fn mul_impl ( lhs : Self , rhs : Self ) -> Self {
430+ Self :: raw ( ( u64:: from ( lhs. val ( ) ) * u64:: from ( rhs. val ( ) ) % u64:: from ( M :: VALUE ) ) as u32 )
431+ }
432+ }
433+
434+ impl < I : Id > InternalImplementations for DynamicModInt < I > {
435+ #[ inline]
436+ fn mul_impl ( lhs : Self , rhs : Self ) -> Self {
437+ BARRETTS . with ( |bts| {
438+ let mut bts = bts. borrow_mut ( ) ;
439+ if bts. len ( ) <= I :: VALUE {
440+ bts. resize_with ( I :: VALUE + 1 , default_barrett) ;
441+ }
442+ Self :: raw ( bts[ I :: VALUE ] . mul ( lhs. val , rhs. val ) )
443+ } )
444+ }
445+ }
432446
433447macro_rules! impl_basic_traits {
434448 ( ) => { } ;
You can’t perform that action at this time.
0 commit comments