예제 #1
0
def getGChMCK(design_p, N, K, runsim):
    p = design_p
    n = int(ma.log(N, 2))
    err = np.zeros(N)
    print "MC(K)..." + str(runsim)
    for i in range(runsim):
        UN = np.random.randint(2, size=N)
        UN_decoded = ec.polarSCdecode(pl.BSCN(p, ec.polarencode(UN, len(UN))),
                                      len(UN), p)
        err = err + np.logical_xor(UN, UN_decoded)

    aZN = err / runsim
    sZN = np.sort(aZN)
    good_channels_all = aZN.argsort().tolist()[:K]
    good_channels = good_channels_all[:K]
    ber_exp = np.log10(sZN).tolist()
    rgood_channels = ec.bitreverseorder(good_channels, n)
    rgood_channels_all = ec.bitreverseorder(good_channels_all, n)

    f2 = open(
        "./simresults/GC/GCMK_" + str(N) + "_" + str(p).replace(".", "p") +
        "_" + str(K) + ".txt", 'w')
    json.dump(rgood_channels, f2)

    f3 = open("./simresults/GC/GCMK_ALL" + str(N) + ".txt", 'w')
    json.dump(rgood_channels_all, f3)

    return (rgood_channels, ber_exp[:K], ber_exp)
예제 #2
0
def getGChZCK(design_p, N, K):
    p = design_p
    #actually here the p is not neccessary
    #print "ZC(K)..."
    n = int(ma.log(N, 2))
    Z = pl.ZBSC(p)
    ZN = Zconstruct(pl.ZBSC(p), n)
    aZN = np.array(ZN)
    sZN = np.sort(aZN)
    good_channels = aZN.argsort().tolist()[:K]
    ber_exp = np.log10(sZN).tolist()
    rgood_channels = ec.bitreverseorder(good_channels, n)

    f2 = open(
        "./simresults/GC/GCZK_" + str(N) + "_" + str(p).replace(".", "p") +
        "_" + str(K) + ".txt", 'w')
    json.dump(rgood_channels, f2)

    return (rgood_channels, ber_exp[:K])
예제 #3
0
def getGChZCL(design_p, N, L):  #L is error exponent
    p = design_p
    #print "ZC(error)..."
    n = int(ma.log(N, 2))
    Z = pl.ZBSC(p)
    ZN = Zconstruct(pl.ZBSC(p), n)
    aZN = np.array(ZN)
    sZN = np.sort(aZN)
    ber_exp = np.log10(sZN).tolist()
    #print ber_exp
    K = 0
    for i in ber_exp:
        if i <= L:
            K += 1

    good_channels = aZN.argsort().tolist()[:K]
    rgood_channels = ec.bitreverseorder(good_channels, n)

    f2 = open(
        "./simresults/GC/GCZL_" + str(N) + "_" + str(p).replace(".", "p") +
        "_" + str(L) + ".txt", 'w')
    json.dump(rgood_channels, f2)

    return (rgood_channels, ber_exp[:K])