Skip to content

Commit fadb1df

Browse files
alejandroaldaspre-commit-ci[bot]MaximSmolskiy
authored andcommitted
Codex/find and fix a bug (TheAlgorithms#12782)
* Fix enumeration order in FFT string representation * updating DIRECTORY.md * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update radix2_fft.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: alejandroaldas <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Maxim Smolskiy <[email protected]>
1 parent 2c84a17 commit fadb1df

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

maths/radix2_fft.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ class FFT:
3939
>>> x = FFT(A, B)
4040
4141
Print product
42-
>>> x.product # 2x + 3x^2 + 8x^3 + 4x^4 + 6x^5
42+
>>> x.product # 2x + 3x^2 + 8x^3 + 6x^4 + 8x^5
4343
[(-0-0j), (2+0j), (3-0j), (8-0j), (6+0j), (8+0j)]
4444
4545
__str__ test
4646
>>> print(x)
47-
A = 0*x^0 + 1*x^1 + 2*x^0 + 3*x^2
48-
B = 0*x^2 + 1*x^3 + 2*x^4
49-
A*B = 0*x^(-0-0j) + 1*x^(2+0j) + 2*x^(3-0j) + 3*x^(8-0j) + 4*x^(6+0j) + 5*x^(8+0j)
47+
A = 0*x^0 + 1*x^1 + 0*x^2 + 2*x^3
48+
B = 2*x^0 + 3*x^1 + 4*x^2
49+
A*B = (-0-0j)*x^0 + (2+0j)*x^1 + (3-0j)*x^2 + (8-0j)*x^3 + (6+0j)*x^4 + (8+0j)*x^5
5050
"""
5151

5252
def __init__(self, poly_a=None, poly_b=None):
@@ -159,13 +159,13 @@ def __multiply(self):
159159
# Overwrite __str__ for print(); Shows A, B and A*B
160160
def __str__(self):
161161
a = "A = " + " + ".join(
162-
f"{coef}*x^{i}" for coef, i in enumerate(self.polyA[: self.len_A])
162+
f"{coef}*x^{i}" for i, coef in enumerate(self.polyA[: self.len_A])
163163
)
164164
b = "B = " + " + ".join(
165-
f"{coef}*x^{i}" for coef, i in enumerate(self.polyB[: self.len_B])
165+
f"{coef}*x^{i}" for i, coef in enumerate(self.polyB[: self.len_B])
166166
)
167167
c = "A*B = " + " + ".join(
168-
f"{coef}*x^{i}" for coef, i in enumerate(self.product)
168+
f"{coef}*x^{i}" for i, coef in enumerate(self.product)
169169
)
170170

171171
return f"{a}\n{b}\n{c}"

0 commit comments

Comments
 (0)