Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 38
# # public link: https://cloud.sagemath.com/projects/026994b5-e264-4071-a9e1-127c5595f170/files/Show%20error%20vector%20list.sagews # GFq = GF(3) import itertools def generate_error_vec_list(GFq, length, total_error): GFq_list = list(GFq) all_list = list(itertools.product(GFq_list, repeat=length)) total_zero = length - total_error error_vec_list = [vector(GFq, u) for u in all_list if u.count(0) == total_zero ] return error_vec_list # # I would like to generate all the GF(3) error vectors of 2 errors. # The codeword length is 4. # error_vec_list = generate_error_vec_list(GF(3), 4, 2) for error_vec in error_vec_list: print error_vec
(0, 0, 1, 1) (0, 0, 1, 2) (0, 0, 2, 1) (0, 0, 2, 2) (0, 1, 0, 1) (0, 1, 0, 2) (0, 1, 1, 0) (0, 1, 2, 0) (0, 2, 0, 1) (0, 2, 0, 2) (0, 2, 1, 0) (0, 2, 2, 0) (1, 0, 0, 1) (1, 0, 0, 2) (1, 0, 1, 0) (1, 0, 2, 0) (1, 1, 0, 0) (1, 2, 0, 0) (2, 0, 0, 1) (2, 0, 0, 2) (2, 0, 1, 0) (2, 0, 2, 0) (2, 1, 0, 0) (2, 2, 0, 0)