Skip to content

Commit

Permalink
changing to 128/256 bit to c/longdouble (PyLops#552)
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-rakowski authored Nov 26, 2023
1 parent cc52ae8 commit 55c42ac
Showing 1 changed file with 48 additions and 16 deletions.
64 changes: 48 additions & 16 deletions pytests/test_ffts.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def test_unknown_engine(par):
(np.float16, 1),
(np.float32, 4),
(np.float64, 11),
(np.float128, 11),
(np.longdouble, 11),
],
norm=["ortho", "none", "1/n"],
ifftshift_before=[False, True],
Expand Down Expand Up @@ -234,7 +234,7 @@ def test_FFT_small_real(par):
(np.float16, 1),
(np.float32, 3),
(np.float64, 11),
(np.float128, 11),
(np.longdouble, 11),
],
ifftshift_before=[False, True],
engine=["numpy", "fftw", "scipy"],
Expand Down Expand Up @@ -280,7 +280,7 @@ def test_FFT_random_real(par):


par_lists_fft_small_cpx = dict(
dtype_precision=[(np.complex64, 4), (np.complex128, 11), (np.complex256, 11)],
dtype_precision=[(np.complex64, 4), (np.complex128, 11), (np.clongdouble, 11)],
norm=["ortho", "none", "1/n"],
ifftshift_before=[False, True],
fftshift_after=[False, True],
Expand Down Expand Up @@ -344,10 +344,10 @@ def test_FFT_small_complex(par):
(np.float16, 1),
(np.float32, 3),
(np.float64, 11),
(np.float128, 11),
(np.longdouble, 11),
(np.complex64, 3),
(np.complex128, 11),
(np.complex256, 11),
(np.clongdouble, 11),
],
ifftshift_before=[False, True],
fftshift_after=[False, True],
Expand Down Expand Up @@ -426,7 +426,7 @@ def test_FFT_random_complex(par):
(np.float16, 1),
(np.float32, 3),
(np.float64, 11),
(np.float128, 11),
(np.longdouble, 11),
],
ifftshift_before=[False, True],
engine=["numpy", "scipy"],
Expand Down Expand Up @@ -484,10 +484,10 @@ def test_FFT2D_random_real(par):
(np.float16, 1),
(np.float32, 3),
(np.float64, 11),
(np.float128, 11),
(np.longdouble, 11),
(np.complex64, 3),
(np.complex128, 11),
(np.complex256, 11),
(np.clongdouble, 11),
],
ifftshift_before=itertools.product([False, True], [False, True]),
fftshift_after=itertools.product([False, True], [False, True]),
Expand Down Expand Up @@ -566,7 +566,7 @@ def test_FFT2D_random_complex(par):
(np.float16, 1),
(np.float32, 3),
(np.float64, 11),
(np.float128, 11),
(np.longdouble, 11),
],
engine=["numpy", "scipy"],
)
Expand Down Expand Up @@ -625,10 +625,10 @@ def test_FFTND_random_real(par):
(np.float16, 1),
(np.float32, 3),
(np.float64, 11),
(np.float128, 11),
(np.longdouble, 11),
(np.complex64, 3),
(np.complex128, 11),
(np.complex256, 11),
(np.clongdouble, 11),
],
engine=["numpy", "scipy"],
)
Expand Down Expand Up @@ -700,7 +700,7 @@ def test_FFTND_random_complex(par):


par_lists_fft2dnd_small_cpx = dict(
dtype_precision=[(np.complex64, 5), (np.complex128, 11), (np.complex256, 11)],
dtype_precision=[(np.complex64, 5), (np.complex128, 11), (np.clongdouble, 11)],
norm=["ortho", "none", "1/n"],
engine=["numpy", "scipy"],
)
Expand Down Expand Up @@ -874,7 +874,15 @@ def test_FFT_1dsignal(par):
assert_array_almost_equal(y_fftshift, np.fft.fftshift(y))

xadj = FFTop_fftshift.H * y_fftshift # adjoint is same as inverse for fft
xinv = lsqr(FFTop_fftshift, y_fftshift, damp=1e-10, iter_lim=10, atol=1e-8, btol=1e-8, show=0)[0]
xinv = lsqr(
FFTop_fftshift,
y_fftshift,
damp=1e-10,
iter_lim=10,
atol=1e-8,
btol=1e-8,
show=0,
)[0]
assert_array_almost_equal(x[:imax], xadj[:imax], decimal=decimal)
assert_array_almost_equal(x[:imax], xinv[:imax], decimal=decimal)

Expand Down Expand Up @@ -958,7 +966,15 @@ def test_FFT_2dsignal(par):
assert_array_almost_equal(D_fftshift, D2)

dadj = FFTop_fftshift.H * D_fftshift # adjoint is same as inverse for fft
dinv = lsqr(FFTop_fftshift, D_fftshift, damp=1e-10, iter_lim=10, atol=1e-8, btol=1e-8, show=0)[0]
dinv = lsqr(
FFTop_fftshift,
D_fftshift,
damp=1e-10,
iter_lim=10,
atol=1e-8,
btol=1e-8,
show=0,
)[0]

dadj = np.real(dadj.reshape(nt, nx))
dinv = np.real(dinv.reshape(nt, nx))
Expand Down Expand Up @@ -1016,7 +1032,15 @@ def test_FFT_2dsignal(par):
assert_array_almost_equal(D_fftshift, D2)

dadj = FFTop_fftshift.H * D_fftshift # adjoint is same as inverse for fft
dinv = lsqr(FFTop_fftshift, D_fftshift, damp=1e-10, iter_lim=10, atol=1e-8, btol=1e-8, show=0)[0]
dinv = lsqr(
FFTop_fftshift,
D_fftshift,
damp=1e-10,
iter_lim=10,
atol=1e-8,
btol=1e-8,
show=0,
)[0]

dadj = np.real(dadj.reshape(nt, nx))
dinv = np.real(dinv.reshape(nt, nx))
Expand Down Expand Up @@ -1193,7 +1217,15 @@ def test_FFT_3dsignal(par):
assert_array_almost_equal(D_fftshift, D2)

dadj = FFTop_fftshift.H * D_fftshift # adjoint is same as inverse for fft
dinv = lsqr(FFTop_fftshift, D_fftshift, damp=1e-10, iter_lim=10, atol=1e-8, btol=1e-8, show=0)[0]
dinv = lsqr(
FFTop_fftshift,
D_fftshift,
damp=1e-10,
iter_lim=10,
atol=1e-8,
btol=1e-8,
show=0,
)[0]

dadj = np.real(dadj.reshape(nt, nx, ny))
dinv = np.real(dinv.reshape(nt, nx, ny))
Expand Down

0 comments on commit 55c42ac

Please sign in to comment.