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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
use fehler::throws;

use crate::{engine, errors::Error};

#[throws]
pub fn calculate_single_integral_simpson<E: Fn(f64) -> f64>(
    equation: E,
    first_integral_begin: f64,
    first_integral_end: f64,
    first_integral_step: f64,
) -> f64 {
    let simpson_quadrature = engine::quadrature::simpson::SimpsonQuadratureSingleIntegral::new(
        equation,
        first_integral_step,
    )?;

    engine::calculate_single_integral(simpson_quadrature, first_integral_begin, first_integral_end)?
}

#[throws]
pub fn calculate_double_integral_simpson<
    E: Fn(f64, f64) -> f64,
    F1: Fn(f64) -> f64,
    F2: Fn(f64) -> f64,
>(
    equation: E,
    first_integral_begin: f64,
    first_integral_end: f64,
    first_integral_step: f64,
    second_integral_begin: F1,
    second_integral_end: F2,
    second_integral_step: f64,
) -> f64 {
    let simpson_quadrature = engine::quadrature::simpson::SimpsonQuadratureDoubleIntegral::new(
        equation,
        first_integral_step,
        second_integral_step,
    )?;

    engine::calculate_double_integral(
        simpson_quadrature,
        first_integral_begin,
        first_integral_end,
        second_integral_begin,
        second_integral_end,
    )?
}

#[throws]
pub fn calculate_triple_integral_simpson<
    E: Fn(f64, f64, f64) -> f64,
    F1: Fn(f64) -> f64,
    F2: Fn(f64) -> f64,
    F3: Fn(f64, f64) -> f64,
    F4: Fn(f64, f64) -> f64,
>(
    equation: E,
    first_integral_begin: f64,
    first_integral_end: f64,
    first_integral_step: f64,
    second_integral_begin: F1,
    second_integral_end: F2,
    second_integral_step: f64,
    third_integral_begin: F3,
    third_integral_end: F4,
    third_integral_step: f64,
) -> f64 {
    let simpson_quadrature = engine::quadrature::simpson::SimpsonQuadratureTripleIntegral::new(
        equation,
        first_integral_step,
        second_integral_step,
        third_integral_step,
    )?;

    engine::calculate_triple_integral(
        simpson_quadrature,
        first_integral_begin,
        first_integral_end,
        second_integral_begin,
        second_integral_end,
        third_integral_begin,
        third_integral_end,
    )?
}