From 892d85a0e1e02f21f0eef700fbc2059b0f828d5b Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Wed, 31 Jul 2024 09:26:36 +0200 Subject: [PATCH] rm abbreviations double1d_t, complex1d_t --- Base/Math/FourierTransform.cpp | 16 ++++++++-------- Base/Math/FourierTransform.h | 14 +++++++------- Base/Type/Vector.h | 6 ++---- Device/Resolution/Convolve.cpp | 3 ++- Device/Resolution/Convolve.h | 3 ++- Sample/Interface/RoughnessMap.cpp | 18 +++++++++--------- 6 files changed, 30 insertions(+), 30 deletions(-) diff --git a/Base/Math/FourierTransform.cpp b/Base/Math/FourierTransform.cpp index 3709ce55d32..7952afc3538 100644 --- a/Base/Math/FourierTransform.cpp +++ b/Base/Math/FourierTransform.cpp @@ -156,7 +156,7 @@ complex2d_t FourierTransform::ifftshift(const complex2d_t& src) /* ************************************************************************* */ // Fourier Transform in 1D /* ************************************************************************* */ -complex1d_t FourierTransform::rfft(const double1d_t& src) +std::vector<complex_t> FourierTransform::rfft(const std::vector<double>& src) { // we simply create 2d arrays with length of first dimension equal to 1, and call 2d FT double2d_t src2d{src}; @@ -166,7 +166,7 @@ complex1d_t FourierTransform::rfft(const double1d_t& src) return result2d[0]; } -double1d_t FourierTransform::irfft(const complex1d_t& src, int w_src) +std::vector<double> FourierTransform::irfft(const std::vector<complex_t>& src, int w_src) { // we simply create 2d arrays with length of first dimension equal to 1, and call 2d FT complex2d_t source2d{src}; @@ -176,7 +176,7 @@ double1d_t FourierTransform::irfft(const complex1d_t& src, int w_src) return result2d[0]; } -double1d_t FourierTransform::ramplitude(const double1d_t& src) +std::vector<double> FourierTransform::ramplitude(const std::vector<double>& src) { complex2d_t complex_result2d{rfft(src)}; @@ -189,20 +189,20 @@ double1d_t FourierTransform::ramplitude(const double1d_t& src) /* ************************************************************************* */ // Fourier Transform 1D shift - center around zero frequency /* ************************************************************************* */ -double1d_t FourierTransform::fftshift(const double1d_t& src) +std::vector<double> FourierTransform::fftshift(const std::vector<double>& src) { return ::fftshift_1d(src, false); } -complex1d_t FourierTransform::fftshift(const complex1d_t& src) +std::vector<complex_t> FourierTransform::fftshift(const std::vector<complex_t>& src) { return ::fftshift_1d(src, false); } -double1d_t FourierTransform::ifftshift(const double1d_t& src) +std::vector<double> FourierTransform::ifftshift(const std::vector<double>& src) { return ::fftshift_1d(src, true); } -complex1d_t FourierTransform::ifftshift(const complex1d_t& src) +std::vector<complex_t> FourierTransform::ifftshift(const std::vector<complex_t>& src) { return ::fftshift_1d(src, true); } @@ -255,7 +255,7 @@ complex2d_t FourierTransform::rfft2complex_vec() const { ASSERT(ws.arr_fftw); - complex2d_t result(ws.h, complex1d_t(ws.w_fftw)); + complex2d_t result(ws.h, std::vector<complex_t>(ws.w_fftw)); double* ptr = ws.arr_fftw; // Storing FT output diff --git a/Base/Math/FourierTransform.h b/Base/Math/FourierTransform.h index 43fc3518eaa..d4db5266678 100644 --- a/Base/Math/FourierTransform.h +++ b/Base/Math/FourierTransform.h @@ -27,15 +27,15 @@ public: FourierTransform(); // forward transform - complex1d_t rfft(const double1d_t& src); + std::vector<complex_t> rfft(const std::vector<double>& src); complex2d_t rfft(const double2d_t& src); // forward transform with real-valued amplitudes in output - double1d_t ramplitude(const double1d_t& src); + std::vector<double> ramplitude(const std::vector<double>& src); double2d_t ramplitude(const double2d_t& src); // backward transform - double1d_t irfft(const complex1d_t& src, int w_src); + std::vector<double> irfft(const std::vector<complex_t>& src, int w_src); double2d_t irfft(const complex2d_t& src, int w_real); // Frequency shifts are useful for providing different representations of spectrum: with lowest @@ -43,14 +43,14 @@ public: // array // shift low frequency from corners to center - static double1d_t fftshift(const double1d_t& src); - static complex1d_t fftshift(const complex1d_t& src); + static std::vector<double> fftshift(const std::vector<double>& src); + static std::vector<complex_t> fftshift(const std::vector<complex_t>& src); static double2d_t fftshift(const double2d_t& src); static complex2d_t fftshift(const complex2d_t& src); // shift low frequency from center to corners - static double1d_t ifftshift(const double1d_t& src); - static complex1d_t ifftshift(const complex1d_t& src); + static std::vector<double> ifftshift(const std::vector<double>& src); + static std::vector<complex_t> ifftshift(const std::vector<complex_t>& src); static double2d_t ifftshift(const double2d_t& src); static complex2d_t ifftshift(const complex2d_t& src); diff --git a/Base/Type/Vector.h b/Base/Type/Vector.h index ccb2b368c1d..5efe90e09e7 100644 --- a/Base/Type/Vector.h +++ b/Base/Type/Vector.h @@ -18,9 +18,7 @@ #include <heinz/Complex.h> #include <vector> -using double1d_t = std::vector<double>; -using double2d_t = std::vector<double1d_t>; -using complex1d_t = std::vector<complex_t>; -using complex2d_t = std::vector<complex1d_t>; +using double2d_t = std::vector<std::vector<double>>; +using complex2d_t = std::vector<std::vector<complex_t>>; #endif // BORNAGAIN_BASE_TYPE_VECTOR_H diff --git a/Device/Resolution/Convolve.cpp b/Device/Resolution/Convolve.cpp index 4ceed5e6c21..a85af775d25 100644 --- a/Device/Resolution/Convolve.cpp +++ b/Device/Resolution/Convolve.cpp @@ -118,7 +118,8 @@ void Convolve::fftconvolve2D(const double2d_t& source, const double2d_t& kernel, } } -void Convolve::fftconvolve1D(const double1d_t& source, const double1d_t& kernel, double1d_t& result) +void Convolve::fftconvolve1D(const std::vector<double>& source, const std::vector<double>& kernel, + std::vector<double>& result) { // we simply create 2d arrays with length of first dimension equal to 1, and call 2d convolution double2d_t source2d, kernel2d; diff --git a/Device/Resolution/Convolve.h b/Device/Resolution/Convolve.h index 0e3c3bfd5e8..aecb9d17896 100644 --- a/Device/Resolution/Convolve.h +++ b/Device/Resolution/Convolve.h @@ -51,7 +51,8 @@ public: }; //! convolution in 1D - void fftconvolve1D(const double1d_t& source, const double1d_t& kernel, double1d_t& result); + void fftconvolve1D(const std::vector<double>& source, const std::vector<double>& kernel, + std::vector<double>& result); //! convolution in 2D void fftconvolve2D(const double2d_t& source, const double2d_t& kernel, double2d_t& result); diff --git a/Sample/Interface/RoughnessMap.cpp b/Sample/Interface/RoughnessMap.cpp index ca7d483581f..ec672300b2f 100644 --- a/Sample/Interface/RoughnessMap.cpp +++ b/Sample/Interface/RoughnessMap.cpp @@ -77,18 +77,18 @@ double2d_t RoughnessMap::mapFromHeights() const const double step = 2 * z_limit / (z_steps - 1); // create mesh of values - double1d_t z_points(z_steps); + std::vector<double> z_points(z_steps); for (size_t i = 0; i < z_steps; i++) z_points[i] = -z_limit + step * i; // fill mesh with weights - double1d_t z_weights(z_steps); + std::vector<double> z_weights(z_steps); for (size_t i = 0; i < z_steps; i++) z_weights[i] = m_layerRoughness->roughnessModel()->distribution(z_points[i], sigma); // fill map with random values std::discrete_distribution<int> d(z_weights.begin(), z_weights.end()); - double2d_t result(m_y_points, double1d_t(m_x_points)); + double2d_t result(m_y_points, std::vector<double>(m_x_points)); for (int j = 0; j < m_y_points; j++) for (int i = 0; i < m_x_points; i++) result[j][i] = z_points[d(m_gen)]; @@ -105,15 +105,15 @@ double2d_t RoughnessMap::mapFromSpectrum() const const int N = m_x_points / 2 + 1; const int M = m_y_points / 2 + 1; - double1d_t fx(N); + std::vector<double> fx(N); for (int i = 0; i < N; i++) fx[i] = 2 * pi * i * dfx; - double1d_t fy(M); + std::vector<double> fy(M); for (int j = 0; j < M; j++) fy[j] = 2 * pi * j * dfy; - double2d_t psd_mag(m_y_points, double1d_t(N)); + double2d_t psd_mag(m_y_points, std::vector<double>(N)); for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) psd_mag[j][i] = std::sqrt(m_layerRoughness->spectralFunction(R3(fx[i], fy[j], 0))); @@ -123,7 +123,7 @@ double2d_t RoughnessMap::mapFromSpectrum() const psd_mag[0][0] = 0; // average height (amplitude at zero frequency) is null std::uniform_real_distribution<double> d(-pi, pi); - double2d_t phase(m_y_points, double1d_t(N)); + double2d_t phase(m_y_points, std::vector<double>(N)); // main axes // x axis @@ -147,7 +147,7 @@ double2d_t RoughnessMap::mapFromSpectrum() const phase[pos_j][pos_i] = +phase[sym_pos_j][pos_i]; } } - complex2d_t spectrum(m_y_points, complex1d_t(N)); + complex2d_t spectrum(m_y_points, std::vector<complex_t>(N)); for (int j = 0; j < m_y_points; j++) for (int i = 0; i < N; i++) spectrum[j][i] = psd_mag[j][i] * std::exp(I * phase[j][i]) * fft_factor; @@ -197,7 +197,7 @@ double2d_t RoughnessMap::applyHeightsToSpectrum(const double2d_t& h_map, void RoughnessMap::createMap() { if (m_layerRoughness->sigma() < 1e-10) { - m_rough_map = double2d_t(m_y_points, double1d_t(m_x_points)); + m_rough_map = double2d_t(m_y_points, std::vector<double>(m_x_points)); return; } -- GitLab