def endpoints(f): f0 = sp.mirror0(sp.matC(f), -1) aa = f - sp.unmirror0( sp.I_space(0, h / 2)(sp.I_space_inv(-h / 2, h / 2)(f0))) bb = f - sp.unmirror0( sp.I_space(-h / 2, 0)(sp.I_space_inv(-h / 2, h / 2)(f0))) return sp.matB(aa) + sp.matB1(bb)
def midpoints(f): f = sp.mirror0(sp.matC(f), -1) # Shift function with S, Sinv to avoid division by zero at x=0, x=pi f = sp.I_space_inv(-h/2, h/2)(f) f = sp.T_space(+h/2)(f) f = f/sp.Omega_d(f.shape[0]) f = sp.T_space(-h/2)(f) f = sp.unmirror0(f) return f
def midpoints(f): f = sp.mirror0(sp.matC(f), -1) # Shift function with S, Sinv to avoid division by zero at x=0, x=pi f = sp.I_space_inv(-h / 2, h / 2)(f) f = sp.T_space(+h / 2)(f) f = f / sp.Omega_d(f.shape[0]) f = sp.T_space(-h / 2)(f) f = sp.unmirror0(f) return f
def H0_cheb(f): ''' >>> sp.to_matrix(H0_cheb, 2) array([[ 0.75, 0.25], [ 0.25, 0.75]]) ''' f = sp.mirror0(f, +1) N = f.shape[0]; h = 2*pi/N f = sp.F(f) f = sp.fourier_K(f, 0, h/2) f = sp.Finv(f) f = sp.fold0(f, -1) return real(f)
def H0_cheb(f): ''' >>> sp.to_matrix(H0_cheb, 2) array([[ 0.75, 0.25], [ 0.25, 0.75]]) ''' f = sp.mirror0(f, +1) N = f.shape[0] h = 2 * pi / N f = sp.F(f) f = sp.fourier_K(f, 0, h / 2) f = sp.Finv(f) f = sp.fold0(f, -1) return real(f)
def S_cheb(f): ''' Interpolate from primal to dual vertices. >>> S_cheb(array([-1, 0, 1])) array([-0.70710678, 0.70710678]) >>> S_cheb(array([1, 0, -1])) array([ 0.70710678, -0.70710678]) >>> sp.to_matrix(S_cheb, 3).round(3) array([[ 0.604, 0.5 , -0.104], [-0.104, 0.5 , 0.604]]) ''' f = sp.mirror0(f, +1) N = f.shape[0]; h = 2*pi/N f = sp.Finv(sp.F(f)*sp.S_diag(N, h/2)) f = sp.unmirror1(f) return real(f)
def H1d_regular(f): r''' .. math:: \widetilde{\mathbf{H}}^{1}= \mathbf{M}_{1}^{\dagger} {\mathbf{I}^{-\frac{h}{2},\frac{h}{2}}}^{-1} \mathbf{M}_{1}^{+} \mathbf{A}^{-1} ''' f = f/sp.A_diag(f.shape[0]) f = sp.mirror0(f, +1) N = f.shape[0]; h = 2*pi/N f = sp.I_space_inv(-h/2, +h/2)(f) f = sp.unmirror0(f) return f
def H0_regular(f): r''' .. math:: \mathbf{H}^{0}= \mathbf{A} \mathbf{M}_{0}^{\dagger} \mathbf{I}^{-\frac{h}{2},\frac{h}{2}} \mathbf{M}_{0}^{+} ''' f = sp.mirror0(f, +1) N = f.shape[0]; h = 2*pi/N f = sp.I_space(-h/2, h/2)(f) f = sp.unmirror0(f) f = f*sp.A_diag(f.shape[0]) return f
def S_cheb(f): ''' Interpolate from primal to dual vertices. >>> S_cheb(array([-1, 0, 1])) array([-0.70710678, 0.70710678]) >>> S_cheb(array([1, 0, -1])) array([ 0.70710678, -0.70710678]) >>> sp.to_matrix(S_cheb, 3).round(3) array([[ 0.604, 0.5 , -0.104], [-0.104, 0.5 , 0.604]]) ''' f = sp.mirror0(f, +1) N = f.shape[0] h = 2 * pi / N f = sp.Finv(sp.F(f) * sp.S_diag(N, h / 2)) f = sp.unmirror1(f) return real(f)
def H0_regular(f): r''' .. math:: \mathbf{H}^{0}= \mathbf{A} \mathbf{M}_{0}^{\dagger} \mathbf{I}^{-\frac{h}{2},\frac{h}{2}} \mathbf{M}_{0}^{+} ''' f = sp.mirror0(f, +1) N = f.shape[0] h = 2 * pi / N f = sp.I_space(-h / 2, h / 2)(f) f = sp.unmirror0(f) f = f * sp.A_diag(f.shape[0]) return f
def H1d_regular(f): r''' .. math:: \widetilde{\mathbf{H}}^{1}= \mathbf{M}_{1}^{\dagger} {\mathbf{I}^{-\frac{h}{2},\frac{h}{2}}}^{-1} \mathbf{M}_{1}^{+} \mathbf{A}^{-1} ''' f = f / sp.A_diag(f.shape[0]) f = sp.mirror0(f, +1) N = f.shape[0] h = 2 * pi / N f = sp.I_space_inv(-h / 2, +h / 2)(f) f = sp.unmirror0(f) return f
def endpoints(f): f0 = sp.mirror0(sp.matC(f), -1) aa = f - sp.unmirror0(sp.I_space(0, h/2)(sp.I_space_inv(-h/2, h/2)(f0))) bb = f - sp.unmirror0(sp.I_space(-h/2, 0)(sp.I_space_inv(-h/2, h/2)(f0))) return sp.matB(aa) + sp.matB1(bb)