~daniele-bigoni/spectraltoolbox/hotfixes

« back to all changes in this revision

Viewing changes to SpectralToolbox/Stroud.py

  • Committer: Daniele Bigoni
  • Date: 2016-01-25 19:41:57 UTC
  • mfrom: (23.1.4 research)
  • Revision ID: dabi@dtu.dk-20160125194157-rw6fsu9gcqq7k85j
Merged from research version 0.2.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
# Author: Daniele Bigoni
25
25
#
26
26
 
27
 
"""
28
 
=========================================
29
 
 Stroud
30
 
=========================================
31
 
 
32
 
Created on Mon Nov 19 09:45:24 2012
33
 
 
34
 
@author: Daniele Bigoni (dabi@imm.dtu.dk)
35
 
 
36
 
Implementation of Stroud equally weighted quadrature rules in N dimensions.
37
 
 
38
 
Available quadrature rules:
39
 
    * Gaussian weights
40
 
    * Beta weights
41
 
    * Gamma weights
42
 
 
43
 
Some useful references used in while developing this toolbox are listed below
44
 
 
45
 
.. [1] A.H. Stroud, "Remarks on the Disposition of Points in Numerical Integration Formulas", Mathematical Tables and Other Aids to Computation, Vol. 11, No. 60 (Oct. 1957), pp. 257-261
46
 
 
47
 
.. [2] D. Xiu, "Numerical integration formulas of degree two", Applied Numerical Mathematics, Vol. 58, No. 10, pp. 1515-1520, 2008
48
 
 
49
 
"""
50
 
 
51
27
__revision__ = filter(str.isdigit, "$Revision: 84 $")
52
28
 
53
29
__author__ = "Daniele Bigoni"
65
41
AVAIL_WEIGHTS = [GAUSSIAN, BETA, GAMMA]
66
42
 
67
43
class Stroud:
 
44
    """ Initialization of the Stroud integral points generator.
 
45
 
 
46
    This method generates an instance of the Stroud class, to be used in order to generate
 
47
    N-dimensional cubature rules with respect to the selected weight. Available weight types can be
 
48
    selected using their string name or by predefined attributes
 
49
 
 
50
        * 'Gaussian' or ``Stroud.GAUSSIAN``
 
51
        * 'Beta' or ``Stroud.BETA``
 
52
        * 'Gamma' or ``Stroud.GAMMA``
 
53
    
 
54
    Additional parameters are required for some weights.
 
55
 
 
56
    +--------------+--------------+
 
57
    | Weight       | Parameters   |
 
58
    +==============+==============+
 
59
    | Gaussian     | None         |
 
60
    +--------------+--------------+
 
61
    | Beta         | (alpha,beta) |
 
62
    +--------------+--------------+
 
63
    | Gamma        | alpha        |
 
64
    +--------------+--------------+
 
65
 
 
66
    See :cite:`Stroud1957` and :cite:`Xiu2008` for details.
 
67
 
 
68
    Args:
 
69
        weight (Stroud.AVAIL_WEIGHTS): type of the multidimensional weight for the formula.
 
70
        params (object): The parameters needed by the selected weight
 
71
 
 
72
    """
68
73
    weight = []
69
74
    params = []
70
75
    
71
76
    def __init__(self, weight, params):
72
 
        """
73
 
        Initialization of the Stroud integral points generator.
74
 
        
75
 
        Syntax:
76
 
            ``stroud = Stroud(weight, params)``
77
 
        
78
 
        Input:
79
 
            * ``weight`` = (Stroud.AVAIL_WEIGHTS) type of the multidimensional weight for the formula.
80
 
            * ``params`` = The parameters needed by the selected weight
81
 
        
82
 
        Description:
83
 
            This method generates an instance of the Stroud class, to be used in order to generate
84
 
            N-dimensional cubature rules with respect to the selected weight. Available weight types can be
85
 
            selected using their string name or by predefined attributes
86
 
                * 'Gaussian' or ``Stroud.GAUSSIAN``
87
 
                * 'Beta' or ``Stroud.BETA``
88
 
                * 'Gamma' or ``Stroud.GAMMA``
89
 
            Additional parameters are required for some weights.
90
 
            
91
 
            +--------------+--------------+
92
 
            | Weight       | Parameters   |
93
 
            +==============+==============+
94
 
            | Gaussian     | None         |
95
 
            +--------------+--------------+
96
 
            | Beta         | (alpha,beta) |
97
 
            +--------------+--------------+
98
 
            | Gamma        | alpha        |
99
 
            +--------------+--------------+
100
 
        """
101
77
        
102
78
        if weight in AVAIL_WEIGHTS:
103
79
            if (weight == BETA):