text:
#
# cls 67: A_2
#
handle67char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[67];
    info:=infos[67];

    rep:=Representative(o);
    #pr[19]=[0,0,1,1,1,0,0,0]
    #pr[17]=[0,1,1,1,0,0,0,0]
    #pr[37]=[1,1,1,2,1,0,0,0]
    tmp1:=ApplyRootsReflections(rep,[19,17,37]);
    uu:=Unipotent(chevalleyAdj(rep),[[3,1]]);
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[3],[-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[19,17,37]);
    uu:=Unipotent(chevalleyAdj(cent),[[3,1]]);
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[3],[-1]);

    return [tmp1,tmp2];
end;

#
# cls 65: A_2A_1
#
handle65char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[65];
    info:=infos[65];

    rep:=Representative(o);
    #pr[53]=[1,1,1,2,1,1,1,0]
    #pr[52]=[1,1,1,2,2,1,0,0]
    #pr[93]=[1,2,3,4,3,2,1,0]
    tmp1:=ApplyRootsReflections(rep,[53,52,93]);
    uu:=Unipotent(chevalleyAdj(rep),[[1,-1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[1],[-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[53,52,93]);
    uu:=Unipotent(chevalleyAdj(cent),[[1,-1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[1],[-1]);

    return [tmp1,tmp2];
end;

#
# cls 61: A_2^2
#
handle61char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[61];
    info:=infos[61];

    rep:=Representative(o);
    #pr[43]=[0,0,1,1,1,1,1,1]
    #pr[41]=[0,1,1,1,1,1,1,0]
    #pr[79]=[1,1,1,2,2,2,2,1]
    tmp1:=ApplyRootsReflections(rep,[43,41,79]);
    uu:=Unipotent(chevalleyAdj(rep),[[1,1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[3],[-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[43,41,79]);
    uu:=Unipotent(chevalleyAdj(cent),[[1,1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[3],[-1]);

    return [tmp1,tmp2];
end;

#
# cls 58: D_4(a_1)
#
handle58char3:=function(orbs,infos)
    local tmp1,tmp2,tmp3,tmp4,o,info,rep,cent,uu;
    o:=Classes(orbs)[58];
    info:=infos[58];

    rep:=Representative(o);
    #pr[4] =[0,0,0,1,0,0,0,0]
    #pr[51]=[1,1,2,2,1,1,0,0]
    #pr[52]=[1,1,1,2,2,1,0,0]
    tmp1:=ApplyRootsReflections(rep,[4,51,52]);
    uu:=Unipotent(chevalleyAdj(rep),[[3,-1],[5,1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[4,1,2,6],[-1,-1,-1,-1]);

    #pr[26]=[0,1,0,1,1,1,0,0]
    #pr[27]=[0,0,1,1,1,1,0,0]
    tmp3:=ApplyRootsReflections(rep,[26,27]);
    uu:=Unipotent(chevalleyAdj(rep),[[3,1],[4,1],[5,-1],[11,1],[12,-1]],Ordering(rep));
    tmp3:=Conj(tmp3,uu);
    tmp3:=ConjugateByTori(tmp3,[2,4],[-1,-1,-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[4,51,52]);
    uu:=Unipotent(chevalleyAdj(cent),[[3,-1],[5,1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[4,1,2,6],[-1,-1,-1,-1]);

    tmp4:=0;
    tmp4:=ApplyRootsReflections(cent,[26,27]);
    uu:=Unipotent(chevalleyAdj(cent),[[3,1],[4,1],[5,-1],[11,1],[12,-1]],Ordering(cent));
    tmp4:=Conj(tmp4,uu);
    tmp4:=ConjugateByTori(tmp4,[2,4],[-1,-1,-1,-1]);

    return [tmp1,tmp3,tmp2,tmp4];
end;

#
# cls 54: D_4(a_1)A_1 Ross' rep
#
handle54char3:=function(orbs,infos)
    local tmp1,tmp2,tmp3,tmp4,o,info,rep,cent,uu;
    o:=Classes(orbs)[54];
    info:=infos[54];

    rep:=Representative(o);

    #pr[23]=[1,1,1,1,0,0,0,0]
    #pr[24]=[1,0,1,1,1,0,0,0]
    tmp1:=ApplyRootsReflections(rep,[23,24]);
    tmp1:=ConjNegUa(tmp1,4,1);
    uu:=Unipotent(chevalleyAdj(rep),[[2,-1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[2],[-1,-1,-1,-1]);

    #pr[65]=[1,1,2,2,1,1,1,1]
    #pr[67]=[1,1,1,2,2,1,1,1]
    tmp3:=ApplyRootsReflections(rep,[65,67,4]);
    uu:=Unipotent(chevalleyAdj(rep),[[12,-1],[11,-1]],Ordering(rep));
    tmp3:=Conj(tmp3,uu);
    tmp3:=ConjugateByTori(tmp3,[1,2,4,6,8],[-1,-1,-1,-1,-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[23,24]);
    tmp2:=ConjNegUa(tmp2,4,1);
    uu:=Unipotent(chevalleyAdj(cent),[[2,-1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[2],[-1,-1,-1,-1]);

    tmp4:=0;
    tmp4:=ApplyRootsReflections(cent,[65,67,4]);
    uu:=Unipotent(chevalleyAdj(cent),[[12,-1],[11,-1]],Ordering(cent));
    tmp4:=Conj(tmp4,uu);
    tmp4:=ConjugateByTori(tmp4,[1,2,4,6,8],[-1,-1,-1,-1,-1]);

    return [tmp1,tmp3,tmp2,tmp4];
end;
#
# cls 54: D_4(a_1)A_1 ([2,5,9,10,7] in E_7) [2,5,10,11,7] in E_8
#
handle54char3old:=function(orbs,infos)
    local tmp1,tmp2,tmp3,tmp4,o,info,rep,cent,uu;
    o:=Classes(orbs)[54];
    info:=infos[54];

    rep:=Representative(o);

    #pr[23]=[1,1,1,1,0,0,0,0]
    #pr[24]=[1,0,1,1,1,0,0,0]
    tmp1:=ApplyRootsReflections(rep,[23,24]);
    uu:=Unipotent(chevalleyAdj(rep),[[4,1],[12,1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[1,2],[-1,-1,-1,-1]);

    #pr[65]=[1,1,2,2,1,1,1,1]
    #pr[67]=[1,1,1,2,2,1,1,1]
    tmp3:=ApplyRootsReflections(rep,[65,67]);
    uu:=Unipotent(chevalleyAdj(rep),[[4,-1]],Ordering(rep));
    tmp3:=Conj(tmp3,uu);
    tmp3:=ConjNegUa(tmp3,4,1);
    uu:=Unipotent(chevalleyAdj(rep),[[3,-1],[4,-1],[5,-1],[12,1]],Ordering(rep));
    tmp3:=Conj(tmp3,uu);
    tmp3:=ConjugateByTori(tmp3,[2,4],[-1,-1,-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[23,24]);
    uu:=Unipotent(chevalleyAdj(cent),[[4,1],[12,1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[1,2],[-1,-1,-1,-1]);

    tmp4:=0;
    tmp4:=ApplyRootsReflections(cent,[65,67]);
    uu:=Unipotent(chevalleyAdj(cent),[[4,-1]],Ordering(cent));
    tmp4:=Conj(tmp4,uu);
    tmp4:=ConjNegUa(tmp4,4,1);
    uu:=Unipotent(chevalleyAdj(cent),[[3,-1],[4,-1],[5,-1],[12,1]],Ordering(cent));
    tmp4:=Conj(tmp4,uu);
    tmp4:=ConjugateByTori(tmp4,[2,4],[-1,-1,-1,-1]);

    return [tmp1,tmp3,tmp2,tmp4];
end;

#
# cls 53: A_3A_2 [3,4,2,6,7]
#
handle53char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[53];
    info:=infos[53];

    rep:=Representative(o);

    #pr[26]=[0,1,0,1,1,1,0,0]
    #pr[27]=[0,0,1,1,1,1,0,0]
    #pr[55]=[0,1,1,2,2,1,1,0]
    tmp1:=ApplyRootsReflections(rep,[26,27,55]);
    uu:=Unipotent(chevalleyAdj(rep),[[2,-1],[3,1],[6,-1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[4,6],[-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[26,27,55]);
    uu:=Unipotent(chevalleyAdj(cent),[[2,-1],[3,1],[6,-1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[4,6],[-1,-1]);

    return [tmp1,tmp2];
end;

#
# cls 52: A_4
#
handle52char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[52];
    info:=infos[52];

    rep:=Representative(o);

    #pr[33]=[0,1,1,1,1,1,0,0]
    #pr[31]=[1,0,1,1,1,1,0,0]
    #pr[64]=[1,1,2,2,2,1,1,0]
    #pr[89]=[1,2,2,4,3,2,1,0]
    tmp1:=ApplyRootsReflections(rep,[33,31,64,89]);
    uu:=Unipotent(chevalleyAdj(rep),[[3,1],[4,1],[11,-1],[17,-1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[1,3,4],[-1,-1,-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[33,31,64,89]);
    uu:=Unipotent(chevalleyAdj(cent),[[3,1],[4,1],[11,-1],[17,-1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[1,3,4],[-1,-1,-1,-1]);

    return [tmp1,tmp2];
end;
#vals[1]:=vals[2];
#vals[3]:=-vals[1]+One(APR);
#vals[4]:=vals[2]+One(APR);
#vals[11]:=-(vals[2]^2-vals[2]-vals[10]+One(APR));
#vals[17]:=-(vals[9]-vals[10]+vals[16]+One(APR));
#
# cls 52: A_4 [1,2,3,4]
#
handle52char3old:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[52];
    info:=infos[52];

    rep:=Representative(o);

    #pr[33]=[0,1,1,1,1,1,0,0]
    #pr[31]=[1,0,1,1,1,1,0,0]
    #pr[64]=[1,1,2,2,2,1,1,0]
    #pr[89]=[1,2,2,4,3,2,1,0]
    tmp1:=ApplyRootsReflections(rep,[33,31,64,89]);
    uu:=Unipotent(chevalleyAdj(rep),[[2,-1],[4,-1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[1,3,4],[-1,-1,-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[33,31,64,89]);
    uu:=Unipotent(chevalleyAdj(cent),[[2,-1],[4,-1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[1,3,4],[-1,-1,-1,-1]);

    return [tmp1,tmp2];
end;

#
# cls 49: D_4(a_1)A_2
#
handle49char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[49];
    info:=infos[49];

    rep:=Representative(o);

    #pr[23]=[1,1,1,1,0,0,0,0]  asta merge si cu rep=[2,3,10,12,7,8] urmat de ConjNegUa(tmp1,4,1)
    #pr[24]=[1,0,1,1,1,0,0,0]
    tmp1:=ApplyRootsReflections(rep,[23,24]);
    tmp1:=ConjNegUa(tmp1,4,1);
    uu:=Unipotent(chevalleyAdj(rep),[[2,-1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[2],[-1,-1,-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[23,24]);
    tmp2:=ConjNegUa(tmp2,4,1);
    uu:=Unipotent(chevalleyAdj(cent),[[2,-1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[2],[-1,-1,-1,-1]);

    return [tmp1,tmp2];
end;
#
# cls 49: D_4(a_1)A_2 [2,5,10,11,7,8] in E_8
#
handle49char3old:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[49];
    info:=infos[49];

    rep:=Representative(o);

    #pr[23]=[1,1,1,1,0,0,0,0]  asta merge si cu rep=[2,3,10,12,7,8] urmat de ConjNegUa(tmp1,4,1)
    #pr[24]=[1,0,1,1,1,0,0,0]
    tmp1:=ApplyRootsReflections(rep,[23,24]);
    uu:=Unipotent(chevalleyAdj(rep),[[4,1],[12,1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[1,2],[-1,-1,-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[23,24]);
    uu:=Unipotent(chevalleyAdj(cent),[[4,1],[12,1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[1,2],[-1,-1,-1,-1]);

    return [tmp1,tmp2];
end;

#
# cls 48: A_4A_1
#
handle48char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[48];
    info:=infos[48];

    rep:=Representative(o);

    #pr[41]=[0,1,1,1,1,1,1,0]
    #pr[39]=[1,0,1,1,1,1,1,0]
    #pr[57]=[1,1,2,2,2,1,0,0]
    #pr[89]=[1,2,2,4,3,2,1,0]
    tmp1:=ApplyRootsReflections(rep,[41,39,57,89]);
    uu:=Unipotent(chevalleyAdj(rep),[[3,-1],[4,-1],[11,-1],[17,-1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[2,3,4],[-1,-1,-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[41,39,57,89]);
    uu:=Unipotent(chevalleyAdj(cent),[[3,-1],[4,-1],[11,-1],[17,-1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[2,3,4],[-1,-1,-1,-1]);

    return [tmp1,tmp2];
end;
#vals[2]:=vals[1];
#vals[3]:=vals[1]-One(APR);
#vals[4]:=-vals[2]-One(APR);
#vals[11]:=vals[1]-vals[9]-One(APR);
#vals[10]:=-vals[1]^2+vals[9];
#vals[17]:=vals[1]^2-vals[16]-One(APR);

#
# cls 46: D_5(a_1)
#
handle46char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[46];
    info:=infos[46];

    rep:=Representative(o);

    #pr[82]=[1,1,2,3,3,2,1,0]
    #pr[80]=[1,2,2,3,2,2,1,0]
    tmp1:=ApplyRootsReflections(rep,[82,80]);
    uu:=Unipotent(chevalleyAdj(rep),[[4,1],[12,1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[2,4],[-1,-1,-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[82,80]);
    uu:=Unipotent(chevalleyAdj(cent),[[4,1],[12,1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[2,4],[-1,-1,-1,-1]);

    return [tmp1,tmp2];
end;

#
# cls 45: A_4A_1^2
#
handle45char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[45];
    info:=infos[45];

    rep:=Representative(o);

    #pr[71]=[1,1,2,2,2,2,1,0]
    #pr[72]=[1,1,2,2,2,1,1,1]
    #pr[112]=[1,3,3,5,4,3,2,1]
    #pr[111]=[2,2,3,5,4,3,2,1]
    tmp1:=ApplyRootsReflections(rep,[71,72,112,111]);
    uu:=Unipotent(chevalleyAdj(rep),[[1,1],[2,1],[3,-1],[9,1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[5,8],[-1,aaa]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[71,72,112,111]);
    uu:=Unipotent(chevalleyAdj(cent),[[1,1],[2,1],[3,-1],[9,1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[5,8],[-1,aaa]);

    return [tmp1,tmp2];
end;

#
# cls 40: D_4A_2
#
handle40char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[40];
    info:=infos[40];

    rep:=Representative(o);

    #pr[34]=[0,1,0,1,1,1,1,0]
    #pr[35]=[0,0,1,1,1,1,1,0]
    #pr[68]=[0,1,1,2,2,2,1,1]
    tmp1:=ApplyRootsReflections(rep,[34,35,68]);
    uu:=Unipotent(chevalleyAdj(rep),[[3,-1],[4,-1],[5,-1],[8,-1],[11,-1],[12,1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[4,6,7,8],[-1,-1,-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[34,35,68]);
    uu:=Unipotent(chevalleyAdj(cent),[[3,-1],[4,-1],[5,-1],[8,-1],[11,-1],[12,1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[4,6,7,8],[-1,-1,-1,-1]);

    return [tmp1,tmp2];
end;
#vals[3]:=vals[2]-One(APR);
#vals[4]:=-vals[2]-One(APR);
#vals[5]:=vals[4];
#vals[8]:=-vals[7]-One(APR);
#vals[11]:=-vals[2]^2+vals[2]-vals[10]-One(APR);
#vals[12]:=vals[2]-vals[10]+One(APR);

#
# cls 39: E_6(a_3) [1,4,6,17,18,19] this doesn't work in char2
#
handle39char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent;
    o:=Classes(orbs)[39];
    info:=infos[39];

    rep:=Representative(o);
    tmp1:=ConjugateByTorus(rep,4,-1);# h_1 --> h_4

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ConjugateByTorus(cent,4,-1);# h_1 --> h_4

    return [tmp1,tmp2];
end;

#
# cls 34: D_6(a_2)
#
handle34char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[34];
    info:=infos[34];

    rep:=Representative(o);

    #pr[42]=[0,1,0,1,1,1,1,0]
    #pr[43]=[0,0,1,1,1,1,1,0]
    tmp1:=ApplyRootsReflections(rep,[42,43]);
    uu:=Unipotent(chevalleyAdj(rep),[[4,1],[6,1],[10,1],[13,1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[4,5,8],[-1,-1,-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[42,43]);
    uu:=Unipotent(chevalleyAdj(cent),[[4,1],[6,1],[10,1],[13,1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[4,5,8],[-1,-1,-1,-1]);

    return [tmp1,tmp2];
end;

#
# cls 33: E_6(a_3)A_1 [1,4,6,8,17,18,19] this doesn't work in char2
#
handle33char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent;
    o:=Classes(orbs)[33];
    info:=infos[33];

    rep:=Representative(o);
    tmp1:=ConjugateByTorus(rep,4,-1);# h_1 --> h_4

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ConjugateByTorus(cent,4,-1);# h_1 --> h_4

    return [tmp1,tmp2];
end;

#
# cls 32: E_7(a_5)
#
handle32char3:=function(orbs,infos)
    local tmp1,tmp2,tmp3,tmp4,o,info,rep,cent,uu;
    o:=Classes(orbs)[32];
    info:=infos[32];

    rep:=Representative(o);
    tmp1:=ConjNegUa(rep,1,1);
    tmp1:=ConjNegUa(tmp1,3,-1);
    tmp1:=ConjNegUa(tmp1,9,-1);
    tmp1:=ConjNegUa(tmp1,2,1);
    uu:=Unipotent(chevalleyAdj(rep),[[1,-1],[3,1],[5,-1],[6,-1],[9,1],[13,-1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    uu:=Unipotent(chevalleyAdj(rep),[[11,1],[14,1],[16,1],[20,1],[21,1],[25,1],[26,-1],[27,-1],[30,1],[33,-1],[35,-1],[37,-1],[38,-1],[39,1],[41,-1],[44,1],[45,1],[46,-1],[51,-1],[52,-1],[59,1],[64,-1],[66,1],[69,-1],[71,-1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTorus(tmp1,1,-1);

    tmp3:=ConjugateByTorus(rep,18,-1);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ConjNegUa(cent,1,1);
    tmp2:=ConjNegUa(tmp2,3,-1);
    tmp2:=ConjNegUa(tmp2,9,-1);
    tmp2:=ConjNegUa(tmp2,2,1);
    uu:=Unipotent(chevalleyAdj(cent),[[1,-1],[3,1],[5,-1],[6,-1],[9,1],[13,-1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    uu:=Unipotent(chevalleyAdj(cent),[[11,1],[14,1],[16,1],[20,1],[21,1],[25,1],[26,-1],[27,-1],[30,1],[33,-1],[35,-1],[37,-1],[38,-1],[39,1],[41,-1],[44,1],[45,1],[46,-1],[51,-1],[52,-1],[59,1],[64,-1],[66,1],[69,-1],[71,-1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTorus(tmp2,1,-1);

    tmp4:=0;
    tmp4:=ConjugateByTorus(cent,18,-1);

    return [tmp1,tmp3,tmp2,tmp4,uu];
end;

#
# cls 30: E_8(a_7) (NOT FINISHED)
#
handle30char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent;
    o:=Classes(orbs)[30];
    info:=infos[30];

    rep:=Representative(o);
    tmp1:=ConjugateByTorus(rep,4,-1);# h_1 --> h_4

    tmp2:=0;
    #cent:=FromPositiveBorel(o,info[2]);
    #tmp2:=ConjugateByTorus(cent,4,-1);# h_1 --> h_4

    return [tmp1,tmp2];
end;

#
# cls 28: D_6(a_1)
#
handle28char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[28];
    info:=infos[28];

    rep:=Representative(o);

    #pr[42]=[0,1,0,1,1,1,1,0]
    #pr[43]=[0,0,1,1,1,1,1,0]
    tmp1:=ApplyRootsReflections(rep,[42,43]);
    uu:=Unipotent(chevalleyAdj(rep),[[4,1],[11,1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[3,4],[-1,-1,-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[42,43]);
    uu:=Unipotent(chevalleyAdj(cent),[[4,1],[11,1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[3,4],[-1,-1,-1,-1]);

    return [tmp1,tmp2];
end;

#
# cls 26: E_7(a_4) [1,4,7,14,17,18,19,26] this doesn't work in char2
#
handle26char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent;
    o:=Classes(orbs)[26];
    info:=infos[26];

    rep:=Representative(o);
    tmp1:=ConjugateByTorus(rep,4,-1);# h_1 --> h_4

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ConjugateByTorus(cent,4,-1);# h_1 --> h_4

    return [tmp1,tmp2];
end;

#
# cls 25: E_6(a_1)
#
handle25char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[25];
    info:=infos[25];

    #pr[58]=[1,1,2,2,1,1,1,0]
    #pr[59]=[1,1,1,2,2,1,1,0]
    #pr[61]=[0,1,1,2,2,2,1,0]

    rep:=Representative(o);
    tmp1:=ApplyRootsReflections(rep,[58,59,61]);
    tmp1:=ConjNegUa(tmp1,4,-1);
    uu:=Unipotent(chevalleyAdj(rep),[[2,1],[5,-1],[10,-1],[11,-1],[12,1],[18,1],[19,1],[26,-1],[27,-1],[32,-1],[40,1],[48,-1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[5,7],[-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[58,59,61]);
    tmp2:=ConjNegUa(tmp2,4,-1);
    uu:=Unipotent(chevalleyAdj(cent),[[2,1],[5,-1],[10,-1],[11,-1],[12,1],[18,1],[19,1],[26,-1],[27,-1],[32,-1],[40,1],[48,-1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[5,7],[-1,-1]);

    return [tmp1,tmp2,uu];
end;

#
# cls 24: D_5A_2
#
handle24char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[24];
    info:=infos[24];

    rep:=Representative(o);

    #pr[87]=[1,1,2,3,3,2,1,1]
    #pr[86]=[1,2,2,3,2,2,1,1]
    #pr[119]=[2,3,4,6,5,4,3,1]
    tmp1:=ApplyRootsReflections(rep,[87,86,119]);
    uu:=Unipotent(chevalleyAdj(rep),[[8,-1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[1,4,7],[-1,-1,-1,-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[87,86,119]);
    uu:=Unipotent(chevalleyAdj(cent),[[8,-1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[1,4,7],[-1,-1,-1,-1]);

    return [tmp1,tmp2];
end;

#
# cls 21: D_7(a_2)
#
handle21char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[21];
    info:=infos[21];

    rep:=Representative(o);

    #pr[113]=[2,3,3,5,4,3,2,1]
    #pr[114]=[2,2,4,5,4,3,2,1]
    tmp1:=ApplyRootsReflections(rep,[113,114]);
    uu:=Unipotent(chevalleyAdj(rep),[[4,1],[6,1],[11,-1],[13,-1],[20,-1],[27,1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[5,6],[-1,-1,-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[113,114]);
    uu:=Unipotent(chevalleyAdj(cent),[[4,1],[6,1],[11,-1],[13,-1],[20,-1],[27,1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[5,6],[-1,-1,-1,-1]);

    return [tmp1,tmp2];
end;
#
# THIS IS FOR THE D_7(a_2) class in E_8 characteristic 3
#
#set:=Filtered(subs,i->i<=63);
#Sort(set);
#uu:=Unipotent(alg,List(set,i->[i,avars[i]]),Ordering(rep));
#
#vals:=ShallowCopy(avars);
#vals[4]:=0;
#vals[3]:=vals[2];
#vals[5]:=vals[3]-vals[2];
#vals[6]:=One(APR);
#vals[7]:=0;
#vals[8]:=vals[2];
#vals[11]:=-vals[3]-vals[10]-One(APR);
#vals[12]:=vals[3];
#vals[13]:=-vals[2]+vals[10]-One(APR);
#vals[14]:=vals[8];
#vals[17]:=vals[2]^2+vals[2]-vals[15];
#vals[18]:=-vals[2]-vals[17];
#vals[19]:=vals[3]^2-vals[2]-vals[18];
#vals[20]:=vals[13]+vals[10];
#vals[21]:=vals[15];
#vals[22]:=-vals[2]^2-vals[2]+vals[15]-vals[17];
#vals[26]:=-vals[2]*vals[10]-vals[10]^2-vals[10]+vals[17];
#vals[27]:=vals[2]+vals[10]+vals[17]-vals[26]+One(APR);
#vals[28]:=vals[18]+vals[15];
#vals[32]:=-(-vals[2]^3-vals[2]+vals[15]-vals[25]-vals[29]);
#vals[33]:=-(vals[2]^2*vals[10]-vals[2]^2+vals[2]*vals[10]-vals[2]-vals[15]-vals[32]);
#vals[34]:=vals[2]^2+vals[25]+vals[32];
#vals[35]:=-vals[2]^3-vals[2]^2-vals[2]+vals[15]+vals[25]-vals[34];
#vals[36]:=vals[2]*vals[15]+vals[10]*vals[15]+vals[15]+vals[29]+vals[34];
#vals[41]:=-(vals[2]^4+vals[2]^3+vals[2]^2-vals[15]^2+vals[25]);
#vals[43]:=vals[2]^3-vals[2]^2*vals[15]+vals[2]^2-vals[2]*vals[15]+vals[15]^2+vals[2]-vals[15]-vals[25]+vals[34]+vals[35]-vals[36]+vals[41]-vals[42];
#vals[48]:=-vals[2]^4+vals[2]^3*vals[10]+vals[2]^3-vals[2]^2*vals[15]+vals[2]*vals[10]*vals[15]+vals[10]^2*vals[15]+vals[2]*vals[10]-vals[10]*vals[15]-vals[15]^2-vals[2]-vals[25]+vals[29]+vals[42];
#vals[49]:=-(vals[2]^4+vals[2]^3+vals[2]^2*vals[15]+vals[2]*vals[10]*vals[15]+vals[10]^2*vals[15]-vals[2]*vals[15]+vals[10]*vals[15]+vals[15]^2+vals[41]-vals[42]);
#vals[55]:=-(-vals[2]^4-vals[2]^2*vals[10]*vals[15]-vals[2]^3+vals[2]^2*vals[15]-vals[2]^2*vals[25]-vals[2]*vals[10]*vals[15]-vals[2]^2+vals[2]*vals[15]+vals[2]*vals[25]-vals[15]^2-vals[15]*vals[25]-vals[25]+vals[50]);
#vals[61]:=-(vals[2]^4*vals[10]+vals[2]^3*vals[10]-vals[2]^2*vals[10]*vals[15]+vals[2]^3+vals[2]^2*vals[10]+vals[2]^2*vals[15]-vals[2]*vals[10]*vals[15]-vals[2]*vals[10]-vals[2]*vals[15]-vals[10]*vals[15]-vals[15]^2-vals[2]-vals[15]-vals[32]-vals[41]+vals[42]+vals[48]-vals[49]+vals[56]);
#vals[62]:=-(-vals[2]^6+vals[2]^5+vals[2]^3*vals[10]*vals[15]-vals[2]^3*vals[15]+vals[2]^3*vals[25]-vals[2]^3*vals[29]+vals[2]^2*vals[10]*vals[15]-vals[2]*vals[10]*vals[15]^2-vals[10]^2*vals[15]^2+vals[2]^3+vals[2]^2*vals[15]+vals[2]^2*vals[25]-vals[2]*vals[10]*vals[15]+vals[2]*vals[15]^2+vals[2]*vals[15]*vals[25]+vals[10]*vals[15]*vals[25]-vals[15]^3-vals[2]^2+vals[2]*vals[15]+vals[2]*vals[25]-vals[2]*vals[29]+vals[15]*vals[29]+vals[25]^2-vals[25]*vals[29]+vals[29]^2+vals[25]-vals[50]);
#
#vv:=Value(uu,avars,vals);
#vvv:=Value(vv,avars,List(avars,i->0));

#
# cls 18: E_6(a_1)A_1
#
handle18char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[18];
    info:=infos[18];

    #pr[106]=[1,2,2,4,4,3,2,1]
    #pr[105]=[1,2,3,4,3,3,2,1]
    #pr[104]=[2,2,3,4,3,2,2,1]

    # this is for E_6(a_1)A_1
    rep:=Representative(o);
    tmp1:=ApplyRootsReflections(rep,[106,105,104]);
    tmp1:=ConjNegUa(tmp1,4,-1);
    uu:=Unipotent(chevalleyAdj(rep),[[2,1],[11,1],[12,-1],[5,1],[10,-1],[18,-1],[19,-1],[26,-1],[27,1],[32,1],[40,-1],[48,-1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[1,2,3,5,6],[-1,-1,-1,-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[106,105,104]);
    tmp2:=ConjNegUa(tmp2,4,-1);
    uu:=Unipotent(chevalleyAdj(cent),[[2,1],[11,1],[12,-1],[5,1],[10,-1],[18,-1],[19,-1],[26,-1],[27,1],[32,1],[40,-1],[48,-1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[1,2,3,5,6],[-1,-1,-1,-1,-1]);

    return [tmp1,tmp2,uu];
end;
#
# THIS IS FOR THE E_6(a_1)A_1 class in E_7 characteristic 3
#
#set:=List(Filtered(pr,i->i[7]=0 and i[8]=0),j->Position(pr,j));
#uu:=Unipotent(alg,List(set,i->[i,avars[i]]),Ordering(rep));
#vals:=ShallowCopy(avars);
#vals[2]:=One(APR)-vals[1];
#vals[3]:=0;
#vals[4]:=0;
#vals[5]:=vals[1]+One(APR);
#vals[6]:=vals[5]-One(APR);
#vals[11]:=One(APR)-vals[1];
#vals[10]:=-One(APR);
#vals[12]:=-vals[1]-vals[10]+One(APR);
#vals[13]:=-vals[1]^2-vals[1]-vals[9];
#vals[16]:=-(-vals[1]^2+vals[1]+vals[9]);
#vals[17]:=-(-vals[1]^2+vals[1]-vals[16]);
#vals[18]:=-vals[1]^2+vals[1]+vals[9]-One(APR);
#vals[19]:=-(-vals[1]^2-vals[1]+vals[9]-vals[16]-One(APR));
#vals[20]:=vals[1]^2-vals[18]-One(APR);
#vals[24]:=-(vals[1]^3-vals[1]^2+vals[1]*vals[9]+vals[9]-vals[23]);
#vals[25]:=-(vals[1]^3-vals[1]^2-vals[1]*vals[9]-vals[9]-vals[23]-vals[24]);
#vals[26]:=-vals[1]^2-vals[23]-One(APR);
#vals[27]:=-(vals[1]^3+vals[1]^2-vals[1]*vals[9]-vals[1]-vals[9]-vals[24]-One(APR));
#vals[30]:=-(vals[1]^4+vals[1]^3+vals[1]^2*vals[9]+vals[1]^2-vals[1]*vals[9]+vals[9]^2-vals[23]);
#vals[32]:=-(vals[1]^3+vals[1]^2-vals[9]-vals[23]+One(APR));
#vals[33]:=-(vals[1]^4-vals[1]^3-vals[1]^2-vals[1]*vals[9]+vals[1]+vals[24]-vals[30]-vals[31]);
#vals[37]:=-vals[1]^4+vals[1]^3+vals[1]^2*vals[9]-vals[1]*vals[9]-vals[9]^2+vals[9]-vals[23]+vals[31];
#vals[40]:=-(vals[1]^4+vals[1]^3-vals[1]^2*vals[9]+vals[1]^2+vals[1]*vals[9]-vals[1]-vals[9]-vals[37]+One(APR));
#vals[44]:=vals[1]^4-vals[1]^3*vals[9]+vals[1]^3+vals[1]^2*vals[9]+vals[1]*vals[9]^2+vals[1]^2-vals[9]^2-vals[23]+vals[38];
#vals[48]:=-(-vals[1]^5-vals[1]^4-vals[1]^3*vals[9]-vals[1]^2*vals[9]-vals[1]^2+vals[1]*vals[9]-vals[9]^2-vals[1]+vals[9]-vals[23]+vals[37]+vals[38]-vals[45]+One(APR));
#vals[51]:=-vals[1]^4-vals[1]^3*vals[23]+vals[1]^2*vals[9]^2-vals[1]^3+vals[1]*vals[9]^2-vals[1]^2-vals[1]*vals[23]-vals[9]^2+vals[23]^2+vals[23]+vals[38];
#vals[52]:=vals[1]^6+vals[1]^5-vals[1]^4*vals[9]+vals[1]^4+vals[1]^3*vals[9]+vals[1]^2*vals[9]^2+vals[1]^3-vals[1]^2*vals[9]-vals[1]^2*vals[23]-vals[1]*vals[9]^2+vals[9]^3-vals[1]^2+vals[9]^2+vals[23]^2+vals[23]-vals[31]-vals[38]+vals[45];
#vals[63]:=-(-vals[1]^6-vals[1]^5*vals[9]-vals[1]^4*vals[9]-vals[1]^3*vals[9]^2-vals[1]^3*vals[9]-vals[1]^3*vals[23]-vals[1]^3*vals[31]-vals[1]*vals[9]^3+vals[1]^3-vals[1]^2*vals[9]+vals[1]^2*vals[23]-vals[1]^2*vals[31]-vals[9]^3-vals[9]^2*vals[23]-vals[1]*vals[9]-vals[1]*vals[23]+vals[9]^2+vals[9]*vals[31]+vals[23]^2+vals[23]*vals[31]-vals[9]+vals[23]-vals[31]);
#
#vv:=Value(uu,avars,vals);
#vvv:=Value(vv,avars,List(avars,i->0));

#
# cls 17: E_7(a_3) ([1,4,6,7,15,16,17] in E_7) [1,4,6,7,17,18,19] in E_8 this doesn't work in char2
#
handle17char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent;
    o:=Classes(orbs)[17];
    info:=infos[17];

    rep:=Representative(o);
    tmp1:=ConjugateByTorus(rep,4,-1);# h_1 --> h_4

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ConjugateByTorus(cent,4,-1);# h_1 --> h_4

    return [tmp1,tmp2];
end;

# This is for Seitz' representative in first table
#
# cls 16: E_8(b_6)
#
#handle16char3:=function(orbs,infos)
#    local tmp1,tmp2,o,info,rep,cent;
#    o:=Classes(orbs)[16];
#    #info:=infos[16];
#
#    rep:=Representative(o);
#    tmp1:=ConjugateByTori(rep,[3,4,7,8],[-1,-1,-1,-1]);# same as [11,15] should be Z(D_8)
#
#    tmp2:=0;
#    #cent:=FromPositiveBorel(o,info[2]);
#    #tmp2:=ConjugateByTori(cent,[3,4,7,8],[-1,-1,-1,-1]);# same as [11,15] should be Z(D_8)
#
#    return [tmp1,tmp2];
#end;

# This is for Seitz' representative used in proof
#
# cls 16: E_8(b_6)
#
handle16char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent;
    o:=Classes(orbs)[16];
    info:=infos[16];

    rep:=Representative(o);
    tmp1:=ConjugateByTori(rep,[12,13,15],[-1,-1,-1,-1]);# should be Z(D_8)

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ConjugateByTori(cent,[12,13,15],[-1,-1,-1,-1]);# should be Z(D_8)

    return [tmp1,tmp2];
end;

#
# cls 15: D_7(a_1)
#
handle15char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[15];
    info:=infos[15];

    rep:=Representative(o);

    #pr[113]=[2,3,3,5,4,3,2,1]
    #pr[114]=[0,0,1,1,1,1,1,0]
    tmp1:=ApplyRootsReflections(rep,[113,114]);
    #uu:=Unipotent(chevalleyAdj(rep),[[4,1],[10,-1]],Ordering(rep)); si asta merge
    uu:=Unipotent(chevalleyAdj(rep),[[4,1],[11,-1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[2,3,4],[aaa,aaa,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[113,114]);
    uu:=Unipotent(chevalleyAdj(cent),[[4,1],[11,-1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[2,3,4],[aaa,aaa,-1]);

    return [tmp1,tmp2];
end;

#
# cls 12: E_8(a_6)
#
handle12char3:=function(orbs,infos)
    local tmp1,tmp2,tmp3,tmp4,o,info,rep,cent,uu,vars;
    o:=Classes(orbs)[12];
    info:=infos[12];

    # L(Q)_2 has dimension 24 and should correspond to [ 4, 12, 14, 15, 21, 23, 25, 26, 31, 37, 46, 47, 53, 55, 57, 72, 73, 82, 90, 92, 97, 104, 106, 113 ]
    rep:=Representative(o);

    vars:=ShallowCopy(avars);#List([1..120],i->avars[i]);
    #vars[5]:=vars[1]*vars[2]*vars[3]-vars[1]*vars[3]*vars[13]-vars[2]*vars[3]*vars[5]+vars[2]*vars[9]-vars[2]*vars[13]-vars[9]*vars[13];
    vars[9]:=One(APR);
    vars[1]:=-vars[9]^2;#0;
    vars[2]:=vars[9]^3;
    #vars[9]:=One(APR);# sau -1
    vars[3]:=0;#-vars[9];
    vars[5]:=vars[1];
    #vars[23]:=-vars[9];
    #vars[2]:=vars[3]*vars[9]*vars[23]-vars[9]^2*vars[23];
    #vars[5]:=1;
    vars[26]:=-One(APR);
    vars[21]:=Zero(APR);
    vars[13]:=vars[1]*vars[3]-vars[3]*vars[5]+vars[9];
    vars[23]:=-vars[9]^3;
    vars[29]:=-(vars[9]^3*vars[21]+vars[2]-vars[9]);#0=-vars[21];

    tmp1:=ConjNegUa(rep,2,vars[2]);#1
    tmp1:=ConjNegUa(tmp1,5,vars[5]);#-1
    #tmp1:=ConjNegUa(tmp1,6,avars[6]);
    tmp1:=ConjNegUa(tmp1,13,vars[13]);#1
    #uu:=Unipotent(chevalleyAdj(rep),[[6,One(APR)]],Ordering(rep));
    #tmp1:=Conj(tmp1,uu);
    tmp1:=ConjNegUa(tmp1,1,vars[1]);#-1
    tmp1:=ConjNegUa(tmp1,3,vars[3]);#0
    tmp1:=ConjNegUa(tmp1,9,vars[9]);#1
    uu:=Unipotent(chevalleyAdj(rep),[[1,vars[21]],[3,vars[23]],[6,vars[26]],[9,vars[29]]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    uu:=Unipotent(chevalleyAdj(rep),[[4, -1 ], [ 8, -1 ], [ 10, 1 ], [ 11, -1 ], [ 14, 1 ], [ 15, 1 ], [ 16, 1 ], [ 19, -1 ], [ 21, -1 ], [ 22, -1 ], [ 23, -1 ], [ 25, 1 ], [ 26, 1 ], [ 27, -1 ], [ 28, 1 ], [ 30, -1 ], [ 31, 1 ], [ 32, 1 ], [ 33, -1 ], [ 34, 1 ], [ 36, -1 ], [ 37, -1 ], [ 40, -1 ], [ 41, 1 ], [ 42, 1 ], [ 44, 1 ], [ 47, -1 ], [ 50, 1 ], [ 52, -1 ], [ 54, 1 ], [ 55, -1 ], [ 57, -1 ], [ 61, -1 ], [ 62, 1 ], [ 65, 1 ], [ 69, 1 ], [ 76, -1 ], [ 77, -1 ], [ 78, 1 ], [ 81, -1 ], [ 82, -1 ], [ 83, 1 ], [ 85, -1 ], [ 86, -1 ], [ 91, 1 ], [ 93, -1 ], [ 94, 1 ], [ 97, 1 ], [ 98, -1 ], [ 102, -1 ], [ 103, -1 ], [ 106, 1 ], [ 107, -1 ], [ 108, 1 ], [ 109, -1 ], [ 111, -1 ], [ 114, -1 ], [ 115, -1 ], [ 117, 1 ], [ 118, -1 ] ],Ordering(rep));
    #uu:=Unipotent(chevalleyAdj(rep),[[1,avars[1]],[9,avars[9]]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    #tmp1:=ConjNegUa(tmp1,3,avars[3]);

    tmp3:=ConjugateByTori(rep,[4,6,7],[-1,-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ConjNegUa(cent,2,vars[2]);
    tmp2:=ConjNegUa(tmp2,5,vars[5]);
    tmp2:=ConjNegUa(tmp2,13,vars[13]);
    tmp2:=ConjNegUa(tmp2,1,vars[1]);
    tmp2:=ConjNegUa(tmp2,3,vars[3]);
    tmp2:=ConjNegUa(tmp2,9,vars[9]);
    uu:=Unipotent(chevalleyAdj(cent),[[1,vars[21]],[3,vars[23]],[6,vars[26]],[9,vars[29]]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    uu:=Unipotent(chevalleyAdj(cent),[[4, -1 ], [ 8, -1 ], [ 10, 1 ], [ 11, -1 ], [ 14, 1 ], [ 15, 1 ], [ 16, 1 ], [ 19, -1 ], [ 21, -1 ], [ 22, -1 ], [ 23, -1 ], [ 25, 1 ], [ 26, 1 ], [ 27, -1 ], [ 28, 1 ], [ 30, -1 ], [ 31, 1 ], [ 32, 1 ], [ 33, -1 ], [ 34, 1 ], [ 36, -1 ], [ 37, -1 ], [ 40, -1 ], [ 41, 1 ], [ 42, 1 ], [ 44, 1 ], [ 47, -1 ], [ 50, 1 ], [ 52, -1 ], [ 54, 1 ], [ 55, -1 ], [ 57, -1 ], [ 61, -1 ], [ 62, 1 ], [ 65, 1 ], [ 69, 1 ], [ 76, -1 ], [ 77, -1 ], [ 78, 1 ], [ 81, -1 ], [ 82, -1 ], [ 83, 1 ], [ 85, -1 ], [ 86, -1 ], [ 91, 1 ], [ 93, -1 ], [ 94, 1 ], [ 97, 1 ], [ 98, -1 ], [ 102, -1 ], [ 103, -1 ], [ 106, 1 ], [ 107, -1 ], [ 108, 1 ], [ 109, -1 ], [ 111, -1 ], [ 114, -1 ], [ 115, -1 ], [ 117, 1 ], [ 118, -1 ] ],Ordering(cent));
    tmp2:=Conj(tmp2,uu);

    tmp4:=0;
    tmp4:=ConjugateByTori(cent,[4,6,7],[-1,-1,-1]);

    return [tmp1,tmp3,tmp2,tmp4,uu];
end;

#
# cls 10: E_8(b_5)
#
handle10char3:=function(orbs,infos)
    local tmp1,tmp2,tmp3,tmp4,o,info,rep,cent,uu;
    o:=Classes(orbs)[10];
    info:=infos[10];

    rep:=Representative(o);
    tmp1:=ConjNegUa(rep,1,1);
    tmp1:=ConjNegUa(tmp1,3,-1);
    tmp1:=ConjNegUa(tmp1,9,-1);
    tmp1:=ConjNegUa(tmp1,2,1);
    uu:=Unipotent(chevalleyAdj(rep),[[1,-1],[3,1],[5,-1],[6,-1],[9,1],[13,-1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    uu:=Unipotent(chevalleyAdj(rep),[[8,1],[10,-1],[11,1],[16,-1],[20,1],[21,1],[25,1],[27,-1],[30,-1],[31,1],[32,-1],[33,-1],[37,1],[38,-1],[40,1],[44,-1],[46,-1],[52,1],[55,-1],[59,1],[61,1],[63,1],[64,-1],[69,-1],[82,-1],[90,1],[93,1],[97,-1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTorus(tmp1,1,-1);

    tmp3:=ConjugateByTorus(rep,18,-1);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ConjNegUa(cent,1,1);
    tmp2:=ConjNegUa(tmp2,3,-1);
    tmp2:=ConjNegUa(tmp2,9,-1);
    tmp2:=ConjNegUa(tmp2,2,1);
    uu:=Unipotent(chevalleyAdj(cent),[[1,-1],[3,1],[5,-1],[6,-1],[9,1],[13,-1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    uu:=Unipotent(chevalleyAdj(cent),[[8,1],[10,-1],[11,1],[16,-1],[20,1],[21,1],[25,1],[27,-1],[30,-1],[31,1],[32,-1],[33,-1],[37,1],[38,-1],[40,1],[44,-1],[46,-1],[52,1],[55,-1],[59,1],[61,1],[63,1],[64,-1],[69,-1],[82,-1],[90,1],[93,1],[97,-1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTorus(tmp2,1,-1);

    tmp4:=0;
    tmp4:=ConjugateByTorus(cent,18,-1);

    return [tmp1,tmp3,tmp2,tmp4,uu];
end;

# For representative deduced from Seitz' E_8(b_6) given in first table
#
# cls 8: E_8(a_5)
#
#handle8char3:=function(orbs,infos)
#    local tmp1,tmp2,o,info,rep,cent;
#    o:=Classes(orbs)[8];
#    #info:=infos[8];
#
#    rep:=Representative(o);
#    tmp1:=ConjugateByTori(rep,[3,4,7,8],[-1,-1,-1,-1]);# same as [11,15] should be Z(D_8)
#
#    tmp2:=0;
#    #cent:=FromPositiveBorel(o,info[2]);
#    #tmp2:=ConjugateByTori(cent,[3,4,7,8],[-1,-1,-1,-1]);# same as [11,15] should be Z(D_8)
#
#    return [tmp1,tmp2];
#end;

# For representative deduced from Seitz' E_8(a_6) used in proof
#
# cls 8: E_8(a_5)
#
handle8char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent;
    o:=Classes(orbs)[8];
    info:=infos[8];

    rep:=Representative(o);
    tmp1:=ConjugateByTori(rep,[4,6,7],[-1,-1,-1,-1]);# should be Z(D_8)

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ConjugateByTori(cent,[4,6,7],[-1,-1,-1,-1]);# should be Z(D_8)

    return [tmp1,tmp2];
end;

#
# cls 7: E_8(b_4) [1,4,7,8,14,17,19,26]  this doesn't work in char2
#
handle7char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent;
    o:=Classes(orbs)[7];
    info:=infos[7];

    rep:=Representative(o);
    tmp1:=ConjugateByTorus(rep,4,-1);# h_1 --> h_4

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ConjugateByTorus(cent,4,-1);# h_1 --> h_4

    return [tmp1,tmp2];
end;

#
# cls 5: E_8(a_4) [1,4,6,8,17,18,19,21]  this doesn't work in char2
#
handle5char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent;
    o:=Classes(orbs)[5];
    info:=infos[5];

    rep:=Representative(o);
    tmp1:=ConjugateByTori(rep,[4,8],[-1,-1]);# h_4, h_8

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ConjugateByTori(cent,[4,8],[-1,-1]); # h_4, h_8

    return [tmp1,tmp2];
end;

#
# cls 4: E_8(a_3) [1,4,6,7,8,17,18,19]  this doesn't work in char2
#
handle4char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent;
    o:=Classes(orbs)[4];
    info:=infos[4];

    rep:=Representative(o);
    tmp1:=ConjugateByTorus(rep,4,-1);# h_1 --> h_4

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ConjugateByTorus(cent,4,-1);# h_1 --> h_4

    return [tmp1,tmp2];
end;


text:
#############################################################################
##
#W  scilab.gi               automgrp package                   Yevgen Muntyan
#W                                                             Dmytro Savchuk
##
#Y  Copyright (C) 2003 - 2018 Yevgen Muntyan, Dmytro Savchuk
##

InstallGlobalFunction(PlotSpectraPermsInScilab,
function(perms, deg, opts)
  local mats, i, j,
  temp_dir, temp_file, temp_file_name, sci_temp_file, sci_temp_file_name,
  plot_spectra_func_file, exec_string,
  round, stacksize, output_filename, title;

  if IsBound(opts.round) then round := opts.round; else round := 7; fi;
  if IsBound(opts.stacksize) then stacksize := opts.stacksize; else stacksize := AG_Globals.scilab_stacksize; fi;
  if IsBound(opts.output) then output_filename := opts.output; else output_filename := ""; fi;
  if IsBound(opts.title) then title := opts.title; else title := ""; fi;

  plot_spectra_func_file := Filename(DirectoriesPackageLibrary("automgrp","scilab"),
                                     "PlotSpectraPermsInScilab.sci");
  if plot_spectra_func_file = fail then
    Print("error in PlotSpectraPermsInScilab:\n  scilab file not found\n");
    return fail;
  fi;

  temp_dir := DirectoryTemporary();
  temp_file_name := Filename(temp_dir, "pass");
  temp_file := OutputTextFile(temp_file_name, false);
  if temp_file = fail then
    Print("error in PlotSpectraPermsInScilab:\n  could not create temp file\n");
    return fail;
  fi;

  for i in [1..deg] do
    for j in [1..Length(perms)] do
      AppendTo(temp_file, i, "\t", i^perms[j], "\t");
    od;
    AppendTo(temp_file, "\n");
  od;
  CloseStream(temp_file);

  sci_temp_file_name := Filename(temp_dir, "commands_for_scilab");
  sci_temp_file := OutputTextFile(sci_temp_file_name, false);

  if sci_temp_file = fail then
    Print("error in PlotSpectraPermsInScilab:\n",
          "  Could not create temp file for scilab script\n");
    return fail;
  fi;

  SetPrintFormattingStatus(sci_temp_file, false);

  PrintTo(sci_temp_file, "getf(\"", plot_spectra_func_file, "\");\n");
  PrintTo(sci_temp_file, "PlotSpectraPermsInScilab(",
                         "\"", temp_file_name, "\", ",
                         Length(perms), ", ",
                         deg, ", ",
                         round, ", ",
                         stacksize, ", ",
                         "\"", output_filename, "\", ",
                         "\"", title, "\");\n");

  if output_filename <> "" then
    PrintTo(sci_temp_file, "exit\n");
  fi;

  CloseStream(sci_temp_file);

  exec_string := Concatenation(#"cat ", sci_temp_file_name, "; ",
                               "xterm -e scilab -nw -f ",
                               sci_temp_file_name);

  if output_filename = "" then
    Append(exec_string, " &");
  fi;

  Exec(exec_string);
end);

#############################################################################
##
##  PlotSpectraInScilab(<list>, <level>[, <opts>])
##
InstallMethod(PlotSpectraInScilab,
              [IsList and IsTreeAutomorphismCollection, IsPosInt],
function(gens, level)
  PlotSpectraPermsInScilab(List(gens, g -> PermOnLevel(g, level)),
                           DegreeOfTree(gens[1])^level, rec());
end);

InstallMethod(PlotSpectraInScilab,
              [IsList and IsTreeAutomorphismCollection, IsPosInt, IsRecord],
function(gens, level, opts)
  PlotSpectraPermsInScilab(List(gens, g -> PermOnLevel(g, level)),
                           DegreeOfTree(gens[1])^level, opts);
end);

InstallMethod(PlotSpectraInScilab,
              [IsTreeAutomorphismGroup, IsPosInt],
function(G, level)
  PlotSpectraInScilab(GeneratorsOfGroup(G), level, rec());
end);

InstallMethod(PlotSpectraInScilab,
              [IsTreeAutomorphismGroup, IsPosInt, IsRecord],
function(G, level, opts)
  PlotSpectraInScilab(GeneratorsOfGroup(G), level, opts);
end);

# InstallOtherMethod(PlotAutomatonSpectraInScilab, [IsList, IsInt, IsInt, IsInt],
# function(list, iter_num, round, stacksize)
#   local mats, i, j,
#   temp_dir, temp_file, temp_file_name, sci_temp_file, sci_temp_file_name,
#   plot_spectra_func_file, exec_string;
#
#   plot_spectra_func_file := "/home/muntyan/math/automata/scilab/plot_spectra.sci";
#
#   ## TODO: input checking
#
#   mats := PermMatrices(list, iter_num);
#
#   temp_dir := DirectoryTemporary();
#   temp_file_name := Filename(temp_dir, "pass");
#   temp_file := OutputTextFile(temp_file_name, false);
#   if temp_file = fail then
#     Error("Could not create temp file\n");
#   fi;
#
#   for i in [1..2^iter_num] do
#     for j in [1..Length(list)] do
#       AppendTo(temp_file, mats[j][i][1], "\t", mats[j][i][2], "\t");
#     od;
#     AppendTo(temp_file, "\n");
#   od;
#   CloseStream(temp_file);
#
#   sci_temp_file_name := Filename(temp_dir, "pass_sci");
#   sci_temp_file := OutputTextFile(sci_temp_file_name, false);
#   if sci_temp_file = fail then
#     Error("Could not create temp file for scilab script\n");
#   fi;
#
#   AppendTo(sci_temp_file, "getf(\"", plot_spectra_func_file, "\");\n");
#   AppendTo(sci_temp_file, "plot_spectra(\"", temp_file_name, "\", ", Length(list), ", ", iter_num, ", ", round, ", ", stacksize, ");\n");
# #  AppendTo(sci_temp_file, "exit\n");
#   CloseStream(sci_temp_file);
#
#   exec_string := Concatenation("xterm -e scilab -nw -f ", sci_temp_file_name, " > /dev/null");
#   Exec(exec_string);
# end);
#
#
# InstallMethod(PlotAutomatonSpectraInScilab, [IsList, IsInt, IsInt],
# function(list, iter_num, round)
#   PlotAutomatonSpectraInScilab(list, iter_num, round, 10000000);
# end);
#
#
# InstallOtherMethod(PlotAutomatonSpectraInScilab, [IsList, IsInt],
# function(list, iter_num)
#   PlotAutomatonSpectraInScilab(list, iter_num, 7, 10000000);
# end);

ext: gi

max_stars_repo_name: gap-packages/automgrp

max_issues_repo_name: gap-packages/automgrp

max_forks_repo_name: gap-packages/automgrp


text:
--/**
-- * <copyright>
-- *
-- * Copyright (c) 2008, 2009 Eclipse.org and others.
-- * All rights reserved.   This program and the accompanying materials
-- * are made available under the terms of the Eclipse Public License v2.0
-- * which accompanies this distribution, and is available at
-- * http://www.eclipse.org/legal/epl-v20.html
-- *
-- * Contributors:
-- *   E.D.Willink - Initial API and implementation
-- *   Adolfo Sanchez-Barbudo Herrera (Open Canarias):
-- *        - 242153: LPG v 2.0.17 adoption.
-- *        - 299396: Introducing new LPG templates.
-- *        - 300534: Removing the use of deprecated macros.
-- *
-- * </copyright>
-- */
--
-- Additional ERROR_TOKEN rules for The EssentialOCL Backtracking Parser
--

%Headers
	/.
	// Some methods for backwards compatibility

	/**
	 * Report error message for given error_token.
	 *
	 * @param error_token
	 *            the error taken index
	 * @param msg
	 *            the message to report
	 *
	 * @since 1.3
	 */
	protected final void reportErrorTokenMessage(int error_token, String msg) {
		getIPrsStream().reportErrorTokenMessage(error_token, msg);
	}
	./
%End

%Rules
	ERROR_Colon ::= ERROR_TOKEN
		/.$BeginCode
					reportErrorTokenMessage(getRhsTokenIndex(1), OCLParserErrors.MISSING_COLON);
		  $EndCode
		./
	ERROR_Empty ::= ERROR_TOKEN
		/.$BeginCode
					reportErrorTokenMessage(getRhsTokenIndex(1), OCLParserErrors.EXTRA_TOKENS);
		  $EndCode
		./

-----------------------------------------------------------------------
--	Names
-----------------------------------------------------------------------

	ERROR_SimpleNameCS ::= ERROR_TOKEN
		/.$BeginCode
					reportErrorTokenMessage(getRhsTokenIndex(1), OCLParserErrors.MISSING_SIMPLE_NAME);
                    IToken iToken = getRhsIToken(1);
					SimpleNameCS result = createSimpleNameCS(
							SimpleTypeEnum.IDENTIFIER_LITERAL,
							iToken
						);
					setOffsets(result, iToken);
					setResult(result);
		  $EndCode
		./

	simpleNameCS -> ERROR_SimpleNameCS
--	simpleNameCS -> reservedKeyword ERROR_SimpleNameCS

-----------------------------------------------------------------------
--	Types
-----------------------------------------------------------------------
	collectionTypeCS ::= CollectionTypeIdentifierCS '(' typeCS ERROR_TOKEN
		/.$BeginCode
					reportErrorTokenMessage(getRhsTokenIndex(4), OCLParserErrors.MISSING_RPAREN);
					CollectionTypeCS result = (CollectionTypeCS)getRhsSym(1);
					result.setTypeCS((TypeCS)getRhsSym(3));
					setOffsets(result, result, getRhsIToken(4));
					setResult(result);
		  $EndCode
		./

-----------------------------------------------------------------------
--	Declarations
-----------------------------------------------------------------------
--	VariableDeclarationCS ::= notLiteralNorReservedSimpleNameCS ERROR_TOKEN
--		/.$BeginCode
--					reportErrorTokenMessage(getRhsTokenIndex(2), OCLParserErrors.MISSING_VARIABLE_TYPE);
--					SimpleNameCS name = (SimpleNameCS)getRhsSym(1);
--					VariableCS result = createVariableCS(name, null, null);
--					setOffsets(result, name, getRhsIToken(2));
--					setResult(result);
--		  $EndCode
--		./

--	variableDeclarationListCS ::= ERROR_TOKEN
--		/.$BeginCode
--					reportErrorTokenMessage(getRhsTokenIndex(1), OCLParserErrors.MISSING_VARIABLES);
--					EList result = new BasicEList();
--					setResult(result);
--		  $EndCode
--		./

-----------------------------------------------------------------------
--	Literals
-----------------------------------------------------------------------
	TupleLiteralExpCS ::= Tuple ERROR_TOKEN
		/.$BeginCode
					reportErrorTokenMessage(getRhsTokenIndex(2), OCLParserErrors.MISSING_LBRACE);
					TupleLiteralExpCS result = createTupleLiteralExpCS((EList<VariableCS>)getRhsSym(3));
					setOffsets(result, getRhsIToken(1), getRhsIToken(4));
					setResult(result);
		  $EndCode
		./

	TupleLiteralPartsCS ::= ERROR_TOKEN
		/.$BeginCode
					reportErrorTokenMessage(getRhsTokenIndex(1), OCLParserErrors.MISSING_VARIABLES);
					EList<VariableCS> result = new BasicEList<VariableCS>();
					setResult(result);
		  $EndCode
		./

-----------------------------------------------------------------------
--	Calls
-----------------------------------------------------------------------
	AssociationClassCallExpCS ::= simpleNameCS '[' argumentsCS ERROR_TOKEN
		/.$BeginCode
					reportErrorTokenMessage(getRhsTokenIndex(4), OCLParserErrors.MISSING_RBRACK);
					VariableExpCS result = createVariableExpCS(
							(SimpleNameCS)getRhsSym(1),
							(EList<OCLExpressionCS>)getRhsSym(3),
							null
						);
					setOffsets(result, (CSTNode)getRhsSym(1), getRhsIToken(4));
					setResult(result);
		  $EndCode
		./

-----------------------------------------------------------------------
--	Expressions
-----------------------------------------------------------------------
	IfExpCS ::= if OclExpressionCS then OclExpressionCS else OclExpressionCS ERROR_TOKEN
		/.$BeginCode
					reportErrorTokenMessage(getRhsTokenIndex(7), OCLParserErrors.MISSING_ENDIF);
					IfExpCS result = createIfExpCS(
							(OCLExpressionCS)getRhsSym(2),
							(OCLExpressionCS)getRhsSym(4),
							(OCLExpressionCS)getRhsSym(6)
						);
					setOffsets(result, getRhsIToken(1), getRhsIToken(7));
					setResult(result);
		  $EndCode
		./
	IfExpCS ::= if OclExpressionCS then OclExpressionCS ERROR_TOKEN
		/.$BeginCode
					reportErrorTokenMessage(getRhsTokenIndex(5), OCLParserErrors.MISSING_ELSE_ENDIF);
					IfExpCS result = createIfExpCS(
							(OCLExpressionCS)getRhsSym(2),
							(OCLExpressionCS)getRhsSym(4),
							createInvalidLiteralExpCS(getRhsTokenText(5))
						);
					setOffsets(result, getRhsIToken(1), getRhsIToken(5));
					setResult(result);
		  $EndCode
		./
	IfExpCS ::= if OclExpressionCS ERROR_TOKEN
		/.$BeginCode
					reportErrorTokenMessage(getRhsTokenIndex(3), OCLParserErrors.MISSING_THEN_ELSE_ENDIF);
					IfExpCS result = createIfExpCS(
							(OCLExpressionCS)getRhsSym(2),
							createInvalidLiteralExpCS(getRhsTokenText(3)),
							createInvalidLiteralExpCS(getRhsTokenText(3))
						);
					setOffsets(result, getRhsIToken(1), getRhsIToken(3));
					setResult(result);
		  $EndCode
		./
	IfExpCS ::= if ERROR_TOKEN endif
		/.$BeginCode
					reportErrorTokenMessage(getRhsTokenIndex(3), OCLParserErrors.MISSING_THEN_ELSE);
					IfExpCS result = createIfExpCS(
							createInvalidLiteralExpCS(getRhsTokenText(2)),
							createInvalidLiteralExpCS(getRhsTokenText(2)),
							createInvalidLiteralExpCS(getRhsTokenText(2))
						);
					setOffsets(result, getRhsIToken(1), getRhsIToken(3));
					setResult(result);
		  $EndCode
		./

	primaryExpCS ::= '(' OclExpressionCS ERROR_TOKEN
		/.$BeginCode
					reportErrorTokenMessage(getRhsTokenIndex(3), OCLParserErrors.MISSING_RPAREN);
					OCLExpressionCS result = (OCLExpressionCS)getRhsSym(2);
					setOffsets(result, getRhsIToken(1), getRhsIToken(3));
					setResult(result);
		  $EndCode
		./
%End


text:
#
# usage:
# Read("~/Workspace/Chevalley.gap/init.gi"); Read(Filename(home_dir,"load.gi")); Read(Filename(f4_dir_char3,"_init_char3.gi")); Read(Filename(f4_dir_char3,"B2.gi"));
#
# Read(Filename(f4_dir_char3,"B2.gi"));
#

label:="B_2";
orb_nr:=Position(labels,label);
#orb:=AllClasses(orbs)[9];
orb:=AllClasses(orbs)[orb_nr];
info:=infos[orb_nr];

#
# ------------------------------------------------------------------------
#

Print("Consider the class ",Label(orb)," in characteristic ",Characteristic(ring(sys)),":\n");
Print("\tBorel representative \n\t",coefficients(BorelRep(orb)),"\n");
Print("\tconnected C_U(u) \n\t",coefficients(info[1]),"\n");
Print("\tconnected double C_U(u) in Levi \n\t",coefficients(info[2]),"\n");
Print("\tconnected double C_U(u) \n\t",coefficients(info[3]),"\n");

Z0:=info[2];
# move Z0 to match the representative
Z0:=FromPositiveBorel(orb,Z0);
# adjust ordering of roots
Z0:=Unipotent(chevalleyAdj(Z0),coefficients(Z0),[1..Length(positiveRoots(sys))]);
Print("Z0 in position of Representative:\n\tZ0=",coefficients(Z0),"\n");

Print("Component group is C2.\n");
Print("On Z0:\n");
n:=[9];
aZ0:=ApplyRootsReflections(Z0,n);
aZ0:=ConjugateByTorus(aZ0,4,-1);

Print("\ta^Z0=",coefficients(aZ0),"\n");

#
# ------------------------------------------------------------------------
#

tmp:=handle9char3();
Print("\nComponent group is check:\n");
Print("\ta^u= \n",coefficients(tmp[1]),"\n");
Print("\tconnected center= \n",coefficients(tmp[2]),"\n");


text:
while true do
    Print("SPAM\n");
od;

ext: gap

max_issues_repo_name: seanwallawalla-forks/RosettaCodeData

max_forks_repo_name: seanwallawalla-forks/RosettaCodeData


text:
x := Indeterminate(Rationals, "x");
p := x^11 + 3*x^8 + 7*x^2 + 3;
q := x^7 + 5*x^3 + 1;
QuotientRemainder(p, q);
# [ x^4+3*x-5, -16*x^4+25*x^3+7*x^2-3*x+8 ]


text:
FizzBuzz := function()
	local i;
	for i in [1 .. 100] do
		if RemInt(i, 15) = 0 then
			Print("FizzBuzz\n");
		elif RemInt(i, 3) = 0 then
			Print("Fizz\n");
		elif RemInt(i, 5) = 0 then
			Print("Buzz\n");
		else
			Print(i, "\n");
		fi;
	od;
end;


text:
# Copyright (c) 2018-2021, Carnegie Mellon University
# See LICENSE for details

#F threadId()
#F
Class(threadId, Exp, rec(
    computeType := self >> TInt
));

#F barrier(<nthreads>, <tid>, <barrier-name>)
#F
#F Example of mapping from SMPBarrier object <o>:
#F    barrier(o.nthreads, o.tid, "&GLOBAL_BARRIER")
#F
Class(barrier, call, rec(
    visitAs := call
));

#F smp_fork(<nthreads>, <cmd>)
#F NOTE: this should take in thread id 'tid' for consistency, but it doesn't!
#F
Class(smp_fork, Command, rec(
    rChildren := self >> [self.nthreads, self.cmd],
    rSetChild := rSetChildFields("nthreads", "cmd"),

    __call__ := (self, nthreads, cmd) >> WithBases(self,
       rec(operations := CmdOps,
           nthreads   := Checked(IsInt(nthreads) or IsScalar(nthreads), nthreads),
           cmd        := Checked(IsCommand(cmd), cmd))),

    print := (self,i,is) >> Print(
         self.__name__, "(", self.nthreads, ",\n",
         Blanks(i+is), self.cmd.print(i+is, is), "\n",
         Blanks(i), ")"
    )
));

#F smp_loop(<nthreads>, <tidvar>, <tidexp>, <loopvar>, <range>, <cmd>)
#F
#F nthreads - # of threads
#F tidvar - thread id variable (will be set to tid value), necessary for nested parallelism
#F tidexp - thread id value
#F
Class(smp_loop, loop_base, rec(
   __call__ := meth(self, nthreads, tidvar, tidexp, loopvar, range, cmd)
       local result;
       Constraint(IsVar(loopvar));
       Constraint(IsCommand(cmd));
       range := toRange(range);
       if range = 0 then
           return skip();
       else
           loopvar.setRange(range);
           loopvar.isLoopIndex := true;
           return WithBases(self, rec(
                   operations := CmdOps,
                   nthreads := nthreads,
                   cmd := cmd,
                   var := loopvar,
                   tidvar := Checked(IsLoc(tidvar), tidvar),
                   tidexp := toExpArg(tidexp),
                   range := range));
       fi;
   end,

   rChildren := self >> [self.nthreads, self.tidvar, self.tidexp, self.var, self.range, self.cmd],
   rSetChild := rSetChildFields("nthreads", "tidvar", "tidexp", "var", "range", "cmd"),

   print := (self, i, is) >> Print(self.name, "(", self.nthreads, ", ",
       self.tidvar, ", ", self.tidexp, ", ", self.var, ", ",
       self.range, ",\n", Blanks(i+is),
       self.cmd.print(i+is, is),
       Print("\n", Blanks(i), ")")),

   DContainer := (self, o, y, x, opts) >> self(o.child(1), y, x, opts),

   free := self >> Difference(self.cmd.free(), [self.var, self.tidvar])
));

# Class(smp_chain, chain, rec(
#    __call__ := meth(arg)
#        local self, nthreads, cmds;
#        [self, nthreads, cmds] := [arg[1], arg[2], Flat(Drop(arg, 2))];
#        return WithBases(self, rec(
#                nthreads   := nthreads,
#                operations := CmdOps,
#                cmds       := Checked(ForAll(cmds, IsCommand), cmds)));
#    end,

#    print := (self,i,is) >> When(Length(self.cmds)=0,
#        Print(self.name, "(", self.nthreads, ")"),
#        Print(self.name, "(", self.nthreads, ",\n", self.printCmds(i+is, is), Blanks(i), ")"))
# ));

Class(SMPCodegenMixin, Codegen, rec(
    SMPBarrier := (self, o, y, x, opts) >> chain(
        self(o.child(1), y, x, opts),
        barrier(o.nthreads, o.tid, "&GLOBAL_BARRIER")),

    SMPSum := (self, o, y, x, opts) >> let(
        outer_tid     := When(IsBound(opts._tid), opts._tid, 0),
        outer_num_thr := When(IsBound(opts._tid), opts._tid.range, 1),
        tid := var.fresh("tid", TInt, o.nthreads * outer_num_thr),
        smp_loop(o.nthreads, tid, (outer_tid * outer_num_thr) + o.tid,
                 o.var, o.domain,
                 self(o.child(1), y, x, CopyFields(opts, rec(_tid := tid))))
    )
));

_PullBuffersSMP := function(expr, type_predicate, nthreads, tid)
    local ch, i, t, data, pullv, stayv;
    if ObjId(expr)=assign then return [[], expr];
    else
        # Implemented as a recursive tree walk
	data := [];

        if ObjId(expr)=decl then
            [pullv, stayv] := SplitBy(expr.vars, x->type_predicate(x.t));
            data := List(pullv, x->[x, nthreads, tid]);
            expr := decl(stayv, expr.cmd);
        elif ObjId(expr)=smp_loop then
            nthreads := nthreads * expr.nthreads;
            tid := expr.tidvar;
        fi;

        ch := _children(expr);
        for i in [1..Length(ch)] do
            t := _PullBuffersSMP(ch[i], type_predicate, nthreads, tid);
            Append(data, t[1]);
            _setChild(expr, i, t[2]);
        od;
        return [data, expr];
    fi;
end;

#F PullBuffersSMP(code, type_predicate)
#F
#F  Pulls out declarations (from decl(..)) that satisfy type_predicate,
#F  and return declared variables as triplets [var, nthreads, tid]
#F
#F  This function handled nested parallelism, thats why the implementation is
#F  not so straightforward.
#F
PullBuffersSMP := (code, type_predicate) -> _PullBuffersSMP(code, type_predicate, 1, 0);


text:
# Copyright (c) 2018-2021, Carnegie Mellon University
# See LICENSE for details

_testJam := (t) -> let(
    xx1 := Last(t.params[2].params[1]),
    xx2 := Last(t.params[3].params[1]),

    (xx1 <> 0 or xx2 <> 0)
    and let(
        M := t.params[1].dims()[1],
        K := t.getTag(ABB).params[1],
        n := When(xx1 <> 0, t.params[4][xx1], t.params[4][xx2]),

		n <= K/2
    )
);

_testIxA := (t) -> let(
    @par := @.cond(e -> e = GTPar),

	PatternMatch(t, [GT, @(1), @par, @par, \.\.\. ], empty_cx())
    and let(
        M := @(1).val.dims()[1],
        K := t.getTag(ABB).params[1],
        m := t.dims()[1],

        K > M
        and m > K
    )
);

_testIxAxI := (t) -> let(
    @ixi := @.cond(e -> e = XChain([1,0,2])),

    PatternMatch(t, [GT, @(1), @ixi, @ixi, \.\.\. ], empty_cx())
    and let(
        M := @(1).val.dims()[1],
        K := t.getTag(ABB).params[1],
        m := t.dims()[1],
        n := t.params[4][1],
        p := t.params[4][2],

		(K/2 < p
		and 1 < K/2)
		or (
			m > K
			and K > M*p
		)
    )
);

_testAxI := (t) -> let(
    @vec := @.cond(e -> e = GTVec),

    PatternMatch(t, [GT, @(1), @vec, @vec, \.\.\. ], empty_cx())
    and let(
        M := @(1).val.dims()[1],
        K := t.getTag(ABB).params[1],
        m := t.dims()[1],
        n := t.params[4][1],

		K/2 < n
		and 1 < K/2
    )
);

NewRulesFor(GT, rec(

    # splits a loop based on basic block size K
    # K is passed in with the tag ABB
    # I_N x A_M -> I_(N/K/M) x I_(K/M) x A_M

    GT_BB_IxA := rec(
        forTransposition := false,
        switch := false,
        applicable := (t) ->
            t.hasTag(ABB)
            and _testIxA(t),

        children := (self, t) >> let(
            K := t.getTag(ABB).params[1],
            spl := t.params[1],
            M := spl.dims()[1],
            n := t.params[4][1],

            r := (K / M),
            s := n / r,

            # if q <=1, just drop the tag, otherwise split the loop
            [[
                GT(
                    spl,
                    XChain([2,1,0]),
                    XChain([2,1,0]),
                    [r, s]
                ).withTags(Filtered(t.getTags(), e -> ObjId(e) <> ABB))
            ]]
        ),

        apply := (self, t, C, nt) >> C[1]
    ),

    # I_n x A_m x I_p, tagged with (K, mu)
    # 1) mp < K
    # 2) mp >= K
    #    a) m > K/mu
    #    b) m <= K/mu
    #    a) p > mu
    #    b) p <= mu

    GT_BB_IxAxI := rec(
        forTransposition := false,
        switch := false,
        applicable := (t) ->
            t.hasTag(ABB)
			and _testIxAxI(t),

        children := (self, t) >> let(
            K := t.getTag(ABB).params[1],
            M := t.params[1].dims()[1],
            spl := t.params[1],
            n := t.params[4][1],
            p := t.params[4][2],
			m := t.dims()[1],

            Cond(
                # cond1
                m > K and K > M*p,
                let(
                    s := K / (M*p),
                    u := n/s,

                    [[GT(
                         spl, XChain([2,1,0,3]), XChain([2,1,0,3]), [s,u,p]
                    ).withTags(t.getTags())]]
                ),

                # cond2
				# p > K/2
                let(
                    s := K / 2,
                    u := p/s,

                    [[GT(
                        spl, XChain([1,0,3,2]), XChain([1,0,3,2]), [n,s,u]
                    ).withTags(t.getTags())]]
                )
            )
        ),

        apply := (self, t, C, nt) >> C[1]
    ),

    #
    GT_BB_AxI := rec(
        forTransposition := false,
        switch := false,
        applicable := (t) ->
            t.hasTag(ABB)
			and _testAxI(t),

        children := (self, t) >> let(
            M := t.params[1].dims()[1],
            K := t.getTag(ABB).params[1],
            n := t.params[4][1],
            spl := t.params[1],

            r := K / 2,
            s := n / r,

            [[GT(
                 spl, XChain([0,2,1]), XChain([0,2,1]), [r,s]
            ).withTags(t.getTags())]]
        ),

        apply := (self, t, C, nt) >> C[1]
    ),

    # when K <= M, we just drop the tag.

    GT_BB_DropTag := rec(
        forTransposition := false,
        switch := false,
        applicable := (self, t) >>
            t.hasTag(ABB)
            and ObjId(t) = GT
            and let(
                K := t.getTag(ABB).params[1],

                K = 2
            ),

        # build a new GT object without the ABB tag.
        children := (self, t) >>
            [[
                t.withoutTag(ABB)
            ]],

        apply := (self, t, C, nt) >> C[1],
    ),

    # just like nthloop except only applicable when
    # the Jam version below isn't.

    GT_BB_NthLoop := CopyFields(GT_NthLoop, rec(
        requiredFirstTag := [AExpRight,ANoTag,ALimitNthLoop,ABB],
        applicable := (t) ->
            Length(t.params[4]) > 0
			and (
				not t.hasTag(ABB)
				or (
					t.hasTag(ABB)
					and not _testIxA(t)
					and not _testIxAxI(t)
					and not _testAxI(t)
					and not _testJam(t)
				)
			)
    )),

    GT_BB_NthLoopJam := rec(
        requiredFirstTag := [ABB,ALimitNthLoop],
        applicable := (t) ->
            Length(t.params[4]) > 0
			and t.hasTag(ABB)
            and _testJam(t),

        # choose the rightmost index.
        freedoms := t -> let(
            xx1 := Last(t.params[2].params[1]),
            xx2 := Last(t.params[3].params[1]),

            When(xx1 <> 0, [[xx1]], [[xx2]])
        ),

        child := (t, fr) -> let(
            spl := t.params[1],
            M := spl.dims()[1],
            g := t.params[2],
            s := t.params[3],
            loopid := fr[1],
            newK := t.getTag(ABB).params[1]/t.params[4][loopid],

            When(t.hasTag(ALimitNthLoop),
                [
                    GT(spl,
                        g.without(loopid),
                        s.without(loopid),
                        ListWithout(t.params[4], loopid)).withTags(
                            When(newK = 2,
                                Filtered(t.getTags(), e -> ObjId(e) <> ABB),
                                Concat(
                                    [ABB(newK)],
                                    Filtered(t.getTags(), e -> ObjId(e) <> ABB)
                                )
                            )
                        ),
                    InfoNt(loopid)
                ],

                [
                    GT(spl, g.without(loopid),
                        s.without(loopid), ListWithout(t.params[4], loopid)),
                    InfoNt(loopid)
                ]
            )
        ),

        apply := (t, C, nt) -> let(
            loopid := nt[2].params[1],
            dft := nt[1].params[1],
            g := t.params[2],
            s := t.params[3],
            loop_dims := t.params[4],
            i := Ind(loop_dims[loopid]),

            JamISum(i,
                Scat(s.part(loopid, i, Rows(dft), loop_dims))
                * C[1]
                * Gath(g.part(loopid, i, Cols(dft), loop_dims))
            )
        )
    )
));


text:
--
-- An instance of this template must have a $Export section and the export_terminals option
--
-- Macros that may be redefined in an instance of this template
--
--     $eof_token
--     $additional_interfaces
--     $super_stream_class -- subclass com.ibm.lpg.LpgLexStream for getKind
--     $prs_stream_class -- use /.PrsStream./ if not subclassing
--     $super_class
--
-- B E G I N N I N G   O F   T E M P L A T E   LexerTemplateF
--
%Options programming_language=rt_cpp,margin=4
%Options table
%options action-block=("*.h", "/.", "./")
%options ParseTable=ParseTable
%Options prefix=Char_

--
-- This template requires that the name of the EOF token be set
-- to EOF and that the prefix be "Char_" to be consistent with
-- KeywordTemplateD.
--
%Eof
    EOF
%End

--
-- This template also requires that the name of the parser EOF
-- Token to be exported be set to EOF_TOKEN
--
%Export
    EOF_TOKEN
%End

%Define
    --
    -- Macros that are be needed in an instance of this template
    --
    $eof_token /.$_EOF_TOKEN./

    $additional_interfaces /../
    $super_stream_class /.$file_prefix$LpgLexStream./
    $prs_stream_class /.IPrsStream./
    $super_class /.Object./

    $prs_stream /. // macro prs_stream is deprecated. Use function getPrsStream
                  getPrsStream()./
    $setSym1 /. // macro setSym1 is deprecated. Use function setResult
               lexParser->setSym1./
    $setResult /. // macro setResult is deprecated. Use function setResult
                 lexParser->setSym1./
    $getSym /. // macro getSym is deprecated. Use function getLastToken
              lexParser->getSym./
    $getToken /. // macro getToken is deprecated. Use function getToken
                lexParser->getToken./
    $getLeftSpan /. // macro getLeftSpan is deprecated. Use function getLeftSpan
                   lexParser->getFirstToken./
    $getRightSpan /. // macro getRightSpan is deprecated. Use function getRightSpan
                    lexParser->getLastToken./

    --
    -- Macros useful for specifying actions
    --
    $Header
    /.
                //
                // Rule $rule_number:  $rule_text
                //
                ./

    $DefaultAction
    /.$Header$case $rule_number: { ./

    $BeginAction /.$DefaultAction./

    $EndAction
    /.            break;
                }./

    $BeginJava
    /.$BeginAction
                $symbol_declarations./

    $EndJava /.$EndAction./

    $NoAction
    /.$Header$case $rule_number:
                    break; ./

    $BeginActions
    /.
         void ruleAction(int ruleNumber)
        {
            switch(ruleNumber)
            {./

    $SplitActions
    /.
                    default:
                        ruleAction$rule_number(ruleNumber);
                        break;
                }
                return;
            }

             void ruleAction$rule_number(int ruleNumber)
            {
                switch (ruleNumber)
                {./

    $EndActions
    /.
                default:
                    break;
            }
            return;
        }./
%End

%Globals
    /.
    ./
%End

%Headers
    /.
    #pragma once
    #include <iostream>
    #include "IPrsStream.h"
    #include "Object.h"
    #include "ParseTable.h"
    #include "RuleAction.h"
    #include "stringex.h"
    #include "Token.h"
    #include "$sym_type.h"
    #include "$prs_type.h"
    #include "$kw_lexer_class.h"
    #include "LexParser.h"
    #include "LpgLexStream.h"
     struct $action_type :public $super_class ,public RuleAction$additional_interfaces
    {
         struct  $super_stream_class;
         $super_stream_class * lexStream = nullptr;

        ~$action_type(){
            delete lexStream;
            delete lexParser;
        }

         inline  static ParseTable* prs = new $prs_type();
         ParseTable* getParseTable() { return prs; }

         LexParser* lexParser = new LexParser();
         LexParser* getParser() { return lexParser; }

         int getToken(int i) { return lexParser->getToken(i); }
         int getRhsFirstTokenIndex(int i) { return lexParser->getFirstToken(i); }
         int getRhsLastTokenIndex(int i) { return lexParser->getLastToken(i); }

         int getLeftSpan() { return lexParser->getToken(1); }
         int getRightSpan() { return lexParser->getLastToken(); }

         void resetKeywordLexer()
        {
            if (kwLexer == nullptr)
                  this->kwLexer = new $kw_lexer_class(lexStream->getInputChars(), $_IDENTIFIER);
            else this->kwLexer->setInput(lexStream->getInputChars());
        }

         void reset(const std::wstring& filename, int tab)
        {
            delete lexStream;
            lexStream = new $super_stream_class(filename, tab);
            lexParser->reset((ILexStream*) lexStream, prs,  this);
            resetKeywordLexer();
        }

         void reset(shared_ptr_wstring input_chars, const std::wstring& filename)
        {
            reset(input_chars, filename, 1);
        }

         void reset(shared_ptr_wstring input_chars, const std::wstring& filename, int tab)
        {
             delete lexStream;
            lexStream = new $super_stream_class(input_chars, filename, tab);
            lexParser->reset((ILexStream*) lexStream, prs,  this);
            resetKeywordLexer();
        }

         $action_type(const std::wstring& filename, int tab)
        {
            reset(filename, tab);
        }

         $action_type(shared_ptr_wstring input_chars, const std::wstring& filename, int tab)
        {
            reset(input_chars, filename, tab);
        }

         $action_type(shared_ptr_wstring input_chars, const std::wstring& filename)
        {
            reset(input_chars, filename, 1);
        }

         $action_type() {}

         ILexStream* getILexStream() { return lexStream; }

        /**
         * @deprecated replaced by {@link #getILexStream()}
         */
         ILexStream* getLexStream() { return lexStream; }

         void initializeLexer($prs_stream_class *prsStream, int start_offset, int end_offset)
        {
            if (!lexStream->getInputChars())
                throw  std::exception("LexStream was not initialized");
            lexStream->setPrsStream(prsStream);
            prsStream->makeToken(start_offset, end_offset, 0); // Token list must start with a bad token
        }

         void addEOF($prs_stream_class *prsStream, int end_offset)
        {
            prsStream->makeToken(end_offset, end_offset, $eof_token); // and end with the end of file token
            prsStream->setStreamLength(prsStream->getSize());
        }

         void lexer($prs_stream_class *prsStream)
        {
            lexer(nullptr, prsStream);
        }

         void lexer(Monitor *monitor, $prs_stream_class *prsStream)
        {
            initializeLexer(prsStream, 0, -1);
            lexParser->parseCharacters(monitor);  // Lex the input characters
            addEOF(prsStream, lexStream->getStreamIndex());
        }

         void lexer($prs_stream_class *prsStream, int start_offset, int end_offset)
        {
            lexer(nullptr, prsStream, start_offset, end_offset);
        }

         void lexer(Monitor* monitor, $prs_stream_class *prsStream, int start_offset, int end_offset)
        {
            if (start_offset <= 1)
                 initializeLexer(prsStream, 0, -1);
            else initializeLexer(prsStream, start_offset - 1, start_offset - 1);

            lexParser->parseCharacters(monitor, start_offset, end_offset);

            addEOF(prsStream, (end_offset >= lexStream->getStreamIndex() ? lexStream->getStreamIndex() : end_offset + 1));
        }

         IPrsStream::Range *incrementalLexer(shared_ptr_wstring input_chars, int start_change_offset, int end_change_offset) {
            int offset_adjustment = input_chars.size() - lexStream->getStreamLength();
//*System.out.println("The offset adjustment is " + offset_adjustment);
            if (start_change_offset <= 0 && start_change_offset < input_chars.size())
            {
                std::string str = "The start offset ";
                std::stringex format;
                format.format("%d", (start_change_offset));
                str += format;
                str += " is out of bounds for range 0..";
                format.format("%d", (input_chars.size() - 1));
                str += format;
                throw  std::out_of_range(str);
            }

            if (end_change_offset <= 0 && end_change_offset < input_chars.size())
            {
                std::string str = "The end offset ";
                std::stringex format;
                format.format("%d", (end_change_offset));
                str += format;
                str += " is out of bounds for range 0..";
                format.format("%d", (input_chars.size() - 1));
                str += format;
            }
            //
            // Get the potential list of tokens to be rescanned
            //
           Tuple<IToken*> affected_tokens = lexStream->getIPrsStream()->incrementalResetAtCharacterOffset(start_change_offset);

            //
            // If the change occured between the first two affected tokens (or adjunct) and not immediately
            // on the characted after the first token (or adjunct), restart the scanning after the first
            // affected token. Otherwise, rescan the first token.
            //
            int affected_index = 0;
            int repair_offset = start_change_offset;
            if (affected_tokens.size() > 0) {
                auto _token_0 = affected_tokens.get(0);
                if (_token_0->getEndOffset() + 1 < start_change_offset)
                {
                     repair_offset = _token_0->getEndOffset() + 1;
                     if (dynamic_cast<Token*>(_token_0))
                    {
                           lexStream->getIPrsStream()->makeToken(_token_0, 0);
                    }
                    else {
                            lexStream->getIPrsStream()->makeAdjunct(_token_0, 0);
                    }

                    affected_index++;
                }
                else
                {
                    repair_offset = _token_0->getStartOffset();
                }
            }

            lexStream->setInputChars(input_chars);
            lexStream->setStreamLength(input_chars.size());
            lexStream->computeLineOffsets(repair_offset);

            int first_new_token_index = lexStream->getIPrsStream()->getTokens().size(),
                first_new_adjunct_index = lexStream->getIPrsStream()->getAdjuncts().size();

            resetKeywordLexer();
            lexParser->resetTokenStream(repair_offset);
            int next_offset;
            do {
//*System.out.println("Scanning token starting at " + (lexStream->peek() - 1));
                next_offset = lexParser->incrementalParseCharacters();
//*System.out.print("***Remaining string: \"");
//*for (int i = next_offset; i < input_chars.length; i++)
//*System.out.print(input_chars[i]);
//*System.out.println("\"");
                while (affected_index < affected_tokens.size() &&
                       affected_tokens.get(affected_index)->getStartOffset() + offset_adjustment < next_offset)
//*{
//*System.out.println("---Skipping token " + affected_index + ": \"" + affected_tokens.get(affected_index).toString() +
//*"\" starting at adjusted offset " + (affected_tokens.get(affected_index).getStartOffset() + offset_adjustment));
                    affected_index++;
//*}
            } while(next_offset <= end_change_offset &&          // still in the damage region and ...
                    (affected_index < affected_tokens.size() &&  // not resynchronized with a token in the list of affected tokens
                     affected_tokens.get(affected_index)->getStartOffset() + offset_adjustment != next_offset));

            //
            // If any new tokens were added, compute the first and the last one.
            //
            IToken* first_new_token = nullptr;
              IToken*      last_new_token = nullptr;
            if (first_new_token_index < lexStream->getIPrsStream()->getTokens().size()) {
                first_new_token = lexStream->getIPrsStream()->getTokenAt(first_new_token_index);
                last_new_token = lexStream->getIPrsStream()->getTokenAt(lexStream->getIPrsStream()->getTokens().size() - 1);
            }
            //
            // If an adjunct was added prior to the first real token, chose it instead as the first token.
            // Similarly, if adjucts were added after the last token, chose the last adjunct added as the last token.
            //
            if (first_new_adjunct_index < lexStream->getIPrsStream()->getAdjuncts().size()) {
                if (first_new_token == nullptr ||
                    lexStream->getIPrsStream()->getAdjunctAt(first_new_adjunct_index)->getStartOffset() <
                    first_new_token->getStartOffset()) {
                    first_new_token = lexStream->getIPrsStream()->getAdjunctAt(first_new_adjunct_index);
                }
                if (last_new_token == nullptr ||
                    lexStream->getIPrsStream()->getAdjunctAt(lexStream->getIPrsStream()->getAdjuncts().size() - 1)->getEndOffset() >
                    last_new_token->getEndOffset()) {
                    last_new_token = lexStream->getIPrsStream()->getAdjunctAt(lexStream->getIPrsStream()->getAdjuncts().size() - 1);
                }
            }

            //
            // For all remainng tokens (and adjuncts) in the list of affected tokens add them to the
            // list of tokens (and adjuncts).
            //
            for (int i = affected_index; i < affected_tokens.size(); i++) {
                if ( dynamic_cast< Token*>(affected_tokens.get(i)) )
                     lexStream->getIPrsStream()->makeToken(affected_tokens.get(i), offset_adjustment);
                else lexStream->getIPrsStream()->makeAdjunct(affected_tokens.get(i), offset_adjustment);
//*System.out.println("+++Added affected token " + i + ": \"" + affected_tokens.get(i).toString() +
//*"\" starting at adjusted offset " + (affected_tokens.get(i).getStartOffset() + offset_adjustment));
            }

            return new IPrsStream::Range(lexStream->getIPrsStream(), first_new_token, last_new_token);
        }

        /**
         * If a parse stream was not passed to this Lexical analyser then we
         * simply report a lexical error. Otherwise, we produce a bad token.
         */
         void reportLexicalError(int startLoc, int endLoc) {
            IPrsStream* prs_stream = lexStream->getIPrsStream();
            if (prs_stream == nullptr)
                lexStream->reportLexicalError(startLoc, endLoc);
            else {
                //
                // Remove any token that may have been processed that fall in the
                // range of the lexical error... then add one error token that spans
                // the error range.
                //
                for (int i = prs_stream->getSize() - 1; i > 0; i--) {
                    if (prs_stream->getStartOffset(i) >= startLoc)
                         prs_stream->removeLastToken();
                    else break;
                }
                prs_stream->makeToken(startLoc, endLoc, 0); // add an error token to the prsStream
            }
        }
    ./
%End

%Rules
    /.$BeginActions./
%End

%Trailers
    /.
        $EndActions
    };
    ./
%End

--
-- E N D   O F   T E M P L A T E
--

max_stars_repo_name: kuafuwang/LPG-VScode

max_issues_repo_name: kuafuwang/LPG-VScode

max_forks_repo_name: kuafuwang/LPG-VScode


text:
--
-- In a parser using this template, the following macro may be redefined:
--
--     $additional_interfaces
--     $ast_class
--
-- B E G I N N I N G   O F   T E M P L A T E   btParserTemplateF
--
%Options programming_language=rt_cpp,margin=4,backtrack
%Options table,error_maps,scopes
%options prefix=TK_
%options action-block=("*.h", "/.", "./")
%options action-block=("*.cpp", "/!", "!/")
%options ast-block=("/!", "!/")
%options ParseTable=ParseTable
%options nt-check

--
-- This template requires that the name of the EOF token be set
-- to EOF_TOKEN to be consistent with LexerTemplateD and LexerTemplateE
--
%EOF
    EOF_TOKEN
%End

%ERROR
    ERROR_TOKEN
%End

%Define

    $Header
    /.
                //
                // Rule $rule_number:  $rule_text
                //
                ./

    $BeginAction
    /!$Header$case $rule_number: {
                   //#line $next_line "$input_file$"!/

    $EndAction
    /!            break;
                }!/

    $BeginJava
    /!$Header$case $rule_number: {
                    $symbol_declarations
                    //#line $next_line "$input_file$"!/

    $EndJava /!$EndAction!/

    $NoAction
    /!$Header$case $rule_number:
                    break;!/

    $BadAction
    /!$Header$case $rule_number:
                    throw  std::exception("No action specified for rule " + $rule_number);!/

    $NullAction
    /!$Header$case $rule_number:
                    setResult(nullptr);
                    break;!/

    $BeginActions
    /!
         #include "$action_type.h"
         void $action_type::ruleAction(int ruleNumber)
        {
            switch (ruleNumber)
            {!/

    $SplitActions
    /!
                    default:
                        ruleAction$rule_number(ruleNumber);
                        break;
                }
                return;
            }

             void ruleAction$rule_number(int ruleNumber)
            {
                switch (ruleNumber)
                {
                    //#line $next_line "$input_file$"!/

    $EndActions
    /!
                default:
                    break;
            }
            return;
        }!/

    $entry_declarations
    /.
         $ast_class * parse$entry_name()
        {
            return parse$entry_name(nullptr, 0);
        }

         $ast_class * parse$entry_name(Monitor* monitor)
        {
            return parse$entry_name(monitor, 0);
        }

         $ast_class * parse$entry_name(int error_repair_count)
        {
            return parse$entry_name(nullptr, error_repair_count);
        }

         $ast_class * parse$entry_name(Monitor *monitor, int error_repair_count)
        {
            btParser->setMonitor(monitor);

            try
            {
                return ($ast_class *) btParser->fuzzyParseEntry($sym_type::$entry_marker, error_repair_count);
            }
            catch (BadParseException& e)
            {
                prsStream->reset(e.error_token); // point to error token

                 std::shared_ptr< DiagnoseParser> diagnoseParser = std::make_shared<DiagnoseParser>(prsStream, prsTable);
                diagnoseParser->diagnoseEntry($sym_type::$entry_marker, e.error_token);
            }

            return nullptr;
        }
    ./

    --
    -- Macros that may be needed in a parser using this template
    --
    $additional_interfaces /../
    $ast_class /.$ast_type./
    $super_class /.Object./
    $unimplemented_symbols_warning /.false./

    --
    -- Old deprecated macros that should NEVER be used.
    --
    $setSym1 /. // macro setSym1 is deprecated. Use function setResult
                getParser().setSym1./
    $setResult /. // macro setResult is deprecated. Use function setResult
                 getParser().setSym1./
    $getSym /. // macro getSym is deprecated. Use function getRhsSym
              getParser().getSym./
    $getToken /. // macro getToken is deprecated. Use function getRhsTokenIndex
                getParser().getToken./
    $getIToken /. // macro getIToken is deprecated. Use function getRhsIToken
                 prsStream->getIToken./
    $getLeftSpan /. // macro getLeftSpan is deprecated. Use function getLeftSpan
                   getParser().getFirstToken./
    $getRightSpan /. // macro getRightSpan is deprecated. Use function getRightSpan
                    getParser().getLastToken./
%End

%Globals
    /.
#pragma once

#include <iostream>
#include "AstPoolHolder.h"
#include "BacktrackingParser.h"
#include "DeterministicParser.h"
#include "diagnose.h"
#include "ErrorToken.h"
#include "Exception.h"
#include "IAbstractArrayList.h"
#include "IAst.h"
#include "IAstVisitor.h"
#include "ILexStream.h"
#include "$sym_type.h"
#include "$prs_type.h"
#include "Object.h"
#include "ParseTable.h"
#include "PrsStream.h"
#include "RuleAction.h"
#include "IcuUtil.h"
#include "stringex.h"
#include "Any.h"
    ./
%End

%Headers
    /.
     struct $action_type :public $super_class ,public RuleAction$additional_interfaces
    {

        PrsStream* prsStream = nullptr;
        ~$action_type (){
            delete prsStream;
            delete btParser;
        }
         bool unimplementedSymbolsWarning = $unimplemented_symbols_warning;

         inline static ParseTable* prsTable = new $prs_type();
         ParseTable* getParseTable() { return prsTable; }

         BacktrackingParser* btParser = nullptr;
         BacktrackingParser* getParser() { return btParser; }

         void setResult(Object* object) { btParser->setSym1(object); }
         Object* getRhsSym(int i) { return btParser->getSym(i); }

         int getRhsTokenIndex(int i) { return btParser->getToken(i); }
         IToken* getRhsIToken(int i) { return prsStream->getIToken(getRhsTokenIndex(i)); }

         int getRhsFirstTokenIndex(int i) { return btParser->getFirstToken(i); }
         IToken* getRhsFirstIToken(int i) { return prsStream->getIToken(getRhsFirstTokenIndex(i)); }

         int getRhsLastTokenIndex(int i) { return btParser->getLastToken(i); }
         IToken* getRhsLastIToken(int i) { return prsStream->getIToken(getRhsLastTokenIndex(i)); }

         int getLeftSpan() { return btParser->getFirstToken(); }
         IToken* getLeftIToken()  { return prsStream->getIToken(getLeftSpan()); }

         int getRightSpan() { return btParser->getLastToken(); }
         IToken* getRightIToken() { return prsStream->getIToken(getRightSpan()); }

         int getRhsErrorTokenIndex(int i)
        {
            int index = btParser->getToken(i);
            IToken* err = prsStream->getIToken(index);
            return ( dynamic_cast<ErrorToken*>(err) ? index : 0);
        }
         ErrorToken * getRhsErrorIToken(int i)
        {
            int index = btParser->getToken(i);
            IToken* err = prsStream->getIToken(index);
            return (ErrorToken*) ( dynamic_cast<ErrorToken*>(err) ? err : nullptr);
        }

         void reset(ILexStream* lexStream)
        {
            delete prsStream;
            prsStream = new PrsStream(lexStream);
            btParser->reset(prsStream);

            try
            {
                prsStream->remapTerminalSymbols(orderedTerminalSymbols(), prsTable->getEoftSymbol());
            }
            catch (NullExportedSymbolsException& e) {
            }
            catch (NullTerminalSymbolsException& e) {
            }
            catch (UnimplementedTerminalsException& e)
            {
                if (unimplementedSymbolsWarning) {
                   auto unimplemented_symbols = e.getSymbols();
                    std::cout << "The Lexer will not scan the following token(s):" << std::endl;
                    for (int i = 0; i < unimplemented_symbols.size(); i++)
                    {
                        auto id = unimplemented_symbols.at(i);
                        std::wcout <<L"    " << $sym_type::orderedTerminalSymbols[id] << std::endl;
                    }
                   std::cout <<std::endl;
                }
            }
            catch (UndefinedEofSymbolException& e)
            {
                std::stringex str= "The Lexer does not implement the Eof symbol ";
                str += IcuUtil::ws2s($sym_type::orderedTerminalSymbols[prsTable->getEoftSymbol()]);
                throw  UndefinedEofSymbolException(str);
            }
        }

         $action_type(ILexStream* lexStream = nullptr)
        {
            try
            {
                btParser = new BacktrackingParser(prsStream, prsTable,  this);
            }
            catch (NotBacktrackParseTableException& e)
            {
                throw ( NotBacktrackParseTableException
                                    ("Regenerate $prs_type.java with -BACKTRACK option"));
            }
            catch (BadParseSymFileException& e)
            {
                throw ( BadParseSymFileException("Bad Parser Symbol File -- $sym_type::java"));
            }

            if(lexStream)
            {
                reset(lexStream);
            }
        }

         int numTokenKinds() { return $sym_type::numTokenKinds; }
         std::vector<std::wstring> orderedTerminalSymbols() {
             return $sym_type::orderedTerminalSymbols;
        }
         std::wstring getTokenKindName(int kind) { return $sym_type::orderedTerminalSymbols[kind]; }
         int getEOFTokenKind() { return prsTable->getEoftSymbol(); }
         IPrsStream* getIPrsStream() { return prsStream; }

        /**
         * @deprecated replaced by {@link #getIPrsStream()}
         *
         */
         PrsStream* getPrsStream() { return prsStream; }

        /**
         * @deprecated replaced by {@link #getIPrsStream()}
         *
         */
         PrsStream* getParseStream() { return prsStream; }

         $ast_class* parser()
        {
            return parser(nullptr, 0);
        }

         $ast_class* parser(Monitor* monitor)
        {
            return parser(monitor, 0);
        }

         $ast_class * parser(int error_repair_count)
        {
            return parser(nullptr, error_repair_count);
        }

         $ast_class * parser(Monitor* monitor, int error_repair_count)
        {
            btParser->setMonitor(monitor);

            try
            {
                return ($ast_class *) btParser->fuzzyParse(error_repair_count);
            }
            catch (BadParseException& e)
            {
                prsStream->reset(e.error_token); // point to error token

                std::shared_ptr< DiagnoseParser> diagnoseParser = std::make_shared<DiagnoseParser>(prsStream, prsTable);
                diagnoseParser->diagnose(e.error_token);
            }

            return nullptr;
        }
         void ruleAction(int ruleNumber);
        //
        // Additional entry points, if any
        //
        $entry_declarations
    ./

%End

%Rules
    /!$BeginActions!/
%End

%Trailers
    /.
    };
    ./

     /!
        $EndActions
    !/
%End

--
-- E N D   O F   T E M P L A T E
--


text:
%Define
    $kw_lexer_class /.NoKWLexer./
    $_IDENTIFIER /.0./
%End
%Headers
    --
    -- Additional methods for the action class not provided in the template
    --
    /.
          export   class NoKWLexer
        {
            public  getKeywordKinds() :number[]{ return null; }

            public  lexer(curtok : number, lasttok : number): number { return 0; }

            public  setInputChars(inputChars : string) : void{ }

            public  getKind(c : number) : number{ return 0; }

            public NoKWLexer(inputChars : string,  identifierKind : number) { }
        }
    ./
%End

%Import
    LexerBasicMapF.gi
%End


text:
# Copyright 2018-2019, Carnegie Mellon University
# See LICENSE for details

Class(implies,  AutoFoldExp, rec(    computeType := self >> TBool      ));

Class(RulesTest, RuleSet, rec(inType := "iCode", outType := "iCode"));
RewriteRules(RulesTest, rec(
 float_reduction  := ARule(DirectSum, [@(1), @(2, OLCompose, e->ObjId(e.child(1))=Reduction)],
                        e->[DirectSum(@(2).val, @(1).val)]),
    ));

Class(RulesEagarEval, RuleSet, rec(inType := "iCode", outType := "iCode"));
RewriteRules(RulesEagarEval, rec(
		eagar_eval_eq := Rule([@(1, eq), @(2), @(3).cond( e->e=@(2).val)],
                    e->let(V(true))),

		eagar_eval_ands_1 := Rule([@(1, logic_and),
										@(2, Value).cond(e->IsBool(e.v)),
										@(3,Value).cond(e->IsBool(e.v))],
                    e->logic_and(@(2).val, @(3).val)),

		eagar_eval_ands_2 := Rule([@(1, logic_and),
										@(2, Value).cond(e->IsBool(e.v)),
										@(3)],
                    e->Cond(@(2).val.v, @(3).val, V(false))),

		eagar_eval_ands_3 := Rule([@(1, logic_and),
										@(2),
										@(3, Value).cond(e->IsBool(e.v))],
                    e->Cond(@(3).val.v, @(2).val, V(false))),

));

update_params := function(cx, d)
  cx.opts.params := cx.opts.params::[d];
end;

Class(RulesTranslate, RuleSet, rec(inType := "iCode", outType := "SigmaSPL"));
RewriteRules(RulesTranslate, rec(
        abs_inclusion := ARule(logic_and, [@(1,implies), @(2,implies, e->let(
                                 e.args[1].args[1]=@(1).val.args[1].args[1] and    #anthesdent must be the same
                                 e.args[1].args[2]=@(1).val.args[1].args[2] and    #anthesdent must be the same
                                 ((ObjId(e.args[1])=leq and ObjId(@(1).val.args[1])=geq) or
                                  (ObjId(e.args[1])=geq and ObjId(@(1).val.args[1])=leq)) and
                                 e.args[2].args[2]=@(1).val.args[2].args[2]))],
                    e->[let(x := var.fresh_t("x", T_Real(32)),
                             i := Ind(1),
                                PointWise(1, Lambda([x, i], ObjId(@(1).val.args[2])(abs(@(2).val.args[1].args[1]), @(1).val.args[2].args[2]))))]),

        ands_translate := ARule(logic_and, [@(1), @(2)],
                   e-> [let(i := Ind(1), x := var.fresh_t("x", T_Real(32)),
                           lhs := ObjId(@(1).val), rhs:= ObjId(@(2).val),
                          OLCompose(
                            Reduction(2, (a, b)->logic_and(a, b), V(true), False),
                            DirectSum(
                                Cond(lhs<>PointWise, PointWise(1, Lambda([x, i], @(1).val)), @(1).val),
                                Cond(rhs<>PointWise, PointWise(1, Lambda([x, i], @(2).val)), @(2).val)  ))  )]),
        ors_translate := ARule(logic_or, [@(1), @(2)],
                   e-> [let(i := Ind(1), x := var.fresh_t("x", T_Real(32)),
                           lhs := ObjId(@(1).val), rhs:= ObjId(@(2).val),
                          OLCompose(
                          Reduction(2, (a, b)->logic_or(a, b), V(false), False),
                          DirectSum(
                                Cond(lhs<>PointWise, PointWise(1, Lambda([x, i], @(1).val)), @(1).val),
                                Cond(rhs<>PointWise, PointWise(1, Lambda([x, i], @(2).val)), @(2).val)  ))  )]),

        undo_nesting := Rule(@(1,PointWise, e->IsLambda(e.op) and IsSPL(e.op.expr)),
                    e->Cond(
						ObjId(e.op.expr).name="OLCompose", OLCompose(e.op.expr.children()),
						ObjId(e.op.expr).name="PointWise", PointWise(e.op.expr.N, Lambda( e.op.expr.op.vars, e.op.expr.op.expr)),
Error("Not Implemented")						)),

		swap_ds_child := Rule([@(1, DirectSum), @(2).cond(e->ObjId(e)<>OLCompose), [@(3, OLCompose), @(4, Reduction), @(5)]],
			e->DirectSum(@(3).val, @(2).val)),

		swap_ds_child_1 := ARule(DirectSum, [@(1, PointWise), @(2, OLCompose)],
			e->[DirectSum(@(2).val, @(1).val)]),

		max_intro := Rule([@(1, OLCompose), @(2, Reduction).cond(e->e.idval=false and e.N=2),
						[@(3, DirectSum), @(4, PointWise),
							@(5, PointWise).cond(e->ObjId(e.op.expr)=ObjId(@(4).val.op.expr) and
								ObjId(e.op.expr) = gt and
								e.op.expr.args[2] = @(4).val.op.expr.args[2])]],
			e-> PointWise(1, Lambda(@(4).val.op.vars, gt(max(@(4).val.op.expr.args[1], @(5).val.op.expr.args[1]), @(4).val.op.expr.args[2])))  ),

		reduce_reduction := Rule([@(1, OLCompose), @(2, Reduction), [@(3, DirectSum), [@(4, OLCompose), @(5, Reduction).cond(e->e.idval=@(2).val.idval), @(6)], @(7)]],
			e-> OLCompose(
					Reduction(@(2).val.N + @(5).val.N-1, @(2).val.op, @(2).val.idval, @(2).val.isSaturated),
					DirectSum(@(6).val, @(7).val) )),

		intro_polynomial := Rule([@(1, PointWise), @(2), @(3, Lambda).cond(e->ObjId(e.expr)=gt and
																			  ObjId(e.expr.args[1]) = max and                                   #check max of all abs values
																			  Length(Filtered(List(e.expr.args[1].args, i->ObjId(i)=abs), x->x=false))=0 and
																			  Length(Collect(e.expr.args[2], pow))<>0                           #has degree higher than 1
																			  #Length(Filtered(List(Collect(e.expr.args[2], pow), i->IsInt(i.args[2])), x->x=false))=0  # and exponents are numeric
															  				   #still need to check for sub within the abs operator to be sure that it is TDistance

																			  )],
			(e, cx)->let(d := var.fresh_t("d", TPtr(T_Real(64))),
				   update_params(cx,d),
				   degree := ApplyFunc(max, List(Collect(@(3).val.expr.args[2], pow), i->i.args[2])),
				   TLess(TEvalPolynomial(degree.v, d), TDistance(TInfinityNorm(2)))))
    ));

TInt_Base.check := v->Cond(IsExp(v), Int(v.ev()),
						   IsInt(v), v,
						   IsBool(v), When(v, true, false),
						    IsDouble(v) and IsInt(IntDouble(v)), IntDouble(v),
							IsValue(v) and IsInt(v.v), v.v,
							Error("<v> must be an integer or an expression"));

TReal.check := (self, v) >> Cond(
							IsExp(v), 		ReComplex(Complex(code.EvalScalar(v))),
							IsInt(v), 		Double(v),
							IsRat(v), 		v,
							IsDouble(v), When(AbsFloat(v) < self.cutoff, 0.0, v),
							IsCyc(v), ReComplex(Complex(v)),
							IsComplex(v),	ReComplex(v),
							IsBool(v), 		When(v, true, false),
							Error("<v> must be a double or an expression"));

max_stars_repo_name: spiral-software/spiral-package-hcol

max_issues_repo_name: spiral-software/spiral-package-hcol

max_forks_repo_name: spiral-software/spiral-package-hcol


text:
SplitString("Hello,How,Are,You,Today", ",");
# [ "Hello", "How", "Are", "You", "Today" ]

JoinStringsWithSeparator(last, ".");
# "Hello.How.Are.You.Today"


text:
# GAP knows gaussian integers, gaussian rationals (i.e. Q[i]), and cyclotomic fields. Here are some examples.
# E(n) is an nth primitive root of 1
i := Sqrt(-1);
# E(4)
(3 + 2*i)*(5 - 7*i);
# 29-11*E(4)
1/i;
# -E(4)
Sqrt(-3);
# E(3)-E(3)^2

i in GaussianIntegers;
# true
i/2 in GaussianIntegers;
# false
i/2 in GaussianRationals;
# true
Sqrt(-3) in Cyclotomics;
# true