Exemple #1
0
    # for ele in testResList:
    #     testResList2.append(copy.deepcopy(pow(ele - pow(2, varsNum), 3)))
    #
    # testRes = 0
    # for ele in testResList2:
    #     testRes = ele + testRes
    # print(testRes)
    # print(walshResList)
    return walshResList


'''
    布尔函数非线性度的计算
    :return 布尔函数非线性度的值
'''


def nonlinearityCompute(varsNum, truthTable):
    tmpList = []
    for ele in walshCompute(varsNum, truthTable):
        tmpList.append(abs(ele))
    # print(tmpList)
    return pow(2, varsNum - 1) - 0.5 * max(tmpList)


if __name__ == '__main__':
    dicIndexList = []
    truthTable = truthTableSelect(3, dicIndexList)
    res = nonlinearityCompute(3, truthTable)
    print(f"nonlinearity = {res}")
def truthTableAndIndexLixt(varsNum):
    dicIndexList = []
    truthTable = truthTableSelect(varsNum, dicIndexList)
    return truthTable, dicIndexList