Method: Numo::Pocketfft.fftn

Defined in:
lib/numo/pocketfft.rb

.fftn(a) ⇒ Numo::DComplex

Compute the N-dimensional discrete Fourier Transform.

Raises:

  • (ArgumentError)

    This error is raised if input array is not Numo::NArray or is empty.



63
64
65
66
67
68
69
70
71
72
73
# File 'lib/numo/pocketfft.rb', line 63

def fftn(a)
  raise ArgumentError, 'Expect class of input array to be Numo::NArray.' unless a.is_a?(Numo::NArray)
  raise ArgumentError, 'Expect input array to be non-empty.' if a.empty?

  return raw_fft(a, 0, inverse: false, real: false) if a.ndim == 1

  last_axis_id = a.ndim - 1
  b = raw_fft(a, last_axis_id, inverse: false, real: false)
  (last_axis_id - 1).downto(0) { |ax_id| b = raw_fft(b, ax_id, inverse: false, real: false) }
  b
end