def int_connection(modes,gamma=0.,delta=0.,G=0,D=0): """ Implements the connection coefficient relation, taking the modes from Szego-Fourier class (g,d) to Szego-Fourier class (g+G,d+D), and casts G and D as integers so that the connection relation is sparse. The convention assumed for an even number of modes is that they are centered around the zero frequency, and that there is one more negative mode than positive modes. Assumes G,D>0. (See int_connection_backward for inverse) """ from numpy import append from scipy import conj from spyctral.jacobi.jfft import rmatrix_apply_seq as jconnection G = int(G) D = int(D) if (G+D)>0: N = modes.shape[0] [cmodes,smodes] = sc_collapse(modes,N) cmodes = jconnection(cmodes,delta-1/2.,gamma-1/2.,D,G) smodes = jconnection(smodes,delta+1/2.,gamma+1/2.,D,G) return sc_expand(cmodes,smodes,N) else: return modes.copy()
from spyctral.jacobi.jfft import rmatrix_invert as jconnection_inv from spyctral.jacobi.jfft import rmatrix_apply_seq as jconnection from spyctral.fourier.connection import sc_collapse, sc_expand from numpy import append from scipy import conj G = gamma; D = delta; delta = 0; gamma=0; NEven = (N%2)==0 ucopy = u.copy() if NEven: N += 1 ucopy[0] /= 2. ucopy = append(ucopy,conj(ucopy[0])) [cmodes,smodes] = sc_collapse(ucopy,N) cmodes = jconnection(cmodes,delta-1/2.,gamma-1/2.,D,G) smodes = jconnection(smodes,delta+1/2.,gamma+1/2.,D,G) utemp = sc_expand(cmodes,smodes,N) if NEven: utemp[0] += conj(utemp[-1]) utemp = utemp[:-1] cmodes3 = jconnection_inv(cmodes,delta-1/2.,gamma-1/2.,D,G) smodes3 = jconnection_inv(smodes,delta+1/2.,gamma+1/2.,D,G) u2 = sc_expand(cmodes3,smodes3,N) utemp2 = int_connection(u,gamma=0.,delta=0.,G=G,D=D) u3 = int_connection_backward(utemp2,gamma=0.,delta=0.,G=G,D=D)