Ejemplo n.º 1
0
def operator(op, N, k, ell, a=alpha):

    q, m = k + a, ell + 1 / 2

    # zeros
    if (op == '0'): return jacobi.operator('0', N, q, m)

    # identity
    if (op == 'I'): return jacobi.operator('I', N, q, m)

    # conversion
    if (op == 'E'): return jacobi.operator('A+', N, q, m, rescale=np.sqrt(0.5))

    # derivatives
    if (op == 'D-'): return jacobi.operator('C+', N, q, m, rescale=2.0)
    if (op == 'D+'): return jacobi.operator('D+', N, q, m, rescale=2.0)

    # r multiplication
    if (op == 'R-'):
        return jacobi.operator('B-', N, q, m, rescale=np.sqrt(0.5))
    if (op == 'R+'):
        return jacobi.operator('B+', N, q, m, rescale=np.sqrt(0.5))

    # z = 2*r*r-1 multiplication
    if op == 'Z': return jacobi.operator('J', N, q, m)

    if op == 'r=1':
        return jacobi.operator('z=+1', N, q, m, rescale=np.sqrt(2.0))
Ejemplo n.º 2
0
def operator(op,N_max,k,m,a=alpha):
    
    q = k + a
    
    N = N_max # - some function of m
    
    # null
    if (op == '0'):  return jacobi.operator('0',N,q,m)
    
    # identity
    if (op == 'I'):  return jacobi.operator('I',N,q,m)
    
    # conversion
    if (op == 'E'):  return jacobi.operator('A+',N,q,m,rescale=np.sqrt(0.5))
    
    # derivatives
    if (op == 'D-'): return jacobi.operator('C+',N,q,m,rescale=np.sqrt(2.0))
    if (op == 'D+'): return jacobi.operator('D+',N,q,m,rescale=np.sqrt(2.0))

    # r multiplication
    if (op == 'R-'): return jacobi.operator('B-',N,q,m,rescale=np.sqrt(0.5))
    if (op == 'R+'): return jacobi.operator('B+',N,q,m,rescale=np.sqrt(0.5))

    # z = 2*r*r-1 multiplication
    if op == 'Z': return jacobi.operator('J',N,q,m)

    if op == 'r=1': return jacobi.operator('z=+1',N,q,m,rescale=np.sqrt(0.5))
Ejemplo n.º 3
0
def jacobi_matrix(N, a, b):
    J = jacobi.operator('J', N - 1, a, b)
    return J.tocsr().astype(np.float64)
Ejemplo n.º 4
0
def operator(op,L_max,m,s):
    """ Various derivative and multiplication operators for spin-weighted spherical harmonics .

        Parameters
        ----------
        L_max, m, s: int
        spherical harmonic parameters
        op: string = 'I', 'C', 'k+', 'k-', 'S+', 'S-'
        I  = Identity
        k+ = sqrt(0.5)*(Grad_theta + i Grad_phi) with (m,s) -> (m,s+1); diagonal in ell
        k- = sqrt(0.5)*(Grad_theta - i Grad_phi) with (m,s) -> (m,s-1); diagonal in ell
        C  = Cosine multiplication with (m,s) -> (m,s);   couples ell
        S+ = Sine multiplication   with (m,s) -> (m,s+1); couples ell
        S- = Sine multiplication   with (m,s) -> (m,s-1); couples ell

    """

    def ds(op):
        """get s increment from the operator string"""
        if len(op)==1: return 0
        return int(op[1]+'1')

    mu, N     = ds(op), L_max-L_min(m,s)
    a,b,da,db = a_and_b(m,s,ds=mu)
    rescale   = -mu*np.sqrt(0.5)

    # identity
    if op == 'I':
        a,b  = a_and_b(m,s)
        return jacobi.operator('I',N,a,b)

    # cosine multiplication
    if op == 'C':
        a,b  = a_and_b(m,s)
        return jacobi.operator('J',N,a,b)

    # derivatives
    if (op == 'k+') or (op=='k-'):
        if (da== 1) and (db==-1): return jacobi.operator('C+',N  ,a,b,rescale=rescale)
        if (da==-1) and (db== 1): return jacobi.operator('C-',N  ,a,b,rescale=rescale)
        if (da== 1) and (db== 1): return jacobi.operator('D+',N  ,a,b,rescale=rescale)[:-1,:]
        if (da==-1) and (db==-1): return jacobi.operator('D-',N+1,a,b,rescale=rescale)[:,:-1]

    # sine multiplication
    if (op == 'S+') or (op=='S-'):
        if (da== 1) and (db==-1):
            A = jacobi.operator('A+',N+1,a,  b)
            B = jacobi.operator('B-',N+1,a+1,b)
            return B.dot(A)[:-1,:-1]
        if (da==-1) and (db== 1):
            A = jacobi.operator('A-',N+1,a,  b)
            B = jacobi.operator('B+',N+1,a-1,b)
            return B.dot(A)[:-1,:-1]
        if (da== 1) and (db== 1):
            A = jacobi.operator('A+',N+1,a,  b)
            B = jacobi.operator('B+',N+1,a+1,b)
            return (B.dot(A))[:-2,:-1]
        if (da==-1) and (db==-1):
            A = jacobi.operator('A-',N+2,a,  b)
            B = jacobi.operator('B-',N+2,a-1,b)
            return (B.dot(A))[:-1,:-2]