|
41 | 41 | #include <hydra/detail/Convolution.inl> |
42 | 42 | #include <hydra/detail/ArgumentTraits.h> |
43 | 43 | #include <hydra/detail/external/hydra_thrust/transform.h> |
| 44 | +#include <hydra/detail/external/hydra_thrust/reduce.h> |
44 | 45 | #include <hydra/detail/external/hydra_thrust/iterator/transform_iterator.h> |
45 | 46 | #include <hydra/detail/external/hydra_thrust/memory.h> |
46 | 47 | #include <hydra/detail/external/hydra_thrust/system/cuda/detail/execution_policy.h> |
@@ -93,6 +94,8 @@ convolute(detail::BackendPolicy<BACKEND> policy, detail::FFTPolicy<T, FFTBackend |
93 | 94 | hydra_thrust::transform(policy, counting_samples.begin(), counting_samples.end(), |
94 | 95 | kernel_samples.first , kernel_sampler); |
95 | 96 |
|
| 97 | + auto norm_factor = hydra_thrust::reduce(policy, kernel_samples.first, kernel_samples.first + kernel_samples.second ); |
| 98 | + |
96 | 99 | // sample function |
97 | 100 | auto functor_sampler = hydra::detail::convolution::FunctorSampler<Functor>(functor, nsamples, min, delta); |
98 | 101 |
|
@@ -135,12 +138,12 @@ convolute(detail::BackendPolicy<BACKEND> policy, detail::FFTPolicy<T, FFTBackend |
135 | 138 |
|
136 | 139 | auto fft_product_output = fft_product.GetOutputData(); |
137 | 140 |
|
138 | | - T n = ::pow(10.0, (long unsigned)::log10((double)nsamples*nsamples )); |
| 141 | + T n = 2*nsamples*norm_factor; |
139 | 142 |
|
140 | 143 | auto normalize_fft = detail::convolution::NormalizeFFT<T>(n); |
141 | 144 |
|
142 | 145 | auto first = hydra_thrust::make_transform_iterator( fft_product_output.first,normalize_fft); |
143 | | - auto last = hydra_thrust::make_transform_iterator(fft_product_output.first + nsamples,normalize_fft); |
| 146 | + auto last = hydra_thrust::make_transform_iterator(fft_product_output.first + nsamples+1,normalize_fft); |
144 | 147 |
|
145 | 148 | auto fft_product_range = make_range(first, last); |
146 | 149 |
|
|
0 commit comments