"Fossies" - the Fresh Open Source Software Archive

Member "jas-2.6/examples/finitefield.py" (17 Nov 2018, 1674 Bytes) of package /linux/privat/jas-2.6.5988-src.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 # jython examples for jas.
    2 # $Id: finitefield.py 5965 2018-11-17 18:36:04Z kredel $                                      
    3 #
    4 
    5 import sys, operator
    6 
    7 from java.lang import System
    8 
    9 from jas import FF, GF, PolyRing
   10 from jas import terminate
   11 
   12 # finite fields and algebraic field extensions
   13 
   14 
   15 #print "------- finite field GF(17,5) ---------";
   16 r = FF(17,5);
   17 print "r     = " + str(r.ring.toScript());
   18 e,a = r.gens();
   19 print "e     = " + str(e);
   20 print "a     = " + str(a);
   21 
   22 ap = a**5 - a + 1;
   23 print "ap    = " + str(ap);
   24 ai = 1/ap;
   25 print "ai    = " + str(ai) + ", ai*ap = " + str(ai*ap);
   26 
   27 q = FF(17,5);
   28 print "q     = " + str(q.ring.toScript());
   29 qe,qa = q.gens();
   30 print "qe    = " + str(qe);
   31 print "qa    = " + str(qa);
   32 
   33 qap = qa**5 - qa + 1;
   34 print "qap   = " + str(qap);
   35 
   36 s = ap - qap;
   37 print "s     = " + str(s);
   38 
   39 
   40 
   41 ar = PolyRing(r,"beta",PolyRing.lex);
   42 print "ar    = " + str(ar);
   43 e,a,b = ar.gens();
   44 print "e     = " + str(e);
   45 print "a     = " + str(a);
   46 print "b     = " + str(b);
   47 
   48 p = a**5 - a + beta**5 - (a**3 + a)*beta;
   49 #p = p*p;
   50 print "p     = " + str(p);
   51 x = p.factors();
   52 print "x     = " + ", ".join([ str(pp)+"**"+str(i) for (pp,i) in x.iteritems() ]);
   53 g = reduce(operator.mul, [ pp**i for (pp,i) in x.iteritems() ], e);
   54 print "g     = " + str(g);
   55 #print "p-g:    " + str(p-g);
   56 print "isFactors(p,x): " + str(p == g);
   57 print;
   58 
   59 #mod = r.ring.modul;
   60 #print "mod   = " + str(mod);
   61 
   62 pg = r.gens()[1];
   63 #pg = RingElem(r.ring.modul.ring.generators()[1]);
   64 print "pg               = " + str(pg);
   65 pol = pg**(17**5) - pg;
   66 print "pg**(17**5) - pg = " + str(pol);
   67 pol = pg**(17**5-1);
   68 print "pg**(17**5-1)    = " + str(pol);
   69 print "17**5            = " + str(17**5);
   70 print
   71 
   72 
   73 terminate();