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 {
416
416
Self :: raw ( val)
417
417
}
418
418
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 ;
424
420
425
421
#[ inline]
426
422
fn div_impl ( lhs : Self , rhs : Self ) -> Self {
427
423
Self :: mul_impl ( lhs, rhs. inv ( ) )
428
424
}
429
425
}
430
426
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
+ }
432
446
433
447
macro_rules! impl_basic_traits {
434
448
( ) => { } ;
You can’t perform that action at this time.
0 commit comments