Skip to content

Commit 838b45b

Browse files
committed
Reduce the number of type parameters
1 parent 4524c31 commit 838b45b

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

src/convolution.rs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ use std::{
1111
};
1212

1313
#[allow(clippy::many_single_char_names)]
14-
pub fn convolution<M: Modulus>(
15-
a: &[StaticModInt<M>],
16-
b: &[StaticModInt<M>],
17-
) -> Vec<StaticModInt<M>> {
14+
pub fn convolution<M>(a: &[StaticModInt<M>], b: &[StaticModInt<M>]) -> Vec<StaticModInt<M>>
15+
where
16+
M: Modulus,
17+
{
1818
if a.is_empty() || b.is_empty() {
1919
return vec![];
2020
}
@@ -49,14 +49,12 @@ pub fn convolution<M: Modulus>(
4949
a
5050
}
5151

52-
pub fn convolution_raw<
53-
T: RemEuclidU32 + TryFrom<u32, Error = E> + Clone,
54-
E: fmt::Debug,
52+
pub fn convolution_raw<T, M>(a: &[T], b: &[T]) -> Vec<T>
53+
where
54+
T: RemEuclidU32 + TryFrom<u32> + Clone,
55+
T::Error: fmt::Debug,
5556
M: Modulus,
56-
>(
57-
a: &[T],
58-
b: &[T],
59-
) -> Vec<T> {
57+
{
6058
let a = a.iter().cloned().map(Into::into).collect::<Vec<_>>();
6159
let b = b.iter().cloned().map(Into::into).collect::<Vec<_>>();
6260
convolution::<M>(&a, &b)
@@ -110,9 +108,9 @@ pub fn convolution_i64(a: &[i64], b: &[i64]) -> Vec<i64> {
110108
let i2 = internal_math::inv_gcd(M1M3 as _, M2 as _).1;
111109
let i3 = internal_math::inv_gcd(M1M2 as _, M3 as _).1;
112110

113-
let c1 = convolution_raw::<i64, _, M1>(a, b);
114-
let c2 = convolution_raw::<i64, _, M2>(a, b);
115-
let c3 = convolution_raw::<i64, _, M3>(a, b);
111+
let c1 = convolution_raw::<i64, M1>(a, b);
112+
let c2 = convolution_raw::<i64, M2>(a, b);
113+
let c3 = convolution_raw::<i64, M3>(a, b);
116114

117115
c1.into_iter()
118116
.zip(c2)

0 commit comments

Comments
 (0)