On Apr 16, 8:55 pm, Alec Mihailovs <alec.mihail...@gmail.com> wrote:

> Maybe, I still don't understand it right, but it seems as if you are
> saying, that the problem is to do a similar thing in cases when the
> solution is not unique, producing the list of all the solutions. That
> can be done similarly, just using the version of solve_left in
> 'decode1' producing the list of all solutions (plain solve_left gives
> only one solution even if there is more than 1), and then multiplying
> each of them by G, as in 'correct',

Here are the procedures for that -

def decode3(w,erasures=[]):
    pos=[i for i in range(27) if not i in erasures]
    G1=G.matrix_from_columns(pos)
    return
G1.solve_left(vector(GF(3),w.list_from_positions(pos))),G1.kernel().basis_matrix()

def correct1(w,erasures=[],listed=False):
    ans=decode3(w,erasures)
    ans0,ans1=ans[0]*G,ans[1]*G
    if not listed:
        return ans0,ans1
    else:
        return [ans0+c*ans1 for c in VectorSpace(GF(3),ans1.nrows())]

For example,

V=VectorSpace(GF(3),10)
m=V.random_element(); m
                (2, 1, 1, 0, 0, 0, 0, 1, 1, 0)
w=m*G; w
                (1, 2, 1, 2, 2, 2, 0, 1, 1, 2, 1, 1, 2, 2, 1, 1, 2, 2, 0, 0,
1, 1, 1, 1, 2, 2, 2)
correct1(w,range(14),True)

[(1, 2, 1, 2, 2, 2, 0, 1, 1, 2, 1, 1, 2, 2, 1, 1, 2, 2, 0, 0, 1, 1, 1,
1, 2, 2, 2), (2, 0, 1, 2, 1, 1, 1, 2, 2, 0, 0, 0, 1, 1, 1, 1, 2, 2, 0,
0, 1, 1, 1, 1, 2, 2, 2), (0, 1, 1, 2, 0, 0, 2, 0, 0, 1, 2, 2, 0, 0, 1,
1, 2, 2, 0, 0, 1, 1, 1, 1, 2, 2, 2)]

correct1(w,range(14))

((1, 2, 1, 2, 2, 2, 0, 1, 1, 2, 1, 1, 2, 2, 1, 1, 2, 2, 0, 0, 1, 1, 1,
1, 2, 2, 2), [1 1 0 0 2 2 1 1 1 1 2 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0])

correct1(w,[],True)

[(1, 2, 1, 2, 2, 2, 0, 1, 1, 2, 1, 1, 2, 2, 1, 1, 2, 2, 0, 0, 1, 1, 1,
1, 2, 2, 2)]

Alec











-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to