new stopping condition
This commit is contained in:
parent
2330879748
commit
749ea72cfe
1 changed files with 13 additions and 9 deletions
|
|
@ -13,12 +13,11 @@ pub fn fractal_dimension(
|
||||||
orthogonal_generators: Vec<Vec<usize>>,
|
orthogonal_generators: Vec<Vec<usize>>,
|
||||||
) -> Result<f64, linregress::Error> {
|
) -> Result<f64, linregress::Error> {
|
||||||
let mut totals = vec![root.len(); n];
|
let mut totals = vec![root.len(); n];
|
||||||
let mut current = vec![(root, std::usize::MAX, false)];
|
let mut current = vec![(root, std::usize::MAX)];
|
||||||
let mut next = vec![];
|
let mut next = vec![];
|
||||||
let mut nodes: u64 = 1;
|
let mut nodes: u64 = 1;
|
||||||
|
|
||||||
let xs: Vec<f64> = (1..=n)
|
let xs: Vec<f64> = (1..=n)
|
||||||
// .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))
|
.map(|x| (x as f64 * upper_bound / (2.0 * n as f64) + upper_bound / 2.0))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
|
|
@ -26,7 +25,9 @@ pub fn fractal_dimension(
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
next.clear();
|
next.clear();
|
||||||
for (tuple, previous_generator, bad) in ¤t {
|
for (tuple, previous_generator) in ¤t {
|
||||||
|
let mut add_children = false;
|
||||||
|
let mut children = vec![];
|
||||||
for (i, generator) in generators.iter().enumerate() {
|
for (i, generator) in generators.iter().enumerate() {
|
||||||
let mut skip = false;
|
let mut skip = false;
|
||||||
for orthogonal_pairs in &orthogonal_generators {
|
for orthogonal_pairs in &orthogonal_generators {
|
||||||
|
|
@ -63,14 +64,17 @@ pub fn fractal_dimension(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if add {
|
if add {
|
||||||
next.push((new_tuple, i, false));
|
add_children = true;
|
||||||
nodes += 1;
|
children.push((new_tuple, i));
|
||||||
} else {
|
} else {
|
||||||
if !bad {
|
children.push((new_tuple, i));
|
||||||
next.push((new_tuple, i, true));
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if add_children {
|
||||||
nodes += 1;
|
nodes += 1;
|
||||||
}
|
for child in children {
|
||||||
}
|
next.push(child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue