Skip to content

Commit 221d61b

Browse files
committed
fixed rare regression in glitch reference creation
1 parent bd0444a commit 221d61b

File tree

2 files changed

+11
-135
lines changed

2 files changed

+11
-135
lines changed

high_experimental.toml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
11
image_width = 1920
22
image_height = 1080
33
rotate = 0
4-
approximation_order = 64
4+
approximation_order = 32
55
glitch_percentage = 0.001
66
frames = 5
7-
frame_offset = 181
7+
frame_offset = 180
88
zoom_scale = 2.0
99
display_glitches = true
1010
auto_adjust_iterations = true
11-
probe_sampling = 3
1211
remove_centre = true
1312
export = "png"
1413

1514
# By default this is squared tolerance. 1e-6 works normally, 1.4e-6 is low tolerance.
1615
glitch_tolerance = 1.4e-6
1716

17+
18+
probe_sampling = 3
19+
1820
# These are experimental options following
19-
experimental = false
21+
experimental = true
2022

2123
# If this is set higher than the maximum iteration value this will cause any additional glitches to be perturbed without series approximation
2224
high_precision_data_interval = 100
23-
valid_iteration_frame_multiplier = 0.90
25+
valid_iteration_frame_multiplier = 0.95
2426
valid_iteration_probe_multiplier = 0.999

src/math/series_approximation.rs

Lines changed: 4 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,9 @@ impl SeriesApproximation {
170170
derivative.exponent = 0;
171171
}
172172

173+
// The first element is reduced, the second might need to be reduced a little more
173174
// Check that the error over the derivative is less than the pixel spacing
174-
if relative_error / derivative > 1e-6 * self.delta_pixel_square {
175+
if relative_error / derivative > self.delta_pixel_square {
175176
break;
176177
}
177178

@@ -231,7 +232,7 @@ impl SeriesApproximation {
231232
}
232233

233234
// Check that the error over the derivative is less than the pixel spacing
234-
if relative_error / derivative > 1e-6 * self.delta_pixel_square {
235+
if relative_error / derivative > self.delta_pixel_square {
235236
// set the current value to the lower one so it is checked in the next iteration
236237
if *probe_iteration_level <= (current_probe_check_value + 10) {
237238
*probe_iteration_level = next_probe_check_value;
@@ -261,133 +262,6 @@ impl SeriesApproximation {
261262
}
262263

263264
self.valid_iterations = valid_iterations;
264-
265-
266-
267-
// let mut previous_value = self.min_valid_iteration;
268-
269-
// while true {
270-
// let mut first_valid_iterations = max(1, (previous_value as f32 * self.valid_iteration_frame_multiplier) as usize);
271-
// let i = 0;
272-
273-
// let mut probe = if first_valid_iterations > 1 {
274-
// self.evaluate(self.probe_start[i], first_valid_iterations)
275-
// } else {
276-
// self.probe_start[i]
277-
// };
278-
279-
// while first_valid_iterations < self.maximum_iteration {
280-
// let coefficients = &self.coefficients[first_valid_iterations - 1];
281-
// let next_coefficients = &self.coefficients[first_valid_iterations];
282-
283-
// // step the probe points using perturbation
284-
// probe = probe * (coefficients[0] * 2.0 + probe);
285-
// probe += self.probe_start[i];
286-
287-
// // This is not done on every iteration
288-
// if first_valid_iterations % 250 == 0 {
289-
// probe.reduce();
290-
// }
291-
292-
// // get the new approximations
293-
// let mut series_probe = next_coefficients[1] * self.approximation_probes[i][0];
294-
// let mut derivative_probe = next_coefficients[1] * self.approximation_probes_derivative[i][0];
295-
296-
// for k in 2..=self.order {
297-
// series_probe += next_coefficients[k] * self.approximation_probes[i][k - 1];
298-
// derivative_probe += next_coefficients[k] * self.approximation_probes_derivative[i][k - 1];
299-
// };
300-
301-
// let relative_error = (probe - series_probe).norm_square();
302-
// let mut derivative = derivative_probe.norm_square();
303-
304-
// // Check to make sure that the derivative is greater than or equal to 1
305-
// if derivative.to_float() < 1.0 {
306-
// derivative.mantissa = 1.0;
307-
// derivative.exponent = 0;
308-
// }
309-
310-
// // Check that the error over the derivative is less than the pixel spacing
311-
// if relative_error / derivative > 1e-6 * self.delta_pixel_square {
312-
// break;
313-
// }
314-
315-
// first_valid_iterations += 1;
316-
// }
317-
318-
// self.valid_iterations = Vec::new();
319-
// self.valid_iterations.push(first_valid_iterations);
320-
321-
// let new_start_iterations = max(1, (previous_value as f32 * self.valid_iteration_probe_multiplier) as usize);
322-
323-
// // we now have a value for valid iterations, lets do the rest of the probes, but with 0.95 * that iteration
324-
325-
// let other_valid_iterations = (1..self.probe_start.len()).into_par_iter()
326-
// .map(|i| {
327-
// let mut valid_iterations = new_start_iterations;
328-
// let mut probe = self.evaluate(self.probe_start[i], valid_iterations);
329-
330-
// while valid_iterations < self.maximum_iteration {
331-
// let coefficients = &self.coefficients[valid_iterations - 1];
332-
// let next_coefficients = &self.coefficients[valid_iterations];
333-
334-
// // step the probe points using perturbation
335-
// probe = probe * (coefficients[0] * 2.0 + probe);
336-
// probe += self.probe_start[i];
337-
338-
// // This is not done on every iteration
339-
// if valid_iterations % 250 == 0 {
340-
// probe.reduce();
341-
// }
342-
343-
// // get the new approximations
344-
// let mut series_probe = next_coefficients[1] * self.approximation_probes[i][0];
345-
// let mut derivative_probe = next_coefficients[1] * self.approximation_probes_derivative[i][0];
346-
347-
// for k in 2..=self.order {
348-
// series_probe += next_coefficients[k] * self.approximation_probes[i][k - 1];
349-
// derivative_probe += next_coefficients[k] * self.approximation_probes_derivative[i][k - 1];
350-
// };
351-
352-
// let relative_error = (probe - series_probe).norm_square();
353-
// let mut derivative = derivative_probe.norm_square();
354-
355-
// // Check to make sure that the derivative is greater than or equal to 1
356-
// if derivative.to_float() < 1.0 {
357-
// derivative.mantissa = 1.0;
358-
// derivative.exponent = 0;
359-
// }
360-
361-
// // Check that the error over the derivative is less than the pixel spacing
362-
// if relative_error / derivative > 1e-6 * self.delta_pixel_square {
363-
// break;
364-
// }
365-
366-
// valid_iterations += 1;
367-
368-
// }
369-
370-
// valid_iterations
371-
// }).collect::<Vec<usize>>();
372-
373-
// self.valid_iterations.extend_from_slice(other_valid_iterations.as_slice());
374-
375-
// self.min_valid_iteration = self.valid_iterations.iter().min().unwrap().clone();
376-
// previous_value = self.min_valid_iteration;
377-
378-
// if new_start_iterations != 0 && self.min_valid_iteration == new_start_iterations {
379-
// // we only need to recurse the ones which didn't work out
380-
// println!("recurse {} {} {}", first_valid_iterations, new_start_iterations, self.min_valid_iteration);
381-
// continue;
382-
// } else {
383-
// println!("break {} {} {}", first_valid_iterations, new_start_iterations, self.min_valid_iteration);
384-
// break;
385-
// }
386-
// }
387-
388-
389-
// println!("{:?}", valid_iterations_array);
390-
391265
} else {
392266
// Possible how to add the roots as probes
393267

@@ -485,7 +359,7 @@ impl SeriesApproximation {
485359
// Get the current reference, and the current number of iterations done
486360
pub fn get_reference(&self, reference_delta: ComplexExtended, center_reference: &Reference) -> Reference {
487361
let precision = center_reference.c.real().prec();
488-
let iteration_reference = self.high_precision_data_interval * (self.min_valid_iteration / self.high_precision_data_interval) + 1;
362+
let iteration_reference = self.high_precision_data_interval * ((self.min_valid_iteration - 1) / self.high_precision_data_interval) + 1;
489363

490364
let mut reference_c = center_reference.c.clone();
491365
let temp = Float::with_val(precision, reference_delta.exponent).exp2();

0 commit comments

Comments
 (0)