Beispiel #1
0
def h0h1(k):
    '''
    USE LONGFLOATS
    
    Compute the h0 & h1 two-scale coefficients

    h0_ij = sqrt(2)*int(phi_i(x)*phi_j(2x),x=0..1/2)
    h1_ij = sqrt(2)*int(phi_i(x)*phi_j(2x-1),x=1/2..1)

    but
    
    h1_ij = (-1)^(i+j) h0_ij from symmetry property of the phi

    The h0/h1 are useful because

    phi_i(x) = sqrt(2)*sum(j) h0_ij*phi_j(2x) + h1_ij*phi_j(2x-1)

    and
    
    phi_i(2x)   = (1/sqrt(2))*sum(j) h0_ji*phi_j(x) + g0_ji*psi(x)
    phi_i(2x-1) = (1/sqrt(2))*sum(j) h1_ji*phi_j(x) + g1_ji*psi(x)
    '''
    q = Quadrature(k, [longfloat(0), longfloat((-1, 1))], uselongfloat=1)
    x = q.points()
    w = q.weights()
    npt = len(x)
    twox = range(npt)
    for i in range(npt):
        twox[i] = x[i] + x[i]

    h0 = zeromatrix(k, k)
    h1 = zeromatrix(k, k)

    root2 = longfloat(2).sqrt()
    for t in range(npt):
        p = philong(x[t], k)
        p2 = philong(twox[t], k)
        for i in range(k):
            faci = p[i] * w[t] * root2
            for j in range(k):
                h0[i][j] = h0[i][j] + faci * p2[j]

    for i in range(k):
        for j in range(k):
            h1[i][j] = ((-1)**(i + j)) * h0[i][j]

    return (h0, h1)
Beispiel #2
0
def h0h1(k):
    '''
    USE LONGFLOATS
    
    Compute the h0 & h1 two-scale coefficients

    h0_ij = sqrt(2)*int(phi_i(x)*phi_j(2x),x=0..1/2)
    h1_ij = sqrt(2)*int(phi_i(x)*phi_j(2x-1),x=1/2..1)

    but
    
    h1_ij = (-1)^(i+j) h0_ij from symmetry property of the phi

    The h0/h1 are useful because

    phi_i(x) = sqrt(2)*sum(j) h0_ij*phi_j(2x) + h1_ij*phi_j(2x-1)

    and
    
    phi_i(2x)   = (1/sqrt(2))*sum(j) h0_ji*phi_j(x) + g0_ji*psi(x)
    phi_i(2x-1) = (1/sqrt(2))*sum(j) h1_ji*phi_j(x) + g1_ji*psi(x)
    '''
    q = Quadrature(k,[longfloat(0),longfloat((-1,1))],uselongfloat=1)
    x = q.points()
    w = q.weights()
    npt = len(x)
    twox = range(npt)
    for i in range(npt):
        twox[i] = x[i] + x[i]

    h0 = zeromatrix(k,k)
    h1 = zeromatrix(k,k)
    
    root2 = longfloat(2).sqrt()
    for t in range(npt):
        p = philong(x[t],k)
        p2= philong(twox[t],k)
        for i in range(k):
            faci = p[i]*w[t]*root2
            for j in range(k):
                h0[i][j] = h0[i][j] + faci*p2[j]

    for i in range(k):
        for j in range(k):
            h1[i][j] = ((-1)**(i+j))*h0[i][j]

    return (h0, h1)
Beispiel #3
0
    #QuadratureTest(uselongfloat=1)

    for k in range(1, 31):
        print '\n\n Testing multiwavelets k =', k, '\n'

        (h0, h1, g0, g1) = twoscalecoeffs(k)
        # Demonstrate that the scaling functions are ortho-normal
        i = 0
        j = 0

        def f(x):
            global k, i, j
            p = phi(x, k)
            return p[i] * p[j]

        q = Quadrature(k, [0, 1.0])
        err = 0.0
        for i in range(k):
            for j in range(i + 1):
                overlap = q.integrate(f)
                if i == j: overlap = overlap - 1
                err = max(err, abs(overlap))
        print ' Maximum errror in the overlap of scaling functions', err

        # Demonstrate that the wavelets are ortho-normal
        i = 0
        j = 0

        def f(x):
            global k, i, j, g0, g1
            p = psi(x, k, g0, g1)
Beispiel #4
0
    print '\n\n Beginning new run \n'

    #QuadratureTest(uselongfloat=1)

    for k in range(1,31):
        print '\n\n Testing multiwavelets k =', k, '\n'

        (h0,h1,g0,g1) = twoscalecoeffs(k)
        # Demonstrate that the scaling functions are ortho-normal
        i = 0
        j = 0
        def f(x):
            global k, i, j
            p = phi(x,k)
            return p[i]*p[j]
        q = Quadrature(k,[0,1.0])
        err = 0.0
        for i in range(k):
            for j in range(i+1):
                overlap = q.integrate(f)
                if i == j: overlap = overlap - 1
                err = max(err,abs(overlap))
        print ' Maximum errror in the overlap of scaling functions', err

        # Demonstrate that the wavelets are ortho-normal
        i = 0
        j = 0
        def f(x):
            global k, i, j, g0, g1
            p = psi(x,k,g0,g1)
            return p[i]*p[j]