Пример #1
0
 def check_splder(self):
     N = 50
     a,b = 0,2*pi
     dx = 0.2*pi
     k = range(3,6)
     x=a+(b-a)*arange(N+1,dtype=float)/float(N)
     v=f1(x)
     for j in range(len(k)):
         tck = splrep(x,v,k=k[j],s=0)
         dr = spalde(dx,tck)
         d2 = splev(dx,tck,der=1)
         assert_almost_equal(1, dr[1]/f1(dx,1.0), decimal=2)
Пример #2
0
 def check_splint_spalde(self):
     per = [0, 1, 0]
     N = [20, 20, 50]
     ia = [0, 0, 0.2*pi]
     ib = [0, 0, pi]
     a,b = 0,2*pi
     dx = 0.2*pi
     k = range(1,6)
     for i in range(len(per)):
         x=a+(b-a)*arange(N[i]+1,dtype=float)/float(N[i])
         v=f1(x)
         for j in range(len(k)):
             tck = splrep(x,v,k=k[j],s=0,per=per[i])
             ir = splint(ia[i],ib[i],tck)
             dr = spalde(dx,tck)
             assert_almost_equal(ir, f1(ib[i],-1)-f1(ia[i],-1), decimal=2)
             d=0
             for ddr in dr:
                 if d<k[j]-1:
                     assert_almost_equal(1, ddr/f1(dx,d), decimal=2)
                 d=d+1