Пример #1
0
 def test_uneven(self):
     # Use uniform weight, should just get the lagendre polynomials.
     # Get lots of polynomials to test the numerical stability.
     m = 300
     n = 10
     x = sp.log(sp.arange(m, dtype=float) / 2 + 0.5)
     window = sp.sin(x)**2
     polys = utils.ortho_poly(x, n, window)
     self.check_ortho_norm(polys, window)
Пример #2
0
 def test_uneven(self):
     # Use uniform weight, should just get the lagendre polynomials.
     # Get lots of polynomials to test the numerical stability.
     m = 300
     n = 10
     x = sp.log(sp.arange(m, dtype=float)/2 + 0.5)
     window = sp.sin(x)**2
     polys = utils.ortho_poly(x, n, window)
     self.check_ortho_norm(polys, window)
Пример #3
0
 def test_multiD2(self):
     # Use uniform weight, should just get the lagendre polynomials.
     m = 40
     n = 10
     x = sp.log(sp.arange(m, dtype=float) / 2 + 0.5)
     window = sp.empty((2, m), dtype=float)
     window[0, :] = sp.sin(x)**2
     window[1, :] = sp.cos(x)**2
     x.shape = (1, m)
     polys = utils.ortho_poly(x, n, window, axis=1)
     self.check_ortho_norm(polys, window, axis=1)
Пример #4
0
 def test_multiD2(self):
     # Use uniform weight, should just get the lagendre polynomials.
     m = 40
     n = 10
     x = sp.log(sp.arange(m, dtype=float)/2 + 0.5)
     window = sp.empty((2, m), dtype=float)
     window[0,:] = sp.sin(x)**2
     window[1,:] = sp.cos(x)**2
     x.shape = (1, m)
     polys = utils.ortho_poly(x, n, window, axis=1)
     self.check_ortho_norm(polys, window, axis=1)
Пример #5
0
 def test_flat_even_spaced(self):
     # Use uniform weight, should just get the lagendre polynomials.
     m = 20
     n = 10
     x = sp.arange(m, dtype=float)
     window = 1.
     polys = utils.ortho_poly(x, n, window)
     # The first one should just be the mean.
     self.assertTrue(sp.allclose(polys[0, :], 1. / sp.sqrt(m)))
     # The second one should be a slope.
     expected = x - sp.mean(x)
     expected = expected / sp.sqrt(sp.sum(expected**2))
     self.assertTrue(sp.allclose(polys[1, :], expected))
     # Check that they are all orthonormal.
     self.check_ortho_norm(polys, 1.)
Пример #6
0
 def test_flat_even_spaced(self):
     # Use uniform weight, should just get the lagendre polynomials.
     m = 20
     n = 10
     x = sp.arange(m, dtype=float)
     window = 1.
     polys = utils.ortho_poly(x, n, window)
     # The first one should just be the mean.
     self.assertTrue(sp.allclose(polys[0,:], 1./sp.sqrt(m)))
     # The second one should be a slope.
     expected = x - sp.mean(x)
     expected = expected / sp.sqrt(sp.sum(expected**2))
     self.assertTrue(sp.allclose(polys[1,:], expected))
     # Check that they are all orthonormal.
     self.check_ortho_norm(polys, 1.)