Skip to content

Commit 0171602

Browse files
committed
finalised some optimizations to the series approximation
1 parent e8035da commit 0171602

File tree

3 files changed

+11
-26
lines changed

3 files changed

+11
-26
lines changed

output.png

439 KB
Loading

src/bin/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ fn main() {
6161
center_im,
6262
0.01,
6363
false,
64-
64
64+
16
6565
);
6666

6767
let time = Instant::now();

src/math/series_approximation.rs

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -136,23 +136,23 @@ impl SeriesApproximation {
136136
self.original_probes.push(delta_probe);
137137
self.current_probes.push(delta_probe);
138138

139-
let mut delta_probe_n = delta_probe;
139+
let mut current_value = delta_probe;
140140

141-
let mut delta_probe_n_2 = Vec::with_capacity(self.order + 1);
142-
let mut delta_probe_n_derivative_2 = Vec::with_capacity(self.order + 1);
141+
let mut delta_n = Vec::with_capacity(self.order + 1);
142+
let mut delta_derivative_n = Vec::with_capacity(self.order + 1);
143143

144144
// The first element will be 1, in order for the derivative to be calculated
145-
delta_probe_n_2.push(delta_probe_n);
146-
delta_probe_n_derivative_2.push(ComplexExtended::new2(1.0, 0.0, 0));
145+
delta_n.push(current_value);
146+
delta_derivative_n.push(ComplexExtended::new2(1.0, 0.0, 0));
147147

148148
for i in 1..=self.order {
149-
delta_probe_n_derivative_2.push(delta_probe_n * (i + 1) as f64);
150-
delta_probe_n *= delta_probe;
151-
delta_probe_n_2.push(delta_probe_n);
149+
delta_derivative_n.push(current_value * (i + 1) as f64);
150+
current_value *= delta_probe;
151+
delta_n.push(current_value);
152152
}
153153

154-
self.approximation_probes.push(delta_probe_n_2);
155-
self.approximation_probes_derivative.push(delta_probe_n_derivative_2);
154+
self.approximation_probes.push(delta_n);
155+
self.approximation_probes_derivative.push(delta_derivative_n);
156156
}
157157

158158
// Get the current reference, and the current number of iterations done
@@ -192,21 +192,6 @@ impl SeriesApproximation {
192192
approximation
193193
}
194194

195-
fn evaluate_next(&self, point_delta: ComplexExtended) -> ComplexExtended {
196-
// 1907 ms packing opus 4K
197-
// Horner's rule
198-
let mut approximation = self.next_coefficients[self.order];
199-
200-
for k in (1..=(self.order - 1)).rev() {
201-
approximation *= point_delta;
202-
approximation += self.coefficients[k];
203-
}
204-
205-
approximation *= point_delta;
206-
approximation.reduce();
207-
approximation
208-
}
209-
210195
// pub fn evaluate_derivative(&self, point_delta: ComplexExtended) -> FloatExtended {
211196
// let mut original_point_derivative_n = ComplexExtended::new(1.0, 0, 0.0, 0);
212197
// let mut approximation_derivative = ComplexExtended::new(0.0, 0, 0.0, 0);

0 commit comments

Comments
 (0)