朋友写的。Python实现的。用的是PyCharm编译。
代码如下
def split_list_average(send, n): # 用于分割指定长度字符串
for i in range(0, len(send), n):
yield send[i:i + n]
def check_chip(chipS, chipT, chipU, chipV): # 判断码片之间是否相互正交
def check(chipA, chipB):
if sum(list(map(lambda x, y: x * y, chipA, chipB))) == 0: return True # 判断其内积是否为0
if check(chipS, chipT) and check(chipS, chipU) and check(chipS, chipV) and check(chipT, chipU) and check(chipT, chipV) and check(chipU, chipV):
return True
return False
def get_vector(chip, send): # 用于通过传输信息与码片信息得出发送的向量信息
vector = []
reverse = list(map(lambda x: x * (-1), chip))
for i in send:
i = int(i)
if i == 1:
vector.extend(chip)
elif i == 0 or i == -1:
vector.extend(reverse)
else:
print(“发送数据出现非法字符。”)
return
return vector
def send_message(chipS, chipT, chipU