1pub mod tables;
17
18pub mod aberth;
20
21pub mod horner;
23
24pub mod matrix2;
26
27pub mod rootfinding;
29
30pub mod autocorr;
32
33pub mod execution_policy;
35
36pub mod solve;
38
39pub mod leja_order;
41
42pub mod scaling;
44
45pub mod seqlock;
47
48pub mod vector2;
50
51pub mod vector2_ref;
53
54pub use crate::aberth::{
55 aberth, aberth_atomic, aberth_autocorr, aberth_mt, initial_aberth, initial_aberth_autocorr,
56 poly_from_autocorr_roots, poly_from_roots,
57};
58pub use crate::autocorr::{
59 extract_autocorr, initial_autocorr, pbairstow_autocorr, pbairstow_autocorr_atomic,
60 pbairstow_autocorr_mt, poly_from_autocorr_factors,
61};
62pub use crate::execution_policy::{should_parallelize, AtomicCell, PARALLEL_THRESHOLD};
63pub use crate::horner::{horner_eval_c, horner_eval_f};
64pub use crate::matrix2::Matrix2;
65pub use crate::rootfinding::{
66 initial_guess, pbairstow_even, pbairstow_even_atomic, pbairstow_even_mt,
67 poly_from_quadratic_factors, Options, Vec2,
68};
69pub use crate::scaling::{derivative_coeffs, residual_scale, scaled_coeffs};
70pub use crate::seqlock::{AtomicComplex, AtomicVec2};
71pub use crate::solve::{
72 solve_aberth, solve_aberth_autocorr, solve_pbairstow_autocorr, solve_pbairstow_even, SolveMode,
73};
74pub use crate::vector2::Vector2;
75
76#[cfg(test)]
77mod tests {
78 use super::*;
79
80 #[test]
81 fn it_works() {
82 let a = Vector2::<f64>::new(1.2, 2.3);
83 a.scale(3.4);
84 a.unscale(3.4);
85 println!("{:?}", a.norm_sqr());
86 println!("{:?}", a.l1_norm());
87
88 let b = Vector2::<f64>::new(3.4, 4.5);
89 println!("{:?}", a + b);
90 println!("{:?}", a - b);
91
92 let mut a = Vector2::<f64>::new(4.2, 5.3);
93 a += b;
94 a -= b;
95 a *= 3.4;
96 a /= 3.4;
97 println!("{:?}", -a);
98 println!("{:?}", a * 3.4);
99 println!("{:?}", 3.4 * a);
100 println!("{:?}", a / 3.4);
101
102 let mm = Vector2::<Vector2<f64>>::new(a, b);
103 println!("{:?}", mm);
104
105 let mm = Matrix2::<f64>::new(a, b);
106 println!("{:?}", mm);
107
108 let b = Vector2::<i32>::new(42, 53);
109 println!("{:?}", b % 3);
110
111 let options = Options {
112 max_iters: 2000,
113 tolerance: 1e-12,
114 tol_ind: 1e-15,
115 };
116
117 let coeffs = vec![10.0, 34.0, 75.0, 94.0, 150.0, 94.0, 75.0, 34.0, 10.0];
118
119 let mut vrs = initial_guess(&coeffs);
120 let (niter, _found) = pbairstow_even(&coeffs, &mut vrs, &options);
121 println!("{niter}");
122
123 let mut vrs = initial_guess(&coeffs);
124 let (niter, _found) = pbairstow_even_mt(&coeffs, &mut vrs, &options);
125 println!("{niter}");
126
127 let mut vrs = initial_autocorr(&coeffs);
128 let (niter, _found) = pbairstow_autocorr(&coeffs, &mut vrs, &options);
129 println!("{niter}");
130
131 let mut vrs = initial_autocorr(&coeffs);
132 let (niter, _found) = pbairstow_autocorr_mt(&coeffs, &mut vrs, &options);
133 println!("{niter}");
134
135 let mut zs = initial_aberth(&coeffs);
136 let (niter, _found) = aberth(&coeffs, &mut zs, &options);
137 println!("{niter}");
138
139 let mut zs = initial_aberth(&coeffs);
140 let (niter, _found) = aberth_mt(&coeffs, &mut zs, &options);
141 println!("{niter}");
142 }
143}