Skip to content

Commit 5c081f0

Browse files
committed
fixed an issue which occurs when pixels escape very fast
1 parent 0de4f4b commit 5c081f0

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

src/math/series_approximation.rs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,10 @@ impl SeriesApproximation {
271271
derivative_probe += next_coefficients[k] * self.approximation_probes_derivative[i][k - 1];
272272
};
273273

274+
probe.reduce();
275+
// series_probe.reduce();
276+
// derivative_probe.reduce();
277+
274278
let relative_error = (probe - series_probe).norm_square();
275279
let mut derivative = derivative_probe.norm_square();
276280

@@ -280,10 +284,14 @@ impl SeriesApproximation {
280284
derivative.exponent = 0;
281285
}
282286

287+
// println!("checking at: {}", *probe_iteration_level);
288+
// println!("relative error: {} derivative: {} delta_square: {}", relative_error, derivative, self.delta_pixel_square);
289+
// println!("probe: {} series_probe: {}", probe, series_probe);
290+
283291
// The first element is reduced, the second might need to be reduced a little more
284292
// Check that the error over the derivative is less than the pixel spacing
285-
if relative_error / derivative > self.delta_pixel_square {
286-
// println!("{} ", *probe_iteration_level);
293+
if relative_error / derivative > self.delta_pixel_square || relative_error.exponent > 0 {
294+
// println!("exceeded at: {} ", *probe_iteration_level);
287295

288296
if *probe_iteration_level <= (current_probe_check_value + self.data_storage_interval + 1) {
289297
*probe_iteration_level = next_probe_check_value;
@@ -354,7 +362,18 @@ impl SeriesApproximation {
354362
}
355363
}
356364

357-
// println!("{:?}", self.valid_interpolation);
365+
println!("series approximation valid interpolation buffer:");
366+
let temp_size = self.probe_sampling - 1;
367+
for i in 0..temp_size {
368+
let test = &self.valid_interpolation[(i * temp_size)..((i + 1) * temp_size)];
369+
print!("[");
370+
371+
for element in test {
372+
print!("{:>8},", element);
373+
}
374+
375+
print!("\x08]\n");
376+
}
358377

359378
if !self.experimental {
360379
self.valid_interpolation = vec![self.min_valid_iteration; (self.probe_sampling - 1) * (self.probe_sampling - 1)];

src/util/complex_extended.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ impl ComplexExtended {
4747

4848
#[inline]
4949
pub fn reduce(&mut self) {
50-
if self.mantissa.re.abs() > self.mantissa.im.abs() {
50+
let positive_real = self.mantissa.re.abs();
51+
let positive_imag = self.mantissa.im.abs();
52+
53+
if positive_real == 0.0 && positive_imag == 0.0 {
54+
self.exponent = 0
55+
} else if positive_real > positive_imag {
5156
let (temp_mantissa, added_exponent) = self.mantissa.re.frexp();
5257
self.mantissa.re = temp_mantissa;
5358
self.mantissa.im = self.mantissa.im.ldexp(-added_exponent);

0 commit comments

Comments
 (0)