Exemplo n.º 1
0
def iadctmatrix(N):
    from iameshgrid import iameshgrid
    x, u = iameshgrid(range(N), range(N))  # (u,x)
    alpha = ones((N, N)) * sqrt(2. / N)
    alpha[0, :] = sqrt(1. / N)  # alpha(u,x)
    A = alpha * cos((2 * x + 1) * u * pi / (2. * N))  # Cn(u,x)
    return A
Exemplo n.º 2
0
def iadctmatrix(N):
    from iameshgrid import iameshgrid
    x, u = iameshgrid(range(N), range(N)) # (u,x)
    alpha = ones((N,N)) * sqrt(2./N)
    alpha[0,:] = sqrt(1./N) # alpha(u,x)
    A = alpha * cos((2*x+1)*u*pi / (2.*N)) # Cn(u,x)
    return A
Exemplo n.º 3
0
def iahaarmatrix(N):
    from iameshgrid import iameshgrid

    n = floor(log(N)/log(2))

    if 2**n != N:
       raise Exception, 'error: size '+str(N)+' is not multiple of power of 2'

    z, k = iameshgrid(1.*arange(N)/N, 1.*arange(N))
    p  = floor(log(maximum(1,k))/log(2))
    q  = k - (2**p) + 1
    z1 = (q-1)   / (2**p)
    z2 = (q-0.5) / (2**p)
    z3 = q       / (2**p)
    A  = (1/sqrt(N)) * ((( 2**(p/2.)) * ((z >= z1) & (z < z2))) \
                              + ((-2**(p/2.)) * ((z >= z2) & (z < z3))))
    A[0,:] = 1/sqrt(N)
    return A
Exemplo n.º 4
0
def iahadamardmatrix(N):
    from iameshgrid import iameshgrid

    def bitsum(x):
        s = 0 * x
        while x.any():
            s += x & 1
            x >>= 1
        return s

    n = floor(log(N)/log(2))

    if 2**n != N:
       raise Exception, 'error: size '+str(N)+' is not multiple of power of 2'

    u, x = iameshgrid(range(N), range(N))

    A = ((-1)**(bitsum(x & u)))/sqrt(N)
    return A
Exemplo n.º 5
0
def iahadamardmatrix(N):
    from iameshgrid import iameshgrid

    def bitsum(x):
        s = 0 * x
        while x.any():
            s += x & 1
            x >>= 1
        return s

    n = floor(log(N) / log(2))

    if 2**n != N:
        raise Exception, 'error: size ' + str(
            N) + ' is not multiple of power of 2'

    u, x = iameshgrid(range(N), range(N))

    A = ((-1)**(bitsum(x & u))) / sqrt(N)
    return A