Skip to content

Commit

Permalink
add tests for montecarlo compute
Browse files Browse the repository at this point in the history
  • Loading branch information
imrn99 committed Oct 15, 2024
1 parent 92b5ad8 commit 7fea280
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 0 deletions.
2 changes: 2 additions & 0 deletions integraal/src/tests/function_a.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ mod double {
const SIMPSON_TOLERANCE: f64 = 1e-5;
const BOOLE_TOLERANCE: f64 = 1e-5;
const ROMBERG_TOLERANCE: f64 = 1e-5;
const MONTECARLO_TOLERANCE: f64 = 1e-5;

all_tests!(
f64,
Expand Down Expand Up @@ -50,6 +51,7 @@ mod simple {
const SIMPSON_TOLERANCE: f32 = 1e-5;
const BOOLE_TOLERANCE: f32 = 1e-5;
const ROMBERG_TOLERANCE: f32 = 1e-5;
const MONTECARLO_TOLERANCE: f32 = 1e-5;

all_tests!(
f32,
Expand Down
2 changes: 2 additions & 0 deletions integraal/src/tests/function_b.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ mod double {
const SIMPSON_TOLERANCE: f64 = 1e-5;
const BOOLE_TOLERANCE: f64 = 1e-5;
const ROMBERG_TOLERANCE: f64 = 1e-5;
const MONTECARLO_TOLERANCE: f64 = 1e-5;

all_tests!(
f64,
Expand Down Expand Up @@ -64,6 +65,7 @@ mod simple {
const SIMPSON_TOLERANCE: f32 = 1e-5;
const BOOLE_TOLERANCE: f32 = 1e-5;
const ROMBERG_TOLERANCE: f32 = 1e-5;
const MONTECARLO_TOLERANCE: f32 = 1e-5;

all_tests!(
f32,
Expand Down
2 changes: 2 additions & 0 deletions integraal/src/tests/function_c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ mod double {
const SIMPSON_TOLERANCE: f64 = 1e-5;
const BOOLE_TOLERANCE: f64 = 1e-5;
const ROMBERG_TOLERANCE: f64 = 1e-5;
const MONTECARLO_TOLERANCE: f64 = 1e-5;

all_tests!(
f64,
Expand Down Expand Up @@ -62,6 +63,7 @@ mod simple {
const SIMPSON_TOLERANCE: f32 = 1e-5;
const BOOLE_TOLERANCE: f32 = 1e-5;
const ROMBERG_TOLERANCE: f32 = 1e-5;
const MONTECARLO_TOLERANCE: f32 = 1e-5;

all_tests!(
f32,
Expand Down
2 changes: 2 additions & 0 deletions integraal/src/tests/function_d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ mod double {
const SIMPSON_TOLERANCE: f64 = 1e-5;
const BOOLE_TOLERANCE: f64 = 1e-5;
const ROMBERG_TOLERANCE: f64 = 1e-5;
const MONTECARLO_TOLERANCE: f64 = 1e-5;

all_tests!(
f64,
Expand Down Expand Up @@ -51,6 +52,7 @@ mod simple {
const SIMPSON_TOLERANCE: f32 = 1e-5;
const BOOLE_TOLERANCE: f32 = 1e-5;
const ROMBERG_TOLERANCE: f32 = 1e-5;
const MONTECARLO_TOLERANCE: f32 = 1e-5;

all_tests!(
f32,
Expand Down
2 changes: 2 additions & 0 deletions integraal/src/tests/function_e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ mod double {
const SIMPSON_TOLERANCE: f64 = 1e-5;
const BOOLE_TOLERANCE: f64 = 1e-5;
const ROMBERG_TOLERANCE: f64 = 1e-5;
const MONTECARLO_TOLERANCE: f64 = 1e-5;

all_tests!(
f64,
Expand Down Expand Up @@ -51,6 +52,7 @@ mod simple {
const SIMPSON_TOLERANCE: f32 = 1e-5;
const BOOLE_TOLERANCE: f32 = 1e-5;
const ROMBERG_TOLERANCE: f32 = 1e-5;
const MONTECARLO_TOLERANCE: f32 = 1e-5;

all_tests!(
f32,
Expand Down
48 changes: 48 additions & 0 deletions integraal/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,54 @@ macro_rules! all_tests {
ROMBERG_TOLERANCE
);
}

#[cfg(feature = "montecarlo")]
#[allow(clippy::cast_sign_loss, clippy::cast_possible_truncation)]
mod montecarlo {
use super::*;

generate_test!(
$ft,
ClosureExplicit,
$dm,
$fnd_cls,
$dmd_xpl,
ComputeMethod::MonteCarlo { n_sample: 100 },
RES,
MONTECARLO_TOLERANCE
);

generate_test!(
$ft,
ClosureUniform,
$fnd_cls,
$dmd_uni,
ComputeMethod::MonteCarlo { n_sample: 100 },
RES,
MONTECARLO_TOLERANCE
);

generate_test!(
$ft,
ValuesExplicit,
$dm,
$fnd_val,
$dmd_xpl,
ComputeMethod::MonteCarlo { n_sample: 100 },
RES,
MONTECARLO_TOLERANCE
);

generate_test!(
$ft,
ValuesUniform,
$fnd_val,
$dmd_uni,
ComputeMethod::MonteCarlo { n_sample: 100 },
RES,
MONTECARLO_TOLERANCE
);
}
};
}

Expand Down

0 comments on commit 7fea280

Please sign in to comment.