Class: NMatrix
- Inherits:
-
Object
- Object
- NMatrix
- Defined in:
- lib/nmatrix/fftw.rb
Defined Under Namespace
Modules: FFTW
Instance Method Summary collapse
-
#fft ⇒ NMatrix
Compute 1D FFT of the matrix using FFTW default parameters.
-
#fft2 ⇒ NMatrix
Compute 2D FFT of a 2D matrix using FFTW default parameters.
Instance Method Details
#fft ⇒ NMatrix
Compute 1D FFT of the matrix using FFTW default parameters.
45 46 47 48 49 50 51 |
# File 'lib/nmatrix/fftw.rb', line 45 def fft input = self.dtype == :complex128 ? self : self.cast(dtype: :complex128) plan = NMatrix::FFTW::Plan.new([self.size]) plan.set_input input plan.execute plan.output end |
#fft2 ⇒ NMatrix
Compute 2D FFT of a 2D matrix using FFTW default parameters.
55 56 57 58 59 60 61 62 |
# File 'lib/nmatrix/fftw.rb', line 55 def fft2 raise ShapeError, "Shape must be 2 (is #{self.shape})" if self.shape.size != 2 input = self.dtype == :complex128 ? self : self.cast(dtype: :complex128) plan = NMatrix::FFTW::Plan.new(self.shape, dim: 2) plan.set_input input plan.execute plan.output end |