use crate::{
integer::Z,
rational::{PolyOverQ, Q},
traits::Evaluate,
};
impl Z {
pub fn exp_taylor(&self, length_taylor_polynomial: impl Into<u32>) -> Q {
let exp_taylor_series = PolyOverQ::exp_function_taylor(length_taylor_polynomial);
exp_taylor_series.evaluate(self)
}
}
#[cfg(test)]
mod test_exp {
use crate::{integer::Z, rational::Q};
#[test]
fn zero_length() {
let z = Z::from(17);
assert_eq!(Q::default(), z.exp_taylor(0_u32));
}
#[test]
fn ten_length_value() {
assert_eq!(Q::from((98641, 36288)), Z::ONE.exp_taylor(10_u32));
assert_eq!(Q::from((22471, 1120)), Z::from(3).exp_taylor(10_u32));
assert_eq!(Q::from((83, 2240)), Z::from(-3).exp_taylor(10_u32));
}
}