def __init__(self):
        def tensor_points(P):
            PP0, PP1 = np.array(np.meshgrid(P, P))
            return np.array((PP0.ravel(), PP1.ravel())).T

        def tensor_weights(W):
            return np.dot(W[:, np.newaxis], W[np.newaxis, :]).ravel()
        self._quadrature_points = [tensor_points(GaussQuadratures.quadrature(npoints=p + 1)[0])
                                   for p in xrange(GaussQuadratures.maxpoints())]
        self._quadrature_weights = [tensor_weights(GaussQuadratures.quadrature(npoints=p + 1)[1])
                                    for p in xrange(GaussQuadratures.maxpoints())]
        self._quadrature_npoints = np.arange(1, GaussQuadratures.maxpoints() + 1) ** 2
        self._quadrature_orders = GaussQuadratures.orders
        self._quadrature_order_map = GaussQuadratures.order_map
Beispiel #2
0
 def quadrature(self, order=None, npoints=None, quadrature_type='default'):
     if quadrature_type == 'default' or quadrature_type == 'gauss':
         P, W = GaussQuadratures.quadrature(order, npoints)
         return P[:, np.newaxis], W
     else:
         raise NotImplementedError(
             'quadrature_type must be "default" or "gauss"')
Beispiel #3
0
 def __init__(self, flux, flux_derivative, gausspoints=5, intervals=1):
     self.__auto_init(locals())
     self.build_parameter_type(flux, flux_derivative)
     points, weights = GaussQuadratures.quadrature(npoints=self.gausspoints)
     points = points / intervals
     points = ((np.arange(self.intervals, dtype=np.float)[:, np.newaxis] *
                (1 / intervals)) + points[np.newaxis, :]).ravel()
     weights = np.tile(weights, intervals) * (1 / intervals)
     self.points = points
     self.weights = weights
Beispiel #4
0
    def __init__(self):
        def tensor_points(P):
            PP0, PP1 = np.array(np.meshgrid(P, P))
            return np.array((PP0.ravel(), PP1.ravel())).T

        def tensor_weights(W):
            return np.dot(W[:, np.newaxis], W[np.newaxis, :]).ravel()

        self._quadrature_points = [
            tensor_points(GaussQuadratures.quadrature(npoints=p + 1)[0])
            for p in range(GaussQuadratures.maxpoints())
        ]
        self._quadrature_weights = [
            tensor_weights(GaussQuadratures.quadrature(npoints=p + 1)[1])
            for p in range(GaussQuadratures.maxpoints())
        ]
        self._quadrature_npoints = np.arange(1,
                                             GaussQuadratures.maxpoints() +
                                             1)**2
        self._quadrature_orders = GaussQuadratures.orders
        self._quadrature_order_map = GaussQuadratures.order_map
Beispiel #5
0
 def __init__(self, flux, flux_derivative, gausspoints=5, intervals=1):
     self.flux = flux
     self.flux_derivative = flux_derivative
     self.gausspoints = gausspoints
     self.intervals = intervals
     self.build_parameter_type(inherits=(flux, flux_derivative))
     points, weights = GaussQuadratures.quadrature(npoints=self.gausspoints)
     points = points / intervals
     points = ((np.arange(self.intervals, dtype=np.float)[:, np.newaxis] * (1 / intervals))
               + points[np.newaxis, :]).ravel()
     weights = np.tile(weights, intervals) * (1 / intervals)
     self.points = points
     self.weights = weights
Beispiel #6
0
 def test_points(self):
     for order in GaussQuadratures.orders:
         P, _ = GaussQuadratures.quadrature(order)
         assert float_cmp_all(P, np.sort(P))
         assert 0.0 < P[0]
         assert P[-1] < 1.0
Beispiel #7
0
 def test_weights(self):
     for order in GaussQuadratures.orders:
         _, W = GaussQuadratures.quadrature(order)
         assert float_cmp(sum(W), 1)
 def quadrature(self, order=None, npoints=None, quadrature_type='default'):
     if quadrature_type == 'default' or quadrature_type == 'gauss':
         P, W = GaussQuadratures.quadrature(order, npoints)
         return P[:, np.newaxis], W
     else:
         raise NotImplementedError('quadrature_type must be "default" or "gauss"')
Beispiel #9
0
 def test_points(self):
     for order in GaussQuadratures.orders:
         P, _ = GaussQuadratures.quadrature(order)
         assert float_cmp_all(P, np.sort(P))
         assert 0.0 < P[0]
         assert P[-1] < 1.0
Beispiel #10
0
 def test_weights(self):
     for order in GaussQuadratures.orders:
         _, W = GaussQuadratures.quadrature(order)
         assert float_cmp(sum(W), 1)
Beispiel #11
0
 def test_points(self):
     for order in GaussQuadratures.orders:
         P, _ = GaussQuadratures.quadrature(order)
         np.testing.assert_array_equal(P, np.sort(P))
         self.assertLess(0.0, P[0])
         self.assertLess(P[-1], 1.0)
Beispiel #12
0
 def test_weights(self):
     for order in GaussQuadratures.orders:
         _, W = GaussQuadratures.quadrature(order)
         self.assertAlmostEqual(sum(W), 1)