Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # https://en.wikiversity.org/wiki/Equivalence_classes_of_Boolean_functions#Walsh
- import numpy as np
- bin_walsh = np.array([[0, 0, 0, 0],
- [0, 1, 0, 1],
- [0, 0, 1, 1],
- [0, 1, 1, 0]])
- walsh = (bin_walsh * -2) + 1
- def int_to_bin_vect(n):
- bin_str = format(n, 'b').zfill(4)[::-1]
- bin_vect = [int(char) for char in bin_str]
- return np.array(bin_vect)
- arr_f = np.zeros((0, 4), np.int8)
- arr_ws = np.zeros((0, 4), np.int8)
- arr_bws = np.zeros((0, 4), np.int8)
- for n in range(16):
- f = int_to_bin_vect(n)
- ws = np.dot(f, walsh)
- bws = np.mod(np.dot(f, bin_walsh), 2)
- arr_f = np.vstack((arr_f , f ))
- arr_ws = np.vstack((arr_ws , ws ))
- arr_bws = np.vstack((arr_bws, bws))
- print(arr_f)
- print(arr_ws)
- print(arr_bws)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement