• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Nov 19th, 2015 223 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. denseform(n, coeff)={
2.   local(f); f = vector(n);
3.   for(i=1, matsize(coeff)[1], f[coeff[i,1]]+=coeff[i,2]);
4.   f;
5. }
6.
7. \\ inequality t_{ij} > t_{ik}, that is, (k-j)v_i + (i-k) v_j + (j-i) v_k > 0
8. \\ (for i < j < k)
9. collideright(n, i,j,k)=denseform(n, [i, k-j; j, i-k; k, j-i]);
10. collideleft(n, i,j,k) =-collideright(n, i,j,k);
11. collide(n, i,j) = denseform(n, [i,1;j,-1]);
12. notcollide(n, i,j) = -collide(n, i, j);
13.
14. ineq(s)={
15.   local(l, d, depth, match, R);
16.   l=Vec(s); depth=vector(#l); d=0;
17.   for(i=1, #l, depth[i]=d; d+=(l[i]=="(")-(l[i]==")"));
18.   match=vector(#l);
19.   for(i=1, #l, if(l[i]=="(", for(j=i+1, #l,
20.     if(depth[j]==depth[i]+1 && l[j]==")", match[i]=j; match[j]=i; next (2)))));
21.
22.   R=[];
23.   for(i1=1,#l,
24.     if (l[i1] == "(", j1=match[i1];
25.       \\ (): v_i > v_j
26.       R = concat(R, [collide(#l, i1, j1)]);
27.       \\ (())
28.       for (i2=i1+1, j1-1, if (l[i2] == "(", j2=match[i2];
29.         R = concat (R,
30.           [collideright (#l, i1, i2, j2), collideleft (#l, i2, j2, j1)])));
31.       \\ ()()
32.       for (i2=j1+1, #l, if (l[i2] == "(", j2=match[i2];
33.         R = concat (R,
34.           [collideleft (#l, i1, j1, i2), collideright (#l, j1, i2, j2)])))
35.     , if (l[i1] != ")", \\ escaped bullet
36.       \\ !! and !()
37.       for (i2=i1+1, #l, if (l[i2]!=")",
38.         R = concat (R, [notcollide (#l, i1, i2)])));
39.       \\ ()!  (!! already done)
40.       for (i2=1, i1-1, if (l[i2]==")",
41.         R = concat (R, [notcollide (#l, i2, i1)])));
42.     ))
43.   );
44.   R;
45. }
46. polytope(s)={
47.   local(R); R=ineq(s);
48.   concat([vector(#R, i, vector(#s+1,j,if(j<=#s, R[i][j]))),
49.     vector(#s,i, vector(#s+1,j, j==i)),
50.     vector(#s,i, vector(#s+1,j, (j>#s)-(j==i)))]);
51. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top