def gauss_lobatto_quadrature(N,alpha=-1/2.,beta=-1/2.,r0=None,shift=0.,scale=1.) : # Returns the N-point Jacobi-Gauss-Lobatto(alpha,beta) quadrature rule over the interval # (-scale,scale)+shift # For nontrivial values of shift, scale, the weight function associated with # this quadrature rule is the directly-mapped Jacobi weight + the Jacobian # factor introduced by scale. from coeffs import recurrence_range from numpy import array from spyctral import chebyshev from spyctral.opoly1d.quad import glq as oglq from spyctral.common.maps import physical_scaleshift as pss from spyctral.common.maps import standard_scaleshift as sss if r0 is None: r0 = array([-scale,scale])+shift r0 = array(r0) tol = 1e-12; if (abs(alpha+1/2.)<tol) & (abs(beta+1/2.)<tol) : return chebyshev.quad.glq(N,shift=shift,scale=scale) else : [a,b] = recurrence_range(N,alpha,beta) sss(r0,scale=scale,shift=shift) temp = oglq(a,b,r0=r0) pss(r0,scale=scale,shift=shift) pss(temp[0],scale=scale,shift=shift) #temp[1] *= scale return temp
def jacobi_polynomial(x,n,alpha=-1/2.,beta=-1/2.,d=0, normalization='normal',scale=1., shift=0.) : """ Evaluates the Jacobi polynomials of class (alpha,beta), 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 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,beta=beta) # dummy function for scaling def scale_ones(n,alpha,beta): 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,beta) pss(x,scale=scale,shift=shift) return temp
def gauss_quadrature(N,alpha=-1/2.,beta=-1/2.,shift=0.,scale=1.) : # Returns the N-point Jacobi-Gauss(alpha,beta) quadrature rule over the interval # (-scale,scale)+shift. # 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 coeffs import recurrence_range from spyctral.opoly1d.quad import gq as ogq from spyctral import chebyshev from spyctral.common.maps import physical_scaleshift as pss tol = 1e-12; if (abs(alpha+1/2.)<tol) & (abs(beta+1/2.)<tol) : return chebyshev.quad.gq(N,shift=shift,scale=scale) else : [a,b] = recurrence_range(N,alpha,beta) temp = ogq(a,b) pss(temp[0],scale=scale,shift=shift) return temp