1use crate::math::fps::inv::*;
3use crate::math::polynomial::{Polynomial, PolynomialOperator};
4use crate::num::ff::*;
5
6pub trait FpsLog {
8 type Poly;
10
11 fn fps_log(&self, f: Self::Poly) -> Result<Self::Poly, &'static str>;
13}
14
15impl<const P: u32, const PR: u32> FpsLog for PolynomialOperator<'_, P, PR> {
16 type Poly = Polynomial<P>;
17
18 fn fps_log(&self, f: Self::Poly) -> Result<Self::Poly, &'static str> {
19 assert_eq!(f.coeff_of(0).value(), 1);
20 let n = f.len();
21 let mut a = f.clone();
22 a.differentiate();
23 let b = self.fps_inv(f)?;
24 let mut ret = self.mul(a, b);
25 ret.integrate();
26 ret.as_mut().resize(n, 0.into());
27 Ok(ret)
28 }
29}