"Fossies" - the Fresh Open Source Software Archive

Member "jas-2.6/examples/solv_resi_ore_iter.rb" (7 May 2016, 3274 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) Ruby source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #
    2 # jruby examples for jas.
    3 # $Id: solv_resi_ore_iter.rb 5499 2016-05-07 10:55:30Z kredel $
    4 #
    5 
    6 require "examples/jas"
    7 
    8 # Ore extension solvable polynomial example, Gomez-Torrecillas, 2003
    9 
   10 pcz = PolyRing.new(QQ(),"x,y,z");
   11 #is automatic: [one,x,y,z] = p.gens();
   12 
   13 zrelations = [z, y,  y * z + x
   14              ];
   15 
   16 puts "zrelations: = [" + zrelations.join(", "){ |r| r.to_s } + "]";
   17 puts;
   18 
   19 pz = SolvPolyRing.new(QQ(), "x,y,z", PolyRing.lex, zrelations);
   20 puts "SolvPolyRing: pz = " + str(pz);
   21 puts;
   22 
   23 #startLog();
   24 
   25 fl = [ z**2 + y, y**2 + x];
   26 ff = pz.ideal("",fl);
   27 puts "ideal ff: " + str(ff);
   28 puts;
   29 
   30 ff = ff.twosidedGB();
   31 puts "ideal ff: " + str(ff);
   32 puts;
   33 
   34 
   35 f0 = SRC(ff,z + x + y + 1);
   36 puts "f0 = " + str(f0);
   37 
   38 #f1 = SRC(ff, z-y+1 );
   39 #f1 = SRC(ff, y*z+1  );
   40 f1 = SRC(ff, y*z+x+1  );
   41 puts "f1 = " + str(f1);
   42 
   43 f2 = f1*f0;
   44 puts "f2 = " + str(f2);
   45 
   46 fi = 1/f1;
   47 puts "fi = " + str(fi);
   48 fi1 = fi*f1;
   49 f1i = f1*fi;
   50 puts "fi*f1 = " + str(fi1);
   51 puts "f1*fi = " + str(f1i);
   52 puts;
   53 
   54 #exit(0);
   55 
   56 pzc = f0.elem.ring;
   57 puts "SolvableResidueRing: pzc = " + str(pzc.toScript); # + ", assoz: " + str(pzc::ring.isAssociative);
   58 puts "gens = " + pzc.generators().join(", ") { |r| r.to_s };
   59 puts;
   60 
   61 pct = PolyRing.new(pzc,"t");
   62 #is automatic: [one,y,z,t] = p.gens(); # no x
   63 
   64 #exit(0);
   65 
   66 trelations = [t, y,  y * t + y,
   67               t, z,  z * t - z
   68              ];
   69 
   70 puts "trelations: = [" + trelations.join(", ") { |r| r.to_s } + "]";
   71 puts;
   72 
   73 #startLog();
   74 
   75 pt = SolvPolyRing.new(pzc, "t", PolyRing.lex, trelations);
   76 puts "SolvPolyRing: pt = " + str(pt);
   77 puts;
   78 
   79 puts "sp.gens(t) = " + pt.gens().join(", ") { |r| r.to_s };
   80 #is automatic: one,y,z,t = rp.gens(); # no x
   81 
   82 #exit(0);
   83 #startLog();
   84 
   85 #yi = 1 / y; # not invertible
   86 #puts "yi   = " + str(yi);
   87 
   88 a = t**2 + y;
   89 b = t + y + 1;
   90 c = t**2 - y * t - z;
   91 puts "a   = " + str(a);
   92 puts "b   = " + str(b);
   93 puts "c   = " + str(c);
   94 puts
   95 
   96 ff = [ a*c, b*c ];
   97 puts "ff = [" + ff.join(", ") { |r| r.to_s } + "]";
   98 puts
   99 
  100 ii = pt.ideal( "", ff );
  101 puts "SolvableIdeal: ii = " + str(ii);
  102 puts;
  103 
  104 #exit(0);
  105 
  106 rgl = ii.leftGB();
  107 puts "seq left GB: " + str(rgl);
  108 puts "isLeftGB: " + str(rgl.isLeftGB());
  109 puts;
  110 
  111 p = RingElem.new(rgl.list.get(0));
  112 puts "p     = " + str(p);
  113 puts "c-p   = " + str(c-p);
  114 #puts "monic(p) = " + str(p.monic());
  115 pp = p * p;
  116 puts "p*p   = " + str(pp);
  117 puts "p*y*z = " + str(p*y*z);
  118 puts "p*t   = " + str(p*t);
  119 puts "t*p   = " + str(t*p);
  120 puts;
  121 
  122 #no: fl = [ p, p*x ]; # x non existent
  123 #fl = [ p, p*y ];
  124 #no: fl = [ p, p*z ];
  125 #fl = [ p, p*t, p*y ];
  126 #bad: fl = [ p, p*t, p*p ];
  127 #bad: fl = [ p, p*p ];
  128 #fl = [ p, p*t ];
  129 #fl = [ p, p*(t+1) ];
  130 fl = [ p*(t*t+1), p*(t*t*t), p*(t-3) ];
  131 #fl = [ p ];
  132 puts "fl = [" + fl.join(", ") { |r| r.to_s } + "]";
  133 puts
  134 
  135 iil = pt.ideal( "", fl );
  136 puts "SolvableIdeal_res: il1 = " + str(iil);
  137 puts;
  138 
  139 iiq = iil.toQuotientCoefficients(); # beware of redefined generators
  140 puts "SolvableIdeal_quot: iiq = " + str(iiq);
  141 puts;
  142 
  143 #exit(0);
  144 startLog();
  145 
  146 rgll = iiq.leftGB();
  147 puts "seq left GB: rgl1 = " + str(rgll);
  148 puts "isLeftGB: rgl1 = " + str(rgll.isLeftGB());
  149 puts;
  150 
  151 #rgr = rgl.rightGB();
  152 #puts "seq right GB: " + str(rgr);
  153 #puts "isRightGB: " + str(rgr.isRightGB());
  154 #puts;
  155 
  156 #startLog();
  157 
  158 rgt = iiq.twosidedGB();
  159 puts "seq twosided GB: rgt = " + str(rgt);
  160 puts "isTwosidedGB: rgt = " + str(rgt.isTwosidedGB());
  161 puts;
  162 
  163 terminate();