Пример #1
0
def weighted_wiener_lemma1_entries(ks,s=1.,t=0.):

    from numpy import sign as sgn

    ks = _np.array(ks,dtype='int')
    ks = ks.ravel()

    entries = _np.zeros([ks.size,6],dtype='complex128')
    al = -1/2.
    be = s-3/2.
    kcount = 0
    i = 1j

    for k in ks:
        n = _np.abs(k)-1
        ka = _np.abs(k)
        tempab = 2*n+al+be

        temp = -i*s/2/(tempab+2)*_np.sqrt((n+al+1)*(n+be+1)/((tempab+1)*(tempab+3)))
        entries[kcount,0] = temp*\
           (_np.sqrt(n+al+be+1)*sgn(k)+_np.sqrt(n))*(sgn(k)*_np.sqrt(n+1) + _np.sqrt(n+al+be+2))
        entries[kcount,1] = temp*\
           (_np.sqrt(n+al+be+1)*sgn(k)-_np.sqrt(n))*(sgn(k)*_np.sqrt(n+1) + _np.sqrt(n+al+be+2))
        entries[kcount,2] = -i*s/2*((be-al)*(al+be+1)/((tempab+2)*(tempab+4))+1)
        entries[kcount,3] = -i*s/2*(al-be)/((tempab+2)*(tempab+4))*(1+sgn(k)*2*_np.sqrt((n+1)*(n+al+be+2)))
        temp = -i*s/(2*(tempab+4))*_np.sqrt((n+al+2)*(n+be+2)/((tempab+3)*(tempab+5)))
        entries[kcount,4] = temp*\
           (sgn(k)*_np.sqrt(n+2)-_np.sqrt(n+al+be+3))*(sgn(k)*_np.sqrt(n+al+be+2)- _np.sqrt(n+1))
        entries[kcount,5] = temp*\
           (sgn(k)*_np.sqrt(n+2)+_np.sqrt(n+al+be+3))*(sgn(k)*_np.sqrt(n+al+be+2)- _np.sqrt(n+1))

        kcount+=1

    return entries
Пример #2
0
def weighted_wiener_stiff_entries(ks,s=1.,t=0.,scale=1.):

    from numpy import sign as sgn
    from numpy import sqrt

    ks = _np.array(ks,dtype='int')
    ks = ks.ravel()

    entries = _np.zeros([ks.size,6],dtype='complex128')
    al = -1/2.
    be = s-3/2.
    kcount = 0
    i = 1j

    for k in ks:
        n = _np.abs(k)-1
        ka = _np.abs(k)
        tempab = 2*n+al+be

        # Special expression if k=0
        if k==0:
            entries[kcount,2] = -i*(s-1/2.)
            entries[kcount,4] = -i/2*sqrt(s-1/2.)*(1-sqrt(s))/sqrt(1+s)
            entries[kcount,5] = -i/2*sqrt(s-1/2.)*(1+sqrt(s))/sqrt(1+s)
        else:
            # Special expression if |k|=1
            if n==0:
                entries[kcount,0] = i/_np.sqrt(2)*_np.sqrt((al+1)*(be+1)/((al+be+3)))*(sgn(k)*\
                _np.sqrt((al+be+2)) - 1)
            else:
                entries[kcount,0] = i/2*_np.sqrt((n+al+1)*(n+be+1)/((tempab+1)*(tempab+3)))*\
                    (sgn(k)*(_np.sqrt((n+al+be+1)*(n+al+be+2)) + _np.sqrt(n*(n+1))) -\
                    (al+be+2)/(tempab+2)*(_np.sqrt((n+1)*(n+al+be+1)) + _np.sqrt(n*(n+al+be+2))))
                entries[kcount,1] = i/2*_np.sqrt((n+al+1)*(n+be+1)/((tempab+1)*(tempab+3)))*\
                    (sgn(k)*(_np.sqrt((n+al+be+1)*(n+al+be+2)) - _np.sqrt(n*(n+1))) -\
                    (al+be+2)/(tempab+2)*(_np.sqrt((n+1)*(n+al+be+1)) - _np.sqrt(n*(n+al+be+2))))

            entries[kcount,2] = i*sgn(k)*_np.sqrt((n+1)*(n+al+be+2)) - \
                i*s*(be-al)*(al+be+1)/(2*(tempab+2)*(tempab+4)) - i*s/2

            entries[kcount,3] = -s/2*i*(al-be)/((tempab+2)*(tempab+4))

            entries[kcount,4] = i/2*_np.sqrt((n+be+2)*(n+al+2)/((tempab+3)*(tempab+5))) *\
                (-s/(tempab+4)*(_np.sqrt((n+2)*(n+al+be+2)) + _np.sqrt((n+1)*(n+al+be+3))) +\
                sgn(k)*(_np.sqrt((n+al+be+2)*(n+al+be+3)) + _np.sqrt((n+1)*(n+2))))

            entries[kcount,5] = i/2*_np.sqrt((n+be+2)*(n+al+2)/((tempab+3)*(tempab+5))) *\
                (-s/(tempab+4)*(_np.sqrt((n+2)*(n+al+be+2)) - _np.sqrt((n+1)*(n+al+be+3))) +\
                sgn(k)*(-_np.sqrt((n+al+be+2)*(n+al+be+3)) + _np.sqrt((n+1)*(n+2))))

        kcount += 1

    return entries/scale
Пример #3
0
def wiener_stiff_entries(ks,s=1.,t=0.):

    import spyctral.opoly1d.jacobi as jac
    from numpy import sign as sgn

    ks = _np.array(ks,dtype='int')
    ks = ks.ravel()

    entries = _np.zeros([ks.size,6],dtype='complex128')
    al = -1/2.
    be = s-3/2.
    kcount = 0

    for k in ks:
        n = _np.abs(k)-1
        ka = _np.abs(k)
        tempab = 2*n+al+be

        #zeta = jac.zetan(ka,al,be)
        #factor = (n+al+be+2)*_np.sqrt(2*(n+al+1)*(n+al+be+2)/((tempab+2)*(tempab+3)))
        #factorp1 = (n+1)*_np.sqrt(2*(n+1)*(n+be+2)/((tempab+3)*(tempab+4)))
        #fs = _np.array([factor,factorp1])
        #gammasn = jac.gamman(n,be+1,al)
        #gammasnp1 = jac.gamman(n+1,be+1,al)
        #[a_s,b_s] = jac.recurrence_ns([ka-1,ka],al+1,be+1)

        # kvee, -kvee, k, -k, kwedge, -kwedge
        #entries[kcount,0] = (fs[0]*gammasn[0]+zeta*_np.sqrt(b_s[0])) 
        entries[kcount,0] = (n+al+be+2)*_np.sqrt((n+al+1)*(n+be+1)/((tempab+1)*(tempab+2)**2*(tempab+3)))* \
                            (_np.sqrt((n+al+be+1)*(n+al+be+2)) + _np.sqrt(n*(n+1)))

        #entries[kcount,1] = (fs[0]*gammasn[0]-zeta*_np.sqrt(b_s[0]))
        entries[kcount,1] = (n+al+be+2)*_np.sqrt((n+al+1)*(n+be+1)/((tempab+1)*(tempab+2)**2*(tempab+3)))* \
                            (_np.sqrt((n+al+be+2)*(n+al+be+1)) - _np.sqrt(n*(n+1)))
        #entries[kcount,2] = (fs[0]*gammasn[1]+fs[1]*gammasnp1[0]+zeta*(a_s[0]+1))
        entries[kcount,2] = _np.sqrt((n+1)*(n+al+be+2))
        #entries[kcount,3] = (fs[0]*gammasn[1]+fs[1]*gammasnp1[0]-zeta*(a_s[0]+1))
        entries[kcount,3] = (al+be+2)*(al-be)/((tempab+2)*(tempab+4))*\
                            _np.sqrt((n+1)*(n+al+be+2))
        #entries[kcount,4] = (fs[1]*gammasnp1[1]+zeta*_np.sqrt(b_s[1]))
        entries[kcount,4] = (n+1)*_np.sqrt((n+be+2)*(n+al+2)/((tempab+3)*(tempab+4)**2*(tempab+5)))* \
                            (_np.sqrt((n+1)*(n+2)) + _np.sqrt((n+al+be+2)*(n+al+be+3)))
        #entries[kcount,5] = (fs[1]*gammasnp1[1]-zeta*_np.sqrt(b_s[1]))
        entries[kcount,5] = (n+1)*_np.sqrt((n+be+2)*(n+al+2)/((tempab+3)*(tempab+4)**2*(tempab+5)))* \
                            (_np.sqrt((n+1)*(n+2)) - _np.sqrt((n+al+be+2)*(n+al+be+3)))

        entries[kcount,:] *= 1j*sgn(k)
        kcount += 1

    return entries
Пример #4
0
 def trnsFnc(self, entrada, zm1):
     self.preintval = -arry(sgn(self.integral - entrada) * self.gain) * arry(
         power(abs(self.integral - entrada), potencia(self.orden))) + zm1
Пример #5
0
def sin_recurrence(ks,g,d):

    from numpy import zeros, abs,sqrt
    from numpy import sign as sgn
    from spyctral.opoly1d.jacobi import etan, epsilonn 

    coeffs = zeros([ks.size,6])
    al = d-1/2.
    be = g-1/2.

    ks0 = (ks==0)
    ks1 = (abs(ks)==1)
    ks2 = ~(ks0 | ks1)

    n = abs(ks)
    N = _np.max(n)
    eta = etan(range(N+2),al,be)
    eps = epsilonn(range(N+2),al+1,be+1)

    # 0 = -kwedge
    # 1 = -k
    # 2 = -kvee
    # 3 = kvee
    # 4 = k
    # 5 = kwedge
    if any(ks0):
        coeffs[ks0,0] = -1/sqrt(2)*eta[0,2]
        coeffs[ks0,5] = 1/sqrt(2)*eta[0,2]
    if any(ks1):
        coeffs[ks1,0] = sgn(ks[ks1])/2.*(-eta[1,2]-eps[0,2])
        coeffs[ks1,1] = sgn(ks[ks1])/2.*(-eta[1,1]-eps[0,1])
        coeffs[ks1,3] = sgn(ks[ks1])/-sqrt(2)*eps[0,0]
        coeffs[ks1,4] = sgn(ks[ks1])/2.*(eta[1,1]-eps[0,1])
        coeffs[ks1,5] = sgn(ks[ks1])/2.*(eta[1,2]-eps[0,2])
    if any(ks2):
        n = n[ks2]
        coeffs[ks2,0] = sgn(ks[ks2])/2.*(-eta[n,2]-eps[n-1,2])
        coeffs[ks2,1] = sgn(ks[ks2])/2.*(-eta[n,1]-eps[n-1,1])
        coeffs[ks2,2] = sgn(ks[ks2])/2.*(-eta[n,0]-eps[n-1,0])
        coeffs[ks2,3] = sgn(ks[ks2])/2.*(eta[n,0]-eps[n-1,0])
        coeffs[ks2,4] = sgn(ks[ks2])/2.*(eta[n,1]-eps[n-1,1])
        coeffs[ks2,5] = sgn(ks[ks2])/2.*(eta[n,2]-eps[n-1,2])

    return coeffs.squeeze()
Пример #6
0
 def activation_dev2(output):
     return np.sgn(output)
Пример #7
0
	def trnsFnc(self,entrada,zm1):
		self.preintval=-arry(sgn(self.integral-entrada)*self.gain)*arry(power(abs(self.integral-entrada),potencia(self.orden)))+zm1
Пример #8
0
def sign(a):
    """Return the sign of a in (1, -1, 0)"""
    return matrix(sgn(array(a)))