Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Lunch Bunch arrangement problem

by abell (Chaplain)
on May 17, 2003 at 10:25 UTC ( [id://258853]=note: print w/replies, xml ) Need Help??


in reply to Lunch Bunch arrangement problem

Try using the following gp script:

multable( p, P, g ) = { P = Mod(1,p) * P; g = Mod( Mod(1,p) * g, P ); d = poldegree( P ); n = p^d; /* This version makes B[2] = Mod( 1, P ) which is wrong B = concat( [0], vector( n-1, i, g^(i-1) ) ); The following line corrects the mistake */ B = concat( [0], vector( n-1, i, Mod( Mod(1,p), P ) * g^(i-1) ) ); R = vector( n ); for( i = 1, n, R[ 1 + subst( lift(lift( B[i] )), x, p )] = i-1; ); for( a = 1, p^d, ae = B[a]; for ( b = 1, p^d, be = B[b]; re = ae * be; print1( R[ 1 + subst( lift(lift( re )), x, p )], "\t" ); ); print; ); }
Save it in a file (say "ff.gp") and then invoke gp (it's an interactive environment for pari). A sample session might be
$ gp -q
? read ("/tmp/ff.gp")
? multable(2, x^3+x+1, x)
0       0       0       0       0       0       0       0
0       1       2       3       4       5       6       7
0       2       3       4       5       6       7       1
0       3       4       5       6       7       1       2
0       4       5       6       7       1       2       3
0       5       6       7       1       2       3       4
0       6       7       1       2       3       4       5
0       7       1       2       3       4       5       6
? 
The arguments to multable are the characteristic, the polynomial generating the field and a generator of the multiplicative group. To generate the addition table, substitute with re = ae + be on the due line.

Cheers

Antonio

The stupider the astronaut, the easier it is to win the trip to Vega - A. Tucket

Update: The mistake for g^0 + g^0 should be corrected now

Replies are listed 'Best First'.
Re: Re: Lunch Bunch arrangement problem
by tall_man (Parson) on May 17, 2003 at 19:03 UTC
    Thanks, Antonio. It looks very close to what I need, but I am getting some errors. For example, when I try for the addition table:
    ? addtable(2, x^3+x+1, x) 0 1 2 3 4 5 6 7 1 2 4 7 2 6 5 3 2 4 0 5 1 3 7 6 3 7 5 0 6 2 4 1 4 2 1 6 0 7 3 5 5 6 3 2 7 0 1 4 6 5 7 4 3 1 0 2 7 3 6 1 5 4 2 0
    The second entry on the second line is supposed to be 0, not 2. I also tried for 3^2, like this:
    ? multable(3,x^2+x+1,x) 0 0 0 0 0 0 0 0 0 + 0 7 8 6 7 8 6 7 8 + 0 8 6 7 8 6 7 8 6 + 0 6 7 8 6 7 8 6 7 + 0 7 8 6 7 8 6 7 8 + 0 8 6 7 8 6 7 8 6 + 0 6 7 8 6 7 8 6 7 + 0 7 8 6 7 8 6 7 8 + 0 8 6 7 8 6 7 8 6
    This table doesn't look right at all. What could be going wrong?

    Update:For the 3^2 case, I see that I didn't use a correct primitive polynomial for GF(3). I tried "x^2+2*x+2" and it looks a lot better. Now I just need to find a way to get other primitive polynomials...

    Update2: I found a program than can compute a primitive polynomial of any order for GF(n), here.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://258853]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2024-04-24 07:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found