|
1 | 1 | use std::sync::{Arc, RwLock}; |
2 | 2 |
|
3 | | -#[cfg(feature = "cuda")] |
4 | | -use either::Either; |
5 | 3 | #[cfg(feature = "cuda")] |
6 | 4 | use anyhow::Result; |
| 5 | +#[cfg(feature = "cuda")] |
| 6 | +use either::Either; |
7 | 7 |
|
8 | 8 | use ndarray::parallel::prelude::*; |
9 | 9 | use ndarray::{concatenate, prelude::*}; |
10 | 10 | use ndarray_rand::rand_distr::StandardNormal; |
11 | 11 | use ndarray_rand::RandomExt; |
12 | | -use ndrustfft::{ndfft, FftHandler}; |
| 12 | +use ndrustfft::{ndfft_par, FftHandler}; |
13 | 13 | use num_complex::{Complex, ComplexDistribution}; |
14 | 14 |
|
15 | 15 | use crate::stochastic::Sampling; |
@@ -51,7 +51,7 @@ impl FGN { |
51 | 51 | let data = r.mapv(|v| Complex::new(v, 0.0)); |
52 | 52 | let r_fft = FftHandler::new(r.len()); |
53 | 53 | let mut sqrt_eigenvalues = Array1::<Complex<f64>>::zeros(r.len()); |
54 | | - ndfft(&data, &mut sqrt_eigenvalues, &r_fft, 0); |
| 54 | + ndfft_par(&data, &mut sqrt_eigenvalues, &r_fft, 0); |
55 | 55 | sqrt_eigenvalues.mapv_inplace(|x| Complex::new((x.re / (2.0 * n as f64)).sqrt(), x.im)); |
56 | 56 |
|
57 | 57 | Self { |
@@ -90,7 +90,7 @@ impl Sampling<f64> for FGN { |
90 | 90 |
|
91 | 91 | let fgn = &*self.sqrt_eigenvalues * &*rnd.read().unwrap(); |
92 | 92 | let mut fgn_fft = Array1::<Complex<f64>>::zeros(2 * self.n); |
93 | | - ndfft(&fgn, &mut fgn_fft, &*self.fft_handler, 0); |
| 93 | + ndfft_par(&fgn, &mut fgn_fft, &*self.fft_handler, 0); |
94 | 94 | let scale = (self.n as f64).powf(-self.hurst) * self.t.unwrap_or(1.0).powf(self.hurst); |
95 | 95 | let fgn = fgn_fft |
96 | 96 | .slice(s![1..self.n - self.offset + 1]) |
|
0 commit comments