def test_call_with_different_striding(self): '''Test the input update with different strides to internal array. ''' input_array_shape = self.input_array.shape + (2,) internal_array_shape = self.internal_array.shape internal_array = byte_align( numpy.random.randn(*internal_array_shape) + 1j*numpy.random.randn(*internal_array_shape)) fft = utils._FFTWWrapper(internal_array, self.output_array, input_array_slicer=self.input_array_slicer, FFTW_array_slicer=self.FFTW_array_slicer) test_output_array = fft().copy() new_input_array = empty_aligned(input_array_shape, dtype=internal_array.dtype) new_input_array[:] = 0 new_input_array[:,:,0][self.input_array_slicer] = ( internal_array[self.FFTW_array_slicer]) new_output = fft(new_input_array[:,:,0]).copy() # Test the test! self.assertTrue( new_input_array[:,:,0].strides != internal_array.strides) self.assertTrue(numpy.alltrue(test_output_array == new_output))
def test_call_with_different_striding(self): """Test the input update with different strides to internal array. """ input_array_shape = self.input_array.shape + (2,) internal_array_shape = self.internal_array.shape internal_array = n_byte_align( numpy.random.randn(*internal_array_shape) + 1j * numpy.random.randn(*internal_array_shape), simd_alignment ) fft = utils._FFTWWrapper( internal_array, self.output_array, input_array_slicer=self.input_array_slicer, FFTW_array_slicer=self.FFTW_array_slicer, ) test_output_array = fft().copy() new_input_array = n_byte_align_empty(input_array_shape, simd_alignment, dtype=internal_array.dtype) new_input_array[:] = 0 new_input_array[:, :, 0][self.input_array_slicer] = internal_array[self.FFTW_array_slicer] new_output = fft(new_input_array[:, :, 0]).copy() # Test the test! self.assertTrue(new_input_array[:, :, 0].strides != internal_array.strides) self.assertTrue(numpy.alltrue(test_output_array == new_output))
def setUp(self): require(self, '64') self.input_array_slicer = tuple([slice(None), slice(256)]) self.FFTW_array_slicer = tuple([slice(128), slice(None)]) self.input_array = empty_aligned((128, 512), dtype='complex128') self.output_array = empty_aligned((256, 256), dtype='complex128') self.internal_array = empty_aligned((256, 256), dtype='complex128') self.fft = utils._FFTWWrapper( self.internal_array, self.output_array, input_array_slicer=self.input_array_slicer, FFTW_array_slicer=self.FFTW_array_slicer) self.input_array[:] = ( numpy.random.randn(*self.input_array.shape) + 1j * numpy.random.randn(*self.input_array.shape)) self.internal_array[:] = 0 self.internal_array[self.FFTW_array_slicer] = ( self.input_array[self.input_array_slicer])
def test_call_with_normalisation_on(self): _input_array = n_byte_align_empty(self.internal_array.shape, simd_alignment, dtype="complex128") ifft = utils._FFTWWrapper( self.output_array, _input_array, direction="FFTW_BACKWARD", input_array_slicer=slice(None), FFTW_array_slicer=slice(None), ) self.fft(normalise_idft=True) # Shouldn't make any difference ifft(normalise_idft=True) self.assertTrue(numpy.allclose(self.input_array[self.input_array_slicer], _input_array[self.FFTW_array_slicer]))
def test_call_with_normalisation_on(self): _input_array = empty_aligned(self.internal_array.shape, dtype='complex128') ifft = utils._FFTWWrapper(self.output_array, _input_array, direction='FFTW_BACKWARD', input_array_slicer=slice(None), FFTW_array_slicer=slice(None)) self.fft(normalise_idft=True) # Shouldn't make any difference ifft(normalise_idft=True) self.assertTrue(numpy.allclose( self.input_array[self.input_array_slicer], _input_array[self.FFTW_array_slicer]))
def test_call_with_normalisation_default(self): _input_array = n_byte_align_empty(self.internal_array.shape, simd_alignment, dtype="complex128") ifft = utils._FFTWWrapper( self.output_array, _input_array, direction="FFTW_BACKWARD", input_array_slicer=slice(None), FFTW_array_slicer=slice(None), ) self.fft() ifft() # Scaling is performed by default self.assertTrue(numpy.allclose(self.input_array[self.input_array_slicer], _input_array[self.FFTW_array_slicer]))
def test_call_with_normalisation_default(self): _input_array = empty_aligned(self.internal_array.shape, dtype='complex128') ifft = utils._FFTWWrapper(self.output_array, _input_array, direction='FFTW_BACKWARD', input_array_slicer=slice(None), FFTW_array_slicer=slice(None)) self.fft() ifft() # Scaling is performed by default self.assertTrue(numpy.allclose( self.input_array[self.input_array_slicer], _input_array[self.FFTW_array_slicer]))
def setUp(self): self.input_array_slicer = [slice(None), slice(256)] self.FFTW_array_slicer = [slice(128), slice(None)] self.input_array = empty_aligned((128, 512), dtype='complex128') self.output_array = empty_aligned((256, 256), dtype='complex128') self.internal_array = empty_aligned((256, 256), dtype='complex128') self.fft = utils._FFTWWrapper(self.internal_array, self.output_array, input_array_slicer=self.input_array_slicer, FFTW_array_slicer=self.FFTW_array_slicer) self.input_array[:] = (numpy.random.randn(*self.input_array.shape) + 1j*numpy.random.randn(*self.input_array.shape)) self.internal_array[:] = 0 self.internal_array[self.FFTW_array_slicer] = ( self.input_array[self.input_array_slicer])
def setUp(self): self.input_array_slicer = [slice(None), slice(256)] self.FFTW_array_slicer = [slice(128), slice(None)] self.input_array = n_byte_align_empty((128, 512), simd_alignment, dtype="complex128") self.output_array = n_byte_align_empty((256, 256), simd_alignment, dtype="complex128") self.internal_array = n_byte_align_empty((256, 256), simd_alignment, dtype="complex128") self.fft = utils._FFTWWrapper( self.internal_array, self.output_array, input_array_slicer=self.input_array_slicer, FFTW_array_slicer=self.FFTW_array_slicer, ) self.input_array[:] = numpy.random.randn(*self.input_array.shape) + 1j * numpy.random.randn( *self.input_array.shape ) self.internal_array[:] = 0 self.internal_array[self.FFTW_array_slicer] = self.input_array[self.input_array_slicer]