@@ -87,18 +87,20 @@ def fft(x1, n=None, axis=-1, norm=None):
87
87
axis_param = axis
88
88
89
89
if n is None :
90
- boundarie = x1 .shape [axis_param ]
90
+ input_boundarie = x1 .shape [axis_param ]
91
91
else :
92
- boundarie = n
92
+ input_boundarie = n
93
93
94
94
if x1 .size < 1 :
95
95
pass # let fallback to handle exception
96
- elif boundarie < 1 :
96
+ elif input_boundarie < 1 :
97
97
pass # let fallback to handle exception
98
98
elif norm is not None :
99
99
pass
100
100
else :
101
- return dpnp_fft (x1 , boundarie , axis_param )
101
+ output_boundarie = input_boundarie
102
+
103
+ return dpnp_fft (x1 , input_boundarie , output_boundarie , axis_param )
102
104
103
105
return call_origin (numpy .fft .fft , x1 , n , axis , norm )
104
106
@@ -202,18 +204,20 @@ def ifft(x1, n=None, axis=-1, norm=None):
202
204
axis_param = axis
203
205
204
206
if n is None :
205
- boundarie = x1 .shape [axis_param ]
207
+ input_boundarie = x1 .shape [axis_param ]
206
208
else :
207
- boundarie = n
209
+ input_boundarie = n
208
210
209
211
if x1 .size < 1 :
210
212
pass # let fallback to handle exception
211
- elif boundarie < 1 :
213
+ elif input_boundarie < 1 :
212
214
pass # let fallback to handle exception
213
215
elif norm is not None :
214
216
pass
215
217
else :
216
- return dpnp_fft (x1 , boundarie , axis_param )
218
+ output_boundarie = input_boundarie
219
+
220
+ return dpnp_fft (x1 , input_boundarie , output_boundarie , axis_param )
217
221
218
222
return call_origin (numpy .fft .ifft , x1 , n , axis , norm )
219
223
@@ -317,18 +321,20 @@ def irfft(x1, n=None, axis=-1, norm=None):
317
321
axis_param = axis
318
322
319
323
if n is None :
320
- boundarie = x1 .shape [axis_param ]
324
+ input_boundarie = x1 .shape [axis_param ]
321
325
else :
322
- boundarie = n
326
+ input_boundarie = n
323
327
324
328
if x1 .size < 1 :
325
329
pass # let fallback to handle exception
326
- elif boundarie < 1 :
330
+ elif input_boundarie < 1 :
327
331
pass # let fallback to handle exception
328
332
elif norm is not None :
329
333
pass
330
334
else :
331
- return dpnp_fft (x1 , boundarie , axis_param )
335
+ output_boundarie = input_boundarie
336
+
337
+ return dpnp_fft (x1 , input_boundarie , output_boundarie , axis_param )
332
338
333
339
return call_origin (numpy .fft .irfft , x1 , n , axis , norm )
334
340
@@ -408,6 +414,7 @@ def irfftn(x1, s=None, axes=None, norm=None):
408
414
409
415
return call_origin (numpy .fft .irfftn , x1 , s , axes , norm )
410
416
417
+
411
418
def rfft (x1 , n = None , axis = - 1 , norm = None ):
412
419
"""
413
420
Compute the one-dimensional discrete Fourier Transform for real input.
@@ -424,25 +431,27 @@ def rfft(x1, n=None, axis=-1, norm=None):
424
431
425
432
is_x1_dparray = isinstance (x1 , dparray )
426
433
427
- if (not use_origin_backend (x1 ) and is_x1_dparray and 0 ):
434
+ if (not use_origin_backend (x1 ) and is_x1_dparray ):
428
435
if axis is None :
429
- axis_param = - 1 # the most right dimension (default value)
436
+ axis_param = - 1 # the most right dimension (default value)
430
437
else :
431
438
axis_param = axis
432
439
433
440
if n is None :
434
- boundarie = x1 .shape [axis_param ]
441
+ input_boundarie = x1 .shape [axis_param ]
435
442
else :
436
- boundarie = n
443
+ input_boundarie = n
437
444
438
445
if x1 .size < 1 :
439
- pass # let fallback to handle exception
440
- elif boundarie < 1 :
441
- pass # let fallback to handle exception
446
+ pass # let fallback to handle exception
447
+ elif input_boundarie < 1 :
448
+ pass # let fallback to handle exception
442
449
elif norm is not None :
443
450
pass
444
451
else :
445
- return dpnp_fft (x1 , boundarie , axis_param )
452
+ output_boundarie = input_boundarie // 2 + 1 # rfft specific requirenment
453
+
454
+ return dpnp_fft (x1 , input_boundarie , output_boundarie , axis_param )
446
455
447
456
return call_origin (numpy .fft .rfft , x1 , n , axis , norm )
448
457
@@ -465,11 +474,11 @@ def rfft2(x1, s=None, axes=(-2, -1), norm=None):
465
474
466
475
is_x1_dparray = isinstance (x1 , dparray )
467
476
468
- if (not use_origin_backend (x1 ) and is_x1_dparray and 0 ):
477
+ if (not use_origin_backend (x1 ) and is_x1_dparray ):
469
478
if norm is not None :
470
479
pass
471
480
else :
472
- return fftn (x1 , s , axes , norm )
481
+ return rfftn (x1 , s , axes , norm )
473
482
474
483
return call_origin (numpy .fft .rfft2 , x1 , s , axes , norm )
475
484
@@ -492,7 +501,7 @@ def rfftn(x1, s=None, axes=None, norm=None):
492
501
493
502
is_x1_dparray = isinstance (x1 , dparray )
494
503
495
- if (not use_origin_backend (x1 ) and is_x1_dparray and 0 ):
504
+ if (not use_origin_backend (x1 ) and is_x1_dparray ):
496
505
if s is None :
497
506
boundaries = tuple ([x1 .shape [i ] for i in range (x1 .ndim )])
498
507
else :
@@ -505,6 +514,8 @@ def rfftn(x1, s=None, axes=None, norm=None):
505
514
506
515
if norm is not None :
507
516
pass
517
+ elif len (axes ) < 1 :
518
+ pass # let fallback to handle exception
508
519
else :
509
520
x1_iter = x1
510
521
iteration_list = list (range (len (axes_param )))
@@ -516,7 +527,7 @@ def rfftn(x1, s=None, axes=None, norm=None):
516
527
except IndexError :
517
528
checker_throw_axis_error ("fft.rfftn" , "is out of bounds" , param_axis , f"< { len (boundaries )} " )
518
529
519
- x1_iter = fft (x1_iter , n = param_n , axis = param_axis , norm = norm )
530
+ x1_iter = rfft (x1_iter , n = param_n , axis = param_axis , norm = norm )
520
531
521
532
return x1_iter
522
533
0 commit comments