clang-format and clang-tidy fixes for 405d21a5

This commit is contained in:
github-actions 2021-11-07 03:57:30 +00:00
parent 280cf61e24
commit 91d669a8d2

View File

@ -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<double> *InverseFastFourierTransform(std::complex<double> *p, uint8_t n) {
std::complex<double> *InverseFastFourierTransform(std::complex<double> *p,
uint8_t n) {
if (n == 1) {
return p; /// Base Case To return
}
@ -39,9 +40,9 @@ std::complex<double> *InverseFastFourierTransform(std::complex<double> *p, uint8
std::complex<double> om = std::complex<double>(
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<double>[n / 2]; /// Coefficients of even power
@ -52,8 +53,9 @@ std::complex<double> *InverseFastFourierTransform(std::complex<double> *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<double> *ye =
@ -75,12 +77,10 @@ std::complex<double> *InverseFastFourierTransform(std::complex<double> *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<std::complex<double>> r2 = {
{1, 0}, {2, 0}, {3, 0}, {4, 0}}; /// True Answer for test case 2
std::complex<double> *o1 = numerical_methods::InverseFastFourierTransform(t1, n1);
std::complex<double> *o2 = numerical_methods::InverseFastFourierTransform(t2, n2);
std::complex<double> *o1 =
numerical_methods::InverseFastFourierTransform(t1, n1);
std::complex<double> *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;