Skip to content

Commit d68a032

Browse files
author
Vahid Tavanashad
committed
get rid of checking to see if input array is already hermitian or not
1 parent dbd5595 commit d68a032

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

dpnp/fft/dpnp_utils_fft.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -433,27 +433,24 @@ def _make_array_hermitian(a, axis, copy_needed):
433433

434434
a = dpnp.moveaxis(a, axis, 0)
435435
n = a.shape[0]
436-
length_is_even = n % 2 == 0
437-
hermitian = dpnp.all(a[0].imag == 0)
436+
437+
# TODO: if the input array is already Hermitian, the following steps are
438+
# not needed, however, validating the input array is hermitian results in
439+
# synchronization of the SYCL queue, find an alternative.
440+
if copy_needed:
441+
a = a.astype(a.dtype, order="C", copy=True)
442+
443+
a[0].imag = 0
438444
assert n is not None
439-
if length_is_even:
445+
if n % 2 == 0:
440446
# Nyquist mode (n//2+1 mode) is n//2-th element
441447
f_ny = n // 2
442448
assert a.shape[0] > f_ny
443-
hermitian = hermitian and dpnp.all(a[f_ny].imag == 0)
449+
a[f_ny].imag = 0
444450
else:
445451
# No Nyquist mode
446452
pass
447453

448-
if not hermitian:
449-
if copy_needed:
450-
a = a.astype(a.dtype, order="C", copy=True)
451-
452-
a[0].imag = 0
453-
if length_is_even:
454-
f_ny = n // 2
455-
a[f_ny].imag = 0
456-
457454
return dpnp.moveaxis(a, 0, axis)
458455

459456

0 commit comments

Comments
 (0)