1pub mod tables;
17
18pub mod aberth;
20
21pub mod horner;
23
24pub mod matrix2;
26
27pub mod rootfinding;
29
30pub mod leja_order;
32
33pub mod vector2;
35
36pub mod vector2_ref;
38
39pub use crate::aberth::{
40 aberth, aberth_autocorr, aberth_mt, initial_aberth, initial_aberth_autocorr,
41 poly_from_autocorr_roots, poly_from_roots,
42};
43pub use crate::horner::{horner_eval_c, horner_eval_f};
44pub use crate::matrix2::Matrix2;
45pub use crate::rootfinding::{
46 extract_autocorr, initial_autocorr, initial_guess, pbairstow_autocorr, pbairstow_autocorr_mt,
47 pbairstow_even, pbairstow_even_mt, poly_from_autocorr_factors, poly_from_quadratic_factors,
48 Options,
49};
50pub use crate::vector2::Vector2;
51
52#[cfg(test)]
53mod tests {
54 use super::*;
55
56 #[test]
57 fn it_works() {
58 let a = Vector2::<f64>::new(1.2, 2.3);
59 a.scale(3.4);
60 a.unscale(3.4);
61 println!("{:?}", a.norm_sqr());
62 println!("{:?}", a.l1_norm());
63
64 let b = Vector2::<f64>::new(3.4, 4.5);
65 println!("{:?}", a + b);
66 println!("{:?}", a - b);
67
68 let mut a = Vector2::<f64>::new(4.2, 5.3);
69 a += b;
70 a -= b;
71 a *= 3.4;
72 a /= 3.4;
73 println!("{:?}", -a);
74 println!("{:?}", a * 3.4);
75 println!("{:?}", 3.4 * a);
76 println!("{:?}", a / 3.4);
77
78 let mm = Vector2::<Vector2<f64>>::new(a, b);
79 println!("{:?}", mm);
80
81 let mm = Matrix2::<f64>::new(a, b);
82 println!("{:?}", mm);
83
84 let b = Vector2::<i32>::new(42, 53);
85 println!("{:?}", b % 3);
86
87 let options = Options {
88 max_iters: 2000,
89 tolerance: 1e-12,
90 tol_ind: 1e-15,
91 };
92
93 let coeffs = vec![10.0, 34.0, 75.0, 94.0, 150.0, 94.0, 75.0, 34.0, 10.0];
94
95 let mut vrs = initial_guess(&coeffs);
96 let (niter, _found) = pbairstow_even(&coeffs, &mut vrs, &options);
97 println!("{niter}");
98
99 let mut vrs = initial_guess(&coeffs);
100 let (niter, _found) = pbairstow_even_mt(&coeffs, &mut vrs, &options);
101 println!("{niter}");
102
103 let mut vrs = initial_autocorr(&coeffs);
104 let (niter, _found) = pbairstow_autocorr(&coeffs, &mut vrs, &options);
105 println!("{niter}");
106
107 let mut vrs = initial_autocorr(&coeffs);
108 let (niter, _found) = pbairstow_autocorr_mt(&coeffs, &mut vrs, &options);
109 println!("{niter}");
110
111 let mut zs = initial_aberth(&coeffs);
112 let (niter, _found) = aberth(&coeffs, &mut zs, &options);
113 println!("{niter}");
114
115 let mut zs = initial_aberth(&coeffs);
116 let (niter, _found) = aberth_mt(&coeffs, &mut zs, &options);
117 println!("{niter}");
118 }
119}