pub fn berlekamp_massey<T>(a: &[T]) -> Vec<T>Examples found in repository?
More examples
crates/competitive/src/math/black_box_matrix.rs (line 230)
214 fn minimal_polynomial(&self) -> Vec<MInt<M>>
215 where
216 M: MIntConvert<u64>,
217 {
218 assert_eq!(self.shape().0, self.shape().1);
219 let n = self.shape().0;
220 let mut rng = Xorshift::new();
221 let b: Vec<MInt<M>> = (0..n).map(|_| MInt::from(rng.rand64())).collect();
222 let u: Vec<MInt<M>> = (0..n).map(|_| MInt::from(rng.rand64())).collect();
223 let a: Vec<MInt<M>> = (0..2 * n)
224 .scan(b, |b, _| {
225 let a = b.iter().zip(&u).fold(MInt::zero(), |s, (x, y)| s + x * y);
226 *b = self.apply(b);
227 Some(a)
228 })
229 .collect();
230 let mut p = berlekamp_massey(&a);
231 p.reverse();
232 p
233 }