From fc9c4fc4347c5418e0fda688e3ea5c4abbe3abfa Mon Sep 17 00:00:00 2001 From: William Ball Date: Thu, 15 Jul 2021 17:15:05 -0400 Subject: [PATCH] upper half only --- fractal_dimension/circle_counting_new/src/lib.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fractal_dimension/circle_counting_new/src/lib.rs b/fractal_dimension/circle_counting_new/src/lib.rs index 2b37898..28628cb 100644 --- a/fractal_dimension/circle_counting_new/src/lib.rs +++ b/fractal_dimension/circle_counting_new/src/lib.rs @@ -15,9 +15,11 @@ pub fn fractal_dimension( let mut totals = vec![root.len(); n]; let mut current = vec![(root, std::usize::MAX, false)]; let mut next = vec![]; + let mut nodes = 1; let xs: Vec = (1..=n) - .map(|x| (x as f64 * upper_bound / (n as f64))) + // .map(|x| (x as f64 * upper_bound / (n as f64))) + .map(|x| (x as f64 * upper_bound / (2.0 * n as f64) + upper_bound / 2.0)) .collect(); let mut i = 0; @@ -62,9 +64,11 @@ pub fn fractal_dimension( } if add { next.push((new_tuple, i, false)); + nodes += 1; } else { if !bad { next.push((new_tuple, i, true)); + nodes += 1; } } } @@ -98,6 +102,7 @@ pub fn fractal_dimension( "\nnumber of circles fewer than each of those sample points:\n{:?}", totals ); + println!("\nTotal number of nodes:\t{}", nodes); } let xs: Vec = xs.iter().map(|x| x.ln()).collect();