def test_hermediv(self):
     for i in range(5):
         for j in range(5):
             msg = "At i=%d, j=%d" % (i, j)
             ci = [0] * i + [1]
             cj = [0] * j + [1]
             tgt = herme.hermeadd(ci, cj)
             quo, rem = herme.hermediv(tgt, ci)
             res = herme.hermeadd(herme.hermemul(quo, ci), rem)
             assert_equal(trim(res), trim(tgt), err_msg=msg)
示例#2
0
 def test_hermediv(self) :
     for i in range(5) :
         for j in range(5) :
             msg = "At i=%d, j=%d" % (i,j)
             ci = [0]*i + [1]
             cj = [0]*j + [1]
             tgt = herme.hermeadd(ci, cj)
             quo, rem = herme.hermediv(tgt, ci)
             res = herme.hermeadd(herme.hermemul(quo, ci), rem)
             assert_equal(trim(res), trim(tgt), err_msg=msg)
 def test_hermemul(self):
     # check values of result
     for i in range(5):
         pol1 = [0] * i + [1]
         val1 = herme.hermeval(self.x, pol1)
         for j in range(5):
             msg = "At i=%d, j=%d" % (i, j)
             pol2 = [0] * j + [1]
             val2 = herme.hermeval(self.x, pol2)
             pol3 = herme.hermemul(pol1, pol2)
             val3 = herme.hermeval(self.x, pol3)
             assert_(len(pol3) == i + j + 1, msg)
             assert_almost_equal(val3, val1 * val2, err_msg=msg)
示例#4
0
 def test_hermemul(self) :
     # check values of result
     for i in range(5) :
         pol1 = [0]*i + [1]
         val1 = herme.hermeval(self.x, pol1)
         for j in range(5) :
             msg = "At i=%d, j=%d" % (i,j)
             pol2 = [0]*j + [1]
             val2 = herme.hermeval(self.x, pol2)
             pol3 = herme.hermemul(pol1, pol2)
             val3 = herme.hermeval(self.x, pol3)
             assert_(len(pol3) == i + j + 1, msg)
             assert_almost_equal(val3, val1*val2, err_msg=msg)
示例#5
0
def product3_herm(i,j,l):
    #compute \Phi_i*\Phi_j*\Phi_l
    return lambda x: H.hermeval(x, H.hermemul(H.hermemul(Phi(i),Phi(j)),Phi(l)))