def bench_random(self): from numpy.fft import irfft as numpy_irfft print() print('Inverse Fast Fourier Transform (real data)') print('==================================') print(' size | scipy | numpy ') print('----------------------------------') for size, repeat in [ (100, 7000), (1000, 2000), (256, 10000), (512, 10000), (1024, 1000), (2048, 1000), (2048 * 2, 500), (2048 * 4, 500), ]: print('%5s' % size, end=' ') sys.stdout.flush() x = random([size]).astype(double) x1 = zeros(size / 2 + 1, dtype=cdouble) x1[0] = x[0] for i in range(1, size // 2): x1[i] = x[2 * i - 1] + 1j * x[2 * i] if not size % 2: x1[-1] = x[-1] y = irfft(x) print('|%8.2f' % measure('irfft(x)', repeat), end=' ') sys.stdout.flush() assert_array_almost_equal(numpy_irfft(x1, size), y) print('|%8.2f' % measure('numpy_irfft(x1,size)', repeat), end=' ') sys.stdout.flush() print(' (secs for %s calls)' % (repeat)) sys.stdout.flush()
def bench_random(self, level=5): from numpy.fft import irfft as numpy_irfft print print "Inverse Fast Fourier Transform (real data)" print "==================================" print " size | scipy | numpy " print "----------------------------------" for size, repeat in [ (100, 7000), (1000, 2000), (256, 10000), (512, 10000), (1024, 1000), (2048, 1000), (2048 * 2, 500), (2048 * 4, 500), ]: print "%5s" % size, sys.stdout.flush() x = random([size]).astype(double) x1 = zeros(size / 2 + 1, dtype=cdouble) x1[0] = x[0] for i in range(1, size / 2): x1[i] = x[2 * i - 1] + 1j * x[2 * i] if not size % 2: x1[-1] = x[-1] y = irfft(x) print "|%8.2f" % self.measure("irfft(x)", repeat), sys.stdout.flush() assert_array_almost_equal(numpy_irfft(x1, size), y) print "|%8.2f" % self.measure("numpy_irfft(x1,size)", repeat), sys.stdout.flush() print " (secs for %s calls)" % (repeat) sys.stdout.flush()
def bench_random(self): from numpy.fft import irfft as numpy_irfft print() print('Inverse Fast Fourier Transform (real data)') print('==================================') print(' size | scipy | numpy ') print('----------------------------------') for size,repeat in [(100,7000),(1000,2000), (256,10000), (512,10000), (1024,1000), (2048,1000), (2048*2,500), (2048*4,500), ]: print('%5s' % size, end=' ') sys.stdout.flush() x = random([size]).astype(double) x1 = zeros(size/2+1,dtype=cdouble) x1[0] = x[0] for i in range(1,size/2): x1[i] = x[2*i-1] + 1j * x[2*i] if not size%2: x1[-1] = x[-1] y = irfft(x) print('|%8.2f' % measure('irfft(x)',repeat), end=' ') sys.stdout.flush() assert_array_almost_equal(numpy_irfft(x1,size),y) print('|%8.2f' % measure('numpy_irfft(x1,size)',repeat), end=' ') sys.stdout.flush() print(' (secs for %s calls)' % (repeat)) sys.stdout.flush()