1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// // Tests for the integration module
// use quad_rs::{GaussKronrod, Integrate};
//
// // Integrate `1/x` along the real line from -1 -> 1. The analytical
// // value of the integral has been calculated utilising mathematica
// #[test]
// fn integrate_singular_function_with_given_singularities() {
// let function = |x: f64| -> f64 { 1. / x };
// let range = std::ops::Range {
// start: (-1f64),
// end: 1f64,
// };
//
// let integrator = GaussKronrod::new(10);
// let analytical_result = 0.;
// let result = integrator
// .integrate(&function, range, Some(vec![0.]))
// .unwrap();
// let error = *result.error().unwrap();
// let result = *result.result().unwrap();
// assert!((analytical_result - result).abs() < error);
// }
//
// /// Integrate `1/x` along the real line from -1 -> 1. The analytical
// /// value of the integral has been calculated utilising mathematica
// #[test]
// fn integrate_singular_function_without_given_singularities() {
// let function = |x: f64| -> f64 { 1. / x };
// let range = std::ops::Range {
// start: (-1f64),
// end: 1f64,
// };
//
// let integrator = GaussKronrod::new(10);
// let analytical_result = 0.;
// let result = integrator.integrate(&function, range, None).unwrap();
// let error = *result.error().unwrap();
// let result = *result.result().unwrap();
// assert!((analytical_result - result).abs() < error);
// }
//
// #[test]
// fn precompute() {
// let integrator: GaussKronrod<f64> = GaussKronrod::new(10);
// println!("{:?}", integrator.wgk);
// println!("{:?}", integrator.wg);
// println!("{:?}", integrator.xgk);
// }