MCPcopy Create free account
hub / github.com/Axect/Peroxide / check_chebyshev_lagrange

Function check_chebyshev_lagrange

examples/clippy_verify.rs:74–95  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

72}
73
74fn check_chebyshev_lagrange() {
75 // chebyshev_nodes carries one of the affected loops directly.
76 for &n in &[4_usize, 8, 16, 32] {
77 let nodes = chebyshev_nodes(n, -2.0, 3.5);
78 print_kv(&format!("chebyshev_nodes(n={n}) hash"), hash_f64s(&nodes));
79 }
80 // lagrange_polynomial uses divided-difference loops touched by clippy.
81 let xs = vec![0.0_f64, 0.5, 1.1, 1.7, 2.4, 3.0];
82 let ys: Vec<f64> = xs.iter().map(|x| x.sin() + 0.5 * x).collect();
83 let p = lagrange_polynomial(xs.clone(), ys.clone());
84 for &q in &[0.1_f64, 0.7, 1.3, 1.9, 2.5] {
85 print_kv(
86 &format!("lagrange.eval({q})"),
87 format!("{:.17e}", p.eval(q)),
88 );
89 }
90 print_kv(
91 "lagrange.derivative coeffs",
92 hash_f64s(&p.derivative().coef),
93 );
94 print_kv("lagrange.integral coeffs", hash_f64s(&p.integral().coef));
95}
96
97fn check_lanczos() {
98 for &z in &[0.5_f64, 1.0, 1.5, 2.5, 3.7, 5.5, 10.25, 100.0] {

Callers 1

mainFunction · 0.85

Calls 8

chebyshev_nodesFunction · 0.85
print_kvFunction · 0.85
hash_f64sFunction · 0.85
lagrange_polynomialFunction · 0.85
iterMethod · 0.80
sinMethod · 0.45
derivativeMethod · 0.45
integralMethod · 0.45

Tested by

no test coverage detected