def dweighted_wiener(x,k,s=1.,t=0.,shift=0.,scale=1.): from numpy import sqrt, array from spyctral.fourier.eval import fseries as genfourier from spyctral.fourier.eval import dfseries as dgenfourier from spyctral.wiener.maps import dtheta_dx from spyctral.wiener.maps import x_to_theta as x2theta from spyctral.wiener.weights import sqrt_weight_bias as wx_sqrt from spyctral.wiener.weights import dsqrt_weight_bias as dwx_sqrt # Preprocessing and setup x = array(x) x = x.ravel() k = array(k,dtype=int) k = k.ravel() theta = x2theta(x,shift=shift,scale=scale) # First term: wx_sqrt * d/dx Phi psi = (dtheta_dx(x,shift=shift,scale=scale)*dgenfourier(theta,k,s-1.,t).T).T psi = (wx_sqrt(x,s,t,shift=shift,scale=scale)*(psi.T)).T # Second term: d/dx wx_sqrt * Phi psi += (dwx_sqrt(x,s,t,shift=shift,scale=scale)*genfourier(theta,k,s-1.,t).T).T return psi/sqrt(scale)
def fft_collocation_overhead(N,s=1.,t=0.,shift=0.,scale=1.): from numpy import sqrt from spyctral.fourier.fft import fft_overhead from spyctral.wiener.weights import sqrt_weight_bias as wx_sqrt from spyctral.wiener.quad import gq overhead = fft_overhead(N,gamma=s-1.,delta=t) x = gq(N,s=1.,t=0.,shift=shift,scale=scale)[0] premult = sqrt(scale)/wx_sqrt(x,s=s,t=t,shift=shift,scale=scale) return [premult,overhead]
def fft_collocation(f,s=1.,t=0.,shift=0.,scale=1.): from spyctral.fourier.fft import fft as fft_Psi from spyctral.wiener.weights import sqrt_weight_bias as wx_sqrt from spyctral.wiener.quad import gq from numpy import sqrt # This stuff can all be overhead N = f.size x = gq(N,s=1.,t=0.,shift=shift,scale=scale)[0] modes = f/wx_sqrt(x,s=s,t=t,shift=shift,scale=scale) temp = fft_Psi(modes,gamma=s-1.,delta=t)*float(sqrt(scale)) temp[-s:] = 0 temp[:s] = 0 return temp
def weighted_wiener(x,k,s=1.,t=0.,shift=0.,scale=1.): from numpy import sqrt, array from spyctral.fourier.eval import fseries as genfourier from spyctral.wiener.maps import x_to_theta as x2theta from spyctral.wiener.weights import sqrt_weight_bias as wx_sqrt # Preprocessing and setup x = array(x) x = x.ravel() k = array(k,dtype=int) k = k.ravel() theta = x2theta(x,shift=shift,scale=scale) psi = genfourier(theta,k,s-1.,t) psi = (wx_sqrt((x-shift)/scale,s,t)*(psi.T)).T return psi/sqrt(scale)
def ifft_collocation(F,s=1.,t=0.,shift=0.,scale=1.): from spyctral.fourier.fft import ifft as ifft_Psi from spyctral.wiener.weights import sqrt_weight_bias as wx_sqrt from spyctral.wiener.quad import gq from numpy import sqrt from spyctral.fourier.fft import fft_overhead, ifft_online N = F.size #overhead = fft_overhead(N,g=s-1.,d=t) #fx = ifft_online(f,overhead) fx = ifft_Psi(F,gamma=s-1.,delta=t) x = gq(N,s=1.,t=0.,shift=shift,scale=scale)[0] fx *= wx_sqrt(x,s=s,t=t,shift=shift,scale=scale)/float(sqrt(scale)) #print "hi" return fx
def xiw(x,n,s=1.,t=0.,shift=0.,scale=1.): from numpy import sqrt, array from spyctral.fourier.eval import fseries as genfourier from spyctral.wiener.weights import sqrt_weight_bias as wx_sqrt from spyctral.wiener.maps import x_to_theta as x2theta # Preprocessing and setup x = array(x) x = x.ravel() n = array(n,dtype=int) n = n.ravel() theta = x2theta(x,shift=shift,scale=scale) psi = genfourier(theta,n,s-1.,t).real psi = (wx_sqrt((x-shift)/scale,s,t)*(psi.T)).T psi[:,n==0] *= sqrt(2) psi[:,n!=0] *= 2 return psi/sqrt(scale)