Beispiel #1
0
    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)
Beispiel #2
0
 def __init__(self, test, trial):
     assert isinstance(test[0], SB)
     assert isinstance(trial[0], SB)
     from shenfun.la import PDMA
     N = test[0].N
     ck = get_ck(N, test[0].quad)
     k = np.arange(N-4, dtype=np.float)
     d = {4: (k[:-4]+1)/(k[:-4]+3)*np.pi/2,
          2: -((k[:-2]+2)/(k[:-2]+3) + (k[:-2]+4)*(k[:-2]+1)/((k[:-2]+5)*(k[:-2]+3)))*np.pi,
          0: (ck[:N-4] + 4*((k+2)/(k+3))**2 + ck[4:]*((k+1)/(k+3))**2)*np.pi/2.}
     d[-2] = d[2]
     d[-4] = d[4]
     SpectralMatrix.__init__(self, d, test, trial)
     self.solve = PDMA(self)
Beispiel #3
0
 def __init__(self, test, trial, measure=1):
     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)
     if test[0].quad == 'GL':
         ek[-1] = 2./(N-1)
     d = {0: ek[:-4] + hk[:-4]**2*ek[2:-2] + gk[:-4]**2*ek[4:],
          2: hk[:-6]*ek[2:-4] + gk[:-6]*hk[2:-4]*ek[4:-2],
          4: gk[:-8]*ek[4:-4]}
     d[-2] = d[2]
     d[-4] = d[4]
     SpectralMatrix.__init__(self, d, test, trial, measure=measure)
     self.solve = PDMA(self)
Beispiel #4
0
 def __init__(self, test, trial, measure=1):
     assert isinstance(test[0], SB)
     assert isinstance(trial[0], SB)
     from shenfun.la import PDMA
     N = test[0].N
     M = trial[0].N
     Q = min(N, M)
     ck = get_ck(Q, test[0].quad)
     k = np.arange(Q-4, dtype=np.float)
     d = {0: (ck[:Q-4] + 4*((k+2)/(k+3))**2 + ck[4:]*((k+1)/(k+3))**2)*np.pi/2.}
     d4 = (k+1)/(k+3)*np.pi/2
     d2 = -((k+2)/(k+3)+(k+4)*(k+1)/((k+5)*(k+3)))*np.pi
     d[2] = d2[:dmax(N-4, M-4, 2)]
     d[4] = d4[:dmax(N-4, M-4, 4)]
     d[-2] = d2[:dmax(N-4, M-4, -2)]
     d[-4] = d4[:dmax(N-4, M-4, -4)]
     SpectralMatrix.__init__(self, d, test, trial, measure=measure)
     self.solve = PDMA(self)