def dfseries(theta,k,gamma=0.,delta=0.,shift=0.,scale=1.): """ Evaluates the derivative of the generalized Szego-Fourier functions at the locations theta \in [-pi,pi]. This function mods the inputs theta to lie in this interval and then evaluates them. The function class is (gamma,delta), and the function index is the vector of integers k """ from numpy import array, zeros, dot, any, sum from numpy import sin, cos, sqrt, abs, sign from scipy import pi from spyctral.jacobi.eval import jpoly, djpoly from spyctral.common.maps import standard_scaleshift as sss from spyctral.common.maps import physical_scaleshift as pss # Preprocessing: unravelling, etc. theta = array(theta) theta = theta.ravel() sss(theta,shift=shift,scale=scale) # Now theta \in [-pi,pi] theta = (theta+pi) % (2*pi) - pi k = array(k) k = k.ravel() kneq0 = k != 0 a = delta-1/2. b = gamma-1/2. r = cos(theta) # Term-by-term: first the even term dPsi = zeros([theta.size,k.size],dtype=complex) dPsi += 1/2.*djpoly(r,abs(k),a,b) dPsi = (-sin(theta)*dPsi.T).T dPsi[:,~kneq0] *= sqrt(2) # Now the odd term: if any(kneq0): term2 = zeros([theta.size,sum(kneq0)],dtype=complex) term2 += (cos(theta)*jpoly(r,abs(k[kneq0])-1,a+1,b+1).T).T term2 += (-sin(theta)**2*djpoly(r,abs(k[kneq0])-1,a+1,b+1).T).T term2 = 1./2*term2*(1j*sign(k[kneq0])) else: term2 = 0. dPsi[:,kneq0] += term2 # Transform theta back to original interval pss(theta,shift=shift,scale=scale) return dPsi/scale
def djacobi_function(x,ns,s=1.,t=1.,scale=1.,shift=0.): from spyctral.jacobi.eval import djpoly from spyctral.mapjpoly.maps import x_to_r, st_to_ab, dr_dx [alpha,beta] = st_to_ab(s,t) jac = dr_dx(x,scale=scale,shift=shift) r = x_to_r(x,scale=scale,shift=shift) ps = djpoly(r,ns,alpha=alpha,beta=beta) return (ps.T*jac).T