text:
da2 :=
[
    [#(1) filter9 ((1)-(34) are from http://homepages.math.uic.edu/~jan/demo.html)
        [m2*m4*m6 - 1/100,
 a*m4*b - 7/500,
 a**2 + m1**2 - 2/25,
 b**2 + m7**2 - 37/50,
 m3**2 + m5**2 + m4**2 + m2**2 + m6**2 - 9401/10000,
 m4**2*m6**2 + m2**2*m4**2 + m3**2*m6**2 + m2**2*m5**2
 + m3**2*m5**2 + m2**2*m6**2 - 38589/1000000,
 m1*m3*m5*m7 - m6*m1*m3*b + m2*m6*a*b - m2*a*m5*m7 + 81/10000,
 -m1*m2*m3*m4*b - a*m4*m5*m6*m7 + a*m4*b*m6**2 + a*m2**2*m4*b + 39/25000,
 -m4**2*m7**2 - m3**2*m7**2 + 2*m5*m6*b*m7 - m2**2*m7**2 - m5**2*m7**2
- m3**2*b**2 - b**2*m6**2 - m2**2*b**2 + 27173/40000
        ],
        [m1,m2,m3,m4,m5,m6,m7,a,b]
    ],
    [#(2) katsura6
        [ 1*x1+2*x2+2*x3+2*x4+2*x5+2*x6+2*x7-1,
 2*x4*x3+2*x5*x2+2*x6*x1+2*x7*x2-1*x6,
 1*x3^2+2*x4*x2+2*x5*x1+2*x6*x2+2*x7*x3-1*x5,
 2*x3*x2+2*x4*x1+2*x5*x2+2*x6*x3+2*x7*x4-1*x4,
 1*x2^2+2*x3*x1+2*x4*x2+2*x5*x3+2*x6*x4+2*x7*x5-1*x3,
 2*x2*x1+2*x3*x2+2*x4*x3+2*x5*x4+2*x6*x5+2*x7*x6-1*x2,
 1*x1^2+2*x2^2+2*x3^2+2*x4^2+2*x5^2+2*x6^2+2*x7^2-1*x1
        ],
        [x1,x2,x3,x4,x5,x6,x7]
    ],
    [#(3) katsura7
        [-x1+2*x8^2+2*x7^2+2*x6^2+2*x5^2+2*x4^2+2*x3^2+2*x2^2+x1^2,
 -x2+2*x8*x7+2*x7*x6+2*x6*x5+2*x5*x4+2*x4*x3+2*x3*x2+2*x2*x1,
 -x3+2*x8*x6+2*x7*x5+2*x6*x4+2*x5*x3+2*x4*x2+2*x3*x1+x2^2,
 -x4+2*x8*x5+2*x7*x4+2*x6*x3+2*x5*x2+2*x4*x1+2*x3*x2,
 -x5+2*x8*x4+2*x7*x3+2*x6*x2+2*x5*x1+2*x4*x2+x3^2,
 -x6+2*x8*x3+2*x7*x2+2*x6*x1+2*x5*x2+2*x4*x3,
 -x7+2*x8*x2+2*x7*x1+2*x6*x2+2*x5*x3+x4^2,
 -1+2*x8+2*x7+2*x6+2*x5+2*x4+2*x3+2*x2+x1
        ],
        [x1,x2,x3,x4,x5,x6,x7,x8]
    ],
    [#(4) katsura8
        [ -x1+2*x9^2+2*x8^2+2*x7^2+2*x6^2+2*x5^2+2*x4^2+2*x3^2+2*x2^2+x1^2,
 -x2+2*x9*x8+2*x8*x7+2*x7*x6+2*x6*x5+2*x5*x4+2*x4*x3+2*x3*x2+2*x2*x1,
 -x3+2*x9*x7+2*x8*x6+2*x7*x5+2*x6*x4+2*x5*x3+2*x4*x2+2*x3*x1+x2^2,
 -x4+2*x9*x6+2*x8*x5+2*x7*x4+2*x6*x3+2*x5*x2+2*x4*x1+2*x3*x2,
 -x5+2*x9*x5+2*x8*x4+2*x7*x3+2*x6*x2+2*x5*x1+2*x4*x2+x3^2,
 -x6+2*x9*x4+2*x8*x3+2*x7*x2+2*x6*x1+2*x5*x2+2*x4*x3,
 -x7+2*x9*x3+2*x8*x2+2*x7*x1+2*x6*x2+2*x5*x3+x4^2,
 -x8+2*x9*x2+2*x8*x1+2*x7*x2+2*x6*x3+2*x5*x4,
 -1+2*x9+2*x8+2*x7+2*x6+2*x5+2*x4+2*x3+2*x2+x1
        ],
        [x1,x2,x3,x4,x5,x6,x7,x8,x9]
    ],
    [#(5) katsura9
        [ -x1+2*x10^2+2*x9^2+2*x8^2+2*x7^2+2*x6^2+2*x5^2+2*x4^2+2*x3^2+2*x2^2+x1^2,
 -x2+2*x10*x9+2*x9*x8+2*x8*x7+2*x7*x6+2*x6*x5+2*x5*x4+2*x4*x3+2*x3*x2+2*x2*x1,
 -x3+2*x10*x8+2*x9*x7+2*x8*x6+2*x7*x5+2*x6*x4+2*x5*x3+2*x4*x2+2*x3*x1+x2^2,
 -x4+2*x10*x7+2*x9*x6+2*x8*x5+2*x7*x4+2*x6*x3+2*x5*x2+2*x4*x1+2*x3*x2,
 -x5+2*x10*x6+2*x9*x5+2*x8*x4+2*x7*x3+2*x6*x2+2*x5*x1+2*x4*x2+x3^2,
 -x6+2*x10*x5+2*x9*x4+2*x8*x3+2*x7*x2+2*x6*x1+2*x5*x2+2*x4*x3,
 -x7+2*x10*x4+2*x9*x3+2*x8*x2+2*x7*x1+2*x6*x2+2*x5*x3+x4^2,
 -x8+2*x10*x3+2*x9*x2+2*x8*x1+2*x7*x2+2*x6*x3+2*x5*x4,
 -x9+2*x10*x2+2*x9*x1+2*x8*x2+2*x7*x3+2*x6*x4+x5^2,
 -1+2*x10+2*x9+2*x8+2*x7+2*x6+2*x5+2*x4+2*x3+2*x2+x1
        ],
        [x1,x2,x3,x4,x5,x6,x7,x8,x9,x10]
    ],
    [#(6) katsura10
        [ -x1+2*x11^2+2*x10^2+2*x9^2+2*x8^2+2*x7^2+2*x6^2+2*x5^2+2*x4^2+2*x3^2+2*x2^2+x1^2,
 -x2+2*x11*x10+2*x10*x9+2*x9*x8+2*x8*x7+2*x7*x6+2*x6*x5+2*x5*x4+2*x4*x3+2*x3*x2+2*x2*x1,
 -x3+2*x11*x9+2*x10*x8+2*x9*x7+2*x8*x6+2*x7*x5+2*x6*x4+2*x5*x3+2*x4*x2+2*x3*x1+x2^2,
 -x4+2*x11*x8+2*x10*x7+2*x9*x6+2*x8*x5+2*x7*x4+2*x6*x3+2*x5*x2+2*x4*x1+2*x3*x2,
 -x5+2*x11*x7+2*x10*x6+2*x9*x5+2*x8*x4+2*x7*x3+2*x6*x2+2*x5*x1+2*x4*x2+x3^2,
 -x6+2*x11*x6+2*x10*x5+2*x9*x4+2*x8*x3+2*x7*x2+2*x6*x1+2*x5*x2+2*x4*x3,
 -x7+2*x11*x5+2*x10*x4+2*x9*x3+2*x8*x2+2*x7*x1+2*x6*x2+2*x5*x3+x4^2,
 -x8+2*x11*x4+2*x10*x3+2*x9*x2+2*x8*x1+2*x7*x2+2*x6*x3+2*x5*x4,
 -x9+2*x11*x3+2*x10*x2+2*x9*x1+2*x8*x2+2*x7*x3+2*x6*x4+x5^2,
 -x10+2*x11*x2+2*x10*x1+2*x9*x2+2*x8*x3+2*x7*x4+2*x6*x5,
 -1+2*x11+2*x10+2*x9+2*x8+2*x7+2*x6+2*x5+2*x4+2*x3+2*x2+x1
        ],
        [x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11]
    ],
    [#(7) utbikker
        [ x^2+x*y+y^2-2*x*z-4*y*z+3*z^2-3*x*t+2*y*t+t^2-3*x-2*y+3*z-2*t-2,
 2*x^2-x*y+y^2-x*z-y*z-6*z^2-x*t+y*t-5*z*t-3*t^2-5*x+y+5*z+2*t+5,
 -3-3*x*y+2*x*z+x*t^2-5*x*z^2-5*z^2*t-3*x*t-2*z*t+x*y*z+x*y*t-x^2*z+x^2
 -y^2+2*z^2+11*z-2*t-x+y+x^3+y^3-3*z^3+2*t^3-3*t^2-5*y^2*z+7*y*z^2,
 -15+2*x*y+11*x*t^2+5*x*z^2-z*t-4*x*y*z+6*x*y*t-x^2*z+3*x^2+2*y^2-z^2+4*z
 -10*t-35*x-14*y-x^3+6*y^3+15*z^3+4*t^3+5*t^2+6*y^2*z+4*y*z^2-x*z*t+6*x^2*y
 -12*x*y^2-7*y^2*t+2*y*t
        ],
        [x,y,z,t]
    ],
    [#(8) kotsireas
        [ (b-d1)*(a-c) - 2*f + 2,
 (b-d1)*(a+c-2*f) + 2*(a-c),
 (b-d1)*(b-d1) - 2*(b+d1) + t + 1,
 a**2*b**3 - 1,
 c**2*d1**3 - 1,
 f**2*t**3 - 1
        ],
        [a,b,c,d1,f,t]
    ],
    [#(9) chandra4
        [ 8*H1 - 051234/100000*H1*(1+(1/2)*H1+(1/3)*H2+(1/4)*H3) - 8,
 8*H2 - 051234/100000*H2*(1+(2/3)*H1+(2/4)*H2+(2/5)*H3) - 8,
 8*H3 - 051234/100000*H3*(1+(3/4)*H1+(3/5)*H2+(3/6)*H3) - 8,
 8*H4 - 051234/100000*H4*(1+(4/5)*H1+(4/6)*H2+(4/7)*H3) - 8
        ],
        [H1,H2,H3,H4]
    ],
    [#(10) chandra5
        [ 10*H1 - 051234/100000*H1*(1+(1/2)*H1+(1/3)*H2+(1/4)*H3+(1/5)*H4) - 10,
 10*H2 - 051234/100000*H2*(1+(2/3)*H1+(2/4)*H2+(2/5)*H3+(2/6)*H4) - 10,
 10*H3 - 051234/100000*H3*(1+(3/4)*H1+(3/5)*H2+(3/6)*H3+(3/7)*H4) - 10,
 10*H4 - 051234/100000*H4*(1+(4/5)*H1+(4/6)*H2+(4/7)*H3+(4/8)*H4) - 10,
 10*H5 - 051234/100000*H5*(1+(5/6)*H1+(5/7)*H2+(5/8)*H3+(5/9)*H4) - 10
        ],
        [H1,H2,H3,H4,H5]
    ],
    [#(11) chandra6
        [ 12*H1 - 051234/100000*H1*(1+(1/2)*H1+(1/3)*H2+(1/4)*H3+(1/5)*H4+(1/6)*H5) - 12,
 12*H2 - 051234/100000*H2*(1+(2/3)*H1+(2/4)*H2+(2/5)*H3+(2/6)*H4+(2/7)*H5) - 12,
 12*H3 - 051234/100000*H3*(1+(3/4)*H1+(3/5)*H2+(3/6)*H3+(3/7)*H4+(3/8)*H5) - 12,
 12*H4 - 051234/100000*H4*(1+(4/5)*H1+(4/6)*H2+(4/7)*H3+(4/8)*H4+(4/9)*H5) - 12,
 12*H5 - 051234/100000*H5*(1+(5/6)*H1+(5/7)*H2+(5/8)*H3+(5/9)*H4+(5/10)*H5) - 12,
 12*H6 - 051234/100000*H6*(1+(6/7)*H1+(6/8)*H2+(6/9)*H3+(6/10)*H4+(6/11)*H5) - 12
        ],
        [H1,H2,H3,H4,H5,H6]
    ],
    [#(12) tangents0
        [x0**2+x1**2+x2**2-1,
x0*x3+x1*x4+x2*x5,
 50*x0**2-2*x0*x4+ 14*x0*x5+x1**2-14*x1*x2+ 2*x1*x3+ 49*x2**2-14*x2*x3+x3**2
+x4**2+x5**2-1,
 29*x0**2-10*x0*x1-4*x0*x2-4*x0*x4+ 10*x0*x5+ 5*x1**2-20*x1*x2+ 4*x1*x3-2*x1
*x5+ 26*x2**2-10*x2*x3+ 2*x2*x4+x3**2+x4**2+x5**2-1,
 9*x0**2-6*x0*x5+ 9*x2**2+ 6*x2*x3+x3**2+x4**2+x5**2-1,
 9*x0**2+ 6*x0*x5+ 9*x2**2-6*x2*x3+x3**2+x4**2+x5**2-1
        ],
        [x0,x1,x2,x3,x4,x5]
    ],
    [#(13) assur44
        [ ca^2+sa^2-1,
 cb^2+sb^2-1,
 cc^2+sc^2-1,
 cd^2+sd^2-1,
 8*cc*cb*ca+8*cc*cb*sa-8*cc*sb*ca+8*cc*sb*sa-8*sc*cb*ca+8*sc*cb*sa-8*sc*
 sb*ca-8*sc*sb*sa+24*cc*cb-24*cc*sb-24*sc*cb-24*sc*sb-16*cb*ca+12*cb*sa-12*sb*ca
-16*sb*sa-4*cc+28*sc-48*cb-36*sb+24*ca+48,
 -8*cd*cb*ca+16*cd*cb*sa-16*cd*sb*ca-8*cd*sb*sa+16*sd*cb*ca+8*sd*cb*sa-8*
sd*sb*ca+16*sd*sb*sa-32*cd*cb+86*cd*sb-86*sd*cb-32*sd*sb+8*cb*ca+12*cb*sa-12*sb
*ca+8*sb*sa+16*cd+28*sd-73*cb+12*sb-28*ca-30*sa+112,
 -980*cd*cb*ca-1960*cd*cb*sa+1960*cd*sb*ca-980*cd*sb*sa-1960*sd*cb*ca+980
*sd*cb*sa-980*sd*sb*ca-1960*sd*sb*sa+280*cc*cb*ca-1400*cc*cb*sa+1400*cc*sb*ca+
280*cc*sb*sa+1400*sc*cb*ca+280*sc*cb*sa-280*sc*sb*ca+1400*sc*sb*sa+6300*cd*cc-
4900*cd*sc+6860*cd*cb+8330*cd*sb-4900*sd*cc-6300*sd*sc-8330*sd*cb+6860*sd*sb+
6860*cc*cb+1540*cc*sb+1540*sc*cb-6860*sc*sb+56*cb*ca+2268*cb*sa-2268*sb*ca+56*
sb*sa-11480*cd+5390*sd-8060*cc+1820*sc-10094*cb-4788*sb+784*ca-1764*sa+19798,
 280*cd*cc-280*sd*sc-336*cd-240*cc+391
        ],
        [ca,cb,cc,cd,sa,sb,sc,sd]
    ],
    [#(14) cyclic9
        [ z0 + z1 + z2 + z3 + z4 + z5 + z6 + z7 + z8,
  z0*z1 + z1*z2 + z2*z3 + z3*z4 + z4*z5 + z5*z6 + z6*z7 + z7*z8 + z8*z0,
  z0*z1*z2 + z1*z2*z3 + z2*z3*z4 + z3*z4*z5 + z4*z5*z6 + z5*z6*z7
+ z6*z7*z8 + z7*z8*z0 + z8*z0*z1,
  z0*z1*z2*z3 + z1*z2*z3*z4 + z2*z3*z4*z5 + z3*z4*z5*z6 + z4*z5*z6*z7
+ z5*z6*z7*z8 + z6*z7*z8*z0 + z7*z8*z0*z1 + z8*z0*z1*z2,
  z0*z1*z2*z3*z4 + z1*z2*z3*z4*z5 + z2*z3*z4*z5*z6 + z3*z4*z5*z6*z7
+ z4*z5*z6*z7*z8 + z5*z6*z7*z8*z0 + z6*z7*z8*z0*z1 + z7*z8*z0*z1*z2
+ z8*z0*z1*z2*z3,
  z0*z1*z2*z3*z4*z5 + z1*z2*z3*z4*z5*z6 + z2*z3*z4*z5*z6*z7 + z3*z4*z5*z6*z7*z8
+ z4*z5*z6*z7*z8*z0 + z5*z6*z7*z8*z0*z1 + z6*z7*z8*z0*z1*z2 + z7*z8*z0*z1*z2*z3
+ z8*z0*z1*z2*z3*z4,
  z0*z1*z2*z3*z4*z5*z6 + z1*z2*z3*z4*z5*z6*z7 + z2*z3*z4*z5*z6*z7*z8
+ z3*z4*z5*z6*z7*z8*z0 + z4*z5*z6*z7*z8*z0*z1 + z5*z6*z7*z8*z0*z1*z2
+ z6*z7*z8*z0*z1*z2*z3 + z7*z8*z0*z1*z2*z3*z4 + z8*z0*z1*z2*z3*z4*z5,
  z0*z1*z2*z3*z4*z5*z6*z7 + z1*z2*z3*z4*z5*z6*z7*z8 + z2*z3*z4*z5*z6*z7*z8*z0
+ z3*z4*z5*z6*z7*z8*z0*z1 + z4*z5*z6*z7*z8*z0*z1*z2 + z5*z6*z7*z8*z0*z1*z2*z3
+ z6*z7*z8*z0*z1*z2*z3*z4 + z7*z8*z0*z1*z2*z3*z4*z5 + z8*z0*z1*z2*z3*z4*z5*z6,
  z0*z1*z2*z3*z4*z5*z6*z7*z8 - 1
        ],
        [z0,z1,z2,z3,z4,z5,z6,z7,z8]
    ],
    [#(15) cyclic10
        [  z0 + z1 + z2 + z3 + z4 + z5 + z6 + z7 + z8 + z9,
  z0*z1 + z1*z2 + z2*z3 + z3*z4 + z4*z5 + z5*z6 + z6*z7 + z7*z8 + z8*z9 + z9*z0,
  z0*z1*z2 + z1*z2*z3 + z2*z3*z4 + z3*z4*z5 + z4*z5*z6 + z5*z6*z7
+ z6*z7*z8 + z7*z8*z9 + z8*z9*z0 + z9*z0*z1,
  z0*z1*z2*z3 + z1*z2*z3*z4 + z2*z3*z4*z5 + z3*z4*z5*z6 + z4*z5*z6*z7
+ z5*z6*z7*z8 + z6*z7*z8*z9 + z7*z8*z9*z0 + z8*z9*z0*z1 + z9*z0*z1*z2,
  z0*z1*z2*z3*z4 + z1*z2*z3*z4*z5 + z2*z3*z4*z5*z6 + z3*z4*z5*z6*z7
+ z4*z5*z6*z7*z8 + z5*z6*z7*z8*z9 + z6*z7*z8*z9*z0 + z7*z8*z9*z0*z1
+ z8*z9*z0*z1*z2 + z9*z0*z1*z2*z3,
  z0*z1*z2*z3*z4*z5 + z1*z2*z3*z4*z5*z6 + z2*z3*z4*z5*z6*z7 + z3*z4*z5*z6*z7*z8
+ z4*z5*z6*z7*z8*z9 + z5*z6*z7*z8*z9*z0 + z6*z7*z8*z9*z0*z1 + z7*z8*z9*z0*z1*z2
+ z8*z9*z0*z1*z2*z3 + z9*z0*z1*z2*z3*z4,
  z0*z1*z2*z3*z4*z5*z6 + z1*z2*z3*z4*z5*z6*z7 + z2*z3*z4*z5*z6*z7*z8
+ z3*z4*z5*z6*z7*z8*z9 + z4*z5*z6*z7*z8*z9*z0 + z5*z6*z7*z8*z9*z0*z1
+ z6*z7*z8*z9*z0*z1*z2 + z7*z8*z9*z0*z1*z2*z3 + z8*z9*z0*z1*z2*z3*z4
+ z9*z0*z1*z2*z3*z4*z5,
  z0*z1*z2*z3*z4*z5*z6*z7 + z1*z2*z3*z4*z5*z6*z7*z8 + z2*z3*z4*z5*z6*z7*z8*z9
+ z3*z4*z5*z6*z7*z8*z9*z0 + z4*z5*z6*z7*z8*z9*z0*z1 + z5*z6*z7*z8*z9*z0*z1*z2
+ z6*z7*z8*z9*z0*z1*z2*z3 + z7*z8*z9*z0*z1*z2*z3*z4 + z8*z9*z0*z1*z2*z3*z4*z5
+ z9*z0*z1*z2*z3*z4*z5*z6,
  z0*z1*z2*z3*z4*z5*z6*z7*z8 + z1*z2*z3*z4*z5*z6*z7*z8*z9
+ z2*z3*z4*z5*z6*z7*z8*z9*z0 + z3*z4*z5*z6*z7*z8*z9*z0*z1
+ z4*z5*z6*z7*z8*z9*z0*z1*z2 + z5*z6*z7*z8*z9*z0*z1*z2*z3
+ z6*z7*z8*z9*z0*z1*z2*z3*z4 + z7*z8*z9*z0*z1*z2*z3*z4*z5
+ z8*z9*z0*z1*z2*z3*z4*z5*z6 + z9*z0*z1*z2*z3*z4*z5*z6*z7,
  z0*z1*z2*z3*z4*z5*z6*z7*z8*z9 - 1
        ],
        [z0,z1,z2,z3,z4,z5,z6,z7,z8,z9]
    ],
    [#(16) cyclic11
        [z0*z1*z2*z3*z4*z5*z6*z7*z8*z9*z10 - 1,
z0 + z1 + z2 + z3 + z4 + z5 + z6 + z7 + z8 + z9 + z10,
z0*z1 + z1*z2 + z2*z3 + z3*z4 + z4*z5 + z5*z6 + z6*z7
+ z7*z8 + z8*z9 + z9*z10 + z10*z0,
z0*z1*z2 + z1*z2*z3 + z2*z3*z4 + z3*z4*z5 + z4*z5*z6 + z5*z6*z7
 + z6*z7*z8 + z7*z8*z9 + z8*z9*z10 + z9*z10*z0 + z10*z0*z1,
z0*z1*z2*z3 + z1*z2*z3*z4 + z2*z3*z4*z5 + z3*z4*z5*z6 + z4*z5*z6*z7
 + z5*z6*z7*z8 + z6*z7*z8*z9 + z7*z8*z9*z10 + z8*z9*z10*z0 + z9*z10*z0*z1
 + z10*z0*z1*z2,
z0*z1*z2*z3*z4 + z1*z2*z3*z4*z5 + z2*z3*z4*z5*z6 + z3*z4*z5*z6*z7
 + z4*z5*z6*z7*z8 + z5*z6*z7*z8*z9 + z6*z7*z8*z9*z10 + z7*z8*z9*z10*z0
 + z8*z9*z10*z0*z1 + z9*z10*z0*z1*z2 + z10*z0*z1*z2*z3,
z0*z1*z2*z3*z4*z5 + z1*z2*z3*z4*z5*z6 + z2*z3*z4*z5*z6*z7
 + z3*z4*z5*z6*z7*z8 + z4*z5*z6*z7*z8*z9 + z5*z6*z7*z8*z9*z10
 + z6*z7*z8*z9*z10*z0 + z7*z8*z9*z10*z0*z1 + z8*z9*z10*z0*z1*z2
 + z9*z10*z0*z1*z2*z3 + z10*z0*z1*z2*z3*z4,
z0*z1*z2*z3*z4*z5*z6 + z1*z2*z3*z4*z5*z6*z7 + z2*z3*z4*z5*z6*z7*z8
 + z3*z4*z5*z6*z7*z8*z9 + z4*z5*z6*z7*z8*z9*z10 + z5*z6*z7*z8*z9*z10*z0
 + z6*z7*z8*z9*z10*z0*z1 + z7*z8*z9*z10*z0*z1*z2 + z8*z9*z10*z0*z1*z2*z3
 + z9*z10*z0*z1*z2*z3*z4 + z10*z0*z1*z2*z3*z4*z5,
z0*z1*z2*z3*z4*z5*z6*z7 + z1*z2*z3*z4*z5*z6*z7*z8 + z2*z3*z4*z5*z6*z7*z8*z9
 + z3*z4*z5*z6*z7*z8*z9*z10 + z4*z5*z6*z7*z8*z9*z10*z0
 + z5*z6*z7*z8*z9*z10*z0*z1 + z6*z7*z8*z9*z10*z0*z1*z2
 + z7*z8*z9*z10*z0*z1*z2*z3 + z8*z9*z10*z0*z1*z2*z3*z4
 + z9*z10*z0*z1*z2*z3*z4*z5 + z10*z0*z1*z2*z3*z4*z5*z6,
z0*z1*z2*z3*z4*z5*z6*z7*z8 + z1*z2*z3*z4*z5*z6*z7*z8*z9
 + z2*z3*z4*z5*z6*z7*z8*z9*z10 + z3*z4*z5*z6*z7*z8*z9*z10*z0
 + z4*z5*z6*z7*z8*z9*z10*z0*z1 + z5*z6*z7*z8*z9*z10*z0*z1*z2
 + z6*z7*z8*z9*z10*z0*z1*z2*z3 + z7*z8*z9*z10*z0*z1*z2*z3*z4
 + z8*z9*z10*z0*z1*z2*z3*z4*z5 + z9*z10*z0*z1*z2*z3*z4*z5*z6
 + z10*z0*z1*z2*z3*z4*z5*z6*z7,
z0*z1*z2*z3*z4*z5*z6*z7*z8*z9 + z1*z2*z3*z4*z5*z6*z7*z8*z9*z10
 + z2*z3*z4*z5*z6*z7*z8*z9*z10*z0 + z3*z4*z5*z6*z7*z8*z9*z10*z0*z1
 + z4*z5*z6*z7*z8*z9*z10*z0*z1*z2 + z5*z6*z7*z8*z9*z10*z0*z1*z2*z3
 + z6*z7*z8*z9*z10*z0*z1*z2*z3*z4 + z7*z8*z9*z10*z0*z1*z2*z3*z4*z5
 + z8*z9*z10*z0*z1*z2*z3*z4*z5*z6 + z9*z10*z0*z1*z2*z3*z4*z5*z6*z7
 + z10*z0*z1*z2*z3*z4*z5*z6*z7*z8
        ],
        [z0,z1,z2,z3,z4,z5,z6,z7,z8,z9,z10]
    ],
    [#(17) simple
        [ x^2,
 x*y,
 y^2
        ],
        [x,y]
    ],
    [#(18) eg1
        [ x**2,
 y**2
        ],
        [x,y]
    ],
    [#(19) eg2
        [ x**2+y**2,
 x-y
        ],
        [x,y]
    ],
    [#(20) eg3
        [ x**2,
 x-y
        ],
        [x,y]
    ],
    [#(21) eg4
        [ x**3,
 x-y
        ],
        [x,y]
    ],
    [#(22) eg5
        [ x**4,
 x-y
        ],
        [x,y]
    ],
    [#(23) baker1
        [ x1**2-x2,
 x1**2+x2
        ],
        [x1,x2]
    ],
    [#(24) cbms1
        [x1**3-x2*x3,
x2**3-x1*x3,
x3**3-x1*x2
        ],
        [x1,x2,x3]
    ],
    [#(25) cbms2
        [ x1**3  - 3*x1**2*x2 + 3*x1*x2**2  - x2**3  - x3**2,
 x3**3  - 3*x3**2*x1 + 3*x3*x1**2  - x1**3  - x2**2,
 x2**3  - 3*x2**2*x3 + 3*x2*x3**2  - x3**3  - x1**2
        ],
        [x1,x2,x3]
    ],
    [#(26) mth191
        [ x^3+y^2+z^2-1,
 x^2+y^3+z^2-1,
 x^2+y^2+z^3-1
        ],
        [x,y,z]
    ],
    [#(27) decker1
        [ x1**3+x1*x2,
 x2**2+x2
        ],
        [x1,x2]
    ],
    [#(28) decker2
        [ x1+x2**3,
 x1**2*x2-x2**4
        ],
        [x1,x2]
    ],
    [#(29) decker3
        [ x1+x2**2,
 15/10*x1*x2+x2**2+x2**3
        ],
        [x1,x2]
    ],
    [#(30) kss3
        [ x1^2 + x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 - 2*x1 - 9,
 x2^2 + x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 - 2*x2 - 9,
 x3^2 + x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 - 2*x3 - 9,
 x4^2 + x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 - 2*x4 - 9,
 x5^2 + x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 - 2*x5 - 9,
 x6^2 + x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 - 2*x6 - 9,
 x7^2 + x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 - 2*x7 - 9,
 x8^2 + x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 - 2*x8 - 9,
 x9^2 + x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 - 2*x9 - 9,
 x10^2 + x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 - 2*x10 - 9
        ],
        [x1,x2,x3,x4,x5,x6,x7,x8,x9,x10]
    ],
    [#(31) ojika1
        [ x**2+y-3,
 x+0125/1000*y**2-15/10
        ],
        [x,y]
    ],
    [#(32) ojika2
        [ x1**2+x2+x3-1,
 x1+x2**2+x3-1,
 x1+x2+x3**2-1
        ],
        [x1,x2,x3]
    ],
    [#(33) ojika3
        [ x1+x2+x3-1,
 02/10*x1**3+05/10*x2**2-x3+05/10*x3**2+05/10,
 x1+x2+05/10*x3**2-05/10
        ],
        [x1,x2,x3]
    ],
    [#(34) ojika4
        [ x1+x3*x1**3+x1*x3*x2**2-x1*x3,
 10*x2-2*x2*x3*x1**2-x3*x2**3-x2*x3,
 -6*x3**2*x1**4-3*x1**2*x2**2*x3**2-x3**2*x1**2+28*x3*x1**2
 -3*x3**2*x2**4+2*x3**2*x2**2+7*x3*x2**2+x3**2-11*x3+10
        ],
        [x1,x2,x3]
    ]
]:

max_stars_repo_name: lihaokun/StrongSfTriDec

max_issues_repo_name: lihaokun/StrongSfTriDec

max_forks_repo_name: lihaokun/StrongSfTriDec


text:
program sample19;
	/* Calculator program	*/
	/*  c n : clear & set n	*/
	/*  + n : add n			*/
	/*  - n : subtract n	*/
	/*  * n : multiply n	*/
	/*  / n : divide by n		*/
	/*  o : off				*/
procedure gcmlcm(m, n, gc, lc : integer);
	/* gc := GCM(m,n), lc := LCM(m,n) */
	/* m and n are not changed        */
 var a,b,r : integer;
begin
	a := m;
	b := n;
	while b <> 0 do begin
		r := a - (a div b) * b;
		a := b;
		b := r
	end;
	gc := a;
	lc := (m div gc) * n
end;
procedure abs(a, b : integer);
begin
  if a < 0 then b := -a  else b := a
end;
procedure gcm(a, b, gc : integer);
 var lc, aa, bb : integer;
begin
  if (a = 0) or (b = 0) then gc := 1
  else begin
  call abs(a,aa);  call abs(b,bb);
  call gcmlcm(aa, bb, gc, lc)
  end
end;
procedure lcm(a, b, lc : integer);
 var gc, aa, bb : integer;
begin
  if (a = 0) or (b = 0) then lc := 1
  else begin
  call abs(a,aa);  call abs(b,bb);
  call gcmlcm(aa, bb, gc, lc)
  end
end;
procedure reduce(a1, a2 : integer);
  var gc : integer;
begin
  if a1 = 0 then begin a2 := 1; return end;
  if a2 = 0 then begin a1 := 1; return end;
  if a2 < 0 then begin a2 := -a2; a1 := -a1 end;
  call gcm(a1, a2, gc);
  a1 := a1 div gc;
  a2 := a2 div gc
end;

procedure sum(x1, x2, y1, y2 : integer);
 var lc, y11 : integer;
begin
  call lcm(x2, y2, lc);
  x1 := x1 * (lc div x2);
  y11 := y1 * (lc div y2);
  x1 := x1 + y11;
  x2 := lc;
  call reduce(x1, x2)
end;
procedure sub(x1, x2, y1, y2 : integer);
 var lc, y11 : integer;
begin
  call sum(x1, x2, -y1, y2)
end;
procedure mult(x1, x2, y1, y2 : integer);
 var gc, y11, y22 : integer;
begin
  call gcm(x1, y2, gc);
  x1 := x1 div gc;
  y22 := y2 div gc;
  call gcm(x2, y1, gc);
  x2 := x2 div gc;
  y11 := y1 div gc;
  x1 := x1 * y11;
  x2 := x2 * y22;
  call reduce(x1, x2)
end;
procedure divide(x1, x2, y1, y2 : integer);
begin
	call mult(x1, x2, y2, y1)
end;

procedure printfinal(a, b : integer);
begin
  if a = 0 then writeln('Final'' Result =', a)
  else if b = 1 then writeln('Final Result =', a)
  else writeln('Final Result =', a, '/', b)
end;
procedure printtemp(a, b : integer);
begin
  if a = 0 then writeln('Temporary Result =', a)
  else if b = 1 then writeln('Temporary Result =', a)
  else writeln('Temporary Result =', a, '/', b)
end;

var	x1, x2, y1,y2 : integer;
var	com :char;
	endflag : boolean;
begin
	writeln('   *** Calculator -- h for help ***');
	x1 := 0;  x2 :=1;
	endflag := false;
	while not endflag do begin
		writeln(' Please input command :');
		readln(com, y1);  y2 := 1;
		if (com = 'c')  or (com = 'C') then begin x1 := y1; x2 := y2 end
		else if com = '+' then call sum(x1, x2, y1, y2)
		else if com = '-' then call sub(x1, x2, y1, y2)
		else if com = '*' then call mult(x1, x2, y1, y2)
		else if com = '/' then call divide(x1, x2, y1, y2)
		else if (com = 'o') or (com = 'O') then endflag := true
		else begin
			writeln;
			writeln('Calculator Usage:');
			writeln('  c number : clear & set it');
			writeln('  + number : add it');
			writeln('  - number : subtract it');
			writeln('  * number : multiply it');
			writeln('  / number : divide by it');
			writeln('  o        : off(terminate execution)');
			writeln
		end;
		if endflag then call printfinal(x1, x2)
		else call printtemp(x1, x2)
	end
end.

ext: mpl


text:
`is_element/SW` := eval(`is_element/prime_simplex_boundary`);
`is_equal/SW` := eval(`is_equal/prime_simplex_boundary`);
`is_leq/SW` := NULL;
`random_element/SW` := eval(`random_element/prime_simplex_boundary`);
`list_elements/SW` := NULL;
`count_elements/SW` := NULL;
`phi/nonempty_subsets/SW` := eval(`phi/nonempty_subsets/prime_simplex_boundary`);


text:
######################################################################

`is_element/SCP2` := (N::posint) -> (A::set,B::set) -> proc(QP)
 local i,Q0,Q,P;

 global reason;

 if not(type(QP,list) and nops(QP) = 2) then
  reason := [convert(procname,string),"QP is not a list of length two",reason];
 fi;

 Q,P := op(QP);

 if not `is_element/SCP`(N)(A)(Q) then
  reason := [convert(procname,string),"Q not in SCP(N)(A)",reason];
  return false;
 fi;

 if not `is_element/SCP`(N)(B)(P) then
  reason := [convert(procname,string),"P not in SCP(N)(B)",reason];
  return false;
 fi;

 Q0 := `res/SCP`(N)(A,B)(Q);

 if Q0 <> P and Q0 <> [`top/autorel`(B)$N] then
  reason := [convert(procname,string),"Q and P are incompatible"];
  return false;
 fi;

 return true;
end:

`is_equal/SCP2` := (N::posint) -> (A::set,B::set) -> proc(QP1,QP2)
 return
  `is_equal/SCP`(N)(A)(QP1[1],QP2[1]) and
  `is_equal/SCP`(N)(B)(QP1[2],QP2[2]);
end:

`is_leq/SCP` := (N::posint) -> (A::set) -> proc(Q1,Q2)
 local i;

 for i from 1 to N do
  if Q2[i] minus Q1[i] <> {} then
   return false;
  fi;
 od;

 return true;
end:

`list_elements/SCP2` := (N::posint) -> proc(A::set,B::set)
 local X,Y,Z,n,Q,P;

 X := `list_elements/SCP`(N)(A);
 Y := `list_elements/SCP`(N)(B);
 Z := NULL;

 n := nops(B);

 for Q in X do
  P := `res/SCP`(N)(A,B)(Q);

  if nops(P[N]) = n^2 then
   Z := Z,seq([Q,P],P in Y);
  else
   Z := Z,[Q,P];
  fi;
 od:

 Z := [Z];

 return Z;
end:

`random_element/SCP2` := (N::posint) -> (A::set,B::set) -> proc(p := 0.5)
 local A0,p0,a,Q0,AA,Q,P,i;
 if rand(1..10000)() < evalf(10000 * p) then
  A0 := (A minus B) union {b0};
  p0 := table();
  for a in A do
   p0[a] := `if`(member(a,B),b0,a);
  od;
  Q0 := `random_element/SCP`(N)(A0)();
  AA := `top/autorel`(A);
  Q := [seq(select(xy -> member(map(p0,xy),Q0[i]),AA),i=1..N)];
  P := `random_element/SCP`(N)(B)();
  return [Q,P];
 else
  Q := `random_element/SCP`(N)(A)();
  P := `res/SCP`(N)(A,B)(Q);

  while `is_constant/ACP`(N)(B)(P) do
   Q := `random_element/SCP`(N)(A)();
   P := `res/SCP`(N)(A,B)(Q);
  od;

  return [Q,P];
 fi;
end:


text:
#int fact(int n) {
#  if (n == 1)
#    return 1;
#  return n * fact(n-1);
#}

func $fact (var %n i32) i32 {
  if (ne i32 i32 (dread i32 %n, constval i32 1)) {
       call &fact (sub i32 (dread i32 %n, constval i32 1))
            return (mul i32 (dread i32 %n, regread i32 %%retval))
             }
  return (constval i32 1)
}

 # EXEC: %irbuild Main.mpl
 # EXEC: %irbuild Main.irb.mpl
 # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl

max_stars_repo_name: harmonyos-mirror/OpenArkCompiler-test

max_issues_repo_name: harmonyos-mirror/OpenArkCompiler-test

max_forks_repo_name: harmonyos-mirror/OpenArkCompiler-test


text:
flavor 1
srclang 3
id 65535
numfuncs 4
import "Arith.mplt"
import "/home/bravewtz/Desktop/openarkcompiler/libjava-core/libjava-core.mplt"
entryfunc &LArith_3B_7Cmain_7C_28ALjava_2Flang_2FString_3B_29V
fileinfo {
  @INFO_filename "Arith.jar"}
srcfileinfo {
  1 "Arith.java"}
javaclass $LArith_3B <$LArith_3B> public
func &LArith_3B_7C_3Cinit_3E_7C_28_29V public constructor (var %_this <* <$LArith_3B>>) void
func &LArith_3B_7Craise__sigfpe_7C_28_29V private static native () void
func &LArith_3B_7CTestMain_7C_28I_29I public static (var %Reg4_I i32) i32
func &LArith_3B_7Cmain_7C_28ALjava_2Flang_2FString_3B_29V public static (var %Reg2_R743 <* <[] <* <$Ljava_2Flang_2FString_3B>>>>) void
var $Ljava_2Flang_2FSystem_3B_7Cout extern <* <$Ljava_2Fio_2FPrintStream_3B>> final public static
var $__cinf_Ljava_2Flang_2FString_3B <$__class_meta__>
func &MCC_GetOrInsertLiteral () <* <$Ljava_2Flang_2FString_3B>>
func &LArith_3B_7C_3Cinit_3E_7C_28_29V public constructor (var %_this <* <$LArith_3B>>) void {
  funcid 48153
  var %Reg1_R43694 <* <$LArith_3B>>
  var %Reg1_R57 <* <$Ljava_2Flang_2FObject_3B>>

  dassign %Reg1_R43694 0 (dread ref %_this)
  #INSTIDX : 0||0000:  aload_0
  #INSTIDX : 1||0001:  invokespecial
  dassign %Reg1_R57 0 (retype ref <* <$Ljava_2Flang_2FObject_3B>> (dread ref %Reg1_R43694))
  callassigned &Ljava_2Flang_2FObject_3B_7C_3Cinit_3E_7C_28_29V (dread ref %Reg1_R57) {}
  #INSTIDX : 4||0004:  return
  return ()
}
func &LArith_3B_7Craise__sigfpe_7C_28_29V private static native () void {
  funcid 48154

}
func &LArith_3B_7CTestMain_7C_28I_29I public static (var %Reg4_I i32) i32 {
  funcid 48155
  var %Reg0_I i32
  var %Reg2_I i32
  var %Reg0_R19929 <* <$Ljava_2Flang_2FArithmeticException_3B>>
  var %Reg0_R510 <* <$Ljava_2Flang_2FThrowable_3B>>
  var %Reg3_R19929 <* <$Ljava_2Flang_2FArithmeticException_3B>>

  intrinsiccallwithtype <$LArith_3B> JAVA_CLINIT_CHECK ()
  #INSTIDX : 0||0000:  iconst_0
  dassign %Reg0_I 0 (constval i32 0)
  #INSTIDX : 1||0001:  istore_1
  dassign %Reg2_I 0 (dread i32 %Reg0_I)
  try { @label2 }
  #INSTIDX : 2||0002:  iinc
  dassign %Reg2_I 0 (add i32 (dread i32 %Reg2_I, constval i32 1))
  #INSTIDX : 5||0005:  iload_0
  #INSTIDX : 6||0006:  ifle
  brtrue @label0 (le i32 i32 (dread i32 %Reg4_I, constval i32 0))
  #INSTIDX : 9||0009:  invokestatic
  intrinsiccallwithtype <$LArith_3B> JAVA_CLINIT_CHECK ()
  callassigned &LArith_3B_7Craise__sigfpe_7C_28_29V () {}
  #INSTIDX : 12||000c:  goto
  goto @label1
@label0   #INSTIDX : 15||000f:  iload_0
  #INSTIDX : 16||0010:  ifne
  brtrue @label1 (ne i32 i32 (dread i32 %Reg4_I, constval i32 0))
  #INSTIDX : 19||0013:  iinc
  dassign %Reg2_I 0 (add i32 (dread i32 %Reg2_I, constval i32 103))
  #INSTIDX : 22||0016:  new
  intrinsiccallwithtype <$Ljava_2Flang_2FArithmeticException_3B> JAVA_CLINIT_CHECK ()
  dassign %Reg0_R19929 0 (gcmalloc ref <$Ljava_2Flang_2FArithmeticException_3B>)
  #INSTIDX : 25||0019:  dup
  #INSTIDX : 26||001a:  invokespecial
  callassigned &Ljava_2Flang_2FArithmeticException_3B_7C_3Cinit_3E_7C_28_29V (dread ref %Reg0_R19929) {}
  #INSTIDX : 29||001d:  athrow
  dassign %Reg0_R510 0 (retype ref <* <$Ljava_2Flang_2FThrowable_3B>> (dread ref %Reg0_R19929))
  throw (dread ref %Reg0_R510)
@label1   #INSTIDX : 30||001e:  iinc
  dassign %Reg2_I 0 (add i32 (dread i32 %Reg2_I, constval i32 3))
  endtry
  dassign %Reg2_I 0 (cvt i32 i32 (dread i32 %Reg2_I))
  #INSTIDX : 33||0021:  goto
  goto @label3
@label2   catch { <* <$Ljava_2Flang_2FArithmeticException_3B>> }
  dassign %Reg0_R19929 0 (regread ptr %%thrownval)
  #INSTIDX : 36||0024:  astore_2
  dassign %Reg3_R19929 0 (dread ref %Reg0_R19929)
  #INSTIDX : 37||0025:  iinc
  dassign %Reg2_I 0 (add i32 (dread i32 %Reg2_I, constval i32 100))
  dassign %Reg2_I 0 (cvt i32 i32 (dread i32 %Reg2_I))
@label3   #INSTIDX : 40||0028:  iload_1
  #INSTIDX : 41||0029:  ireturn
  return (dread i32 %Reg2_I)
}
func &LArith_3B_7Cmain_7C_28ALjava_2Flang_2FString_3B_29V public static (var %Reg2_R743 <* <[] <* <$Ljava_2Flang_2FString_3B>>>>) void {
  funcid 48156
  var %Reg0_R562 <* <$Ljava_2Fio_2FPrintStream_3B>>
  var %Reg1_I i32

  intrinsiccallwithtype <$LArith_3B> JAVA_CLINIT_CHECK ()
  #INSTIDX : 0||0000:  getstatic
  intrinsiccallwithtype <$Ljava_2Flang_2FSystem_3B> JAVA_CLINIT_CHECK ()
  dassign %Reg0_R562 0 (dread ref $Ljava_2Flang_2FSystem_3B_7Cout)
  #INSTIDX : 3||0003:  bipush
  dassign %Reg1_I 0 (constval i32 -5)
  #INSTIDX : 5||0005:  invokestatic
  intrinsiccallwithtype <$LArith_3B> JAVA_CLINIT_CHECK ()
  callassigned &LArith_3B_7CTestMain_7C_28I_29I (dread i32 %Reg1_I) { dassign %Reg1_I 0 }
  #INSTIDX : 8||0008:  invokevirtual
  virtualcallassigned &Ljava_2Fio_2FPrintStream_3B_7Cprintln_7C_28I_29V (dread ref %Reg0_R562, dread i32 %Reg1_I) {}
  #INSTIDX : 11||000b:  getstatic
  intrinsiccallwithtype <$Ljava_2Flang_2FSystem_3B> JAVA_CLINIT_CHECK ()
  dassign %Reg0_R562 0 (dread ref $Ljava_2Flang_2FSystem_3B_7Cout)
  #INSTIDX : 14||000e:  iconst_0
  dassign %Reg1_I 0 (constval i32 0)
  #INSTIDX : 15||000f:  invokestatic
  intrinsiccallwithtype <$LArith_3B> JAVA_CLINIT_CHECK ()
  callassigned &LArith_3B_7CTestMain_7C_28I_29I (dread i32 %Reg1_I) { dassign %Reg1_I 0 }
  #INSTIDX : 18||0012:  invokevirtual
  virtualcallassigned &Ljava_2Fio_2FPrintStream_3B_7Cprintln_7C_28I_29V (dread ref %Reg0_R562, dread i32 %Reg1_I) {}
  #INSTIDX : 21||0015:  return
  return ()
}

max_stars_repo_name: Bravewtz/OpenArkCompiler

max_issues_repo_name: Bravewtz/OpenArkCompiler

max_forks_repo_name: Bravewtz/OpenArkCompiler


text:
(*
 Copyright (C) 2017 M.A.L. Marques

 This Source Code Form is subject to the terms of the Mozilla Public
 License, v. 2.0. If a copy of the MPL was not distributed with this
 file, You can obtain one at http://mozilla.org/MPL/2.0/.
*)

(* type: lda_exc *)
(* prefix:
  lda_c_hl_params *params;

  assert(p->params != NULL);
  params = (lda_c_hl_params * )(p->params);
*)

$ifdef lda_c_vbh_params
params_a_hl_r := [30, 75.0]:
params_a_hl_c := [0.0252, 0.0127]:
$endif

hl_xx := (k, rs) -> rs/params_a_hl_r[k]:
hl_f0 := (k, rs) -> -params_a_hl_c[k]*
  ((1 + hl_xx(k, rs)^3)*log(1 + 1/hl_xx(k, rs)) - hl_xx(k, rs)^2 + 1/2*hl_xx(k, rs) - 1/3):

hl_f := (rs, zeta) -> hl_f0(1, rs) + f_zeta(zeta)*(hl_f0(2, rs) - hl_f0(1, rs)):
f    := (rs, zeta) -> hl_f(rs, zeta):


text:
# JACOBI
#
# A package for the computation of the Jacobi property for Poisson brackets
#

#
# See https://gdeq.org/Weakly_nonlocal_Poisson_brackets for further details
#
# Authors: M. Casati, P. Lorenzoni, D. Valeri, R. Vitolo (2021)
#
#  L i c e n s e
#
# JACOBI is a free software distributed under the terms of the GNU General
# Public License <http://www.gnu.org/copyleft/gpl.html> as published by
# the Free Software Foundation.
#
# In particular, JACOBI comes with ABSOLUTELY NO WARRANTY.
#
# Version history
#
# Version 1.0, 15 January 2021

print(`JACOBI 1.0 for Maple 2020`);
print(`Authors: M. Casati, P. Lorenzoni, D. Valeri, R. Vitolo`);
print(`Web site: https://gdeq.org/Weakly_nonlocal_Poisson_brackets`);

Schouten_bracket:= proc(P,Q,T,N,M)
  description "Calculate the Schouten bracket [P,Q]",
              "N: number of components of the operators P,Q;",
              "M: order of derivatives in P,Q",
	      "T: the three-vector T=[P,Q]";

  local P_xy,P_yx,P_xz,P_zx,P_zy,P_yz,Q_xy,Q_yx,Q_xz,Q_zx,Q_yz,Q_zy,
  i,j,k,l,r,s,t,T0,T1,T2,cfnl_xyxz,cfnl_zxzy,cfnl_yzyx,cfl_xyxz:
  global delta:

  print("Step 0: calculating Dubrovin-Zhang formula");

# Calculate the total derivatives of the operator P
  for i from 1 to N do
    for j from 1 to N do
      for k from 1 to M do
        P[i,j,k]:=add(
	  add(
	    diff(P[i,j,k-1],u[q,x,s])*u[q,x,s+1],
	    s=0..M-1),
	  q=1..N)
	  + add(
	      diff(P[i,j,k-1],delta[x-y,s])*delta[x-y,s+1],
	    s=-1..M-1)
      end do
    end do
  end do:

#Generate the operators P in all variables needed in Dubrovin-Zhang formula
  P_xy:=P:
  P_yx:=subs({x=y,y=x},P_xy):
  P_xz:=subs(y=z,P_xy):
  P_zx:=subs(y=z,P_yx):
  P_yz:=subs(x=y,P_xz):
  P_zy:=subs(x=z,P_xy):

# Calculate the total derivatives of the operator Q
  for i from 1 to N do
    for j from 1 to N do
      for k from 1 to M do
        Q[i,j,k]:=add(
	  add(
	    diff(Q[i,j,k-1],u[q,x,s])*u[q,x,s+1],
	    s=0..M-1),
	  q=1..N)
	  + add(
	      diff(Q[i,j,k-1],delta[x-y,s])*delta[x-y,s+1],
	    s=-1..M-1)
      end do
    end do
  end do:

#Generate the operators Q in all variables needed in Dubrovin-Zhang formula
  Q_xy:=Q:
  Q_yx:=subs({x=y,y=x},Q_xy):
  Q_xz:=subs(y=z,Q_xy):
  Q_zx:=subs(y=z,Q_yx):
  Q_yz:=subs(x=y,Q_xz):
  Q_zy:=subs(x=z,Q_xy):

# The three-vector T0 from Dubrovin-Zhang formula
T0:=Array(1..N,1..N,1..N):

  for i from 1 to N do
    for j from 1 to N do
      for k from 1 to N do
        T0[i,j,k]:=
	add(add(diff(P_xy[i,j,0],u[l,x,s])*Q_xz[l,k,s],s=0..M)
	+ subs(delta[x-y,-1]=-delta[y-x,-1],
	    add(diff(P_xy[i,j,0],u[l,y,s])*Q_yz[l,k,s],s=0..M))
	+ add(diff(P_zx[k,i,0],u[l,z,s])*Q_zy[l,j,s],s=0..M)
	+ subs(delta[z-x,-1]=-delta[x-z,-1],
	    add(diff(P_zx[k,i,0],u[l,x,s])*Q_xy[l,j,s],s=0..M))
	+ add(diff(P_yz[j,k,0],u[l,y,s])*Q_yx[l,i,s],s=0..M)
	+ subs(delta[y-z,-1]=-delta[z-y,-1],
	    add(diff(P_yz[j,k,0],u[l,z,s])*Q_zx[l,i,s],s=0..M))
	+ add(diff(Q_xy[i,j,0],u[l,x,s])*P_xz[l,k,s],s=0..M)
	+ subs(delta[x-y,-1]=-delta[y-x,-1],
	    add(diff(Q_xy[i,j,0],u[l,y,s])*P_yz[l,k,s],s=0..M))
	+ add(diff(Q_zx[k,i,0],u[l,z,s])*P_zy[l,j,s],s=0..M)
	+ subs(delta[z-x,-1]=-delta[x-z,-1],
	    add(diff(Q_zx[k,i,0],u[l,x,s])*P_xy[l,j,s],s=0..M))
	+ add(diff(Q_yz[j,k,0],u[l,y,s])*P_yx[l,i,s],s=0..M)
	+ subs(delta[y-z,-1]=-delta[z-y,-1],
	    add(diff(Q_yz[j,k,0],u[l,z,s])*P_zx[l,i,s],s=0..M))
	    ,l=1..N)
      end do
    end do
  end do:

# Here we calculate the step 1 of the algorithm
# enhanced by a first application of the step 3
# in order to reconstruct a new three-vector T1
# which is equivalent to T0 up to total derivatives.

print("Step 1 of the algorithm");

# Replacing nu(z-y)*delta(z-x)
  delta[z-y,-1,z-x,0]:=delta[x-y,-1]*delta[x-z,0]:
  for i from 1 to M-1 do
    delta[z-y,-1,z-x,i]:= - add(diff(delta[z-y,-1,z-x,i-1],
      delta[x-y,k])*delta[x-y,k+1],k=-1..M)
       - add(diff(delta[z-y,-1,z-x,i-1],
         delta[x-z,k])*delta[x-z,k+1],k=-1..M)
  end do:

# Replacing nu(y-x)*delta(y-z)
  delta[y-x,-1,y-z,0]:=delta[z-x,-1]*delta[z-y,0]:
  for i from 1 to M-1 do
    delta[y-x,-1,y-z,i]:= - add(diff(delta[y-x,-1,y-z,i-1],
      delta[z-x,k])*delta[z-x,k+1],k=-1..M)
       - add(diff(delta[y-x,-1,y-z,i-1],
         delta[z-y,k])*delta[z-y,k+1],k=-1..M)
  end do:

# Replacing nu(x-z)*delta(x-y)
  delta[x-z,-1,x-y,0]:=delta[y-z,-1]*delta[y-x,0]:
  for i from 1 to M-1 do
  delta[x-z,-1,x-y,i]:= - add(diff(delta[x-z,-1,x-y,i-1],
    delta[y-z,k])*delta[y-z,k+1],k=-1..M)
     - add(diff(delta[x-z,-1,x-y,i-1],
       delta[y-x,k])*delta[y-x,k+1],k=-1..M)
  end do:

# Replacing all products of delta's to products of the form
# delta^(m)(x-y)*delta^(n)(x-z)
  for l from 0 to M do
    delta[x-y,0,y-z,l]:=delta[x-y,0]*delta[x-z,l]
  end do:

  for k from 1 to M do
    for l from 0 to M do
      delta[x-y,k,y-z,l]:=add(diff(delta[x-y,k-1,y-z,l],delta[x-y,m])
        *delta[x-y,m+1],m=-1..M)
        +add(diff(delta[x-y,k-1,y-z,l],delta[x-z,m])*delta[x-z,m+1],m=-1..M)
    end do
  end do:

  for l from 0 to M do
    delta[z-x,0,z-y,l]:=delta[x-y,l]*delta[x-z,0]
  end do:

  for k from 1 to M do
    for l from 0 to M do
      delta[z-x,k,z-y,l]:=-add(diff(delta[z-x,k-1,z-y,l],delta[x-y,m])
        *delta[x-y,m+1],m=-1..M)
	 - add(diff(delta[z-x,k-1,z-y,l],delta[x-z,m])
        *delta[x-z,m+1],m=-1..M)
    end do
  end do:

  for k from 0 to M do
    for l from 0 to M do
      delta[z-x,k,x-y,l]:=(-1)^k*delta[x-y,l]*delta[x-z,k]
    end do
  end do:

  for k from 0 to M do
    delta[y-z,k,y-x,0]:=delta[x-y,0]*delta[x-z,k]
  end do:

  for l from 1 to M do
    for k from 0 to M do
      delta[y-z,k,y-x,l]:=-add(diff(delta[y-z,k,y-x,l-1],delta[x-y,m])
        *delta[x-y,m+1],m=-1..M)
	-add(diff(delta[y-z,k,y-x,l-1],delta[x-z,m])
	*delta[x-z,m+1],m=-1..M)
    end do
  end do:

  for k from 0 to M do
    delta[y-z,k,z-x,0]:=(-1)^k*delta[x-y,k]*delta[x-z,0]
  end do:

  for l from 1 to M do
    for k from 0 to M do
      delta[y-z,k,z-x,l]:=-add(diff(delta[y-z,k,z-x,l-1],delta[x-y,m])
        *delta[x-y,m+1],m=-1..M)
	-add(diff(delta[y-z,k,z-x,l-1],delta[x-z,m])
	*delta[x-z,m+1],m=-1..M)
    end do
  end do:

# The three-vector T1
T1:=Array(1..N,1..N,1..N):

  for i from 1 to N do
    for j from 1 to N do
      for k from 1 to N do
        T1[i,j,k]:=
	  coeff(coeff(T0[i,j,k],delta[x-y,-1]),delta[x-z,-1])
	  *delta[x-y,-1]*delta[x-z,-1]
	  + coeff(coeff(T0[i,j,k],delta[y-x,-1]),delta[y-z,-1])
	  *delta[y-x,-1]*delta[y-z,-1]
	  + coeff(coeff(T0[i,j,k],delta[z-x,-1]),delta[z-y,-1])
	  *delta[z-x,-1]*delta[z-y,-1]
	  + add(coeff(coeff(T0[i,j,k],delta[z-y,-1]),delta[z-x,m])
	  *delta[z-y,-1,z-x,m],m=0..M)
	  + add(coeff(coeff(T0[i,j,k],delta[x-y,-1]),delta[x-z,m])
	  *delta[x-y,-1]*delta[x-z,m],m=0..M)
	  + add(coeff(coeff(T0[i,j,k],delta[y-x,-1]),delta[y-z,m])
	  *delta[y-x,-1,y-z,m],m=0..M)
	  + add(coeff(coeff(T0[i,j,k],delta[z-x,-1]),delta[z-y,m])
	  *delta[z-x,-1]*delta[z-y,m],m=0..M)
	  + add(coeff(coeff(T0[i,j,k],delta[x-z,-1]),delta[x-y,m])
	  *delta[x-z,-1,x-y,m],m=0..M)
	  + add(coeff(coeff(T0[i,j,k],delta[y-z,-1]),delta[y-x,m])
	  *delta[y-z,-1]*delta[y-x,m],m=0..M)
	  + add(add(coeff(coeff(T0[i,j,k],delta[x-y,l]),delta[x-z,m])
	  *delta[x-y,l]*delta[x-z,m],l=0..M),m=0..M)
	  + add(add(coeff(coeff(T0[i,j,k],delta[x-y,l]),delta[y-z,m])
	  *delta[x-y,l,y-z,m],l=0..M),m=0..M)
	  + add(add(coeff(coeff(T0[i,j,k],delta[z-x,l]),delta[z-y,m])
	  *delta[z-x,l,z-y,m],l=0..M),m=0..M)
	  + add(add(coeff(coeff(T0[i,j,k],delta[z-x,l]),delta[x-y,m])
	  *delta[z-x,l,x-y,m],l=0..M),m=0..M)
	  + add(add(coeff(coeff(T0[i,j,k],delta[y-z,l]),delta[y-x,m])
	  *delta[y-z,l,y-x,m],l=0..M),m=0..M)
	  + add(add(coeff(coeff(T0[i,j,k],delta[y-z,l]),delta[z-x,m])
	  *delta[y-z,l,z-x,m],l=0..M),m=0..M)
      end do
    end do
  end do:

  for i from 1 to N do
    for j from 1 to N do
      for k from 1 to N do
        T1[i,j,k]:=coeff(coeff(T1[i,j,k],delta[x-y,-1]),delta[x-z,-1])
	*delta[x-y,-1]*delta[x-z,-1]
	+ coeff(coeff(T1[i,j,k],delta[y-x,-1]),delta[y-z,-1])
	*delta[y-x,-1]*delta[y-z,-1]
	+ coeff(coeff(T1[i,j,k],delta[z-x,-1]),delta[z-y,-1])
	*delta[z-x,-1]*delta[z-y,-1]
	+ add(coeff(coeff(T1[i,j,k],delta[z-y,-1]),delta[z-x,m])
	*delta[z-y,-1,z-x,m],m=0..M)
	+ add(coeff(coeff(T1[i,j,k],delta[x-y,-1]),delta[x-z,m])
	*delta[x-y,-1]*delta[x-z,m],m=0..M)
	+ add(coeff(coeff(T1[i,j,k],delta[y-x,-1]),delta[y-z,m])
	*delta[y-x,-1,y-z,m],m=0..M)
	+ add(coeff(coeff(T1[i,j,k],delta[z-x,-1]),delta[z-y,m])
	*delta[z-x,-1]*delta[z-y,m],m=0..M)
	+ add(coeff(coeff(T1[i,j,k],delta[x-z,-1]),delta[x-y,m])
	*delta[x-z,-1,x-y,m],m=0..M)
	+ add(coeff(coeff(T1[i,j,k],delta[y-z,-1]),delta[y-x,m])
	*delta[y-z,-1]*delta[y-x,m],m=0..M)
	+ add(add(coeff(coeff(T1[i,j,k],delta[x-y,l]),delta[x-z,m])
	*delta[x-y,l]*delta[x-z,m],l=0..M),m=0..M)
	+ add(add(coeff(coeff(T1[i,j,k],delta[x-y,l]),delta[y-z,m])
	*delta[x-y,l,y-z,m],l=0..M),m=0..M)
	+ add(add(coeff(coeff(T1[i,j,k],delta[z-x,l]),delta[z-y,m])
	*delta[z-x,l,z-y,m],l=0..M),m=0..M)
	+ add(add(coeff(coeff(T1[i,j,k],delta[z-x,l]),delta[x-y,m])
	*delta[z-x,l,x-y,m],l=0..M),m=0..M)
	+ add(add(coeff(coeff(T1[i,j,k],delta[y-z,l]),delta[y-x,m])
	*delta[y-z,l,y-x,m],l=0..M),m=0..M)
	+ add(add(coeff(coeff(T1[i,j,k],delta[y-z,l]),delta[z-x,m])
	*delta[y-z,l,z-x,m],l=0..M),m=0..M)
      end do
    end do
  end do:

# Here we calculate the step 2 of the algorithm

print("Step 2 of the algorithm");

# The three-vector T2
T2:=Array(1..N,1..N,1..N):

# Array for coefficients
cfnl_xyxz:=Array(1..N,1..N,1..N,0..M,0..M):
cfnl_zxzy:=Array(1..N,1..N,1..N,0..M,0..M):
cfnl_yzyx:=Array(1..N,1..N,1..N,0..M,0..M):
cfl_xyxz:=Array(1..N,1..N,1..N,0..M,0..M,0..M):

  for i from 1 to N do
    for j from 1 to N do
      for k from 1 to N do
        for r from 0 to M do
	  cfnl_xyxz[i,j,k,r,0]:=
	  coeff(coeff(T1[i,j,k],delta[x-y,-1]),delta[x-z,r])
	end do
      end do
    end do
  end do:

  for i from 1 to N do
    for j from 1 to N do
      for k from 1 to N do
        for r from 0 to M do
	  for s from 1 to M do
	    cfnl_xyxz[i,j,k,r,s]:=
	    add(add(diff(cfnl_xyxz[i,j,k,r,s-1],u[l,z,t])
	    *u[l,z,t+1],t=0..M),l=1..N)
	  end do
	end do
      end do
    end do
  end do:

  for i from 1 to N do
    for j from 1 to N do
      for k from 1 to N do
        for r from 0 to M do
	  cfnl_zxzy[i,j,k,r,0]:=
	  coeff(coeff(T1[i,j,k],delta[z-x,-1]),delta[z-y,r])
        end do
      end do
    end do
  end do:

  for i from 1 to N do
    for j from 1 to N do
      for k from 1 to N do
        for r from 0 to M do
	  for s from 1 to M do
	    cfnl_zxzy[i,j,k,r,s]:=
	    add(add(diff(cfnl_zxzy[i,j,k,r,s-1],u[l,y,t])
	    *u[l,y,t+1],t=0..M),l=1..N)
	  end do
	end do
      end do
    end do
  end do:

  for i from 1 to N do
    for j from 1 to N do
      for k from 1 to N do
        for r from 0 to M do
	  cfnl_yzyx[i,j,k,r,0]:=
	  coeff(coeff(T1[i,j,k],delta[y-z,-1]),delta[y-x,r])
	end do
      end do
    end do
  end do:

  for i from 1 to N do
    for j from 1 to N do
      for k from 1 to N do
        for r from 0 to M do
	  for s from 1 to M do
	    cfnl_yzyx[i,j,k,r,s]:=add(add(diff(cfnl_yzyx[i,j,k,r,s-1],u[l,x,t])
	    *u[l,x,t+1],t=0..M),l=1..N)
	  end do
	end do
      end do
    end do
  end do:

  for i from 1 to N do
    for j from 1 to N do
      for k from 1 to N do
        for r from 0 to M do
	  for s from 0 to M do
	    cfl_xyxz[i,j,k,r,s,0]:=
	    coeff(coeff(T1[i,j,k],delta[x-y,r]),delta[x-z,s])
	  end do
	end do
      end do
    end do
  end do:

  for i from 1 to N do
    for j from 1 to N do
      for k from 1 to N do
        for r from 0 to M do
	  for s from 0 to M do
	    for t from 1 to M do
	      cfl_xyxz[i,j,k,r,s,t]:=
	      add(add(diff(cfl_xyxz[i,j,k,r,s,t-1],u[l,y,p])
	      *u[l,y,p+1],p=0..M),l=1..N)
	    end do
	  end do
	end do
      end do
    end do
  end do:

  for i from 1 to N do
    for j from 1 to N do
      for k from 1 to N do
        T2[i,j,k]:=coeff(coeff(T1[i,j,k],delta[x-y,-1]),delta[x-z,-1])
	*delta[x-y,-1]*delta[x-z,-1]
	+ coeff(coeff(T1[i,j,k],delta[y-x,-1]),delta[y-z,-1])
	*delta[y-x,-1]*delta[y-z,-1]
	+ coeff(coeff(T1[i,j,k],delta[z-x,-1]),delta[z-y,-1])
	*delta[z-x,-1]*delta[z-y,-1]
	+ delta[x-y,-1]*add(add(binomial(m,s)*subs(z=x,cfnl_xyxz[i,j,k,m,s])
	*delta[x-z,m-s],s=0..m),m=0..M)
	+ delta[z-x,-1]*add(add(binomial(m,s)*subs(y=z,cfnl_zxzy[i,j,k,m,s])
	*delta[z-y,m-s],s=0..m),m=0..M)
	+ delta[y-z,-1]*add(add(binomial(m,s)*subs(x=y,cfnl_yzyx[i,j,k,m,s])
	*delta[y-x,m-s],s=0..m),m=0..M)
	+ add(add(add(binomial(l,s)*subs(y=x,cfl_xyxz[i,j,k,l,m,s])
	*delta[x-y,l-s],s=0..l)*delta[x-z,m],l=0..M),m=0..M)
      end do
    end do
  end do:

# Here we calculate the step 3 of the algorithm

# The three-vector T is set equal to the result
# of the third step of the algorithm

print("Step 3 of the algorithm");

  for i from 1 to N do
    for j from 1 to N do
      for k from 1 to N do
        for r from 0 to M do
	  for s from 0 to M do
	    cfl_xyxz[i,j,k,r,s,0]:=coeff(coeff(T2[i,j,k],delta[x-y,r]),
	    delta[x-z,s])
	  end do
	end do
      end do
    end do
  end do:

  for i from 1 to N do
    for j from 1 to N do
      for k from 1 to N do
        for r from 0 to M do
	  for s from 0 to M do
	    for t from 1 to M do
	      cfl_xyxz[i,j,k,r,s,t]:=
	      add(add(diff(cfl_xyxz[i,j,k,r,s,t-1],u[l,z,p])
	      *u[l,z,p+1],p=0..M),l=1..N)
	    end do
	  end do
	end do
      end do
    end do
  end do:

  for i from 1 to N do
    for j from 1 to N do
      for k from 1 to N do
        T[i,j,k]:=simplify(coeff(coeff(T2[i,j,k],delta[x-y,-1]),delta[x-z,-1])
	*delta[x-y,-1]*delta[x-z,-1]
	+ coeff(coeff(T2[i,j,k],delta[y-x,-1]),delta[y-z,-1])
	*delta[y-x,-1]*delta[y-z,-1]
	+ coeff(coeff(T2[i,j,k],delta[z-x,-1]),delta[z-y,-1])
	*delta[z-x,-1]*delta[z-y,-1]
	+ add(coeff(coeff(T2[i,j,k],delta[x-y,-1]),delta[x-z,m])
	*delta[x-y,-1]*delta[x-z,m],m=0..M)
	+ add(coeff(coeff(T2[i,j,k],delta[z-x,-1]),delta[z-y,m])
	*delta[z-x,-1]*delta[z-y,m],m=0..M)
	+ add(coeff(coeff(T2[i,j,k],delta[y-z,-1]),delta[y-x,m])
	*delta[y-z,-1]*delta[y-x,m],m=0..M)
	+ add(add(add(binomial(m,s)*subs(z=x,cfl_xyxz[i,j,k,l,m,s])
	*delta[x-z,m-s],s=0..m)*delta[x-y,l],m=0..M),l=0..M))
      end do
    end do
  end do:

end proc:

max_stars_repo_name: Jakub-Vasicek/WDVV-computations

max_issues_repo_name: Jakub-Vasicek/WDVV-computations

max_forks_repo_name: Jakub-Vasicek/WDVV-computations


text:
make_boys_complex := proc()
 local T,U,F,p,f,i,L,w,n,P,vb,vn;
 global boys_complex,boys_complex_alt;

 T := table([
  "vertices" = [1,2,3,4,5,6],
  "edges"  = [[1,2],[1,3],[1,5],[1,6],[2,3],[2,4],[2,6],[3,4],[3,5],[4,5],[4,6],[5,6]],
  "faces"  = [[1,2,3],[1,2,6],[1,5,3],[1,5,6],[4,2,3],[4,2,6],[4,5,3],[4,5,6]],
  "embedding" = table(),
  "embedding_dim" = 3
 ]);

 T["max_simplices"] := T["faces"];

 for i from 1 to 6 do
  T["embedding"][i]   :=    boys_corners[i];
 od:

 T := eval(`triangular_subdivision/simplicial_complex`(T)):
 T := eval(`condense/simplicial_complex`(T)):
 `normalise_embedding/simplicial_complex`(T):
 `star_subdivide/simplicial_complex`(T,{7,8,11}):
 `star_subdivide/simplicial_complex`(T,{16,17,18}):
 `normalise_embedding/simplicial_complex`(T):
 for p from 1 to 4 do
  T := eval(`triangular_subdivision/simplicial_complex`(T)):
  T := eval(`condense/simplicial_complex`(T)):
  `normalise_embedding/simplicial_complex`(T):
 od:
 F := select(f -> min(op(f)) <= 6,T["max_simplices"]):
 for f in F do
  `star_subdivide/simplicial_complex`(T,{op(f)} minus {min(op(f))});
 od:
 `normalise_embedding/simplicial_complex`(T):
 for p from 1 to 3 do
  for i from 1 to 6 do
   L := `link/simplicial_complex`(T,i);
   w := max(op(L["vertices"]));
   w := `square_refine/simplicial_complex`(T,i,w);
  od:
  `normalise_embedding/simplicial_complex`(T):
 od:

 n := nops(T["vertices"]);
 P := eval(T["embedding"]):
 vb := table():
 vn := table():
 for i from 1 to n do
  vb[i] := evalf(boys_embedding(P[i]));
  vn[i] := evalf(boys_normal(P[i]));
 od:

 T["boys_embedding"] := eval(vb);
 T["boys_normal"] := eval(vn);

 `set_javascript/simplicial_complex`(T);

 boys_complex := eval(T):

 U := table();
 U["vertices"] := boys_complex["vertices"];
 U["embedding"] := eval(boys_complex["boys_embedding"]);
 U["normal"]    := eval(boys_complex["boys_normal"]);
 U["max_simplices"] := boys_complex["max_simplices"];
 `set_javascript/simplicial_complex`(U);

 boys_complex_alt := eval(U);

 return eval(T);
end:

save_boys_complex := proc()
 local js_file,T;
 global boys_complex;

 if not(type(boys_complex,table)) then
  make_boys_complex();
 fi;

 save(boys_complex,boys_complex_alt,cat(data_dir,"/boys_complex.m"));

 js_file := cat(data_dir,"/boys_cover_complex.js");
 fprintf(js_file,"%s",boys_complex["javascript"]);
 fclose(js_file);

 js_file := cat(data_dir,"/boys_complex_alt.js");
 fprintf(js_file,"%s",boys_complex_alt["javascript"]);
 fclose(js_file);

end:


text:
# Konvertierung Vektor zu symmetrischer Matrix
# Einleitung
# Generiere die Umwandlung von Vektor mit oberem rechten Teil einer Symmetrischen Matrix zur Matrix selbst für die Dimensionen des Roboters.
# Diese Umwandlung verursacht weniger Rechenoperationen als die Verwendung der numerischen Funktion vec2symmat in Matlab, da dort jedes Mal die Indizes beim Zusammenbauen der Matrix getestet werden müssen.
# Autor
# Tim Job (Studienarbeit bei Moritz Schappler), 2019-4
# Moritz Schappler, moritz.schappler@imes.uni-hannover.de
# (C) Institut für Mechatronische Systeme, Universität Hannover
# Initialization
interface(warnlevel=0): # Unterdrücke die folgende Warnung.
restart: # Gibt eine Warnung, wenn über Terminal-Maple mit read gestartet wird.
interface(warnlevel=3):
with(LinearAlgebra):
with(ArrayTools):
with(codegen):
with(CodeGeneration):
with(StringTools):
# Einstellungen für Code-Export: Optimierungsgrad (2=höchster) und Aktivierung jedes Terms.
read "../helper/proc_MatlabExport":
read "../helper/proc_vector2mat":
read "../robot_codegen_definitions/robot_env_par":
read sprintf("../codeexport/%s/tmp/para_definitions", robot_name):
printf("Generiere Symmat2Vector-Funktionen für %s\n", robot_name):
codegen_opt := 0: # Soll nicht von Einstellung in robot_env überschrieben werden.
;
# Funktion symmat2vector für den Roboter definieren
# Erstelle eine Dummy-Variable (mv), die als temporäre Variable in Matlab dient (zum Zusammensetzen der Matrix).
clear('mv'):
M_NX:= vec2mat(mv, NX):
# Warnungen bei Code-Generierung unterdrücken. Die Meldung das der Ausdruck mv() in Matlab nicht bekannt ist, spielt keine Rolle, da diese Variable nach dem Einsetzen des Codes vorher definiert sein wird.
interface(warnlevel=0):
MatlabExport(M_NX, sprintf("../codeexport/%s/tmp/vec2mat_%d_matlab.m", robot_name, NX), codegen_opt):

max_stars_repo_name: SchapplM/robsynth-modelgen

max_issues_repo_name: SchapplM/robsynth-modelgen

max_forks_repo_name: SchapplM/robsynth-modelgen


text:
### Domain abstraction

# A domain is abstractly a pair of a "square" domain (a product of square
# domains, or an interval), the domain "bounds", and a domain "shape". The
# domain "bounds" are essentially the variables, each with the type of domain
# (Int,Sum, etc) ; the domains "shape" is sums of products of constraints
# (relations) on the domain, interspersed with 'makes' (DInto) which parametrize
# a subdomain by one of the domain variables ('picking' a particular
# parametrization of the domain, in which one variable is fixed in subsequent
# "shape" constructors).

# the seperation between the two 'stages' of domain exists mainly because
# certain simplifications need to happen after extracting the domain
# bounds but before extracting the domain shape, as the shape ends up
# becoming part of the bounds of an inner simplification.

# Broad TODOs:
#
# Mechanism for 'checking if' and 'making' constraints about variables should
#   be abstracted out into its own module (it is needed in multiple places, and
#   done sort of ad-hoc) (this could be fixed by a broader design - see "merging
#   KB with Domain")
#
# DInto should also optionally omit the bounds if they are identical to the
#   bounds in the a-priori domain bounds (i.e. just `DInto(x)`); DInto sort of
#   means 'we've solved this bound in this subcontext' but the `DInto`s where
#   the bound is identically the a-priori bound are erased (as they should be)
#   - we want a slightly seperate form to mean "we are done improving this", but
#   we still want to be able to omit bounds which would be identical. It should
#   also allow specifying only a subset of the bounds.
#
# A more granular interface for composing/re-composing simplifiers, including
#   call simplifier A {before/after} B
#
# Domain bounds should store a representation of 'dependancy' of variables
#   (a more refined representation; the current one is a linear order of variables)
#   Basically we want a list of graphs, nodes are variables and edges are
#   variable dependencies. If each graph is acyclic, the variable dependency
#   in the bounds is valid. e.g.
#     [x=0..1, y=0..1, z=0..1]  =>  [ {[x, {}]}, {[y, {}]}, {[z, {}]} ]
#     [x=0..1, y=x..1, z=0..y]  =>  [ {[z, {y}], [y, {x}], [x, {}]} ]
#   This generalizes the previous notion of variable order, although in certain
#     cases it is ambiguous what the 'original' order was. This is only when
#     there are variable dependencies, so perhaps this isn't a big deal - we may
#     want to rearrange the dependant bounds even when there is no 'interesting'
#     constraint to solve in the shape, because we know a particular order will
#     be better in some way.
#   The graph is probably not a convenient place to store the variable bounds.
#    (this is one of the big reasons we want to view the variables as a table -
#    we have lots of different information for which the convenient formats are
#    all different)
#
# Long term, KB and Domain should be merged, as their functionality overlaps
#   quite a bit; basically
#     - Introduce becomes a variable in DBound
#     - Constrain becomes DConstrain
#     - DBound becomes DInto
#     - Let becomes (probably?) a one piece partition,
#           or maybe a new variable type
#          (it doesn't seem to appear in present code?)
#  Logically, this is at most an ephemeral change - Domain already generalizes
#   KB. But mechanically it is no small undertaking.
#  assert_deny becomes a "DConstrain" smart constructor (note that in the
#   current AST for Domain, DConstrain appears only at leaves, i.e. products
#   are pushed all the way down; whereas KB is 'flat') but the shape of domains
#   means it is probably much simpler to 'normalize' the constraints all at
#   once, as opposed to when every constrain is inserted, as KB currently does.
#  kb_subtract becomes a similar `domain_combine` function (kb_subtract is really
#   an 'combine' as well as a 'deconstruct into a way to rebuild the KB' together in
#   one - we don't really need the 'deconstruct' part anymore, but 'add' is
#   still useful) - basically this function takes two domains, checks if the
#   variables of the first are a subset of the second (non commutative!) and if
#   so, combines the shapes according to the passed 'shape constructor'; all of
#   the constructors (aside from DInto)
#  gen{whatever} becomes a part of `Domain:-Extract` - basically we will not
#   have `gen` as part of the "interface" to KB+Domain, but rather an entry in
#   the `Ext` function tables.
#  most of the other functions in KB can be basically literally translated to
#    the subset of Domain which corresponds to KB

# The `Domain' type, i.e., its constructors. For a description of the
# intended semantics (as an algebraic datatype), see Domain/Types.mpl
Domain_Type := module()
  option package;
  export
    DOMAIN, DBound, DConstrain, DSum,
    # These intentionally have no definition
    DSplit, DInto, DNoSol;

  DOMAIN := proc()
    local errs := indets([args[2..-1]], specfunc(`DNoSol`));
    if errs <> {} then
      'procname'(args[1], 'DNoSol'(map(op,errs)[]));
    end if;
    'procname'(args);
  end proc;

  DBound := proc(a)
    local b,cs;
    b := `if`(nargs>=2,[args[2]],[KB:-empty])[];
    cs := `if`(nargs>=3,[args[3..-1]],[])[];
    'procname'(a,b,cs) ;
  end proc;

  DConstrain := proc()
    local as := {args};
    if false in as then return DSum() end if;
    as := remove(x->x::identical(false),as);
    'procname'(op(as));
  end proc;

  DSum := proc()
    local as := [args];
    as := subsindets(as, specfunc(`DSum`), xs->
                     map(x->if op(0,x)=`DSum` then op(x) else x end if,
                         xs));
    if nops(as) = 1 then return op(1,as) end if;
    'procname'(op(as));
  end proc;
end module;

Domain := module()
    uses Hakaru, Utilities, Partition, SolveTools[Inequality], Domain_Type ;

    local ModuleLoad := proc($)
      local g;
      BindingTools:-load_types_from_table(DomainTypes);

      #op([2,6], ...) of a module is its globals.
      for g in op([2,6], thismodule) do
        if g <> eval(g) then
          unassign(g);
          WARNING("Previous value of global name '%1' erased.", g)
        end if;
        protect(g);
      end do;
      Apply:-ModuleLoad(); # Needed to load types properly (?)
    end proc;

    local ModuleUnload := proc($) NULL; end proc;

    # Extending domain extraction and replacement.
    export ExtBound := table();
    export ExtShape := table();

    export Set_ExtBound := proc(nm,val,$)
      unprotect(Domain:-ExtBound);
      Domain:-ExtBound[nm] := val;
      protect(Domain:-ExtBound);
    end proc;

    export Set_ExtShape := proc(nm,val,$)
      unprotect(Domain:-ExtShape);
      Domain:-ExtShape[nm] := val;
      protect(Domain:-ExtShape);
    end proc;

$include "Domain/Has.mpl"
$include "Domain/Bound.mpl"
$include "Domain/Shape.mpl"
$include "Domain/Types.mpl"
$include "Domain/Extract.mpl"
$include "Domain/Apply.mpl"
$include "Domain/Improve.mpl"

    local default_handlers :=
      Record('f_apply'=((f,x)->f(x)), 'f_nosimp'=(_->FAIL));

    # The main interface to Domain
    export Reduce :=
      proc(e0,dom_ctx::t_kb,handlers0,opts:=[],$)
      local e := e0, dom_specb, dom_specw, dom_spec, dom_ctx1, rn, ws
          , handlers := merge_record_default(default_handlers, handlers0)
          , apply_ctx ;

      # Build the domain
      dom_specb, e, ws := op(Domain:-Extract:-Bound(e));
      # No simplification needed if the bounds are empty
      if Domain:-Bound:-isEmpty(dom_specb)
      then return handlers:-f_nosimp(e0) end if;
      # Bounds are converted to a KB to use during extraction of the shape
      dom_ctx1, rn := Domain:-Bound:-toKB(dom_specb)[];
      dom_specb, e, ws := subs(rn,[dom_specb,e,ws])[];
      dom_specw, e := op(Domain:-Extract:-Shape(e, dom_ctx1));
      # Append the outer context (a KB) to the domain bounds
      dom_specb := DBound(op(1,dom_specb), dom_ctx);
      # Create the actual domain
      dom_spec := DOMAIN(dom_specb, dom_specw);

      # Improve, if necessary, then apply back to the expression
      if dom_specw <> DConstrain() and not ("no_domain" in {opts[]})
      then dom_spec := Domain:-Improve(dom_spec) end if;

      # The handlers which are used by Domain:-Apply
      apply_ctx := Record[handlers]('weights'=table(ws),-'f_apply',-'f_nosimp');
      handlers:-f_apply(Domain:-Apply(dom_spec, apply_ctx), e);
    end proc;

    ModuleLoad();
end module;

max_stars_repo_name: vmchale/hakaru

max_issues_repo_name: vmchale/hakaru

max_forks_repo_name: vmchale/hakaru


text:
(*
 Copyright (C) 2017 M.A.L. Marques

 This Source Code Form is subject to the terms of the Mozilla Public
 License, v. 2.0. If a copy of the MPL was not distributed with this
 file, You can obtain one at http://mozilla.org/MPL/2.0/.
*)

(* type: lda_exc *)

AA := -0.655868:
BB :=  4.888270:
CC :=  3.177037:
DD :=  0.897889:

phi := z -> 1/2*(opz_pow_n(z,2/3) + opz_pow_n(-z,2/3)):

f_rc04 := (rs, zeta) -> phi(zeta)^3 * (AA*arctan(BB + CC*rs) + DD)/rs:

f      := (rs, zeta) -> f_rc04(rs, zeta):


text:
[3][26]/Poprzednio:
[1252][1263]Dutch.
[10906][10933]- Dlaczego?|- Nie jestem pewna.

max_stars_repo_name: backup-fork/subtitle-tools


text:
(*
 Copyright (C) 2017 M.A.L. Marques

 This Source Code Form is subject to the terms of the Mozilla Public
 License, v. 2.0. If a copy of the MPL was not distributed with this
 file, You can obtain one at http://mozilla.org/MPL/2.0/.
*)

(* The B97 function g *)
b97_g := (gamma, cc, x) -> add(cc[i]*(gamma*x^2/(1 + gamma*x^2))^(i-1), i=1..5):

(* The parallel and perpendicular components of the energy *)
b97_fpar  := (lda_func, mgamma, cc, rs, z, xs0, xs1) ->
  + lda_stoll_par(lda_func, rs,  z) * b97_g(mgamma, cc, xs0)
  + lda_stoll_par(lda_func, rs, -z) * b97_g(mgamma, cc, xs1):

b97_fperp := (lda_func, mgamma, cc, rs, z, xs0, xs1) ->
  lda_stoll_perp(lda_func, rs, z) * b97_g(mgamma, cc, sqrt(xs0^2 + xs1^2)/sqrt(2)):

b97_f := (lda_func, gamma_ss, cc_ss, gamma_ab, cc_ab, rs, z, xs0, xs1) ->
  + b97_fpar (lda_func, gamma_ss, cc_ss, rs, z, xs0, xs1)
  + b97_fperp(lda_func, gamma_ab, cc_ab, rs, z, xs0, xs1):


text:
#!/bin/bash maple
# Use `maple -q expand2.mpl -D n=15` to run

e := (x + y + z + w) ^ n:
f := e * (e + w):

st := time[real]():
f := expand(f):
1000*(time[real]() - st);

done

max_issues_repo_name: HQSquantumsimulations/symengine

max_forks_repo_name: HQSquantumsimulations/symengine


text:
(*
 Copyright (C) 2017 M.A.L. Marques

 This Source Code Form is subject to the terms of the Mozilla Public
 License, v. 2.0. If a copy of the MPL was not distributed with this
 file, You can obtain one at http://mozilla.org/MPL/2.0/.
*)

(* type: work_lda *)
(* prefix:
  lda_c_ml1_params *params;

  assert(p->params != NULL);
  params = (lda_c_ml1_params * )(p->params);
*)

C := 6.187335:
b := [2.763169, 1.757515, 1.741397, 0.568985, 1.572202, 1.885389]:

malpha := z -> params_a_fc*((1 + z)^params_a_q + (1 - z)^params_a_q):
mbeta  := z -> (1 + z)^(1/3)*(1 - z)^(1/3)/((1 + z)^(1/3) + (1 - z)^(1/3)):

k := (rs, z) -> C*malpha(z)*mbeta(z)*RS_FACTOR/rs:
Q := (rs, z) ->
  - b[1]/(1 + b[2]*k(rs, z))
  + b[3]*log(1 + b[4]/k(rs, z))/k(rs, z)
  + b[5]/k(rs, z)
  - b[6]/k(rs, z)^2:

f := (rs, zeta) -> 1/2*(RS_FACTOR/rs)^3 * (1 - zeta^2)/4 * Q(rs, zeta):

max_stars_repo_name: rdietric/lsms

max_issues_repo_name: rdietric/lsms

max_forks_repo_name: rdietric/lsms


text:
 # a function returning unary(i + j) * -998
 func $foo (
  var %i i32,
   var %j i32) f32 {
   return (
     recip f32(
       sqrt f32(
      cvt f32 i32(
        mul i32 (
         extractbits i32 1 23 ( add i32 ( bnot i32 (dread i32 %i), lnot i32 (dread i32 %j))),
         neg i32 ( constval i32 -998))))))}

 # EXEC: %irbuild Main.mpl
 # EXEC: %irbuild Main.irb.mpl
 # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl


text:
(*
 Copyright (C) 2017 M.A.L. Marques

 This Source Code Form is subject to the terms of the Mozilla Public
 License, v. 2.0. If a copy of the MPL was not distributed with this
 file, You can obtain one at http://mozilla.org/MPL/2.0/.
*)

(* type: lda_exc *)

$include "vwn.mpl"

f_vwn := (rs, z) ->
  + f_aux(A_vwn[1], b_vwn[1], c_vwn[1], x0_vwn[1], rs)
  + f_aux(A_rpa[3], b_rpa[3], c_rpa[3], x0_rpa[3], rs)*f_zeta(z)*(1 - z^4)/fpp_vwn
  - DRPA(rs, z)*f_zeta(z)*(1 - z^4)
  +  DMC(rs, z)*f_zeta(z):

f := (rs, z) -> f_vwn(rs, z):

max_stars_repo_name: francoMU/lsms


text:
`is_element/binary_trees` := (A::set) -> proc(TT)
 global reason;

 if not(`is_element/full_trees`(A)(TT)) then
  reason := [convert(procname,string),"TT is not a full tree",TT,reason];
  return false;
 fi;

 if not(`is_binary/full_trees`(A)(TT)) then
  reason := [convert(procname,string),"TT is not binary",TT,reason];
  return false;
 fi;
end:

######################################################################

`is_equal/binary_trees` := eval(`is_equal/full_trees`);

######################################################################

`is_leq/binary_trees` := eval(`is_leq/full_trees`);

######################################################################

`list_elements/binary_trees` := proc(A::set)
 option remember;
 local n,L,P,B,C,UUU,VVV,UU,VV;

 n := nops(A);

 if n = 0 then
  return [];
 elif n = 1 then
  return [{A}];
 fi;

 L := NULL;
 P := `list_elements/nonempty_subsets`(A minus {A[n]});

 for B in P do
  C := A minus B;
  UUU := `list_elements/binary_trees`(B);
  VVV := `list_elements/binary_trees`(C);
  L := L,seq(seq({op(UU),op(VV),A},VV in VVV),UU in UUU);
 od;
 return [L];
end:

######################################################################

`random_element/binary_trees` := (A::set) -> proc()
 local n,B,C,UU,VV;

 n := nops(A);
 if n = 0 then return FAIL; fi;
 if n = 1 then return {A}; fi;
 B := `random_element/nonempty_subsets`(A minus {A[n]})();
 C := A minus B;
 UU := `random_element/binary_trees`(B)();
 VV := `random_element/binary_trees`(C)();
 return {op(UU),op(VV),A};
end:

######################################################################
# OEIS: A001147
`count_elements/binary_trees` := proc(A::set) local k; mul(2*k-1,k=1..nops(A)-1); end:


text:
(*
 Copyright (C) 2017 M.A.L. Marques

 This Source Code Form is subject to the terms of the Mozilla Public
 License, v. 2.0. If a copy of the MPL was not distributed with this
 file, You can obtain one at http://mozilla.org/MPL/2.0/.
*)

(* type: mgga_exc *)
(* prefix:
  mgga_c_bc95_params *params;

  assert(p->params != NULL);
  params = (mgga_c_bc95_params * )(p->params);
*)

$define lda_c_pw_params
$define lda_c_pw_modified_params
$include "lda_c_pw.mpl"

(* The B97 function g *)
bc95_gpar  := (xs, ts) -> ts*Fermi_D(xs, ts)/(K_FACTOR_C*(1 + params_a_css*xs^2)^2):
bc95_gperp := (xs0, xs1) -> 1/(1 + params_a_copp*(xs0^2 + xs1^2)):

(* The parallel and perpendicular components of the energy *)
bc95_fpar  := (rs, z, xs0, xs1, ts0, ts1) ->
  + lda_stoll_par(f_pw, rs,  z,  1) * bc95_gpar(xs0, ts0)
  + lda_stoll_par(f_pw, rs, -z, -1) * bc95_gpar(xs1, ts1):

bc95_fperp := (rs, z, xs0, xs1) ->
  lda_stoll_perp(f_pw, rs, z) * bc95_gperp(xs0, xs1):

f_bc95 := (rs, z, xs0, xs1, ts0, ts1) ->
  + bc95_fpar (rs, z, xs0, xs1, ts0, ts1)
  + bc95_fperp(rs, z, xs0, xs1):

f := (rs, z, xt, xs0, xs1, us0, us1, ts0, ts1) ->
 f_bc95(rs, z, xs0, xs1, ts0, ts1):


text:
(*
 Copyright (C) 2017 M.A.L. Marques

 This Source Code Form is subject to the terms of the Mozilla Public
 License, v. 2.0. If a copy of the MPL was not distributed with this
 file, You can obtain one at http://mozilla.org/MPL/2.0/.
*)

(* type: work_gga_c *)
(* prefix:
  gga_c_sogga11_params *params;

  assert(p->params != NULL);
  params = (gga_c_sogga11_params * )(p->params);
*)

$define lda_c_pw_params
$define lda_c_pw_modified_params
$include "lda_c_pw.mpl"

mbeta  := 15.75592*0.004235: (* the usual value of 0.066726 *)
malpha := mbeta/(16*2^(2/3)):

yy := (rs, z, xt) -> -malpha*mphi(z)*xt^2/(rs*f_pw(rs, z)):

f0 := (rs, z, xt) -> 1 - 1/(1 + yy(rs, z, xt)):
f1 := (rs, z, xt) -> 1 - exp(-yy(rs, z, xt)):

t0 := (rs, z, xt) -> add(params_a_sogga11_a[i]*f0(rs, z, xt)^(i-1), i=1..6):
t1 := (rs, z, xt) -> add(params_a_sogga11_b[i]*f1(rs, z, xt)^(i-1), i=1..6):

f_sogga11 := (rs, z, xt, xs0, xs1) ->
  f_pw(rs, z)*(t0(rs, z, xt) + t1(rs, z, xt)):

f  := (rs, z, xt, xs0, xs1) -> f_sogga11(rs, z, xt, xs0, xs1):


text:
(*
 Copyright (C) 2017 M.A.L. Marques

 This Source Code Form is subject to the terms of the Mozilla Public
 License, v. 2.0. If a copy of the MPL was not distributed with this
 file, You can obtain one at http://mozilla.org/MPL/2.0/.
*)

(* type: lda_exc *)

params_a_alpha := 1:
$include "lda_x.mpl"

beta := rs -> (9*Pi/4)^(1/3)/(rs*M_C):
phi  := rs -> 1 - 1.5*(sqrt(1 + beta(rs)^2)/beta(rs) - arcsinh(beta(rs))/beta(rs)^2)^2:

f    := (rs, z) -> f_lda_x(rs, z)*phi(rs):


text:
print "Give a number: ";
var n : int;
read n;
var v : int := 2;
var i : int;
for i in 1..n do
v := v * i;
end for;
print "The result is: ";
print v;
print "\n";

max_stars_repo_name: nicohi/mini-pl-interpreter

max_issues_repo_name: nicohi/mini-pl-interpreter

max_forks_repo_name: nicohi/mini-pl-interpreter


text:
var X : int := 4 + (6 * 2);
print X;
print "\n";


text:
# Strehl's identity. See §7.2.1 in “Multiple binomial sums”.

# The identity is S1 = S2.
S1 := Sum(z^n*Sum(Binomial3(n,k)*Multinomial([n,k])*Sum(Binomial3(k,j)^3, j=0..infinity), k=0..infinity), n=0..infinity);
S2 := Sum(z^n*Sum(Binomial3(n,k)^2*Binomial3(n+k,k)^2, k=0..infinity), n=0..infinity);

# Quick check
BinomSums[computesum](S1, 5) - BinomSums[computesum](S2, 5);

R1, ord1 := BinomSums[sumtores](S1, u);

# Consistency check
BinomSums[rser](R1, ord1, 6);

R2, ord2 := BinomSums[sumtores](S2, u);

# Consistency check
BinomSums[rser](R2, ord2, 6);

# For R1 and R2 we find the same Picard Fuchs equation :
# D^3 + (6*t^2 - 153*t + 3)/(t^3 - 34*t^2 + t)*D^2 + (7*t^2 - 112*t + 1)/(t^4 - 34*t^3 + t^2)*D + (t - 5)/(t^4 - 34*t^3 + t^2)
# Since the initial conditions are the same, S1 = S2.

max_stars_repo_name: lairez/binomsum

max_issues_repo_name: lairez/binomsum

max_forks_repo_name: lairez/binomsum


text:
# 以代表元为核心，进行合并、化简以及补全的工作

$ifndef _COMBINE_
$define _COMBINE_

$include "RepSol.mpl"
$include "Utils.mpl"

RepsHolder:=module()
    option object;
    export reps;
end module:

# 重新建立代表元
buildReps:=proc(_sols)
    RepsHolder:-reps:=table();
    addReps(_sols);
    # 按照不变量方程进行排序输出
    return getReps();
end proc:

# 获取排序后的reps
getReps:=proc()
    return sort([entries(eval(RepsHolder:-reps),nolist)],
            key=(x->[x:-osol[1]:-ieqCode,getRep(x:-osol[1])]));
end proc:

# 增加代表元
addReps:=proc(_sols)
    local inds;
    inds:=formReps(_sols);
    return map(x->RepsHolder:-reps[x],inds);
end proc:

# 建立代表元变量
# 同时将条件按复杂度排序
# 现在是按照方程个数排序的
formReps:=proc(_sols)
    local sols,r,ss,rep,inds;
    sols:=select(x->(x:-stateCode=5),_sols);# 只取求解成功的
    inds,sols:=collectObj(sols,x->getRep(x),output=[ind,val]);# 按代表元分类
    for ss in sols do
        rep:=getRep(ss[1]);
        if assigned(RepsHolder:-reps[rep]) then
            r:=RepsHolder:-reps[rep];
        else
            r:=Object(RepSol);
            RepsHolder:-reps[rep]:=r;
        end if ;
        map[2](RepSol:-appendSol,r,ss);
        uniqueAndSort(r);
        # conRefine(r);
    end do;
    return inds;
end proc:

# 删除某个rep
rmRep:=proc(r::RepSol)
    local rep;
    rep:=getRep(r:-osol[1]);
    if assigned(RepsHolder:-reps[rep]) then
        RepsHolder:-reps[rep]:=evaln(RepsHolder:-reps[rep]);
    end if;
    return NULL;
end proc:

# 修改rep
updateRep:=proc(r::RepSol)
    RepsHolder:-reps[getRep(r:-osol[1])]:=r;
end proc:

$endif


text:
$ifndef _TSOLS_LIST_
$define _TSOLS_LIST_

$include "Utils.mpl"

TsolsList:=module()
    option object;
    export
            reps,
            teqs,
            torders,
            tsols,
            tcons,
            ModuleApply::static,
            sortTsolsList::static,
            printTsolsList::static;

    ModuleApply:=proc(ss::list(TeqSol))
        local s;
        s:=Object(TsolsList);
        s:-reps:=map(x->getRep(x)$getNSols(x),ss);
        s:-teqs:=map(x->x:-teq[x:-teqInd][],ss);
        s:-torders:=map(x->x:-teqInd[],ss);
        s:-tsols:=map(x->x:-tsols[],ss);
        s:-tcons:=map(x->x:-tcons[],ss);
        sortTsolsList(s);
        return s;
    end proc:

    sortTsolsList:=proc(s::TsolsList)
        local ind,n:=numelems(s:-reps);
        ind:=map(x->`if`(x=[],1,0),s:-tsols)*n^3 # 有解的排在无解的前面
            +numelems~(s:-tcons)*n^2             # 约束条件少的排在前面
            +sortByComplexity(s:-tcons,index)*n; # 约束条件简单的排在前面
        ind:=sort(ind,output=permutation);
        s:-reps:=s:-reps[ind];
        s:-teqs:=s:-teqs[ind];
        s:-torders:=s:-torders[ind];
        s:-tsols:=s:-tsols[ind];
        s:-tcons:=s:-tcons[ind];
    end proc:

    printTsolsList:=proc(s::TsolsList)
        local i,n:=numelems(s:-reps);
        printf("============================================\n");
        for i from 1 to n do
            printf(`if`(s:-torders[i]=1,"正向\n","逆向\n"));
            print(s:-reps[i]);
            # print(s:-teqs[i]);
            print(s:-tsols[i]);
            print(s:-tcons[i]);
        end do;
        printf("============================================\n");
        return;
    end proc:

end module:
$endif


text:
######################################################################
# simplex(A) is the set of maps x : A -> [0,1] with sum = 1.

`is_element/simplex` := (A::set) -> proc(x)
 local a,u,v;
 global reason;

 if not type(x,table) then
  reason := [convert(procname,string),"x is not a table",x];
  return false;
 fi;

 if map(op,{indices(x)}) <> A then
  reason := [convert(procname,string),"x is not indexed by A",x,A];
  return false;
 fi;

 v := 0;
 for a in A do
  u := x[a];
  if not (`is_element/RR`(u) and u >= 0 and u <= 1) then
   reason := [convert(procname,string),"x[a] is not in the unit interval",a,u];
   return false;
  fi;

  v := v + u;
 od;

 if simplify(v - 1) <> 0 then
  reason := [convert(procname,string),"entries in x do not sum to 1",x,v];
  return false;
 fi;

 return true;
end;

`is_equal/simplex` := (A::set) -> proc(x,y)
 local a;
 global reason;

 for a in A do
  if simplify(x[a] - y[a]) <> 0 then
   reason := [convert(procname,string),"x[a] <> y[a]",a,x[a],y[a]];
   return false;
  fi;
 od;
 return true;
end;

`is_leq/simplex` := NULL;

`random_element/simplex` := (A::set) -> proc(d::posint := 5)
 local x,a,r1,r2,u;
 if A = {} then return FAIL; fi;

 r1 := rand(0..d);
 r2 := rand(1..d);
 x := table();
 u := 0;
 while u = 0 do
  for a in A do
   x[a] := r1()/r2();
   u := u + x[a];
  od;
 od;

 for a in A do x[a] := x[a]/u; od;

 return eval(x);
end;

`list_elements/simplex` := NULL;
`count_elements/simplex` := NULL;


text:
(*
 Copyright (C) 2017 M.A.L. Marques

 This Source Code Form is subject to the terms of the Mozilla Public
 License, v. 2.0. If a copy of the MPL was not distributed with this
 file, You can obtain one at http://mozilla.org/MPL/2.0/.
*)

(* type: gga_exc *)

herman_c1 := 0.003:

herman_f := x -> 1 + herman_c1/X_FACTOR_C * x^2:

f := (rs, zeta, xt, xs0, xs1) -> gga_exchange(herman_f, rs, zeta, xs0, xs1):


text:
(*
    所有文件的变量和函数声明
*)

$ifndef _HEADERS_
$define _HEADERS_

# Basic.mpl
export
        d,                              # 导出微分算子，用于生成输入表达式
        setSymbols,                     # 设置输入表达式所含变量
        getSymbols;                     # 获取输入表达式所含变量
local
        SymsHolder,                     # 保留符号信息
        getTransMatAndPDE,              # 获取伴随变换矩阵和偏微分方程
        getInvariants,                  # 根据偏微分方程获取不变量

        `&c`,                           # 交换子运算符
        getKd,                          # 将表达式分解为非线性项并提取系数
        getPmVec,                       # 获取表达式关于给定非线性项集的系数向量
        ans2v,                          # 求解表达式关于基的线性表出

        getPDE;                         # 获取生成不变量的偏微分方程
uses    Pa=`\x26\x50\x61\x72\x74\x69\x61\x6C\x44\x3B`;

# Classifyer.mpl
local
        ClassifyHolder,             # 状态保存器
        getCname,                   # 获取不变量方程中常数项c[k]的名字
        getIeqCode,                 # 获取不变量方程的编号
        getUsolsKey,                # 获取全零方程在usols中的key
        getNewSols,                 # 获取新解
        addSol,                     # 新增解
        reset,                      # 状态重置

        buildInvEqs,                # 构造不变量方程
        genInvariants,              # 产生新的不变量
        subsOeq,                    # 产生新的偏微分方程
        solveInvEqs,                # 求解不变量方程
        solveAllZero,               # 求解全零不变量方程
        fetchRep,                   # 取特解定代表元
        solveTransEq,               # 求解伴随变换方程
        solveRestAllZeroIeqs,       # 求解剩余全零不变量方程
        solveTeq,                   # 指定求解伴随变换方程

        clearConditions,            # 删去与a无关的约束
        eqOfEpsilon,                # 检查是否和epsilon有关
        printDeltas,                # 输出Delta

        ieqsolve,                   # 自定义求解不变量方程
        teqsolve,                   # 自定义求解变换方程

        resolve,                    # 重新分类
        classify;                   # 自动分类
export
        getSols;                    # 获取所有解

# Combine.mpl
export
        rmRep,                      # 删除代表元
        updateRep,                  # 修改代表元
        getReps;                    # 获取排序后的代表元
local
        RepsHolder,                 # 保存reps
        buildReps,                  # 重新计算代表元
        addReps,                    # 新增代表元
        formReps;                   # 建立代表元

# Condition.mpl
local
        findSolutionDomain,         # 求解解的定义域
        classifySolve,              # 分类求解约束
        findDomain,                 # 求解表达式定义域
        findDomainCondtions;        # 求解表达式约束条件

# Fetch.mpl
export  fetchSolRep;                # 取特解
local
        fetchSpecSol,               # 根据方程和约束取特解
        rebuildAndFetch,            # 转化关于c的不等式约束之后，再对约束进行分类
        fetchByCons,                # 求解关于a的约束之后，转化为单边约束，再逐解取特解
        fetchBySingleCons,          # 对于和a有关的约束，采用逐步替换的方法取特解
        isSingleCon,                # 是否是单变量约束
        filtCon,                    # 筛选：自由变量，确定性约束，和c无关的不等式约束，和c有关的不等式约束
        transIeq,                   # 将不等式约束转化为等式约束
        fetchIeq;                   # 最邻近整数方法取特解

# InvSimplify.mpl
local
        simplifyInvariants,             # 化简不变量
        simplifyInvs,                   # 单次化简
        simpleSimplify,                 # 消除不变量的倍数
        myAlgsubs,                      # 解决algsubs对分式进行替换的问题
        dealsubs,                       # 预处理替换表达式
        rmOrd,                          # 简化不变量次数
        getOrd,                         # 获取连乘项的各项幂次
        setOrd,                         # 设置连乘项的各项幂次
        isInv,                          # 检查是否为不变量
        rmK,                            # 删除多项式的倍数
        myGcd,                          # 多个数的gcd
        spAdd,                          # 简化不变量之和
        spMul,                          # 简化不变量之积
        invOrd;                         # 化简分数次数的不变量

# InvOrder.mpl
local   findInvariantsOrder,        # 计算不变量阶数
        findOrder,                  # 计算表达式阶数（不含分母）
        findItemOrder;              # 计算某一项的阶数

# Utils.mpl
local
        sortByComplexity,           # 表达式按照复杂度进行排序
        tappend,                    # 按照集合拓展table键值
        tpop,                       # 提取并删除值
        collectObj,                 # 对象按键值分类
        uniqueObj;                  # 对象按键值唯一化

# Interaction.mpl
export

        canTransform,               # 检查两个代表元之间能否相互转化
        resolveRep,                 # 添加新的RepSol进行求解
        resolveSol,                 # 添加新的InvSol进行求解
        fetchNewRep,                # 获取新的代表元

        summaryReps,                # 简要输出代表元及其成立条件以及不变量方程和变换方程的解
        printRepCon,                # 简要输出代表元及其成立条件
        printSols,                  # 输出所有InvSol
        printReps;                  # 输出所有RepSol
local
        testTransform;              # 检查两个解之间能否相互转化

# Logout.mpl
(*
    输出级别：
        1   输出所有过程
        2   输出关键结果
        3   不输出
*)
export  setLogLevel;                # 设置输出级别
local
        LogLevelHolder,             # 保留logLevel状态
        flog,                       # 对应 print
        flogf;                      # 对应 printf

$endif


text:
flavor 1
srclang 3
id 65535
numfuncs 4
import "IteratorAndTemplateTest.mplt"
import "/home/bravewtz/Desktop/openarkcompiler/libjava-core/libjava-core.mplt"
entryfunc &LIteratorAndTemplateTest_3B_7Cmain_7C_28ALjava_2Flang_2FString_3B_29V
fileinfo {
  @INFO_filename "IteratorAndTemplateTest.jar"}
srcfileinfo {
  1 "IteratorAndTemplateTest.java"}
javaclass $LIteratorAndTemplateTest_3B <$LIteratorAndTemplateTest_3B> public
func &LIteratorAndTemplateTest_3B_7C_3Cinit_3E_7C_28_29V public constructor (var %_this <* <$LIteratorAndTemplateTest_3B>>) void
func &LIteratorAndTemplateTest_3B_7Cmain_7C_28ALjava_2Flang_2FString_3B_29V public static (var %Reg0_R743 <* <[] <* <$Ljava_2Flang_2FString_3B>>>>) void
func &LIteratorAndTemplateTest_3B_7CtestIterator_7C_28_29V public static () void
func &LIteratorAndTemplateTest_3B_7CtestTemplate_7C_28_29V public static () void
var $_C_STR_480065006c006c006f00 fstatic <[4] u64> readonly = [0, 0xb00000000, 0x6c6c6548042628b2, 111]
var $_C_STR_200057006f0072006c006400 fstatic <[4] u64> readonly = [0, 0xd00000000, 0x726f57203b993f52, 0x646c]
var $Ljava_2Flang_2FSystem_3B_7Cout extern <* <$Ljava_2Fio_2FPrintStream_3B>> final public static
var $__cinf_Ljava_2Flang_2FString_3B <$__class_meta__>
func &MCC_GetOrInsertLiteral () <* <$Ljava_2Flang_2FString_3B>>
func &LIteratorAndTemplateTest_3B_7C_3Cinit_3E_7C_28_29V public constructor (var %_this <* <$LIteratorAndTemplateTest_3B>>) void {
  funcid 48153
  var %Reg1_R43694 <* <$LIteratorAndTemplateTest_3B>>
  var %Reg1_R57 <* <$Ljava_2Flang_2FObject_3B>>

  dassign %Reg1_R43694 0 (dread ref %_this)
  #INSTIDX : 0||0000:  aload_0
  #INSTIDX : 1||0001:  invokespecial
  dassign %Reg1_R57 0 (retype ref <* <$Ljava_2Flang_2FObject_3B>> (dread ref %Reg1_R43694))
  callassigned &Ljava_2Flang_2FObject_3B_7C_3Cinit_3E_7C_28_29V (dread ref %Reg1_R57) {}
  #INSTIDX : 4||0004:  return
  return ()
}
func &LIteratorAndTemplateTest_3B_7Cmain_7C_28ALjava_2Flang_2FString_3B_29V public static (var %Reg0_R743 <* <[] <* <$Ljava_2Flang_2FString_3B>>>>) void {
  funcid 48154

  intrinsiccallwithtype <$LIteratorAndTemplateTest_3B> JAVA_CLINIT_CHECK ()
  #INSTIDX : 0||0000:  invokestatic
  intrinsiccallwithtype <$LIteratorAndTemplateTest_3B> JAVA_CLINIT_CHECK ()
  callassigned &LIteratorAndTemplateTest_3B_7CtestIterator_7C_28_29V () {}
  #INSTIDX : 3||0003:  invokestatic
  intrinsiccallwithtype <$LIteratorAndTemplateTest_3B> JAVA_CLINIT_CHECK ()
  callassigned &LIteratorAndTemplateTest_3B_7CtestTemplate_7C_28_29V () {}
  #INSTIDX : 6||0006:  return
  return ()
}
func &LIteratorAndTemplateTest_3B_7CtestIterator_7C_28_29V public static () void {
  funcid 48155
  var %Reg0_R2958 <* <$Ljava_2Futil_2FArrayList_3B>>
  var %Reg4_R2958 <* <$Ljava_2Futil_2FArrayList_3B>>
  var %Reg0_R43 <* <$Ljava_2Flang_2FString_3B>>
  var %Reg1_R43 <* <$Ljava_2Flang_2FString_3B>>
  var %L_STR_161343 <* <$Ljava_2Flang_2FString_3B>>
  var %Reg4_R3006 <* <$Ljava_2Futil_2FAbstractCollection_3B>>
  var %Reg0_R57 <* <$Ljava_2Flang_2FObject_3B>>
  var %Reg0_Z u1
  var %L_STR_161344 <* <$Ljava_2Flang_2FString_3B>>
  var %Reg0_R562 <* <$Ljava_2Fio_2FPrintStream_3B>>
  var %Reg1_I i32

  intrinsiccallwithtype <$LIteratorAndTemplateTest_3B> JAVA_CLINIT_CHECK ()
  #INSTIDX : 0||0000:  new
  intrinsiccallwithtype <$Ljava_2Futil_2FArrayList_3B> JAVA_CLINIT_CHECK ()
  dassign %Reg0_R2958 0 (gcmalloc ref <$Ljava_2Futil_2FArrayList_3B>)
  #INSTIDX : 3||0003:  dup
  #INSTIDX : 4||0004:  invokespecial
  callassigned &Ljava_2Futil_2FArrayList_3B_7C_3Cinit_3E_7C_28_29V (dread ref %Reg0_R2958) {}
  #INSTIDX : 7||0007:  astore_0
  dassign %Reg4_R2958 0 (dread ref %Reg0_R2958)
  #INSTIDX : 8||0008:  aload_0
  #INSTIDX : 9||0009:  new
  intrinsiccallwithtype <$Ljava_2Flang_2FString_3B> JAVA_CLINIT_CHECK ()
  dassign %Reg0_R43 0 (gcmalloc ref <$Ljava_2Flang_2FString_3B>)
  #INSTIDX : 12||000c:  dup
  #INSTIDX : 13||000d:  ldc
  callassigned &MCC_GetOrInsertLiteral (addrof ptr $_C_STR_480065006c006c006f00) { dassign %L_STR_161343 0 }
  dassign %Reg1_R43 0 (dread ptr %L_STR_161343)
  #INSTIDX : 15||000f:  invokespecial
  callassigned &Ljava_2Flang_2FString_3B_7C_3Cinit_3E_7C_28Ljava_2Flang_2FString_3B_29V (dread ref %Reg0_R43, dread ref %Reg1_R43) {}
  #INSTIDX : 18||0012:  invokevirtual
  dassign %Reg4_R3006 0 (retype ref <* <$Ljava_2Futil_2FAbstractCollection_3B>> (dread ref %Reg4_R2958))
  dassign %Reg0_R57 0 (retype ref <* <$Ljava_2Flang_2FObject_3B>> (dread ref %Reg0_R43))
  virtualcallassigned &Ljava_2Futil_2FAbstractCollection_3B_7Cadd_7C_28Ljava_2Flang_2FObject_3B_29Z (dread ref %Reg4_R3006, dread ref %Reg0_R57) { dassign %Reg0_Z 0 }
  #INSTIDX : 21||0015:  pop
  #INSTIDX : 22||0016:  aload_0
  #INSTIDX : 23||0017:  new
  intrinsiccallwithtype <$Ljava_2Flang_2FString_3B> JAVA_CLINIT_CHECK ()
  dassign %Reg0_R43 0 (gcmalloc ref <$Ljava_2Flang_2FString_3B>)
  #INSTIDX : 26||001a:  dup
  #INSTIDX : 27||001b:  ldc
  callassigned &MCC_GetOrInsertLiteral (addrof ptr $_C_STR_200057006f0072006c006400) { dassign %L_STR_161344 0 }
  dassign %Reg1_R43 0 (dread ptr %L_STR_161344)
  #INSTIDX : 29||001d:  invokespecial
  callassigned &Ljava_2Flang_2FString_3B_7C_3Cinit_3E_7C_28Ljava_2Flang_2FString_3B_29V (dread ref %Reg0_R43, dread ref %Reg1_R43) {}
  #INSTIDX : 32||0020:  invokevirtual
  dassign %Reg4_R3006 0 (retype ref <* <$Ljava_2Futil_2FAbstractCollection_3B>> (dread ref %Reg4_R2958))
  dassign %Reg0_R57 0 (retype ref <* <$Ljava_2Flang_2FObject_3B>> (dread ref %Reg0_R43))
  virtualcallassigned &Ljava_2Futil_2FAbstractCollection_3B_7Cadd_7C_28Ljava_2Flang_2FObject_3B_29Z (dread ref %Reg4_R3006, dread ref %Reg0_R57) { dassign %Reg0_Z 0 }
  #INSTIDX : 35||0023:  pop
  #INSTIDX : 36||0024:  getstatic
  intrinsiccallwithtype <$Ljava_2Flang_2FSystem_3B> JAVA_CLINIT_CHECK ()
  dassign %Reg0_R562 0 (dread ref $Ljava_2Flang_2FSystem_3B_7Cout)
  #INSTIDX : 39||0027:  aload_0
  #INSTIDX : 40||0028:  invokevirtual
  dassign %Reg4_R3006 0 (retype ref <* <$Ljava_2Futil_2FAbstractCollection_3B>> (dread ref %Reg4_R2958))
  virtualcallassigned &Ljava_2Futil_2FAbstractCollection_3B_7Csize_7C_28_29I (dread ref %Reg4_R3006) { dassign %Reg1_I 0 }
  #INSTIDX : 43||002b:  invokevirtual
  virtualcallassigned &Ljava_2Fio_2FPrintStream_3B_7Cprintln_7C_28I_29V (dread ref %Reg0_R562, dread i32 %Reg1_I) {}
  #INSTIDX : 46||002e:  getstatic
  intrinsiccallwithtype <$Ljava_2Flang_2FSystem_3B> JAVA_CLINIT_CHECK ()
  dassign %Reg0_R562 0 (dread ref $Ljava_2Flang_2FSystem_3B_7Cout)
  #INSTIDX : 49||0031:  aload_0
  #INSTIDX : 50||0032:  invokevirtual
  dassign %Reg4_R3006 0 (retype ref <* <$Ljava_2Futil_2FAbstractCollection_3B>> (dread ref %Reg4_R2958))
  virtualcallassigned &Ljava_2Futil_2FAbstractCollection_3B_7CtoString_7C_28_29Ljava_2Flang_2FString_3B (dread ref %Reg4_R3006) { dassign %Reg1_R43 0 }
  #INSTIDX : 53||0035:  invokevirtual
  virtualcallassigned &Ljava_2Fio_2FPrintStream_3B_7Cprintln_7C_28Ljava_2Flang_2FString_3B_29V (dread ref %Reg0_R562, dread ref %Reg1_R43) {}
  #INSTIDX : 56||0038:  return
  return ()
}
func &LIteratorAndTemplateTest_3B_7CtestTemplate_7C_28_29V public static () void {
  funcid 48156
  var %Reg0_R2958 <* <$Ljava_2Futil_2FArrayList_3B>>
  var %Reg2_R2958 <* <$Ljava_2Futil_2FArrayList_3B>>
  var %Reg0_I i32
  var %Reg0_R5353 <* <$Ljava_2Flang_2FInteger_3B>>
  var %Reg2_R521 <* <$Ljava_2Futil_2FList_3B>>
  var %Reg0_R57 <* <$Ljava_2Flang_2FObject_3B>>
  var %Reg0_Z u1
  var %Reg0_R77 <* <$Ljava_2Futil_2FIterator_3B>>
  var %Reg3_R77 <* <$Ljava_2Futil_2FIterator_3B>>
  var %Reg4_R5353 <* <$Ljava_2Flang_2FInteger_3B>>
  var %Reg0_R562 <* <$Ljava_2Fio_2FPrintStream_3B>>
  var %Reg4_R57 <* <$Ljava_2Flang_2FObject_3B>>

  intrinsiccallwithtype <$LIteratorAndTemplateTest_3B> JAVA_CLINIT_CHECK ()
  #INSTIDX : 0||0000:  new
  intrinsiccallwithtype <$Ljava_2Futil_2FArrayList_3B> JAVA_CLINIT_CHECK ()
  dassign %Reg0_R2958 0 (gcmalloc ref <$Ljava_2Futil_2FArrayList_3B>)
  #INSTIDX : 3||0003:  dup
  #INSTIDX : 4||0004:  invokespecial
  callassigned &Ljava_2Futil_2FArrayList_3B_7C_3Cinit_3E_7C_28_29V (dread ref %Reg0_R2958) {}
  #INSTIDX : 7||0007:  astore_0
  dassign %Reg2_R2958 0 (dread ref %Reg0_R2958)
  #INSTIDX : 8||0008:  aload_0
  #INSTIDX : 9||0009:  iconst_1
  dassign %Reg0_I 0 (constval i32 1)
  #INSTIDX : 10||000a:  invokestatic
  intrinsiccallwithtype <$Ljava_2Flang_2FInteger_3B> JAVA_CLINIT_CHECK ()
  callassigned &Ljava_2Flang_2FInteger_3B_7CvalueOf_7C_28I_29Ljava_2Flang_2FInteger_3B (dread i32 %Reg0_I) { dassign %Reg0_R5353 0 }
  #INSTIDX : 13||000d:  invokeinterface
  dassign %Reg2_R521 0 (retype ref <* <$Ljava_2Futil_2FList_3B>> (dread ref %Reg2_R2958))
  dassign %Reg0_R57 0 (retype ref <* <$Ljava_2Flang_2FObject_3B>> (dread ref %Reg0_R5353))
  interfacecallassigned &Ljava_2Futil_2FList_3B_7Cadd_7C_28Ljava_2Flang_2FObject_3B_29Z (dread ref %Reg2_R521, dread ref %Reg0_R57) { dassign %Reg0_Z 0 }
  #INSTIDX : 18||0012:  pop
  #INSTIDX : 19||0013:  aload_0
  #INSTIDX : 20||0014:  iconst_2
  dassign %Reg0_I 0 (constval i32 2)
  #INSTIDX : 21||0015:  invokestatic
  intrinsiccallwithtype <$Ljava_2Flang_2FInteger_3B> JAVA_CLINIT_CHECK ()
  callassigned &Ljava_2Flang_2FInteger_3B_7CvalueOf_7C_28I_29Ljava_2Flang_2FInteger_3B (dread i32 %Reg0_I) { dassign %Reg0_R5353 0 }
  #INSTIDX : 24||0018:  invokeinterface
  dassign %Reg2_R521 0 (retype ref <* <$Ljava_2Futil_2FList_3B>> (dread ref %Reg2_R2958))
  dassign %Reg0_R57 0 (retype ref <* <$Ljava_2Flang_2FObject_3B>> (dread ref %Reg0_R5353))
  interfacecallassigned &Ljava_2Futil_2FList_3B_7Cadd_7C_28Ljava_2Flang_2FObject_3B_29Z (dread ref %Reg2_R521, dread ref %Reg0_R57) { dassign %Reg0_Z 0 }
  #INSTIDX : 29||001d:  pop
  #INSTIDX : 30||001e:  aload_0
  #INSTIDX : 31||001f:  invokeinterface
  dassign %Reg2_R521 0 (retype ref <* <$Ljava_2Futil_2FList_3B>> (dread ref %Reg2_R2958))
  interfacecallassigned &Ljava_2Futil_2FList_3B_7Citerator_7C_28_29Ljava_2Futil_2FIterator_3B (dread ref %Reg2_R521) { dassign %Reg0_R77 0 }
  #INSTIDX : 36||0024:  astore_1
  dassign %Reg3_R77 0 (dread ref %Reg0_R77)
@label0   #INSTIDX : 37||0025:  aload_1
  #INSTIDX : 38||0026:  invokeinterface
  interfacecallassigned &Ljava_2Futil_2FIterator_3B_7ChasNext_7C_28_29Z (dread ref %Reg3_R77) { dassign %Reg0_Z 0 }
  #INSTIDX : 43||002b:  ifeq
  brtrue @label1 (eq i32 i32 (dread u1 %Reg0_Z, constval i32 0))
  #INSTIDX : 46||002e:  aload_1
  #INSTIDX : 47||002f:  invokeinterface
  interfacecallassigned &Ljava_2Futil_2FIterator_3B_7Cnext_7C_28_29Ljava_2Flang_2FObject_3B (dread ref %Reg3_R77) { dassign %Reg0_R57 0 }
  #INSTIDX : 52||0034:  checkcast
  intrinsiccallwithtypeassigned <* <$Ljava_2Flang_2FInteger_3B>> JAVA_CHECK_CAST (dread ref %Reg0_R57) { dassign %Reg0_R5353 0 }
  #INSTIDX : 55||0037:  astore_2
  dassign %Reg4_R5353 0 (dread ref %Reg0_R5353)
  #INSTIDX : 56||0038:  getstatic
  intrinsiccallwithtype <$Ljava_2Flang_2FSystem_3B> JAVA_CLINIT_CHECK ()
  dassign %Reg0_R562 0 (dread ref $Ljava_2Flang_2FSystem_3B_7Cout)
  #INSTIDX : 59||003b:  aload_2
  #INSTIDX : 60||003c:  invokevirtual
  dassign %Reg4_R57 0 (retype ref <* <$Ljava_2Flang_2FObject_3B>> (dread ref %Reg4_R5353))
  virtualcallassigned &Ljava_2Fio_2FPrintStream_3B_7Cprintln_7C_28Ljava_2Flang_2FObject_3B_29V (dread ref %Reg0_R562, dread ref %Reg4_R57) {}
  #INSTIDX : 63||003f:  goto
  goto @label0
@label1   #INSTIDX : 66||0042:  return
  return ()
}


text:
 func &addf32r(
  var %i f32, var %j f32
  ) f32 {
   return (
     add f32(dread f32 %i, dread f32 %j))}

 func &addf32I (
  var %i f32
  ) f32 {
   return (
     add f32(dread f32 %i,
       constval f32 1.234f))}
 # EXEC: %irbuild Main.mpl
 # EXEC: %irbuild Main.irb.mpl
 # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl


text:
read "../IdentifiabilityODE.mpl";

sys := [
diff(v(t), t) = k*y(t) - v(t)*u,
diff(x(t), t) = lm - x(t)*d - x(t)*v(t)*beta,
diff(z(t), t) = c*w(t)*q*y(t) - h*z(t),
diff(w(t), t) = -b*w(t) + c*w(t)*x(t)*y(t) - c*w(t)*q*y(t),
diff(y(t), t) = x(t)*v(t)*beta - a*y(t),
y2(t) = z(t),
y1(t) = w(t)
];
CodeTools[CPUTime](IdentifiabilityODE(sys, GetParameters(sys)));


text:
(*
 Copyright (C) 2017 M.A.L. Marques

 This Source Code Form is subject to the terms of the Mozilla Public
 License, v. 2.0. If a copy of the MPL was not distributed with this
 file, You can obtain one at http://mozilla.org/MPL/2.0/.
*)

(* type: gga_exc *)

lag_a1 :=   0.041106:
lag_a2 :=   2.626712:
lag_a3 :=   0.092070:
lag_a4 :=   0.657946:

lag_f0 := s-> lag_a1 * s^lag_a2/(1 + lag_a3 * s^lag_a2)^lag_a4:
lag_f  := x-> lag_f0(X2S*x):

f := (rs, zeta, xt, xs0, xs1) -> gga_exchange(lag_f, rs, zeta, xs0, xs1):


text:
flavor 1
srclang 3
id 65535
numfuncs 2
import "huaweitest.mplt"
import "/home/bravewtz/Desktop/openarkcompiler/libjava-core/libjava-core.mplt"
entryfunc &Lhuaweitest_3B_7Cmain_7C_28ALjava_2Flang_2FString_3B_29V
fileinfo {
  @INFO_filename "huaweitest.jar"}
srcfileinfo {
  1 "huaweitest.java"}
javaclass $Lhuaweitest_3B <$Lhuaweitest_3B> public
func &Lhuaweitest_3B_7C_3Cinit_3E_7C_28_29V public constructor (var %_this <* <$Lhuaweitest_3B>>) void
func &Lhuaweitest_3B_7Cmain_7C_28ALjava_2Flang_2FString_3B_29V public static (var %Reg2_R743 <* <[] <* <$Ljava_2Flang_2FString_3B>>>>) void
var $_C_STR_907ba9a10d33c74f1c37be3b41544334 fstatic <[10] u64> readonly = [0, 0x6b00000000, 0x20490949984357f2, 0x4909490909490920, 0x909494949494949, 0x2020202020202049, 0x2020200909492020, 0x4949494920204920, 0x4949202049494949, 73]
var $_C_STR_194a027f7d649763903a7dcda50cf5a0 fstatic <[9] u64> readonly = [0, 0x5b00000000, 0x94909491faf02dc, 0x2009490949090949, 0x2020492009094920, 0x4920492020202020, 0x4920202020202020, 0x2020090949202020, 73]
var $_C_STR_901191d3899ab5fc7be3d97fe762f978 fstatic <[9] u64> readonly = [0, 0x5f00000000, 0x49494949fbe6d2fb, 0x4909490909490949, 0x2020090949202009, 0x2049202020202049, 0x2020202020492020, 0x909492020200949, 0x492020]
var $_C_STR_4a20a28a5a71422be90661b1072ca29e fstatic <[9] u64> readonly = [0, 0x6500000000, 0x94909494f3904e4, 0x2009490949090949, 0x4920202009094920, 0x2020202049202020, 0x2009492020204920, 0x4949494949492020, 0x492020204949]
var $_C_STR_e4c52869a15445bee0db530b07e9b98a fstatic <[8] u64> readonly = [0, 0x5100000000, 0x949094949ddeb72, 0x2009490949090949, 0x4920490909094920, 0x4920202020202020, 0x949202020094920, 0x49202009]
var $_C_STR_58a8c3b0d70b92b64324906ef9c02c90 fstatic <[10] u64> readonly = [0, 0x6d00000000, 0x94909497041ce40, 0x4949494949494949, 0x4949494949490949, 0x2049200909494949, 0x2020202020202020, 0x4949492020200949, 0x4920094949494949, 0x4949]
var $Ljava_2Flang_2FSystem_3B_7Cout extern <* <$Ljava_2Fio_2FPrintStream_3B>> final public static
var $__cinf_Ljava_2Flang_2FString_3B <$__class_meta__>
func &MCC_GetOrInsertLiteral () <* <$Ljava_2Flang_2FString_3B>>
func &Lhuaweitest_3B_7C_3Cinit_3E_7C_28_29V public constructor (var %_this <* <$Lhuaweitest_3B>>) void {
  funcid 48153
  var %Reg1_R43694 <* <$Lhuaweitest_3B>>
  var %Reg1_R57 <* <$Ljava_2Flang_2FObject_3B>>

  dassign %Reg1_R43694 0 (dread ref %_this)
  #INSTIDX : 0||0000:  aload_0
  #INSTIDX : 1||0001:  invokespecial
  dassign %Reg1_R57 0 (retype ref <* <$Ljava_2Flang_2FObject_3B>> (dread ref %Reg1_R43694))
  callassigned &Ljava_2Flang_2FObject_3B_7C_3Cinit_3E_7C_28_29V (dread ref %Reg1_R57) {}
  #INSTIDX : 4||0004:  return
  return ()
}
func &Lhuaweitest_3B_7Cmain_7C_28ALjava_2Flang_2FString_3B_29V public static (var %Reg2_R743 <* <[] <* <$Ljava_2Flang_2FString_3B>>>>) void {
  funcid 48154
  var %Reg0_R562 <* <$Ljava_2Fio_2FPrintStream_3B>>
  var %Reg1_R43 <* <$Ljava_2Flang_2FString_3B>>
  var %L_STR_161334 <* <$Ljava_2Flang_2FString_3B>>
  var %L_STR_161335 <* <$Ljava_2Flang_2FString_3B>>
  var %L_STR_161336 <* <$Ljava_2Flang_2FString_3B>>
  var %L_STR_161337 <* <$Ljava_2Flang_2FString_3B>>
  var %L_STR_161338 <* <$Ljava_2Flang_2FString_3B>>
  var %L_STR_161339 <* <$Ljava_2Flang_2FString_3B>>

  intrinsiccallwithtype <$Lhuaweitest_3B> JAVA_CLINIT_CHECK ()
  #INSTIDX : 0||0000:  getstatic
  intrinsiccallwithtype <$Ljava_2Flang_2FSystem_3B> JAVA_CLINIT_CHECK ()
  dassign %Reg0_R562 0 (dread ref $Ljava_2Flang_2FSystem_3B_7Cout)
  #INSTIDX : 3||0003:  ldc
  callassigned &MCC_GetOrInsertLiteral (addrof ptr $_C_STR_907ba9a10d33c74f1c37be3b41544334) { dassign %L_STR_161334 0 }
  dassign %Reg1_R43 0 (dread ptr %L_STR_161334)
  #INSTIDX : 5||0005:  invokevirtual
  virtualcallassigned &Ljava_2Fio_2FPrintStream_3B_7Cprintln_7C_28Ljava_2Flang_2FString_3B_29V (dread ref %Reg0_R562, dread ref %Reg1_R43) {}
  #INSTIDX : 8||0008:  getstatic
  intrinsiccallwithtype <$Ljava_2Flang_2FSystem_3B> JAVA_CLINIT_CHECK ()
  dassign %Reg0_R562 0 (dread ref $Ljava_2Flang_2FSystem_3B_7Cout)
  #INSTIDX : 11||000b:  ldc
  callassigned &MCC_GetOrInsertLiteral (addrof ptr $_C_STR_194a027f7d649763903a7dcda50cf5a0) { dassign %L_STR_161335 0 }
  dassign %Reg1_R43 0 (dread ptr %L_STR_161335)
  #INSTIDX : 13||000d:  invokevirtual
  virtualcallassigned &Ljava_2Fio_2FPrintStream_3B_7Cprintln_7C_28Ljava_2Flang_2FString_3B_29V (dread ref %Reg0_R562, dread ref %Reg1_R43) {}
  #INSTIDX : 16||0010:  getstatic
  intrinsiccallwithtype <$Ljava_2Flang_2FSystem_3B> JAVA_CLINIT_CHECK ()
  dassign %Reg0_R562 0 (dread ref $Ljava_2Flang_2FSystem_3B_7Cout)
  #INSTIDX : 19||0013:  ldc
  callassigned &MCC_GetOrInsertLiteral (addrof ptr $_C_STR_901191d3899ab5fc7be3d97fe762f978) { dassign %L_STR_161336 0 }
  dassign %Reg1_R43 0 (dread ptr %L_STR_161336)
  #INSTIDX : 21||0015:  invokevirtual
  virtualcallassigned &Ljava_2Fio_2FPrintStream_3B_7Cprintln_7C_28Ljava_2Flang_2FString_3B_29V (dread ref %Reg0_R562, dread ref %Reg1_R43) {}
  #INSTIDX : 24||0018:  getstatic
  intrinsiccallwithtype <$Ljava_2Flang_2FSystem_3B> JAVA_CLINIT_CHECK ()
  dassign %Reg0_R562 0 (dread ref $Ljava_2Flang_2FSystem_3B_7Cout)
  #INSTIDX : 27||001b:  ldc
  callassigned &MCC_GetOrInsertLiteral (addrof ptr $_C_STR_4a20a28a5a71422be90661b1072ca29e) { dassign %L_STR_161337 0 }
  dassign %Reg1_R43 0 (dread ptr %L_STR_161337)
  #INSTIDX : 29||001d:  invokevirtual
  virtualcallassigned &Ljava_2Fio_2FPrintStream_3B_7Cprintln_7C_28Ljava_2Flang_2FString_3B_29V (dread ref %Reg0_R562, dread ref %Reg1_R43) {}
  #INSTIDX : 32||0020:  getstatic
  intrinsiccallwithtype <$Ljava_2Flang_2FSystem_3B> JAVA_CLINIT_CHECK ()
  dassign %Reg0_R562 0 (dread ref $Ljava_2Flang_2FSystem_3B_7Cout)
  #INSTIDX : 35||0023:  ldc
  callassigned &MCC_GetOrInsertLiteral (addrof ptr $_C_STR_e4c52869a15445bee0db530b07e9b98a) { dassign %L_STR_161338 0 }
  dassign %Reg1_R43 0 (dread ptr %L_STR_161338)
  #INSTIDX : 37||0025:  invokevirtual
  virtualcallassigned &Ljava_2Fio_2FPrintStream_3B_7Cprintln_7C_28Ljava_2Flang_2FString_3B_29V (dread ref %Reg0_R562, dread ref %Reg1_R43) {}
  #INSTIDX : 40||0028:  getstatic
  intrinsiccallwithtype <$Ljava_2Flang_2FSystem_3B> JAVA_CLINIT_CHECK ()
  dassign %Reg0_R562 0 (dread ref $Ljava_2Flang_2FSystem_3B_7Cout)
  #INSTIDX : 43||002b:  ldc
  callassigned &MCC_GetOrInsertLiteral (addrof ptr $_C_STR_58a8c3b0d70b92b64324906ef9c02c90) { dassign %L_STR_161339 0 }
  dassign %Reg1_R43 0 (dread ptr %L_STR_161339)
  #INSTIDX : 45||002d:  invokevirtual
  virtualcallassigned &Ljava_2Fio_2FPrintStream_3B_7Cprintln_7C_28Ljava_2Flang_2FString_3B_29V (dread ref %Reg0_R562, dread ref %Reg1_R43) {}
  #INSTIDX : 48||0030:  return
  return ()
}


text:
`mu/BA` := proc()
 apply_bilinear_assoc(`mu_aux0/BA`,`bar/BA`())(args);
 local xx,ca,cb,pa,pb;
 if nargs > 2 then
  return `mu/BA`(`mu/BA`(a,b),args[3..-1]);
 fi;
 if type(a,numeric) or type(b,numeric) then
  return expand(a*b);
 elif type(a,`+`) then
  return map(`mu/BA`,a,b);
 elif type(b,`+`) then
  return map2(`mu/BA`,a,b);
 fi;
 if type(a,`*`) then
  xx := selectremove(type,a,numeric);
  ca := xx[1];
  pa := xx[2];
 else
  ca := 1;
  pa := a;
 fi;
 if type(b,`*`) then
  xx := selectremove(type,b,numeric);
  cb := xx[1];
  pb := xx[2];
 else
  cb := 1;
  pb := b;
 fi;
 if type(pa,specfunc(anything,`bar/BA`)) and
    type(pb,specfunc(anything,`bar/BA`)) then
  return expand(ca*cb*`mu_aux0/BA`(pa,pb));
 else
  return('`mu/BA`'(args))
 fi;
end:

`mu/EA` := proc()
 apply_linear_assoc(`mu0/EA`,`bar/EA`())(args);
end:

`mu/EC` := proc(a,b)
 local xx,ca,cb,pa,pb,na,nb,ka,kb,la,lb,ia,ib;
 if nargs > 2 then
  return `mu/EC`(`mu/EC`(a,b),args[3..-1]);
 fi;
 if type(a,numeric) or type(b,numeric) then
  return expand(a*b);
 elif type(a,`+`) then
  return map(`mu/EC`,a,b);
 elif type(b,`+`) then
  return map2(`mu/EC`,a,b);
 fi;
 if type(a,`*`) then
  xx := selectremove(type,a,numeric);
  ca := xx[1];
  pa := xx[2];
 else
  ca := 1;
  pa := a;
 fi;
 if type(b,`*`) then
  xx := selectremove(type,b,numeric);
  cb := xx[1];
  pb := xx[2];
 else
  cb := 1;
  pb := b;
 fi;
 if type(pa,specfunc(anything,`e/EC`)) and
    type(pb,specfunc(anything,`e/EC`)) then
  na,ka,ia := op(pa);
  nb,kb,ib := op(pb);
  if nb <> na then return FAIL; fi;
  if modp(ka,2) = 1 and modp(kb,2) = 1 then
   return 0;
  fi;
  la := floor(ka/2);
  lb := floor(kb/2);
  return ca * cb * binomial(la+lb,la) * `e/EC`(na,ka+kb,modp(ia+ib,na));
 else
  return('`mu/EC`'(args))
 fi;
end:


text:
inputfile := "AOC4-input.txt":

# parse input
input := subs(""=NULL,StringTools:-Split(
        FileTools:-Text:-ReadFile(inputfile), "\n\n")):
numbers := [parse(input[1])]: # list of numbers to "call"
# list of bingo boards stored as square lists of lists
boards := [seq(map(s->map(parse, StringTools:-Split(s)),
    input[(i-1)*5+2..(i*5+1)]), i=1..ceil( nops(input[2..]) / 5 ))]:

# helper to check for row or column bingos marked with the symbol X
checkbingo := b->ormap(r->numboccur(X,r)=5,b) or
     `or`(seq(numboccur(X,b[..,i])=5,i=1..5)):

answer1 := -1:
for n in numbers while answer1<0 do
    boards := subs(n=X, boards); # mark all the boards at once
    for b in boards while answer1<0 do
        if checkbingo(b) then
            answer1 := add(subs(X=0,map(op,b)))*n;
        end if;
    end do;
end do:
answer1;

for n in numbers while not checkbingo(boards[1]) do
    if nops(boards) > 1 then
        boards := remove(checkbingo, subs(n=X, boards));
    else
        boards := subs(n=X, boards);
        answer2 := add(subs(X=0,map(op,boards[1])))*n;
    end if;
end do:
answer2;


text:
A_infinity_rel := (m) -> proc(n::posint)
 local p,r,s,t,u,i;
 p := 0;
 for r from 0 to n do
  for s from 1 to n-r do
   t := n - r - s;
   u := r + 1 + t;
   p := p + (-1)^(r+s*t) *
    m(u)(seq(x[i],i=1..r),
      m(s)(seq(x[i],i=r+1..r+s)),
      seq(x[i],i=r+s+1..n));
  od;
 od;
 return unapply(p,seq(x[i],i=1..n));
end:

A_infinity_deg := (n) -> n - 2;

twisted_complex_rel := (d) -> proc(u) local i;
 unapply(add((-1)^i * d(i)(d(u-i)(x)),i=0..u),x);
end:

twisted_complex_bideg := (i) -> [i,i-1];

DA_infinity_rel := (mm) -> proc(i::nonnegint,n::posint)
 local p,r,s,t,u,j,k,l,x;
 p := 0;
 for r from 0 to n do
  for s from 1 to n-r do
   for j from 0 to i do
    t := n - r - s;
    u := r + 1 + t;
    k := i - j;
    p := p + (-1)^(r*s+t+k*u) *
     mm(j,u)(seq(x[l],l=1..r),
       mm(k,s)(seq(x[l],l=r+1..r+s)),
       seq(x[l],l=r+s+1..n));
   od;
  od;
 od;
 return unapply(p,seq(x[l],l=1..n));
end:

DA_infinity_bideg := (i,n) -> [i,i+n-2];


text:
input := FileTools:-Text:-ReadFile("AoC-2021-2-input.txt" ):

sample_input := "forward 5
down 5
forward 8
up 3
down 8
forward 2";

# split input into a flat list: one letter directions, and numbers into integers
course := map(s->ifelse(parse(s)::posint, parse(s), s[1]), StringTools:-Split(input)):

hpos := 0:
depth := 0:
aim := 0: # aim = depth in part 1

for i from 1 to nops(course) by 2 do
    if course[i] = "f" then
        x := course[i+1];
        hpos := hpos + x;
        depth := depth + aim*x;
    elif course[i] = "d" then
        aim := aim + course[i+1];
    elif course[i] = "u" then
        aim := aim - course[i+1];
    end if;
end do:

hpos * aim; # answer part 1
hpos * depth; # answer part 2


text:
func $fact (
 var %n i32) i32 {
@fred2
 if (ne i32 i32 (dread i32 %n, constval i32 1)) {
     brfalse @fred2 (dread i32 %n)
@fred1
     return (constval i32 0) }
 else {
     return (constval i32 1) } }
 # EXEC: %irbuild Main.mpl
 # EXEC: %irbuild Main.irb.mpl
 # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl


text:
(*
 Copyright (C) 2017 M.A.L. Marques

 This Source Code Form is subject to the terms of the Mozilla Public
 License, v. 2.0. If a copy of the MPL was not distributed with this
 file, You can obtain one at http://mozilla.org/MPL/2.0/.
*)

(* type: work_gga_c *)
(* prefix:
  gga_x_n12_params *params;

  assert(p->params != NULL);
  params = (gga_x_n12_params * )(p->params);
*)

omega_x := 2.5:
gamma_x := 0.004:

rss := (rs, z) -> rs * (2/(1 + z))^(1/3):

vx := rs -> 1/(1 + (1/(RS_FACTOR*omega_x))*rs):
ux := x -> gamma_x*x^2/(1 + gamma_x*x^2):

FN12 := (rs, x) ->
  + add(1*params_a_CC_0_[i+1]*ux(x)^i, i=0..3)
  + add(1*params_a_CC_1_[i+1]*ux(x)^i, i=0..3) * vx(rs)
  + add(1*params_a_CC_2_[i+1]*ux(x)^i, i=0..3) * vx(rs)^2
  + add(1*params_a_CC_3_[i+1]*ux(x)^i, i=0..3) * vx(rs)^3:

f_n12 := (rs, z, xt, xs0, xs1) -> -X_FACTOR_C*RS_FACTOR*(
  + (1 + z)*FN12(rss(rs,  z), xs0)/(2*rss(rs,  z))
  + (1 - z)*FN12(rss(rs, -z), xs1)/(2*rss(rs, -z))
):

f  := (rs, z, xt, xs0, xs1) -> f_n12(rs, z, xt, xs0, xs1):