On Apr 15, 8:45 am, Andrea Gobbi <[email protected]> wrote:
> Hi!
> I'm using sage for coding theory, and it sems to be great! I have a
> linear code like this:
> MS = MatrixSpace(GF(3),10,27)
> G  = MS([
> [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
> [1,2,0,0,0,0,1,1,2,2,0,0,0,0,1,1,2,2,1,1,1,1,2,2,2,2,0],
> [0,0,1,2,0,0,1,2,1,2,1,1,2,2,0,0,0,0,1,1,2,2,1,1,2,2,0],
> [0,0,0,0,1,2,0,0,0,0,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,0],
> [0,0,0,0,0,0,1,2,2,1,0,0,0,0,0,0,0,0,1,1,2,2,2,2,1,1,0],
> [0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,2,1,1,2,1,2,2,1,2,1,0],
> [0,0,0,0,0,0,0,0,0,0,1,2,2,1,0,0,0,0,1,2,2,1,1,2,2,1,0],
> [1,1,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0],
> [0,0,1,1,0,0,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1,0],
> [0,0,0,0,1,1,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0]]);
> C  = LinearCode(G);
> C.dimension();
> C.length();
> C.minimum_distance();
> C.weight_distribution();
> And I want use the minimum distance (in this case 9) for correct a
> vector with 8 erasures. There are some tools in sage to do this? I try
> to look to the reference manual but seems that the decoding part is
> not implemented...
>  Or someone created a soubrutine that can be used for this problem?
> Sorry for my english,
> Thanks!

The following seems to be working,

def decode(w,erasures=[],num_tries=10):
    pos=[i for i in range(27) if not i in erasures]
    G1=G.matrix_from_columns(pos)
    if G1.rank()!=10:
        print "Too many erasures"
        return None
    else:
        MH=MatrixSpace(GF(3),G1.ncols(),10)
        for i in range(num_tries):
            R=MH.random_element()
            H=G1*R
            if H.rank()==10:
                break
        return vector(GF(3),w.list_from_positions(pos))*R*H.inverse()

For example,

m=V.random_element(); m

                (2, 1, 0, 0, 1, 2, 0, 1, 0, 0)

w=m*G; w
                (1, 2, 2, 2, 2, 2, 2, 0, 1, 0, 2, 2, 2, 2, 0, 2, 0, 1, 1, 0,
2, 1, 2, 0,
1, 2, 2)

decode(w)

               (2, 1, 0, 0, 1, 2, 0, 1, 0, 0)

decode(w, range(8))

                (2, 1, 0, 0, 1, 2, 0, 1, 0, 0)

decode(w,range(15))

                Too many erasures

Alec Mihailovs



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

Reply via email to