use crate::rational::PolyOverQ;
use flint_sys::fmpq_poly::fmpq_poly_exp_series;
use std::str::FromStr;
impl PolyOverQ {
pub(crate) fn exp_function_taylor(length: impl Into<u32>) -> Self {
let mut out = Self::default();
let x_poly = PolyOverQ::from_str("2 0 1").unwrap();
unsafe { fmpq_poly_exp_series(&mut out.poly, &x_poly.poly, length.into().into()) };
out
}
}
#[cfg(test)]
mod test_exp_series {
use crate::{
rational::{PolyOverQ, Q},
traits::GetCoefficient,
};
#[test]
fn coefficient_set_correctly() {
let length: u32 = 1000;
let poly = PolyOverQ::exp_function_taylor(length);
let mut fac_value = Q::ONE;
assert_eq!(fac_value, poly.get_coeff(0).unwrap());
for i in 1..length {
fac_value *= Q::from((1, i));
assert_eq!(fac_value, poly.get_coeff(i).unwrap());
}
}
#[test]
fn correct_len() {
let length: u32 = 170;
let poly = PolyOverQ::exp_function_taylor(length);
assert_eq!(length as i64, poly.poly.length);
}
}