Esempio n. 1
0
 def check_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)
Esempio n. 2
0
 def check_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))
Esempio n. 3
0
 def bench_random(self,level=5):
     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' % self.measure('tilbert(f,1)',repeat),
         sys.stdout.flush()
         print '| %9.2f' % self.measure('direct_tilbert(f,1)',repeat),
         sys.stdout.flush()
         print ' (secs for %s calls)' % (repeat)
Esempio n. 4
0
 def check_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)