-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
56 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,65 @@ | ||
// ------ IMPORTS | ||
|
||
use super::*; | ||
|
||
// ------ TESTS | ||
|
||
// integral E (odd) | ||
// y = f(x) = x^3 from -4 to 4 | ||
// expected value = 0 | ||
|
||
mod rectangle_left {} | ||
mod double { | ||
use super::*; | ||
const STEP: f64 = 0.001; | ||
const RES: f64 = 0.0; | ||
|
||
mod rectangle_right {} | ||
const RECTANGLE_TOLERANCE: f64 = 1e-5; | ||
const TRAPEZOID_TOLERANCE: f64 = 1e-5; | ||
|
||
mod trapezoid {} | ||
all_tests!( | ||
f64, | ||
let domain: Vec<f64> = (-4000..4000) | ||
.map(|step_id| f64::from(step_id) * STEP) | ||
.collect(), | ||
FunctionDescriptor::Closure(Box::new(|x: f64| x.powi(2))), | ||
FunctionDescriptor::Values( | ||
(-4000..4000) | ||
.map(|step_id| (f64::from(step_id) * STEP).powi(2)) | ||
.collect() | ||
), | ||
DomainDescriptor::Explicit(&domain), | ||
DomainDescriptor::Uniform { | ||
start: -4., | ||
step: STEP, | ||
n_step: 8000, | ||
}, | ||
); | ||
} | ||
|
||
mod simpson {} | ||
mod simple { | ||
use super::*; | ||
const STEP: f32 = 0.001; | ||
const RES: f32 = 0.0; | ||
|
||
#[cfg(feature = "boole")] | ||
mod boole {} | ||
const RECTANGLE_TOLERANCE: f32 = 1e-5; | ||
const TRAPEZOID_TOLERANCE: f32 = 1e-5; | ||
|
||
#[cfg(feature = "romberg")] | ||
mod romberg {} | ||
all_tests!( | ||
f32, | ||
let domain: Vec<f32> = (-4000..4000) | ||
.map(|step_id| step_id as f32 * STEP) | ||
.collect(), | ||
FunctionDescriptor::Closure(Box::new(|x: f32| x.powi(2))), | ||
FunctionDescriptor::Values( | ||
(-4000..4000) | ||
.map(|step_id| (step_id as f32 * STEP).powi(2)) | ||
.collect() | ||
), | ||
DomainDescriptor::Explicit(&domain), | ||
DomainDescriptor::Uniform { | ||
start: -4., | ||
step: STEP, | ||
n_step: 8000, | ||
}, | ||
); | ||
} |