Example #1
0
 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)
Example #2
0
 def __init__(self, test, trial, measure=1):
     assert isinstance(test[0], SN)
     assert isinstance(trial[0], SN)
     N = test[0].N
     k = np.arange(N-2, dtype=np.float)
     d = {0: -2*np.pi*k**2*(k+1)/(k+2)}
     for i in range(2, N-2, 2):
         d[i] = -4*np.pi*(k[:-i]+i)**2*(k[:-i]+1)/(k[:-i]+2)**2
     SpectralMatrix.__init__(self, d, test, trial, measure=measure)
Example #3
0
 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)
Example #4
0
 def __init__(self, test, trial, measure=1):
     assert isinstance(test[0], SD)
     assert isinstance(trial[0], LB)
     N = test[0].N
     d = {1: -2}
     if test[0].is_scaled():
         k = np.arange(N - 2, dtype=np.float)
         d[1] = -2. / np.sqrt(4 * k + 6)
     SpectralMatrix.__init__(self, d, test, trial, measure=measure)
Example #5
0
 def __init__(self, test, trial, measure=1):
     assert isinstance(test[0], CB)
     assert isinstance(trial[0], SN)
     N = test[0].N
     ck = get_ck(N, test[0].quad)
     k = np.arange(N, dtype=np.float)
     d = {-2: -np.pi/2*ck[2:]*((k[2:]-2)/k[2:])**2,
           0: np.pi/2*ck[:-2]}
     SpectralMatrix.__init__(self, d, test, trial, measure=measure)
Example #6
0
 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)
     self._matvec_methods += ['cython', 'self']
Example #7
0
 def __init__(self, test, trial, measure=1):
     assert isinstance(test[0], LB)
     assert isinstance(trial[0], LB)
     N = test[0].N
     k = np.arange(N, dtype=np.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)
Example #8
0
 def __init__(self, test, trial):
     assert isinstance(test[0], SB)
     assert isinstance(trial[0], SB)
     N = test[0].N
     k = np.arange(N - 4, dtype=np.float)
     gk = (2 * k + 3) / (2 * k + 7)
     d = {0: -2 * (2 * k + 3) * (1 + gk), 2: 2 * (2 * k[:-2] + 3)}
     d[-2] = d[2]
     SpectralMatrix.__init__(self, d, test, trial)
Example #9
0
 def __init__(self, test, trial):
     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)
     self.solve = TDMA(self)
Example #10
0
 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)
Example #11
0
 def __init__(self, test, trial):
     assert isinstance(test[0], SN)
     assert isinstance(trial[0], SN)
     N = test[0].N
     k = np.arange(N - 2, dtype=np.float)
     alpha = k * (k + 1) / (k + 2) / (k + 3)
     d0 = 2. / (2 * k + 1)
     d = {0: d0 * alpha * (k + 0.5) * ((k + 2) * (k + 3) - k * (k + 1))}
     SpectralMatrix.__init__(self, d, test, trial)
Example #12
0
 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)
Example #13
0
 def __init__(self, test, trial, measure=1):
     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
     SpectralMatrix.__init__(self, d, test, trial, measure=measure)
     self._matvec_methods += ['cython', 'self']
Example #14
0
 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=np.float)
     d = {-2: 2*(k[2:]-1)*(k[2:]+2)*np.pi,
           0: -4*((k+1)*(k+2)**2)/(k+3)*np.pi,
           2: 2*(k[:-2]+1)*(k[:-2]+2)*np.pi}
     SpectralMatrix.__init__(self, d, test, trial, measure=measure)
Example #15
0
 def __init__(self, test, trial, measure=1):
     assert isinstance(test[0], SD)
     assert isinstance(trial[0], SB)
     N = test[0].N
     k = np.arange(N, dtype=np.float)
     d = {-3: (k[3:-2]-2)*(k[3:-2]+1)/k[3:-2]*np.pi,
          -1: -2*(k[1:-3]+1)**2/(k[1:-3]+2)*np.pi,
           1: (k[:-5]+1)*np.pi}
     SpectralMatrix.__init__(self, d, test, trial, measure=measure)
Example #16
0
 def __init__(self, test, trial, measure=1):
     assert isinstance(test[0], SB)
     assert isinstance(trial[0], SD)
     N = test[0].N
     k = np.arange(N, dtype=np.float)
     d = {-1: -(k[1:N-4]+1)*np.pi,
           1: 2*(k[:N-4]+1)*np.pi,
           3: -(k[:N-5]+1)*np.pi}
     SpectralMatrix.__init__(self, d, test, trial, measure=measure)
Example #17
0
 def __init__(self, test, trial, scale=1, measure=1):
     assert isinstance(test[0], SD)
     assert isinstance(trial[0], SD)
     N = test[0].N
     d = {-1: -2, 1: 2}
     if trial[0].is_scaled():
         k = np.arange(N-2, dtype=np.float)
         d[-1] = -2. / np.sqrt(4*k[:-1]+6)
         d[1] = 2. / np.sqrt(4*k[:-1]+6)
     SpectralMatrix.__init__(self, d, test, trial, scale=scale, measure=measure)
Example #18
0
 def __init__(self, test, trial, measure=1):
     assert isinstance(test[0], LB)
     assert isinstance(trial[0], LB)
     N = test[0].N
     k = np.arange(N, dtype=np.float)
     d = {}
     for j in range(2, N, 2):
         jj = j if trial[1] else -j
         d[jj] = (k[:-j]+0.5)*((k[:-j]+j)*(k[:-j]+j+1) - k[:-j]*(k[:-j]+1))*2./(2*k[:-j]+1)
     SpectralMatrix.__init__(self, d, test, trial, measure=measure)
Example #19
0
 def __init__(self, test, trial, scale=1, measure=1):
     assert isinstance(test[0], SD)
     assert isinstance(trial[0], SD)
     N = test[0].N
     k = np.arange(N-2, dtype=np.float)
     if not test[0].is_scaled():
         d = {0: 4*k+6}
     else:
         d = {0: 1}
     SpectralMatrix.__init__(self, d, test, trial, scale=scale, measure=measure)
Example #20
0
 def __init__(self, test, trial):
     assert isinstance(test[0], SD)
     assert isinstance(trial[0], SN)
     N = test[0].N
     ck = get_ck(N, test[0].quad)
     k = np.arange(N-2, dtype=np.float)
     d = {-2: -np.pi/2*(k[:N-4]/(k[:N-4]+2))**2,
           0:  np.pi/2.*(ck[:-2]+ck[2:]*(k/(k+2))**2),
           2: -np.pi/2}
     SpectralMatrix.__init__(self, d, test, trial)
Example #21
0
 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 i in range(1, N, 2):
         d[i] = np.pi * k[i:]
     SpectralMatrix.__init__(self, d, test, trial, measure=measure)
     self._matvec_methods += ['cython']
Example #22
0
 def __init__(self, test, trial, measure=1):
     assert isinstance(test[0], SN)
     assert isinstance(trial[0], SD)
     N = test[0].N
     k = np.arange(N-2, dtype=np.float)
     d = {-1: -(k[1:]+1)*np.pi,
           1: -(2-k[:-1]**2/(k[:-1]+2)**2*(k[:-1]+3))*np.pi}
     for i in range(3, N-1, 2):
         d[i] = -(1-k[:-i]**2/(k[:-i]+2)**2)*2*np.pi
     SpectralMatrix.__init__(self, d, test, trial, measure=measure)
Example #23
0
 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)
Example #24
0
 def __init__(self, test, trial, measure=1):
     assert isinstance(test[0], CB)
     assert isinstance(trial[0], SD)
     N = test[0].N
     M = trial[0].N - 2
     Q = min(N, M)
     ck = get_ck(N, test[0].quad)
     d = {0: np.pi / 2 * ck[:Q]}
     d[-2] = -np.pi / 2 * ck[2:(dmax(N, M, -2) + 2)]
     SpectralMatrix.__init__(self, d, test, trial, measure=measure)
Example #25
0
    def __init__(self, test, trial, measure=1):
        assert isinstance(test[0], SD)
        assert isinstance(trial[0], BD)
        d = {
            0: np.array([np.pi / 2, np.pi / 4]),
            1: np.array([np.pi / 2]),
            -1: np.array([-np.pi / 4, 0])
        }

        SpectralMatrix.__init__(self, d, test, trial, measure=measure)
Example #26
0
 def __init__(self, test, trial):
     assert isinstance(test[0], SD)
     assert isinstance(trial[0], SD)
     N = test[0].N
     k = np.arange(N - 2, dtype=np.float)
     if not test[0].is_scaled():
         d = {0: -(4 * k + 6)}
     else:
         d = {0: -1}
     SpectralMatrix.__init__(self, d, test, trial)
Example #27
0
 def __init__(self, test, trial):
     assert isinstance(test[0], HB)
     assert isinstance(trial[0], HB)
     N = test[0].N
     k = np.arange(N, dtype=np.float)
     d = {0: k + 0.5, 2: -np.sqrt((k[:-2] + 1) * (k[:-2] + 2)) / 2}
     d[0][-1] = (N - 1) / 2.
     d[-2] = d[2]
     SpectralMatrix.__init__(self, d, test, trial)
     self.solve = TDMA(self)
Example #28
0
    def __init__(self, test, trial, measure=1):
        assert isinstance(test[0], L)
        assert isinstance(trial[0], L)
        N = test[0].N
        self._keyscale = 1

        def _getkey(i):
            return 2 * self._keyscale

        d = dict.fromkeys(-np.arange(1, N, 2), _getkey)
        SpectralMatrix.__init__(self, d, test, trial, measure=measure)
Example #29
0
    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-2, dtype=np.float)
        d = {-2: 4*(k[2:]-1)*(k[2:]+1)/(2*k[2:]-1)/(2*k[2:]+3)*(-2./(2*k[2:] + 1)),
              0: 4*(k+1)**2/(2*k+3)**2*(2./(2.*k+1) + 2./(2*k+5))}

        d[2] = d[-2]
        SpectralMatrix.__init__(self, d, test, trial)
        self.solve = TDMA(self)
Example #30
0
 def __init__(self, test, trial):
     assert isinstance(test[0], SN)
     assert isinstance(trial[0], SN)
     N = test[0].N
     ck = get_ck(N, test[0].quad)
     k = np.arange(N-2, dtype=np.float)
     d = {0: np.pi/2*(ck[:-2]+ck[2:]*(k[:]/(k[:]+2))**4),
          2: -np.pi/2*((k[2:]-2)/(k[2:]))**2}
     d[-2] = d[2]
     SpectralMatrix.__init__(self, d, test, trial)
     self.solve = neumann_TDMA(self)