Example #1
0
def gauss_radau_quadrature(N, alpha=0.0, r0=None, shift=0.0, scale=1.0):
    """
    Returns the N-point Laguerre-Gauss-Radau(alpha) quadrature rule over
    the interval (shift,inf) For nontrivial values of shift, scale, the
    weight function associated with this quadrature rule is the directly-mapped
    Laguerre weight + the Jacobian factor introduced by scale.
    """

    from numpy import array
    from spyctral.laguerre.coeffs import recurrence_range
    from spyctral.opoly1d.quad import grq as ogrq
    from spyctral.common.maps import physical_scaleshift as pss
    from spyctral.common.maps import standard_scaleshift as sss

    if r0 is None:
        r0 = 0 + shift

    r0 = array(r0)

    [a, b] = recurrence_range(N, alpha)
    sss(r0, scale=scale, shift=shift)
    temp = ogrq(a, b, r0=r0)
    pss(r0, scale=scale, shift=shift)
    pss(temp[0], scale=scale, shift=shift)
    return temp
Example #2
0
def gauss_quadrature(N, alpha=0.0, shift=0.0, scale=1.0):
    """
    Returns the N-point Laguerre-Gauss(alpha) quadrature rule over the interval
    (shift,inf).  The quadrature rule is *not* normalized in the sense
    that the affine parameters shift and scale are built into the new weight
    function for which this quadrature rule is valid.
    """

    from spyctral.laguerre.coeffs import recurrence_range
    from spyctral.opoly1d.quad import gq as ogq
    from spyctral.common.maps import physical_scaleshift as pss

    [a, b] = recurrence_range(N, alpha)
    temp = ogq(a, b)
    pss(temp[0], scale=scale, shift=shift)
    return temp
Example #3
0
def laguerre_polynomial(x,n,alpha=0.,d=0, normalization='normal',scale=1., shift=0.) :
    """
    Evaluates the Laguerre polynomials of class alpha, order n (list)
    at the points x (list/array). The normalization is specified by the keyword
    argument. Possibilities:
        'normal', 'normalized':
        'monic':
    """
    from numpy import array, ndarray, ones, sqrt
    from spyctral.laguerre.coeffs import recurrence_range
    from spyctral.opoly1d.eval import eval_opoly, eval_normalized_opoly
    from spyctral.common.maps import physical_scaleshift as pss
    from spyctral.common.maps import standard_scaleshift as sss

    x = array(x)
    if all([type(n) != dtype for dtype in [list,ndarray]]):
        # Then it's probably an int
        n = array([n])
    n = array(n)

    [a,b] = recurrence_range(max(n)+2,alpha=alpha)

    # dummy function for scaling
    def scale_ones(n,alpha):
        return ones([1,len(n)])

    # Set up different normalizations
    normal_fun = {'normal': eval_normalized_opoly,
                  'normalized': eval_normalized_opoly,
                  'monic': eval_opoly}

    normal_scale = {'normal': scale_ones,
                    'normalized': scale_ones,
                    'monic': scale_ones}

    # Shift to standard interval and use opoly 3-term recurrence
    normalization = normalization.lower()
    sss(x,scale=scale,shift=shift)
    temp = normal_fun[normalization](x,n,a,b,d=d)
    temp *= normal_scale[normalization](n,alpha)
    pss(x,scale=scale,shift=shift)

    return temp