From 91d669a8d2be11e34df0c2052fd977b722c52b68 Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Sun, 7 Nov 2021 03:57:30 +0000 Subject: [PATCH] clang-format and clang-tidy fixes for 405d21a5 --- .../inverse_fast_fourier_transform.cpp | 43 +++++++++---------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/numerical_methods/inverse_fast_fourier_transform.cpp b/numerical_methods/inverse_fast_fourier_transform.cpp index 28ae330a0..3837c21f9 100644 --- a/numerical_methods/inverse_fast_fourier_transform.cpp +++ b/numerical_methods/inverse_fast_fourier_transform.cpp @@ -4,10 +4,10 @@ * (IFFT)](https://www.geeksforgeeks.org/python-inverse-fast-fourier-transformation/) * is an algorithm that computes the inverse fourier transform. * @details - * This algorithm has an application in use case scenario where a user wants find coefficients of - * a function in a short time by just using points generated by DFT. - * Time complexity - * this algorithm computes the IDFT in O(nlogn) time in comparison to traditional O(n^2). + * This algorithm has an application in use case scenario where a user wants + * find coefficients of a function in a short time by just using points + * generated by DFT. Time complexity this algorithm computes the IDFT in + * O(nlogn) time in comparison to traditional O(n^2). * @author [Ameya Chawla](https://github.com/ameyachawlaggsipu) */ @@ -23,14 +23,15 @@ */ namespace numerical_methods { /** - * @brief InverseFastFourierTransform is a recursive function which returns list of - * complex numbers + * @brief InverseFastFourierTransform is a recursive function which returns list + * of complex numbers * @param p List of Coefficents in form of complex numbers * @param n Count of elements in list p * @returns p if n==1 * @returns y if n!=1 */ -std::complex *InverseFastFourierTransform(std::complex *p, uint8_t n) { +std::complex *InverseFastFourierTransform(std::complex *p, + uint8_t n) { if (n == 1) { return p; /// Base Case To return } @@ -39,9 +40,9 @@ std::complex *InverseFastFourierTransform(std::complex *p, uint8 std::complex om = std::complex( cos(2 * pi / n), sin(2 * pi / n)); /// Calculating value of omega - - om.real(om.real()/n); /// One change in comparison with DFT - om.imag(om.imag()/n); /// One change in comparison with DFT + + om.real(om.real() / n); /// One change in comparison with DFT + om.imag(om.imag() / n); /// One change in comparison with DFT auto *pe = new std::complex[n / 2]; /// Coefficients of even power @@ -52,8 +53,9 @@ std::complex *InverseFastFourierTransform(std::complex *p, uint8 if (j % 2 == 0) { pe[k1++] = p[j]; /// Assigning values of even Coefficients - } else + } else { po[k2++] = p[j]; /// Assigning value of odd Coefficients + } } std::complex *ye = @@ -75,12 +77,10 @@ std::complex *InverseFastFourierTransform(std::complex *p, uint8 k1++; k2++; } - - if(n!=2){ - + + if (n != 2) { delete[] pe; delete[] po; - } delete[] ye; /// Deleting dynamic array ye @@ -118,16 +118,17 @@ static void test() { std::vector> r2 = { {1, 0}, {2, 0}, {3, 0}, {4, 0}}; /// True Answer for test case 2 - std::complex *o1 = numerical_methods::InverseFastFourierTransform(t1, n1); - - std::complex *o2 = numerical_methods::InverseFastFourierTransform(t2, n2); + std::complex *o1 = + numerical_methods::InverseFastFourierTransform(t1, n1); + + std::complex *o2 = + numerical_methods::InverseFastFourierTransform(t2, n2); for (uint8_t i = 0; i < n1; i++) { assert((r1[i].real() - o1[i].real() < 0.000000000001) && (r1[i].imag() - o1[i].imag() < 0.000000000001)); /// Comparing for both real and imaginary /// values for test case 1 - } for (uint8_t i = 0; i < n2; i++) { @@ -135,10 +136,8 @@ static void test() { (r2[i].imag() - o2[i].imag() < 0.000000000001)); /// Comparing for both real and imaginary /// values for test case 2 - } - - + delete[] t1; delete[] t2; delete[] o1;