def int_connection_backward_online(modes,matrices): from spyctral.jacobi.jfft import rmatrix_entries_invert as jconnection_apply if matrices[0].shape[1]>1: N = modes.shape[0] [cmodes,smodes] = sc_collapse(modes,N) cmodes = jconnection_apply(cmodes,matrices[0]) smodes = jconnection_apply(smodes,matrices[1]) return sc_expand(cmodes,smodes,N) else: return modes.copy()
def int_connection_online(modes,matrices): from spyctral.jacobi.jfft import rmatrix_entries_apply as jconnection_apply from numpy import sqrt,zeros,hstack,flipud if matrices[0].shape[1]>1: N = modes.shape[0] # How to read the code below: # cmodes = matrices[2] # smodes = matrices[3] # NEven = matrices[4] Nmiddle = matrices[5] ### sc_collapse ### # Ensures modes is odd-length if matrices[4]: modes = hstack((modes,0.)) matrices[3] = flipud(modes[:Nmiddle]) matrices[2][1:] = 1/2.*(modes[(Nmiddle+1):] + matrices[3]) matrices[2][0] = sqrt(2)/2*modes[Nmiddle] matrices[3] = 1/2.*(modes[(Nmiddle+1):] - matrices[3]) ### connection ### matrices[2] = jconnection_apply(matrices[2],matrices[0]) matrices[3] = jconnection_apply(matrices[3],matrices[1]) #[matrices[2],matrices[3]] = jconnection_apply(matrices[2],matrices[0],\ # matrices[3],matrices[1]) #### sc_expand ### modes[Nmiddle] = matrices[2][0]*sqrt(2) modes[(Nmiddle+1):] = matrices[2][1:]+matrices[3] modes[Nmiddle-1::-1] = (matrices[2][1:]-matrices[3]) if matrices[4]: return modes[:-1] else: return modes # Using utility functions: #[cmodes,smodes] = sc_collapse(modes,N) #cmodes = jconnection_apply(cmodes,matrices[0]) #smodes = jconnection_apply(smodes,matrices[1]) #return sc_expand(cmodes,smodes,N) else: return modes.copy()