test_gmp_mpir
=============
test gmp mpir for Rust
Sample
------
calc pi/4 sum arctan Gregory
- arctan x = sigma[n=0->inf]{(-1**n)*x**(2n+1)/(2n+1)}
- sum_n = sigma[k=0->ax.len](a_k * arctan_n x_k)
- result = sigma[n=0->m]sum_n
- inner loop may be slow (should be outer mul a_k) to check stop iterator
```Rust
pub fn sum_arctan_gregory(ax: &[(si_t, ui_t)], m: ui_t) -> Self {
let mut sa = mpf_s::from(0);
let ax = ax.into_iter().map(|&(a, x)|
if a < 0 { (1, -a as ui_t, x) } else { (0, a as ui_t, x) } // care range
).collect::<Vec<_>>();
let _s = (0..=m).try_fold(&mut sa, |mut sa, n| {
let pre = &mpf_s::from(&*sa);
let k = 2 * n + 1;
let mut sn = mpf_s::from(0);
let _a = ax.iter().fold(&mut sn, |mut sn, (sgn, a, x)| {
// let s = a * (mpz_s::ui_pow_ui(*x, k) * k).inv_f(); // outer a to faster
let s = a / mpf_s::from(&(mpz_s::ui_pow_ui(*x, k) * k));
if 1 == ((n & 1) ^ sgn) { sn -= s; } else { sn += s; }
sn
});
sa += sn;
if sa.cmp(pre) == 0 { None } else { Some(sa) }
});
sa
}
```
Links
-----
- [https://crates.io/crates/test_gmp_mpir](https://crates.io/crates/test_gmp_mpir)
- [https://github.com/nomissbowling/test_gmp_mpir](https://github.com/nomissbowling/test_gmp_mpir)
Requirements
------------
- [gmp](https://gmplib.org)
- [mpir](https://github.com/ChillMagic/MPIR-Binary)
License
-------
MIT License