def __init__(self, test, trial): assert isinstance(test[0], CB) assert isinstance(trial[0], SD) N = test[0].N ck = get_ck(N, test[0].quad) d = {-2: -np.pi / 2 * ck[2:], 0: np.pi / 2 * ck[:N - 2]} SpectralMatrix.__init__(self, d, test, trial)
def __init__(self, test, trial, measure=1): k = test[0].wavenumbers(bcast=False, scaled=False, eliminate_highest_freq=False) N = test[0].N d = {1: -0.5 * k[1:], -1: 0.5 * k[:-1], N - 1: -0.5} SpectralMatrix.__init__(self, d, test, trial, measure=measure)
def __init__(self, test, trial, measure=1): assert isinstance(test[0], SD) assert isinstance(trial[0], SD) N = test[0].N k = np.arange(N, dtype=np.float) d = {-1: -(k[1:N - 2] + 1) * np.pi, 1: (k[:(N - 3)] + 1) * np.pi} SpectralMatrix.__init__(self, d, test, trial, measure=measure)
def __init__(self, test, trial, measure=1): assert isinstance(test[0], SD) assert isinstance(trial[0], CB) N = test[0].N k = np.arange(N, dtype=np.float) d = {1: np.pi * (k[:N - 2] + 1)} SpectralMatrix.__init__(self, d, test, trial, measure=measure)
def __init__(self, test, trial, measure=1): N = test[0].N d = {} if measure == 1: k = test[0].wavenumbers(N, scaled=False) if isinstance(test[1], (int, np.integer)): k_test, k_trial = test[1], trial[1] elif isinstance(test[1], np.ndarray): assert len(test[1]) == 1 k_test = test[1][(0, ) * np.ndim(test[1])] k_trial = trial[1][(0, ) * np.ndim(trial[1])] else: raise RuntimeError if abs(k_trial) + abs(k_test) > 0: if N % 2 == 0 and (k_trial + k_test) % 2 == 1: pass #k[N//2] = 0 val = (1j * k)**(k_trial) * (-1j * k)**k_test if (k_trial + k_test) % 2 == 0: val = val.real d = {0: val} else: d = {0: 1.0} SpectralMatrix.__init__(self, d, test, trial, measure=measure)
def __init__(self, test, trial, measure=1): assert isinstance(test[0], SB) assert isinstance(trial[0], SB) N = test[0].N k = np.arange(N - 4, dtype=float) d = {0: 2 * (2 * k + 3)**2 * (2 * k + 5)} SpectralMatrix.__init__(self, d, test, trial, measure=measure)
def __init__(self, test, trial): from shenfun.la import PDMA assert isinstance(test[0], SB) assert isinstance(trial[0], SB) N = test[0].N k = np.arange(N, dtype=np.float) gk = (2 * k + 3) / (2 * k + 7) hk = -(1 + gk) ek = 2. / (2 * k + 1) p0 = 16 * (k[:-4] + 2)**2 * (k[:-4] + 1)**2 / (2 * k[:-4] + 5)**2 / ( 2 * k[:-4] + 3)**2 p2 = 16 * (k[:-6] + 2) * (k[2:-4] + 2) * (k[:-6] + 1) * ( k[2:-4] + 1) / (2 * k[:-6] + 5) / (2 * k[2:-4] + 5) / ( 2 * k[:-6] + 3) / (2 * k[2:-4] + 3) p4 = 16 * (k[:-8] + 2) * (k[4:-4] + 2) * (k[:-8] + 1) * ( k[4:-4] + 1) / (2 * k[:-8] + 5) / (2 * k[4:-4] + 5) / ( 2 * k[:-8] + 3) / (2 * k[4:-4] + 3) d = { 0: p0 * (ek[:-4] + hk[:-4]**2 * ek[2:-2] + gk[:-4]**2 * ek[4:]), 2: p2 * ((hk[:-6] * ek[2:-4] + gk[:-6] * hk[2:-4] * ek[4:-2])), 4: p4 * (gk[:-8] * ek[4:-4]) } d[-2] = d[2] d[-4] = d[4] SpectralMatrix.__init__(self, d, test, trial) self.solve = PDMA(self)
def __init__(self, test, trial, scale=1): assert isinstance(test[0], SB) assert isinstance(trial[0], SB) N = test[0].N k = np.arange(N - 4, dtype=np.float) d = {0: 32 * (k + 2)**2 * (k + 1)**2 / (2 * k + 5)} SpectralMatrix.__init__(self, d, test, trial, scale=scale)
def __init__(self, test, trial, scale=1, measure=1): assert isinstance(test[0], SD) assert isinstance(trial[0], SD) assert test[0].quad == 'LG' k = np.arange(test[0].N - 2) d = { 0: 2 / (2 * k + 1) + 2 / (2 * k + 5), 1: 2 / (2 * k[:-1] + 1) / (2 * k[:-1] + 5) + 2 * (k[:-1] + 3) / (2 * k[:-1] + 5) / (2 * k[:-1] + 7), 2: -2 / (2 * k[:-2] + 5), 3: -2 * (k[:-3] + 3) / (2 * k[:-3] + 5) / (2 * k[:-3] + 7) } d[-1] = d[1] d[-2] = d[2] d[-3] = d[3] SpectralMatrix.__init__(self, d, test, trial, scale=scale, measure=measure)
def __init__(self, test, trial, measure=1): assert isinstance(test[0], DN) assert isinstance(trial[0], DN) N = test[0].N k = np.arange(N - 2, dtype=float) km = k[:-1] kp = k[:-2] d = { 0: 2 / (2 * k + 1) + 2 * ((2 * k + 3) / (k + 2)) / (k + 2)**3 + 2 * ((k + 1) / (k + 2))**4 / (2 * k + 5), 1: (2 / (km + 2)**2 - 2 * ((km + 1) / (km + 2))**2 / (km + 3)**2), 2: -2 * ((kp + 1) / (kp + 2))**2 / (2 * kp + 5) } d[-1] = d[1].copy() d[-2] = d[2].copy() if test[0].quad == 'GL': k = N - 3 d[0][-1] = 2 / (2 * k + 1) + 2 * ( (2 * k + 3) / (k + 2)) / (k + 2)**3 + 2 * ((k + 1) / (k + 2))**4 / (N - 1) SpectralMatrix.__init__(self, d, test, trial, measure=measure)
def __init__(self, test, trial, scale=1.): assert isinstance(test[0], SD) assert isinstance(trial[0], SD) N = test[0].N k = np.arange(N - 2, dtype=np.float) d = {0: 4 * (4 * k + 6) * (k + 1)**2 / (2 * k + 3)**2} SpectralMatrix.__init__(self, d, test, trial, scale=scale)
def __init__(self, test, trial, scale=1, measure=1): assert isinstance(test[0], SU) assert isinstance(trial[0], SU) assert test[0].quad == 'LG' k = np.arange(test[0].N-1) d = {0: 2*k+2} SpectralMatrix.__init__(self, d, test, trial, scale=scale, measure=measure)
def __init__(self, test, trial, scale=1, measure=1): assert isinstance(test[0], SU) assert isinstance(trial[0], SU) assert test[0].quad == 'LG' k = np.arange(test[0].N - 1) a00 = 2 / (2 * k + 1) a11 = 2 / (2 * k + 3) a22 = 2 / (2 * k + 5) c00 = ((k + 1)**2 / (2 * k + 1) / (2 * k + 3) + k**2 / (2 * k + 1) / (2 * k - 1)) * a00 c11 = ((k + 2)**2 / (2 * k + 3) / (2 * k + 5) + (k + 1)**2 / (2 * k + 3) / (2 * k + 1)) * a11 c02 = (k + 2) * (k + 1) / (2 * k + 5) / (2 * k + 3) * a00 c13 = ((k + 3) * (k + 2) / (2 * k + 7) / (2 * k + 5)) * a11 b01 = (k + 1) / (2 * k + 3) * a00 b12 = (k + 2) / (2 * k + 5) * a11 d = { 0: a00 + c00 - 4 * b01 + a11 + c11, 1: (2 * b01 - c02 - a11 - c11 + 2 * b12)[:-1], -1: (2 * b01 - c02 - a11 - c11 + 2 * b12)[:-1], 2: (c02 - 2 * b12 + c13)[:-2], -2: (c02 - 2 * b12 + c13)[:-2], 3: -c13[:-3].copy(), -3: -c13[:-3].copy() } SpectralMatrix.__init__(self, d, test, trial, scale=scale, measure=measure)
def __init__(self, test, trial, scale=1, measure=1): assert isinstance(test[0], SU) assert isinstance(trial[0], SU) assert test[0].quad == 'LG' k = np.arange(test[0].N - 1) d = { 0: -4 * k**2 * (k + 1) / (2 * k + 1) - 4 * (k + 1)**2 * (k + 2) / (2 * k + 3) + 4 * k * (k + 1) + 4 * (k + 1) / (2 * k + 1) - 4 * (k + 1) / (2 * k + 3), 1: -(2 * (k[:-1] + 1) * (k[:-1] + 2) - 4 * (k[:-1] + 1)**2 * (k[:-1] + 2) / (2 * k[:-1] + 3)) - 4 * (k[1:] + 1) / (2 * k[1:] + 1), -1: -(2 * (k[:-1] + 1) * (k[:-1] + 2) - 4 * (k[:-1] + 1)**2 * (k[:-1] + 2) / (2 * k[:-1] + 3)) + 4 * (k[:-1] + 1) / (2 * k[:-1] + 3) } SpectralMatrix.__init__(self, d, test, trial, scale=scale, measure=measure)
def __init__(self, test, trial, scale=1, measure=1): assert isinstance(test[0], SD) assert isinstance(trial[0], SD) assert test[0].quad == 'LG' k = np.arange(test[0].N-2) d = {0: 4*k+6, 1: 2*k[:-1]+4, -1: 2*k[:-1]+4} SpectralMatrix.__init__(self, d, test, trial, scale=scale, measure=measure)
def __init__(self, test, trial, measure=1): assert isinstance(test[0], SD) assert isinstance(trial[0], SN) N = test[0].N k = np.arange(N-2, dtype=np.float) d = {-1: -((k[1:]-1)/(k[1:]+1))**2*(k[1:]+1)*np.pi, 1: (k[:-1]+1)*np.pi} SpectralMatrix.__init__(self, d, test, trial, measure=measure)
def __init__(self, test, trial, measure=1): k = test[0].wavenumbers(bcast=False, scaled=False, eliminate_highest_freq=False) N = test[0].N d = {2: -0.25*k[2:], -2: 0.25*k[:-2], N-2: 0.25*k[-2:], -(N-2): -0.25*k[:2]} SpectralMatrix.__init__(self, d, test, trial, measure=measure)
def __init__(self, test, trial): assert isinstance(test[0], LB) assert isinstance(trial[0], LB) N = test[0].N d = {} for i in range(-1, -N, -2): d[i] = 2.0 SpectralMatrix.__init__(self, d, test, trial)
def __init__(self, test, trial, scale=1, measure=1): assert isinstance(test[0], SD) assert isinstance(trial[0], SD) assert test[0].quad == 'LG' k = np.arange(test[0].N-2) d = {0: 2*(2*k+3)/(k+1)/(k+2), 1: -2/(k[:-1]+2), -1: -2/(k[:-1]+2)} SpectralMatrix.__init__(self, d, test, trial, scale=scale, measure=measure)
def __init__(self, test, trial, measure=1): assert isinstance(test[0], L) assert isinstance(trial[0], L) N = test[0].N d = {} for i in range(-1, -N, -2): d[i] = 2 SpectralMatrix.__init__(self, d, test, trial, measure=measure)
def __init__(self, test, trial, measure=1): assert isinstance(test[0], LD) assert isinstance(trial[0], LD) d = {0: 0.5, 1: 0.25, -1: 0.25} SpectralMatrix.__init__(self, d, test, trial) self.solve = TDMA_O(self)
def __init__(self, test, trial, measure=1): assert isinstance(test[0], SD) assert isinstance(trial[0], SD) ck = get_ck(test[0].N, test[0].quad) d = {0: np.pi / 2 * (ck[:-2] + ck[2:]), 2: np.array([-np.pi / 2])} d[-2] = d[2] SpectralMatrix.__init__(self, d, test, trial, measure=measure) self.solve = TDMA(self)
def __init__(self, test, trial): assert isinstance(test[0], SB) assert isinstance(trial[0], SB) N = test[0].N k = np.arange(N - 6, dtype=np.float) #FIXME Find the correct diagonal d = {0: 32 * (k + 2)**2 * (k + 1)**2 / (2 * k + 5)} SpectralMatrix.__init__(self, d, test, trial)
def __init__(self, test, trial, measure=1): assert isinstance(test[0], CB) assert isinstance(trial[0], SD) N = test[0].N k = np.arange(N, dtype=np.float) d = {-1: -(k[1:N - 1] + 1) * np.pi, 1: -2 * np.pi} for i in range(3, N - 2, 2): d[i] = -2 * np.pi SpectralMatrix.__init__(self, d, test, trial, measure=measure)
def __init__(self, test, trial, measure=1): assert isinstance(test[0], L) assert isinstance(trial[0], L) N = test[0].N k = np.arange(N, dtype=float) d = {0: 2. / (2. * k + 1)} if test[0].quad == 'GL': d[0][-1] = 2. / (N - 1) SpectralMatrix.__init__(self, d, test, trial, measure=measure)
def __init__(self, test, trial, measure=1): assert isinstance(test[0], SD) assert isinstance(trial[0], CB) N = test[0].N - 2 M = trial[0].N Q = min(N, M) ck = get_ck(Q + 2, test[0].quad) d = {0: np.pi / 2 * ck[:Q], 2: -np.pi / 2 * ck[2:(dmax(N, M, 2) + 2)]} SpectralMatrix.__init__(self, d, test, trial, measure=measure)
def __init__(self, test, trial, measure=1): assert isinstance(test[0], CB) assert isinstance(trial[0], CB) N = test[0].N k = np.arange(N, dtype=np.float) d = {} for j in range(2, N, 2): d[j] = k[j:] * (k[j:]**2 - k[:-j]**2) * np.pi / 2. SpectralMatrix.__init__(self, d, test, trial, measure=measure)
def __init__(self, test, trial, measure=1): assert isinstance(test[0], SD) assert isinstance(trial[0], SD) N = test[0].N k = np.arange(N, dtype=np.float) d = {0: -2 * np.pi * (k[:N - 2] + 1) * (k[:N - 2] + 2)} for i in range(2, N - 2, 2): d[i] = -4 * np.pi * (k[:-(i + 2)] + 1) SpectralMatrix.__init__(self, d, test, trial, measure=measure)
def __init__(self, test, trial, measure=1): assert isinstance(test[0], L) assert isinstance(trial[0], L) N = test[0].N d = {} for i in range(1, N, 2): d[i] = 2 SpectralMatrix.__init__(self, d, test, trial, measure=measure) self._matvec_methods += ['cython', 'self']
def __init__(self, test, trial, measure=1): assert isinstance(test[0], SD) assert isinstance(trial[0], L) N = test[0].N d = {1: -2} if test[0].is_scaled(): k = np.arange(N - 2, dtype=float) d[1] = -2. / np.sqrt(4 * k + 6) SpectralMatrix.__init__(self, d, test, trial, measure=measure)