Beispiel #1
0
 def test_random_odd(self):
     for h in [0.1,0.5,1,5.5,10]:
         for n in [33,65,55]:
             f = random((n,))
             af = sum(f,axis=0)/n
             f = f-af
             assert_almost_equal(sum(f,axis=0),0.0)
             assert_array_almost_equal(itilbert(tilbert(f,h),h),f)
             assert_array_almost_equal(tilbert(itilbert(f,h),h),f)
Beispiel #2
0
 def test_random_odd(self):
     for h in [0.1, 0.5, 1, 5.5, 10]:
         for n in [33, 65, 55]:
             f = random((n, ))
             af = sum(f, axis=0) / n
             f = f - af
             assert_almost_equal(sum(f, axis=0), 0.0)
             assert_array_almost_equal(itilbert(tilbert(f, h), h), f)
             assert_array_almost_equal(tilbert(itilbert(f, h), h), f)
Beispiel #3
0
 def test_definition(self):
     for h in [0.1, 0.5, 1, 5.5, 10]:
         for n in [16, 17, 64, 127]:
             x = arange(n) * 2 * pi / n
             y = tilbert(sin(x), h)
             y1 = direct_tilbert(sin(x), h)
             assert_array_almost_equal(y, y1)
             assert_array_almost_equal(tilbert(sin(x), h),
                                       direct_tilbert(sin(x), h))
             assert_array_almost_equal(tilbert(sin(2 * x), h),
                                       direct_tilbert(sin(2 * x), h))
Beispiel #4
0
 def test_definition(self):
     for h in [0.1,0.5,1,5.5,10]:
         for n in [16,17,64,127]:
             x = arange(n)*2*pi/n
             y = tilbert(sin(x),h)
             y1 = direct_tilbert(sin(x),h)
             assert_array_almost_equal(y,y1)
             assert_array_almost_equal(tilbert(sin(x),h),
                                       direct_tilbert(sin(x),h))
             assert_array_almost_equal(tilbert(sin(2*x),h),
                                       direct_tilbert(sin(2*x),h))
Beispiel #5
0
 def bench_random(self):
     print()
     print(' Tilbert transform of periodic functions')
     print('=========================================')
     print(' size  | optimized |    naive')
     print('-----------------------------------------')
     for size,repeat in [(100,1500),(1000,300),
                         (256,1500),
                         (512,1000),
                         (1024,500),
                         (2048,200),
                         (2048*2,100),
                         (2048*4,50),
                         ]:
         print('%6s' % size, end=' ')
         sys.stdout.flush()
         x = arange(size)*2*pi/size
         if size < 2000:
             f = sin(x)*cos(4*x)+exp(sin(3*x))
         else:
             f = sin(x)*cos(4*x)
         assert_array_almost_equal(tilbert(f,1),direct_tilbert(f,1))
         print('| %9.2f' % measure('tilbert(f,1)',repeat), end=' ')
         sys.stdout.flush()
         print('| %9.2f' % measure('direct_tilbert(f,1)',repeat), end=' ')
         sys.stdout.flush()
         print(' (secs for %s calls)' % (repeat))
 def bench_random(self):
     print
     print ' Tilbert transform of periodic functions'
     print '========================================='
     print ' size  | optimized |    naive'
     print '-----------------------------------------'
     for size,repeat in [(100,1500),(1000,300),
                         (256,1500),
                         (512,1000),
                         (1024,500),
                         (2048,200),
                         (2048*2,100),
                         (2048*4,50),
                         ]:
         print '%6s' % size,
         sys.stdout.flush()
         x = arange (size)*2*pi/size
         if size<2000:
             f = sin(x)*cos(4*x)+exp(sin(3*x))
         else:
             f = sin(x)*cos(4*x)
         assert_array_almost_equal(tilbert(f,1),direct_tilbert(f,1))
         print '| %9.2f' % measure('tilbert(f,1)',repeat),
         sys.stdout.flush()
         print '| %9.2f' % measure('direct_tilbert(f,1)',repeat),
         sys.stdout.flush()
         print ' (secs for %s calls)' % (repeat)
Beispiel #7
0
 def test_tilbert_relation(self):
     for n in [16, 17, 64, 127]:
         x = arange(n) * 2 * pi / n
         f = sin(x) + cos(2 * x) * sin(x)
         y = hilbert(f)
         y1 = direct_hilbert(f)
         assert_array_almost_equal(y, y1)
         y2 = tilbert(f, h=10)
         assert_array_almost_equal(y, y2)
Beispiel #8
0
 def test_tilbert_relation(self):
     for n in [16,17,64,127]:
         x = arange(n)*2*pi/n
         f = sin(x)+cos(2*x)*sin(x)
         y = hilbert(f)
         y1 = direct_hilbert(f)
         assert_array_almost_equal(y,y1)
         y2 = tilbert(f,h=10)
         assert_array_almost_equal(y,y2)
 def time_tilbert(self, size, soltype):
     if soltype == 'fft':
         tilbert(self.f, 1)
     else:
         direct_tilbert(self.f, 1)
Beispiel #10
0
 def time_tilbert(self, size, soltype):
     if soltype == 'fft':
         tilbert(self.f, 1)
     else:
         direct_tilbert(self.f, 1)