Пример #1
0
 def test_legfromroots(self) :
     res = leg.legfromroots([])
     assert_almost_equal(trim(res), [1])
     for i in range(1,5) :
         roots = np.cos(np.linspace(-np.pi, 0, 2*i + 1)[1::2])
         pol = leg.legfromroots(roots)
         res = leg.legval(roots, pol)
         tgt = 0
         assert_(len(pol) == i + 1)
         assert_almost_equal(leg.leg2poly(pol)[-1], 1)
         assert_almost_equal(res, tgt)
Пример #2
0
 def test_legfromroots(self) :
     res = leg.legfromroots([])
     assert_almost_equal(trim(res), [1])
     for i in range(1, 5) :
         roots = np.cos(np.linspace(-np.pi, 0, 2*i + 1)[1::2])
         pol = leg.legfromroots(roots)
         res = leg.legval(roots, pol)
         tgt = 0
         assert_(len(pol) == i + 1)
         assert_almost_equal(leg.leg2poly(pol)[-1], 1)
         assert_almost_equal(res, tgt)
Пример #3
0
 def test_legroots(self) :
     assert_almost_equal(leg.legroots([1]), [])
     assert_almost_equal(leg.legroots([1, 2]), [-.5])
     for i in range(2,5) :
         tgt = np.linspace(-1, 1, i)
         res = leg.legroots(leg.legfromroots(tgt))
         assert_almost_equal(trim(res), trim(tgt))
Пример #4
0
 def test_legroots(self) :
     assert_almost_equal(leg.legroots([1]), [])
     assert_almost_equal(leg.legroots([1, 2]), [-.5])
     for i in range(2, 5) :
         tgt = np.linspace(-1, 1, i)
         res = leg.legroots(leg.legfromroots(tgt))
         assert_almost_equal(trim(res), trim(tgt))
Пример #5
0
def legfromroots(roots):
    from numpy.polynomial.legendre import legfromroots
    return legfromroots(roots)
Пример #6
0
def legfromroots(roots) :
    from numpy.polynomial.legendre import legfromroots
    return legfromroots(roots)