Esempio n. 1
0
def my_func(x):
    # Declare empty arrays to be filled with the values passed into the function 
    # and the inverse of A into B
    A = numba.cuda.shared.array((N,N), dtype=numba.types.complex64)
    B = numba.cuda.shared.array((N,N), dtype=numba.types.complex64)
    #tmp = numba.cuda.shared.array((N,N), dtype=numba.types.complex64)

    # Assign the values in the array
    A[0, 0] = x[0]
    A[0, 1] = complex(x[1], x[2])
    A[1, 0] = complex(x[1], -x[2])
    A[1, 1] = x[3]

    for i in range(N):
        for j in range(N):
            if i == j:
                B[i,j] = complex(1,0)
        
            else:
                B[i,j] = complex(0,0)

    B = la.myInvSZ(A, B, N)

    tr = 0 + 0j
    tr = la.trace(B, N, tr)

    return tr.real 
Esempio n. 2
0
def my_func(x):
    # Declare empty arrays to be filled with the values passed into the function 
    # and the inverse of A into B
    A = numba.cuda.shared.array((N,N), dtype=numba.types.complex64)
    B = numba.cuda.shared.array((N,N), dtype=numba.types.complex64)
    #tmp = numba.cuda.shared.array((N,N), dtype=numba.types.complex64)

    # Assign the values in the array
    A[0, 0] = 1 / complex(x[0], x[1])
    A[0, 1] = complex(0, 0)
    A[1, 0] = complex(0, 0)
    A[1, 1] = 1 / complex(x[2], x[3])

    for i in range(N):
        for j in range(N):
            if i == j:
                B[i,j] = complex(1,0)
        
            else:
                B[i,j] = complex(0,0)

    # B = la.myInvSZ(A, B, N)

    for k in range(N-1):

        if (A[k,k].real != 1) or (A[k,k].imag != 0):
            scale = A[k,k]
            for j in range(N):
                B[k,j] = B[k,j] / scale
                A[k,j] = A[k,j] / scale
                
        for i in range(k+1, N):
            if (A[i,k].real != 0) or (A[i,k].imag != 0):
                ratio =  A[i,k]

                for j in range(N):
                    A[i,j] = A[i,j] - ratio * A[k,j]
                    B[i,j] = B[i,j] - ratio * B[k,j]

    if (A[N-1,N-1].real != 1) or (A[N-1,N-1].imag != 0):
        for j in range(N):
            B[N-1,j] = B[N-1,j] / A[N-1,N-1]

        A[N-1,N-1] = complex(1,0)

    # # ELIMINATE UPPER TRIANGLE
    for k in range(1, N):  
        for i in range(k):
            ratio = A[i,k] 

            for j in range(N):
                A[i,j] = A[i,j] - ratio * A[k,j]
                B[i,j] = B[i,j] - ratio * B[k,j]

    tr = 0 + 0j
    tr = la.trace(B, N, tr)

    return (tr * complex(tr.real, - tr.imag)).real
Esempio n. 3
0
def my_func(x):
    # Declare empty arrays to be filled with the values passed into the function
    # and the inverse of A into B
    A = numba.cuda.shared.array((N, N), dtype=numba.types.complex64)
    B = numba.cuda.shared.array((N, N), dtype=numba.types.complex64)
    C = numba.cuda.shared.array((N, N), dtype=numba.types.complex64)

    # Assign the values in the array
    A[0, 0] = complex(x[0], x[1])
    A[0, 1] = complex(x[2], x[3])
    A[1, 0] = complex(-x[2], x[3])
    A[1, 1] = complex(x[0], -x[1])

    B[0, 0] = complex(x[0], -x[1])
    B[1, 0] = complex(x[2], -x[3])
    B[0, 1] = complex(-x[2], -x[3])
    B[1, 1] = complex(x[0], x[1])

    C = la.squareMatMul(A, B, C, N)

    #for i in range(N):
    #
    #    for j in range(N):
    #        tmp = 0+0j
    #
    #        for l in range(N):
    #            tmp = A[i,l] * B[l,j] + tmp
    #
    #        C[i,j] = tmp

    # tr = C[0,0] + C[1,1]

    tr = 0 + 0j

    tr = la.trace(C, N, tr)

    return tr.real