mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-05 09:21:13 +08:00
maths/radix2_fft.py: Fix calculation for Python 3.14 (#12772)
* maths/radix2_fft.py: Fix calculation for Python 3.14 As suggested at: * https://github.com/TheAlgorithms/Python/issues/12729#issuecomment-2878608477 * https://github.com/TheAlgorithms/Python/pull/12710#discussion_r2080117333 @MaximSmolskiy @KirilBangachev @skirpichev Careful review, please. I am just implementing the suggestion, but I do not have any expertise in this area. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Change test results * GitHub Actions: Rename job from build to directory_writer It is confusing to have two jobs named `build`. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
2
.github/workflows/directory_writer.yml
vendored
2
.github/workflows/directory_writer.yml
vendored
@ -3,7 +3,7 @@
|
||||
name: directory_writer
|
||||
on: [push]
|
||||
jobs:
|
||||
build:
|
||||
directory_writer:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
@ -40,13 +40,13 @@ class FFT:
|
||||
|
||||
Print product
|
||||
>>> x.product # 2x + 3x^2 + 8x^3 + 4x^4 + 6x^5
|
||||
[(-0+0j), (2+0j), (3+0j), (8+0j), (6+0j), (8+0j)]
|
||||
[(-0-0j), (2+0j), (3-0j), (8-0j), (6+0j), (8+0j)]
|
||||
|
||||
__str__ test
|
||||
>>> print(x)
|
||||
A = 0*x^0 + 1*x^1 + 2*x^0 + 3*x^2
|
||||
B = 0*x^2 + 1*x^3 + 2*x^4
|
||||
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)
|
||||
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)
|
||||
"""
|
||||
|
||||
def __init__(self, poly_a=None, poly_b=None):
|
||||
@ -147,7 +147,9 @@ class FFT:
|
||||
inverce_c = new_inverse_c
|
||||
next_ncol *= 2
|
||||
# Unpack
|
||||
inverce_c = [round(x[0].real, 8) + round(x[0].imag, 8) * 1j for x in inverce_c]
|
||||
inverce_c = [
|
||||
complex(round(x[0].real, 8), round(x[0].imag, 8)) for x in inverce_c
|
||||
]
|
||||
|
||||
# Remove leading 0's
|
||||
while inverce_c[-1] == 0:
|
||||
|
Reference in New Issue
Block a user