From 4baea29904442f98eef6974490951fcb7cad1320 Mon Sep 17 00:00:00 2001 From: Daniel Boros Date: Thu, 29 Aug 2024 18:07:18 +0200 Subject: [PATCH] feat: calc scale factor once --- src/noises/fgn.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/noises/fgn.rs b/src/noises/fgn.rs index 2eaf2c8..d816cde 100644 --- a/src/noises/fgn.rs +++ b/src/noises/fgn.rs @@ -109,9 +109,10 @@ impl Generator for FgnFft { let fft_handler = self.fft_handler.clone(); let mut fgn_fft = self.fft_fgn.clone(); ndfft_par(&fgn, &mut fgn_fft, &fft_handler, 0); + let scale_factor = self.t.powf(self.hurst) * (self.n as f64).powf(-self.hurst); let fgn = fgn_fft .slice(s![1..self.n - self.offset + 1]) - .mapv(|x: Complex| (x.re * (self.n as f64).powf(-self.hurst)) * self.t.powf(self.hurst)); + .mapv(|x: Complex| x.re * scale_factor); fgn }