Merge remote-tracking branch 'origin/main'
# Conflicts: # src/main.rs
This commit is contained in:
@@ -6,11 +6,11 @@ use crate::point::Point;
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct Function{
|
||||
f: fn(&f64)->f64,
|
||||
f: fn(f64)->f64,
|
||||
}
|
||||
|
||||
impl Function {
|
||||
pub fn new(f: fn(&f64) -> f64) -> Function {
|
||||
pub fn new(f: fn(f64) -> f64) -> Function {
|
||||
return Function {f};
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ impl Function {
|
||||
}
|
||||
|
||||
fn includes(&self, point: &Point) -> bool {
|
||||
let y_0: f64 = (self.f)(&point.get_x());
|
||||
let y_0: f64 = (self.f)(point.get_x());
|
||||
return y_0.abs() > point.get_y().abs() && y_0 * point.get_y() >= 0_f64;
|
||||
}
|
||||
|
||||
|
||||
10
src/main.rs
10
src/main.rs
@@ -14,17 +14,17 @@ mod bounds;
|
||||
mod function;
|
||||
mod plot;
|
||||
|
||||
const THREAD_CNT: usize = 8;
|
||||
const THREAD_CNT: usize = 20;
|
||||
const SAMPLE_LIMIT: usize = 100_000_000;
|
||||
const SUB_SAMPLES: [usize; 3] = [1, 2, 5];
|
||||
const SAMPLES_PER_ITERATION: usize = 250;
|
||||
|
||||
fn f(x: &f64) -> f64 {
|
||||
E.powf(*x) * (1.0 / (*x).sin()).cos() + (*x).powf(2.0)
|
||||
fn f(x: f64) -> f64 {
|
||||
E.powf(x) * (1.0 / x.sin()).cos() + x.powf(2.0)
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let bounds: Bounds = Bounds::new(LinearBounds::new(3.1_f64, 3.2_f64), LinearBounds::new(-15_f64, 35_f64));
|
||||
let bounds: Bounds = Bounds::new(LinearBounds::new(3.1_f64, 3.2_f64), LinearBounds::new(-10_f64, 35_f64));
|
||||
let func: Function = Function::new(f);
|
||||
|
||||
//let start: Instant = Instant::now();
|
||||
@@ -48,6 +48,8 @@ fn simulate(bounds: &Bounds, func: &Function) {
|
||||
println!();
|
||||
}
|
||||
sample_cnt *= 10;
|
||||
}
|
||||
result.print();
|
||||
|
||||
let file: io::Result<File> = File::create(format!("output{}.json", sample_cnt.ilog10()));
|
||||
if file.is_err() {
|
||||
|
||||
Reference in New Issue
Block a user