1 2# PROGRAM FOR COMPUTING THE FUNCTION SL(Polytope,variable); 3 4# 5with(linalg):with(LinearAlgebra):with(combinat): 6kernelopts(assertlevel=1): ### Enable checking ASSERTions 7# General Notations: 8# If we work in R^d: 9# 10# 11# A vector: a list of d rational numbers: 12# A Cone : a list of d vectors of lenght d: (we will only consider simplicial cones) 13# when we say Cone in Z^d we mean that the vectors have integral coordinates; 14# 15# A Signed cone: [epsilon, Cone] where epsilon is -1 or 1. 16# 17# L represents a linear subspace which is represented by a list of linearly independent vectors. 18# 19 20# 21# 22# 23# 24# 25# 26# 27# 28# 29# 30# 31# 32# 33# 34# 35# 36# 37# 38# Programs on lists: addition on lists, complement of a list, sublist,etc... 39# 40# 41# In particular we need them in the extreme cases of empty lists... 42# 43# 44# 45# Input: a a list of lenght m , v a list of m vectors in R^n, n an integer: 46# Output: a list of lenght n; 47# The program check also if a and v have the same nimber of elements 48# Here we deal with the special case where v:=[] where we return the vector with coordinates 0; 49# Math: we compute the vector V:= sum_i a_i v[i]; 50# Example: special_lincomb_v([1,1],[[1,0],[0,1]],2) ->[1,1] 51 52# 53# 54special_lincomb_v:=proc(a,v,n) local out; 55ASSERT(nops(a)=nops(v)," the number of coefficients and vectors do not match"); 56if v=[] then out:=[seq(0,i=1..n)];else 57out:=[seq(add(a[i]*v[i][j],i=1..nops(v)),j=1..nops(v[1]))]; 58fi;out; 59end: 60#special_lincomb_v([1],[[1,0]],2); 61# Input: a a list of lenght n, , v a list of n vectors, n an integer: 62# Output: a list of lenght n; 63# 64# Math: we compute the vector V:= sum_i a_i v[i]; 65# Example: special_lincomb_v([1,1],[[1,0],[0,1]],2) ->[1,1] 66# 67# Same program; 68# but we restrict where the list v is not empty. 69# 70# 71lincomb_v:=proc(a,v) 72ASSERT(nops(a)=nops(v) and nops(v)>=1," the number of coefficients and vectors do not match"); 73 74[seq(add(a[i]*v[i][j],i=1..nops(v)),j=1..nops(v[1]))]; 75 76end: 77#lincomb_v([],[],3); 78# Input: two integers N,d: 79# Output: a vector of lenght d: 80 81# Math: the vector is randomly chosen with coordiantes between 1 and N: 82# 83# 84# 85random_vector:=proc(N,d) local R; 86R:=rand(N); 87[seq(R()+1,i=1..d)]: 88end: 89 90# Input: an integer N and sigma a list of vectors in R^d: 91# Output: a vector of lenght d: 92 93# Math: the vector is sum_i x_i sigma_i, where the x_i are randomly chosen with coordiantes between 1 and N: 94# Example:cone_random_vector(10,[[sigma[1],sigma[2]],[nu[1],nu[2]]])->`invalid character in short integer encoding 17 `; 95# 96# 97cone_random_vector:=proc(N,sigma) local R,d,randcoeff; 98R:=rand(N); 99d:=nops(sigma[1]); 100randcoeff:=random_vector(N,nops(sigma)); 101[seq(add(randcoeff[i]*sigma[i][j],i=1..nops(sigma)),j=1..d)]: 102end: 103#cone_random_vector(10,[[sigma[1],sigma[2]],[nu[1],nu 104 105# Input: K a subset of integers, L a list.The output takes the elements of the list L in the position of the list K 106# 107# 108insert:=proc(K,L) local out; 109out:=[seq(L[K[i]],i=1..nops(K))]; 110end: 111#The output is the Complement List, within the list [1,..,d] 112ComplementList:=proc(K,d); 113RETURN([seq (`if` (member(i,K)=false, i, op({})),i=1..d)]); 114end: 115#The output is the Complement List, within the list [a[1],..,a[d]] 116GeneralComplementList:=proc(K,L)local d;d:=nops(L); 117RETURN([seq (`if` (member(L[i],K)=false, L[i], op({})),i=1..d)]); 118end: 119#GeneralComplementList([2,3],[1,2,3,7]); 120# Miscellanea 121# 122# Input: A :a vector with rational coordinates. 123# Output: A vector with integral coordinates: 124# Math: the primitive vector on the half line R^+A; 125# Example: #primitive_vector([0,-1/2])->[0,-1]; 126 127# 128primitive_vector:=proc(A) local d,n,g; 129d:=nops(A); 130n:=ilcm(seq(denom(A[i]),i=1..d)); 131g:=igcd(seq(n*A[i],i=1..d));if g<>0 then 132[seq(n*A[i]/g,i=1..d)];else [seq(n*A[i],i=1..d)];fi; 133end: 134ortho_basis:=proc(d) local i,v; 135for i from 1 to d do 136v[i]:=[seq(0,j=1..i-1),1,seq(0,j=i+1..d)] 137od;[seq(v[j],j=1..d)]; 138end: 139# Signed decomposition into unimodular cones 140# A "simplicial cone" is a list of d linearly independent vectors in Z^d, sometimes assumed primitive. 141# 142# short_vector(A) 143# 144# # Input: A is a list of d linearly independent vectors. 145# # Output: sho is a vector of dimension d. 146short_vector:=proc(A) local n,base,i,sho; 147n:=nops(A); 148base:=IntegerRelations[LLL](A); 149sho:=base[1]; 150i:=1; 151while i<=n-1 do 152 if max(seq(abs(sho[j]),j=1..n))<=max(seq(abs(base[i+1][j]),j=1..n)) 153 then sho:=sho; else sho:=base[i+1]; 154 fi; 155 i:=i+1; 156od; 157sho; 158end: 159# # sign_entries_vector(V) 160# 161# # Input : vector V of dimension d. 162# # Output: L=[ Lplus,Lminus,Lzero] is a partition of [1..d] into three sublists, 163# # according to the signs of the entries of the vector V. 164sign_entries_vector:=proc(V) local d,i,Lplus,Lminus,Lzero; 165 d:=nops(V); Lplus:=[]; Lminus:=[];Lzero:=[]; 166 167 for i from 1 to d do 168 if type(V[i],positive) then Lplus:=[op(Lplus),i]; 169 elif type(V[i],negative) then Lminus:=[op(Lminus),i]; 170 else Lzero:=[op(Lzero),i]; 171 fi; 172 od; 173[Lplus,Lminus,Lzero]; 174end: 175# # good_vector(G) 176# # 177# # Input G is a "simplicial cone" 178# # Output consists of 2 elements: 179# # V is a vector in Z^d. 180# # L=[ Lplus,Lminus,Lzero] is a partition of [1..d] into three sublists, 181# # according to the signs of the entries of the vector V. in the basis G. 182good_vector:=proc(G) local n,A,Ainverse,B,sho,V,L; 183 n:=nops(G); 184 A:=Transpose(Matrix(G)); 185 Ainverse:=MatrixInverse(A); 186 B:=[seq(convert(Ainverse[1..n,i],list),i=1..n)]; 187 sho:=short_vector(B); 188 V :=[seq(add(G[j][i]*sho[j],j=1..n),i=1..n)]; 189 L:= sign_entries_vector(sho); 190[V,L]; 191end: 192# # signed_decomp(eps,G,v,L) 193# 194# # Input : eps = 1 or -1 195# # G is a "simplicial cone" 196# # V is a vector of dim d 197# # L= [ Lplus,Lminus,Lzero] is a partition of [1..d] into three sublists, 198# # 199# # Output : [Nonuni,Uni] 200# # Nonuni and Uni are lists of terms [eps,detG,G], where 201# # eps=1 or -1, 202# # detG is an integer, 203# # G is a list of d linearly independant primitive vectors in Z^d. 204 205signed_decomp:=proc(eps,G,v,L) local Nonuni,Uni,Lplus,Lminus,Lzero,kplus,kminus,kzero,i,j, C,M, detC, Csigned ; 206Nonuni:=[]; Uni:=[]; 207Lplus:=L[1]; Lminus:=L[2]; Lzero:=L[3]; 208 kplus:=nops(Lplus); kminus:=nops(Lminus); kzero:=nops(Lzero); 209if kplus>0 then 210 for i from 1 to kplus do 211 C:=[seq(G[Lplus[j]],j=1..i-1),seq(-G[Lplus[j]],j=i+1..kplus),v,seq(G[Lminus[j]],j=1..kminus),seq(G[Lzero[j]],j=1..kzero)]; 212 213 detC := Determinant(Matrix(C)); 214 Csigned:=[eps*(-1)^(i+kplus),detC,C]; 215 216 if abs(detC)>1 then 217 Nonuni:=[op(Nonuni),Csigned] else Uni:=[op(Uni),Csigned]; 218 fi; 219 od; 220 fi; 221 222if kminus>0 then 223 for i from 1 to kminus do 224 C:=[seq(G[Lplus[j]],j=1..kplus),-v,seq(-G[Lminus[j]],j=1..i-1),seq(G[Lminus[j]],j=i+1..kminus),seq(G[Lzero[j]],j=1..kzero)]; 225 226 detC := Determinant(Matrix(C)); 227 Csigned:=[eps*(-1)^(i+1),detC,C]; 228 229 if abs(detC)>1 then 230 Nonuni:=[op(Nonuni),Csigned] else Uni:=[op(Uni), Csigned]; 231 fi; 232 od; 233 end if; 234 [Nonuni,Uni]; 235 end: 236# 237# 238# # good_cone_dec(eps,G) 239# # Input: eps = 1 or -1 240# # G is a simplicial cone 241# # 242# # Output: two lists [Nonuni,Uni] as in procedure signed_decomp: 243# # 244good_cone_dec:=proc(eps,G) local n,A,R,Output; 245n:=nops(G); A:=Matrix([seq(G[i],i=1..n)]); 246 if abs(Determinant(A))=1 then Output:=[[],[[eps,Determinant(A),G]]]; 247 else R:=good_vector(G); 248 Output:=signed_decomp(eps,G,R[1],R[2]); 249 fi; 250end: 251# # more_decomposition_in_cones(cones) 252# 253# # Input: cones =[cones[1],cones[2]] as in procedure signed_decomp 254# # Output: [Newnonuni,Newuni] as in procedure signed_decomp 255# 256# 257more_decomposition_in_cones:=proc(cones) local i,Newuni,Newnonuni,newcones: 258Newnonuni:=[]; 259Newuni:=cones[2]; 260 for i from 1 to nops(cones[1]) do 261 newcones:=good_cone_dec(cones[1][i][1],cones[1][i][3]); 262 Newnonuni:=[op(Newnonuni),op(newcones[1])]; 263 Newuni:=[op(Newuni),op(newcones[2])]; 264 od; 265[Newnonuni,Newuni]; 266end: 267 268# # cone_dec(G) 269# # 270# # Input: G is a "simplicial cone" 271# # Output: A list of terms [eps,detG,G] where 272# " eps =1 or -1, 273# # detG is an integer ( hopefully 1 or -1), 274# # G is a "simplicial cone", (hopefully unimodular) 275# # 276cone_dec:=proc(G) local seed, i,ok; 277if G=[] then RETURN([[1,1,[]]]);fi: 278seed:=good_cone_dec(1,G); 279 ok:=0; 280i:=1; while ok=0 do 281seed:=more_decomposition_in_cones(seed); 282if seed[1]=[] then 283 ok:=1;else ok:=0;i:=i+1; 284 fi; 285od; 286 RETURN(seed[2]); 287end: 288# Input: A signed list of cones; 289# Output: a set of vectors; 290 291collectgene:=proc(signedcones) local i,j,gene,newgen1,newgen2,gene1,gene2,cc; 292gene:={}; 293for i from 1 to nops(signedcones) do 294cc:=signedcones[i][2]; 295for j from 1 to nops(cc) do 296newgen1:=cc[j]; 297newgen2:=[seq(-cc[j][q],q=1..nops(cc[j]))]; 298gene1:={op(gene),newgen1}; 299gene2:={op(gene),newgen2}; 300if nops(gene1)<=nops(gene2) then 301gene:=gene1; 302else gene:=gene2; fi; 303od; 304od; 305gene; 306end: 307# 308# Signed decomposition into cones with faces parallel to L; 309# 310# Here I have replaced welleda unique long procedure by many smaller procedures that I understand better. 311# 312# 313 314# In this subsection, we solve the following problem: 315# Given a cone Cone(W), and a subspace L, 316# we express the characteristic function of Cone(W) as a signed sum of cones C_a 317# where the cones C_a have the following property: 318# If d=k+dim(L) these cones C_a have d-k generators in L and k other generators in W. 319# Example: L_cone_dec([[1,0],[0,1]],[[1,1]])-> 202, "unexpected end of statement";; 320 321# 322 323# 324# 325# 326# 327# 328# 329# 330# Input: L a subspace: list of s v ectors in R^d; The codimension 331# Output: a list of 332# k=d-s vectors in R^d ; 333# Math: A basis H_1,H_2,...,H_k of the space L^{perp}; 334 335# Example:basis_L_perp([[1,1,1]])->[[-1, 0, 1], [-1, 1, 0]]; 336 337 338 339basis_L_perp:=proc(L) local d,s,ML,VV; 340d:=nops(L[1]); s:=nops(L); 341ML:=Matrix(L): VV:=NullSpace(ML); 342[seq(convert(VV[i],list),i=1..d-s)]; 343end: 344 345# Input: W a list of vectors in R^d; 346# L a list of vectors in R^d of lenght s; 347# Oputput: a list of vectors in R^k; with k=d-s; 348# 349# Math: we project the vectors in X in Lperp; with basis H1,H2,...,Hk; 350# Our list is the list of the projections of the elements of W written in the basis Hk (computed by basis_L_perp(L) as a list): 351# 352# Example: Oursmallmatrix([[1,0,0],[0,1,0],[0,0,1]],[[1,1,1]])-> `invalid character in short integer encoding 203 Ë`;; 353# 354# 355 356Oursmallmatrix:=proc(W,L) local s,d,HH,i,C,M,wbars,j,VV,cW; 357d:=nops(W[1]); s:=nops(L); 358C:=[]; 359HH:=basis_L_perp(L); 360for i from 1 to d-s do 361C:=[op(C),[seq(add(HH[i][k]*HH[j][k],k=1..d),j=1..(d-s))]]; 362od; 363M:=Transpose(Matrix(C)); 364wbars:=[]; 365for j from 1 to nops(W) do 366VV:=Vector([seq(add(W[j][k]*HH[i][k],k=1..d),i=1..(d-s))]); 367cW:=convert(LinearSolve(M,VV),list); 368wbars:=[op(wbars),cW]; 369od; 370wbars; 371end: 372 373 374 375 376#Oursmallmatrix([[1,0,0],[0,1,0],[0,0,1]],[[1,1,1]]);basis_L_perp([[1,1,1]]); 377 378 379# Input: a list of N vectors in R^k; 380# ouput; a list . Each element of the list is [B,B_c,D,edges]. 381# Here B is a subset of [1,...,N]; B_c is the complement subset in [1,...,N]; 382# and D is a Matrix, edges is a list of vectors in R^k. 383# Maths; 384# The list is [a_1,a_2,..., a_N]; 385# B is a subset of B is a subset of [1,...,N] such that a_i, i in B are linearly independent. 386# Then we express w_j with j in B_c as a vector with respect to the basis (w_i,i in B). 387# D is the matrix, edges is the list of colums of this matrix; This is a redundant information, but I kept this because I had problems in converting in lists using only D in the next procedure after. 388# # This procedure should be done using reverse search. 389# 390# 391# AllDictionaries([[1,0],[1,0],[1,1]])-> `invalid character in short integer encoding 212 Ô`;; 392# 393# 394# 395# 396# 397# 398AllDictionaries:=proc(Listvectors) local LL, N,k,K,h,MM,Kc,bandc,Matrix2,Dict,edges,newbc; 399LL:=Listvectors; 400N:=nops(LL); 401k:=nops(LL[1]); 402K:=choose(N,k); 403bandc:=[]; 404for h from 1 to nops(K) do 405MM:=Matrix([seq(LL[K[h][i]],i=1..k)]); 406if Rank(MM)=k then 407Kc:=ComplementList(K[h],N); 408Matrix2:=Transpose(Matrix([seq(LL[Kc[i]],i=1..nops(Kc))])); 409Dict:=MatrixMatrixMultiply(MatrixInverse(Transpose(MM)),Matrix2); 410edges:=[seq(convert(Column(Dict,u),list),u=1..N-k)]; 411newbc:=[K[h],Kc,Dict,edges]; 412bandc:=[op(bandc),newbc]; 413else bandc:=bandc; 414fi; 415od; 416bandc; 417end: 418 419 420 421 422 423 424#DDD:=AllDictionaries([[1,0],[0,1],[1,1]]); 425# Input:= a list of N vectors in R^k 426# Ouput: a vector in R^k; 427# Math: we compute a vector a which is not on any hyperplane generated by some of the vectors in the list. 428# Furthermore, we choose it to be in the cone generated by the list of vectors. 429# 430# I did not do the choice of the "deterministic" regular vector. 431# Example: randomRegularpositivevector([[1,0],[0,1],[1,1]])->[5,10]; 432randomRegularpositivevector:=proc(Listvectors) local LL,t,ok,w,K,f,MM,N,k,indexsigma,sigma; 433LL:=Listvectors; 434N:=nops(LL); 435k:=nops(LL[1]); 436indexsigma:=AllDictionaries(Listvectors)[1][1]; 437sigma:=[seq(LL[indexsigma[i]],i=1..k)]; ###print("sigma",sigma); 438K:=choose(N,k-1); 439t:=1; ok:=0; 440 while t<=10 do 441 w:=cone_random_vector(10*t,sigma); 442f:=1; 443while f<=nops(K) do 444MM:=Matrix([seq(LL[K[f][i]],i=1..k-1),w]); 445if Determinant(MM)<>0 446then 447f:=f+1; 448ok:=ok: 449 ##print('ok,f',ok); 450 else f:=nops(K)+1; 451 ok:=ok+1; 452 fi:od; 453if ok=0 then t:=11; 454else 455t:=t+1;ok:=0; 456fi; 457od: 458w; 459end: 460 461 462#randomRegularpositivevector([[0,0],[0,-1],[-1,-1]]); 463# 464# 465# 466# Input:= a list of N vectors in R^k 467# Ouput: a list of lists: each list is of the form [[sigma,epsilon, listsigns], [complementofsigma,A]]; 468# sigma is a subset of [1,2,...,N], epsilon is a sign, listsigns is a sequence of k elements epsilon_i 469# with epsilon_i a sign. complement of sigma is a subset of [1...N] (the complement of sigma), 470# A is a list of N-k vectors in R^k. 471# Math; sigma, epsilon will lead to generators epsilon_i w_i (i in sigma), the complement of sigma will lead to the generators 472# w_j-a_j^i w_i with j not in sigma. 473# 474# Example: coeff_cone_dec([[1,0],[0,1],[1,1]])->[op1,op2,op3]`invalid character in short integer encoding 212 Ô`; 475# 476# 477# 478 479coeff_cone_dec:=proc(Listvectors) local N,k,w,out,LL,sigma,M1,cw,signswonsigma,edges,coeffs,i; 480LL:=Listvectors; 481N:=nops(LL); 482k:=nops(LL[1]); 483coeffs:=[]; 484w:=randomRegularpositivevector(LL); ##print("randvector",w); 485out:= AllDictionaries(LL); 486for i from 1 to nops(out) do 487sigma:=out[i][1]; ##print(sigma); 488M1:=Matrix([seq(LL[sigma[u]],u=1..nops(sigma))]); 489cw:=convert(LinearSolve(Transpose(M1),Vector(w)),list); 490signswonsigma:=[sigma, mul(sign(cw[j]),j=1..k),[seq(sign(cw[j]),j=1..k)]]; 491coeffs:=[op(coeffs),[signswonsigma,[out[i][2],out[i][4]]]]; 492od; 493coeffs; 494end: 495 496 497 498#op(1,coeff_cone_dec([[1,0],[0,1],[1,1]])); 499# FINALLY: 500# 501# Input: W a list of d vectors in R^d; L a list of vectors in R^d; 502# Output: a list of signed cones in R^d 503# 504# 505# ; 506# 507# Math: W represents a cone, we express the characteristic function of C as a signed sum of cones C_a 508# where the cones C_a have the following property: 509# If d=k+dim(L) these cones C_a have d-k generators in L and k other generators in W. 510# Example: L_cone_dec([[1,0],[0,1]],[[1,1]])-> 202, "unexpected end of statement";; 511 512# 513# 514# 515# 516# 517L_cone_dec:=proc(W,L) local d,LL,coeffs,conedec,i,generatorsonL,coe1,coe2,generatorssigma,u,a,vL,g,conesigma; 518if L=[] 519or nops(W)=Rank(Matrix(L)) then 520RETURN([[1,W]]); 521fi; 522d:=nops(W[1]); 523LL:=Oursmallmatrix(W,L); ##print(LL); 524coeffs:=coeff_cone_dec(LL); 525conedec:=[]; 526for i from 1 to nops(coeffs) do 527generatorsonL:=[]; 528 coe1:=coeffs[i][1]; 529 coe2:=coeffs[i][2]; 530 generatorssigma:=[seq(coe1[3][i]*primitive_vector(W[coe1[1][i]]),i=1..nops(coe1[1]))]; 531 for u from 1 to nops(coe2[2]) do 532 a:=[1,op(coe2[2][u])]; 533vL:=[W[coe2[1][u]],seq(-W[coe1[1][i]],i=1..nops(coe1[1]))]; 534g:=special_lincomb_v(a,vL,d); 535generatorsonL:=[op(generatorsonL),primitive_vector(g)]; 536od; 537conesigma:=[coe1[2],[op(generatorssigma),op(generatorsonL)]]; 538conedec:=[op(conedec),conesigma]; 539od; 540end: 541 542 543 544 545 546 547 548 549#L_cone_dec([[1,0],[0,1]],[[1,0],[1,1]]); 550 551# Projections: 552 553# Input: W is a list of vectors of V , [v[1],..v[d]], of lenght d. 554# II =[i[1]..,i[s]], is a list of integers, b is a vector of lenght d. 555# Output: a vector of lenght d,. 556# 557# Math: 558# We decompose the space V in lin(II)+lin(IIc) where lin(II) of the vectors v[i], i in II, and lin(II_c) of the vectors in the complement indices. We project a vector b on lin(II) 559# Thus we write b=b_II+b_II_c; 560# Our output is b_II; 561# Example: projectedvector([[1,0,0],[0,1,2],[0,1,0]],[3],[0,0,1])->[0,-1/2,0]; 562projectedvector:=proc(W,II,b) local M,S,j,v,V,m; 563M:=transpose(matrix([seq(W[i],i=1..nops(W))])); 564S:=linsolve(M,b); 565m:=det(M); 566for j from 1 to nops(W) do 567 v[j]:=add(S[II[i]]*W[II[i]][j],i=1..nops(II)); 568od: 569V:=[seq(v[j],j=1..nops(W))]; 570end: 571# Projected lattice 572# # Input: W=[v1,v2,.., vd]; a "Cone" in R^d; 573# BE CAREFUl: The vectors in W must hage integral coordinates. 574# II a subset of [1,2..d] of cardinal k; 575 576# # Output a list [H1,H2,...,Hk] of vectors in R^d with k terms. 577# 578# 579# projectedlattice: 580# Math: we 581# decompose V in lin(II)+lin(II_c); 582# we project the standard lattice (that is Ze[1]+..+Ze[d], that is Z[1,0,0..0]+... Z.[0,0,0..,1]]) 583# on lin[II] which is a subspace of dimension k of a space of dim d. 584# output: (using ihermite) a basis of k elements (of lenght d) of the projected lattice on lin(II). 585# We will use over and over again this list H1,H2,..., Hk, so that we will work in Z^k (embedded in R^d via H1,H2,..Hk). 586# EXAMPLE: 587#projectedlattice([[1,3,0],[0,1,0],[0,0,2]],[1,3])-># [[0, 1/2, 0]]; 588# 589# 590# 591# 592# 593# 594projectedlattice:=proc(W,II) local m,B, d,k,i,r,S,IS,List; 595d:=nops(W); 596B:=ortho_basis(d); 597k:=nops(II); 598m:=abs(Determinant(Transpose(Matrix([seq(W[i],i=1..nops(W))])))); 599for i from 1 to d do 600 r[i]:=[seq(m*projectedvector(W,II,B[i])[j],j=1..nops(W))]; 601od; 602 S:=Matrix([seq(r[i],i=1..d)]);; 603 IS:=ihermite(S); 604 List:=[seq(1/m*convert(row(IS,j),list),j=1..k)]; 605List; 606end: 607# Projected cone and projected vertex (expressed in the lattice basis) 608# Input: W is a Cone in Z^d and II is a subset of [1,..,d] of cardinal k; 609# Output: A "Cone" in Z^k; 610 611# Be careful: our input must have integral coordinates. 612# The ouput then will have integral coordinates. 613# 614# 615# Here W is the cone and we are projecting W over lin( II) and expressing it in term of the standard projectedlattice(W,II). 616# Example: projectedconeinbasislattice([[1,1,0],[0,1,0],[0,0,2]],[1,3])→[[1,0],[0,1]] 617projectedconeinbasislattice:=proc(W,II) local P,M,output,i,F; 618P:=projectedlattice(W,II); ##print(P); 619M:=Transpose(Matrix([seq(P[i],i=1..nops(P))])); 620output:=[]; 621for i from 1 to nops(II) do 622F:=convert(LinearSolve(M,Vector(W[II[i]])),list); 623output:=[op(output),primitive_vector(F)]; 624 od; 625output; 626end: 627 628# 629# #Input; W a Cone in Z^d; 630# II a subset of [1,2,..d] of cardinal k; 631# s a vector in R^d with rational coordinates (or symbolic coordinates); 632# #Ouput: a vector in R^k with rational coordinates; 633 634# Math: Here W is the cone and we are projecting V over lin( II) using V:=lin(II) oplus 635# lin(II_c). We express the projection of s 636# with respect to the basis of the projected lattice. If the ouput is [a1,a2], this means that our 637# projected vertex is s_II=a1*H1+a2*H2 where H1,H2 is the basis of the projected lattice computed before. 638# 639# 640# Example: projectedvertexinbasislattice([[1,0,0],[0,2,1],[0,1,1]],[1,3],[s1,s2,s3]) ->[s1, 2*s3-s2];; 641# 642projectedvertexinbasislattice:=proc(W,II,s) local m,P,M,output,i,F; P:=projectedlattice(W,II);##print(P); 643if II=[] then RETURN([]);fi; 644M:=Transpose(Matrix([seq(P[i],i=1..nops(P))])); 645F:=convert(LinearSolve(M,Vector(projectedvector(W,II,s))),list); 646output:=F; 647end: 648# Input: s a vector in R^d with rational coordinates (or symbolic). 649# W a cone in Z^d 650# Output: a vector in R^d 651# 652# Math: We decompose V in lin(II) oplus lin (II_c), and here we write s=s_II+s_(II_c): Here the output is s_(II_c); 653# Example:s_IIc([s1,s2],[[1,0],[0,1]],[1])-> [0,s2]; 654 655s_IIc:=proc(s,W,II) local DD,IIc,M,s_in_cone_coord,s_IIc; 656DD:=[seq(i,i=1..nops(W))]; 657IIc:=GeneralComplementList(II,DD); 658M:=Matrix([seq(Vector([W[i]]),i=1..nops(W))]); 659 660s_in_cone_coord:=convert(LinearSolve(M,Vector(s)),list); 661 662s_IIc:=[seq(s_in_cone_coord[IIc[k]],k=1..nops(IIc))]; 663special_lincomb_v(s_IIc,[seq(W[IIc[k]],k=1..nops(IIc))],nops(W)); 664end: 665# Basic functions 666# 667# 668# 669# Todd(z,x): the function (e^(zx)*x/(1-exp(x))); 670Todd:=proc(z,x); 671exp(z*x)*x/(1-exp(x)); 672end: 673# Relative volume 674# 675# 676# 677# Input: W is a Cone in R^d and II is a subset of [1,..,d] of cardinal k; 678# Ouput: a number; 679# 680# Math; the volume of the Box(v[i], i not in II), with respect to the intersected lattice. 681# Example: relativevolumeoffaceIIc([[1,1],[0,1]],[1])->1; 682# 683relativevolumeoffaceIIc:=proc(W,II) local DD,IIc,P,M,H,MM,output; 684DD:=[seq(i,i=1..nops(W))]; 685IIc:=GeneralComplementList(II,DD); 686if IIc=[] then output:=1; 687else P:=matrix([seq(W[IIc[i]],i=1..nops(IIc))]); 688 M:=transpose(matrix(P)); 689 H:=ihermite(M); 690 MM:=matrix([seq(row(H,i),i=1..nops(IIc))]); 691 output:=det(MM); 692fi; 693 output; 694end: 695#relativevolumeoffaceIIc([[1,0],[0,1]],[1]); 696# The 2 functions to compute S_L 697# Input: s a vector in R^d; W a "Cone" in R^d; II a subset of [1, 2,...,d]; 698# x a variable: 699 700# Output: a list of two functions of x; 701# Math: #We compute integral over the cone IIc of 702# exp^(csi,x) ; the answer is given as [exp (<q,x>, product of linear forms] 703# Representing separately the numerator and the denominator. 704# Furthermore, we enter exp as a "black box" EXP(x); later on we might want to replace it. 705# Example functionI([1/2,1/2],[[1,0],[0,1]],[],x) `invalid character in short integer encoding 17 `;; 706# 707# 708functionI:=proc(s,W,II,x) 709local s_on_IIc,DD,IIc,d,T,i,y,r,out; 710d:=nops(W); 711DD:=[seq(i,i=1..d)]; 712s_on_IIc:=s_IIc(s,W,II); 713if nops(II)=nops(W) 714then out:=[1,1]; 715else 716IIc:=GeneralComplementList(II,DD); 717r:=relativevolumeoffaceIIc(W,II); 718T:=1; 719for i from 1 to nops(IIc) do 720y:=add(W[IIc[i]][j]*x[j],j=1..d); 721T:=T*y; 722od; 723T:=(-1)^(nops(IIc))*T; 724out:=[r*EXP(add(s_on_IIc[m]*x[m],m=1..d)),T]; 725fi; 726out; 727end: 728# Input: z =[z1,...,zd], x=[x1,x2,..,xd]; two lists of symbolic expressions, W a cone in R^d. 729# Output: a symbolic expression. 730# Math: Our cone has generator w1,w2,...,wd. 731# We replace x by <x,w_i> and we compute the product of Todd(z_i,<x,w_i>); 732# Example: prod_Todd([z1,z2],[x1,x2],[[1,1],[1,0]])->`invalid character in short integer encoding 17 `;; 733 734# 735# 736prod_Todd:=proc(z,x,W) local d,E,i,T,y; 737d:=nops(W); 738ASSERT(d = nops(z) and d = nops(x), 739 "z, x, W need to be of the same length"); 740T:=1; 741for i from 1 to d do 742ASSERT(nops(W[i])=nops(x),"W[i], x need to be of the same length"); 743y:=add(W[i][j]*x[j],j=1..nops(W[i])); 744T:=T*TODD(z[i],y); 745od; 746T; 747end: 748# 749# Input: z =[z1,...,zd], x=[x1,x2,..,xd]; two lists of symbolic expression, W a cone in R^d. 750# Output: a list of two symbolic expressions [P1,Q1]. 751# Math: P1 is the product of Todd(z_i,<x,w_i>), while Q1 is the product of the (<x,wi>) 752# Example: functionS([z[1],z[2],z[3]],[x[1],x[2],x[3]],[[1,1,0],[0,1,0],[0,0,1]]) -> 753# `invalid character in short integer encoding 209 Ñ`; 754# 755functionS:=proc(z,x,W) local P,Q,y,i; 756P:=prod_Todd(z,x,W); 757Q:=1; 758for i from 1 to nops(W) do 759ASSERT(nops(W[i])=nops(x),"W[i], x need to be of the same length"); 760 y:=add(W[i][j]*x[j],j=1..nops(W[i])); 761 Q:=Q*y; 762od; 763[P,Q]; 764end: 765# 766# 767# Input: a Cone W; II a subset of [1..d] of cardinal k; x a list [x1,x2,...,xd]: 768# Ouput: a list of k linear forms 769# Math: 770# We write R^d=V(II)+V(II_c). We computed a basis H1,H2n...H_k of the projection of the lattice Z^d in V(II). 771# Thus the output is the list is <x,h_i> where H_i are the basis of the projected lattice 772# 773# Example: changeofcoordinates([[1,0,0],[0,1,0],[1,2,3]],[1,2],[x1,x2,x3])-> 202, "unexpected end of statement";; 774# 775# 776# 777 778changeofcoordinates:=proc(W,II,x) local H,newx,i; 779H:=projectedlattice(W,II); 780newx:=[]; 781for i from 1 to nops(H) do 782newx:=[op(newx),innerprod(x,H[i])]; 783od; 784newx; 785end: 786# THE FUNCTION S_L for a cone. 787# THIS IS THE MAIN PROCEDURE. thue output is a function, and a product of linear forms; 788function_SL:=proc(s,W,L,x) local DD,i,parallel_cones,uni_cones,function_on_II,function_on_IIc,WW_projected,WW,WWW,signuni,signL,j,II,IIc,out1,out2,s_in_cone_coord,s_II_in_cone_coord,s_prime_II,M,newx,dimL,g,testrank,newP, 789s_II_in_lattice_coord,news; 790DD:=[seq(i,i=1..nops(W))]; 791#I added this 792if L=W then RETURN(functionI(s,W,[],x)[1]/functionI(s,W,[],x)[2]);fi; 793#up to here 794parallel_cones:=L_cone_dec(W,L); 795out2:=0; 796for i from 1 to nops(parallel_cones) do 797WW:=parallel_cones[i][2]; 798signL:=parallel_cones[i][1]; 799IIc:=[]; 800II:=[]; 801dimL:=Rank(Matrix(L)); 802for g from 1 to nops(WW) do 803testrank:=Rank(Matrix([op(L),WW[g]])); 804if testrank=dimL 805 then IIc:=[op(IIc),g]; 806 else II:=[op(II),g]; 807fi: 808 809od; 810ASSERT(nops(IIc)=dimL,"decompositioninL_parallel is wrong"); 811M:=Matrix([seq(Vector(WW[h]),h=1..nops(WW))]); 812s_II_in_lattice_coord:=projectedvertexinbasislattice(WW,II,s); 813function_on_IIc:=functionI(s,WW,II,x); 814#from here express in terms of the basis lattice for projected cone. 815 816WW_projected:=projectedconeinbasislattice(WW,II): 817 818if WW_projected=[] then 819out1:=1 else 820newx:=changeofcoordinates(WW,II,x); 821uni_cones:=cone_dec(WW_projected): 822out1:=0; 823for j from 1 to nops(uni_cones) do 824WWW:=uni_cones[j][3]; 825signuni:=uni_cones[j][1]; 826ASSERT(abs(uni_cones[j][2])=1, "decomposition not unimodular"); 827newP:=MatrixInverse(Transpose(Matrix(WWW))): 828news:=convert(Multiply(newP,Vector(s_II_in_lattice_coord)),list); 829s_prime_II:=[seq(ceil(news[f]),f=1..nops(news))]; 830function_on_II:=functionS(s_prime_II,newx,WWW); 831out1:=out1+ 832signuni*function_on_II[1]/function_on_II[2]; 833od: 834fi; 835out2:=out2+out1*function_on_IIc[1]/function_on_IIc[2]*signL; 836od: 837out2; 838end: 839 840 841#function_SL([1/2,0,0],[[-1,0,1],[-1,2,0],[0,0,1]],[[-1,2,0]],[x1,x2,x3]); 842# Input: W a cone, L a linear space,x a variable. 843# Output: a list of linear forms. 844# Math: this is the forms in denominator of the big func. 845linindenom:=proc(W,L,x) local YY,i, 846parallel_cones,VDD,IIc,II,dimL,g,testrank,WW,newx,d,a,z,cc, 847WW_projected,uni_cones,t,cleanYY,r; 848VDD:=[seq(i,i=1..nops(W))]; 849d:=nops(W); 850parallel_cones:=L_cone_dec(W,L); 851 YY:={}; 852for i from 1 to nops(parallel_cones) do 853WW:=parallel_cones[i][2];# We should know I, II 854IIc:=[]; 855II:=[]; 856dimL:=Rank(Matrix(L)); 857for g from 1 to nops(WW) do 858testrank:=Rank(Matrix([op(L),WW[g]])); 859if testrank=dimL 860 then IIc:=[op(IIc),g]; 861 else II:=[op(II),g]; 862fi: 863od; 864ASSERT(nops(IIc)=dimL,"decompositioninL_parallel is wrong"); 865for a from 1 to nops(IIc) do 866YY:={op(YY),add(WW[IIc[a]][j]*x[j],j=1..d)}; 867od; 868 WW_projected:=projectedconeinbasislattice(WW,II): 869newx:=changeofcoordinates(WW,II,x); 870##print("newx,WW_projected",newx,WW_projected); 871uni_cones:=cone_dec(WW_projected): 872##print("i,unicones,newx",i,uni_cones,newx,YY); 873for z from 1 to nops(uni_cones) do 874cc:=uni_cones[z][3]; 875for t from 1 to nops(cc) do 876YY:={op(YY), add(cc[t][s]*newx[s],s=1..nops(newx))} 877od; 878od; 879od; 880##print(YY); 881cleanYY:={}; 882for r from 1 to nops(YY) do 883if member(-YY[r],cleanYY)=false then 884cleanYY:={op(cleanYY),YY[r]} 885fi; 886od; 887cleanYY; 888end: 889 890 891#function_SL([0,0,0],[[1,0,0],[0,2,1],[0,0,1]],[[1,1,1]],[x1,x2,x3]); 892# The Valuation S_L for a simplex. 893function_SL_simplex:=proc(S,L,x) local F,W,i; 894F:=0; 895for i from 1 to nops(S) do 896W:=[seq(primitive_vector(S[j]-S[i]),j=1..i-1),seq(primitive_vector(S[j]-S[i]),j=i+1..nops(S))]; 897F:=F+function_SL(S[i],W,L,x); 898od: 899F: 900end: 901# 902#betedim1:=subs({TODD=Todd,EXP=exp},function_SL_simplex([[0],[1]],[],[x1])); 903#Sbete2:=[[0,0+2/10],[1,2/10],[0,2+2/10]]; 904#check2:=subs({TODD=Todd,EXP=exp},function_SL_simplex(Sbete2,[[1,0]],[x1,x2])); 905#series(subs({x1=t,x2=2*t},check2),t=0); 906#SA:=[[0,0],[0,4/10],[1,1]]; SB:=[[0,4/10],[1,1],[1,1+4/10]]; 907 908#check3:=subs({TODD=Todd,EXP=exp},function_SL_simplex([[0,0,0],[2,0,0],[0,2,0],[0,0,2]],[[1,0,0],[0,1,0]],[x1,x2,x3])); 909#SERT:=subs({x1=t,x2=5*t,x3=17*t},check3); 910#series(SERT,t=0,20); 911# Regular vector 912 913# Input, t a variable, alpha= a list of lenght k of linear forms l_i of x1,x2,...,x_n, 914# n a number ; 915# The ouptut is a vector v such that l_i(v) is not zero for all i 916# 917 918# 919regular:=proc(t,alpha,n) local ok,p,i,pp,v,j,s,deg,newP,P,PP,out: 920ok:=0; 921P:=1; 922for i from 1 to nops(alpha) do 923P:=P*alpha[i]; 924od; 925 926v:=[seq(t^i,i=0..n-1)]; 927for j from 1 to n 928do P:=subs(x[j]=t^(j-1),P); 929od: 930deg:=degree(P); 931s:=1; while ok=0 and s<=deg+1 do 932newP:=subs(t=s,P); ##print(newP); 933if newP<>0 934then out:=[v,s,subs(t=s,v)]; 935ok:=1; 936else s:=s+1; 937fi; 938od: 939out[3]; 940end: 941regular(t,{-x[1],-x[1]+x[2]},2); 942 943 944denomWL:=proc(W,L) local xx,alpha; 945xx:=[seq(x[i],i=1..nops(W))]; 946alpha:=linindenom(W,L,xx); #print("alpha",alpha); 947 end: 948 949#denomWL([[1,-1,0],[0,2,1],[0,0,1]],[[1,1,1]]); 950 951#Sbete2:=[[0,0],[1,0],[0,1]]; 952# DEFORMATION OF FUNCTION S_L 953# 954 955# The input is a s a vertex,W a cone, L a linear space , ell a list with numeric coefficients. 956# The output is a function of delta, epsilon; 957defSLell:=proc(s,W,L,ell,reg) local xx,defell,ff; 958#reg:=regularWL(W,L); #print("reg",reg); 959xx:=[seq(x[i],i=1..nops(W))]; 960defell:=[seq(delta*(ell[j]+epsilon*reg[j]),j=1..nops(W))]; 961ff:=function_SL(s,W,L,defell); 962##print(ff,defell); 963ff:=eval(subs({TODD=Todd,EXP=exp},ff)); 964ff; 965end: 966#series(SLell([1/2,1/2],[[1,0],[1,2]],[[1,1]], [1,-1]),delta=0,3); 967#function_SL([1/2,1/2],[[1,0],[0,1]],[[1,-1]], [x1,x2]); 968deftruncatedSL:=proc(s,W,L,ell,reg,M) local SS,cc; 969#SS:=subs({epsilon=0},SLell(s,W,L,ell,reg)); #print(SLell(s,W,L,ell)); 970##print("SS",SS); 971##print(series(SS,delta=0,M+nops(W)+2)); 972cc:=convert(series(defSLell(s,W,L,ell,reg),delta=0,M+nops(W)+2),polynom); 973coeff(series(cc,epsilon=0,nops(W)+2),epsilon,0); 974 975end: 976 977#deftruncatedSL([1/2,1/2],[[1,0],[1,2]],[[1,1]],[1,1],[3,7],4); 978# The function S_L for a simplex. 979# 980regularSL:=proc(S,L) local i,W,reg,xx,alpha; 981xx:=[seq(x[i],i=1..nops(S)-1)]; 982alpha:={}; 983for i from 1 to nops(S) do 984W:=[seq(primitive_vector(S[j]-S[i]),j=1..i-1),seq(primitive_vector(S[j]-S[i]),j=i+1..nops(S))]; 985alpha:={op(alpha),op(denomWL(W,L,xx))}; 986od: 987 988reg:=regular(t,alpha,nops(S)-1); 989end: 990function_SL_simplex_ell:=proc(S,L,ell,M) local reg,F,W,i; 991F:=0; 992reg:=regularSL(S,L); 993for i from 1 to nops(S) do 994W:=[seq(primitive_vector(S[j]-S[i]),j=1..i-1),seq(primitive_vector(S[j]-S[i]),j=i+1..nops(S))]; 995F:=F+deftruncatedSL(S[i],W,L,ell,reg,M); 996od: 997coeff(F,delta,M): 998end: 999#function_SL_simplex_ell(Sbete2,[[1,0]],[0,0],0);Sbete2; 1000Sbetedilated:=proc(n,t) local ze, S,j,zej; ze:=[seq(0,i=1..n)]; 1001S:=[ze]; 1002for j from 1 to n do zej:=subsop(j=t,ze);; 1003 S:=[op(S),zej]; 1004od; 1005end: 1006#Sbetedilated(3,2); 1007#function_SL_simplex_ell(Sbetedilated(2,2),[[1,2]],[0,0],0); 1008#S1:=[[0,0],[1,0],[1,2]]; 1009#function_SL_simplex_ell(S1,[[1,0]],[1,1],1); 1010 1011# Dilated polytope 1012# 1013# 1014# We have to compute S_L(t,s,W,L,x); 1015 1016# 1017fmod:=proc(p,q,t) local u: 1018u:=modp(p,q); 1019#print(u); 1020ModP(u*t,q); 1021end: 1022ourmod:=proc(p,q,t) local our,T; 1023if q=1 then our:=0; 1024elif type(t,integer) then our:=modp(t*p,q); 1025else our:=fmod(p,q,t); 1026fi; 1027RETURN(our); 1028end: 1029ourfloor:=proc(t,x)local our,p,q; 1030p:=numer(x); 1031q:=denom(x); 1032our:=t*x-ourmod(p,q,t)/q; 1033end: 1034formal_ceil:=proc(t,x); 1035-ourfloor(t,-x); 1036end: 1037#formal_ceil(t,3/2); 1038tfunction_SL:=proc(t,s,W,L,x) local st,DD,i,parallel_cones,uni_cones,function_on_II,function_on_IIc,WW_projected,WW,WWW,signuni,signL,j,II,IIc,out1,out2,s_in_cone_coord,s_II_in_cone_coord,s_prime_II,M,newx,dimL,g,testrank,newP, 1039s_II_in_lattice_coord,news; 1040DD:=[seq(i,i=1..nops(W))]; 1041parallel_cones:=L_cone_dec(W,L): 1042##print("parallel_cones",parallel_cones); 1043out2:=0; #listgene:={}; 1044for i from 1 to nops(parallel_cones) do 1045WW:=parallel_cones[i][2]; 1046signL:=parallel_cones[i][1]; 1047IIc:=[]; 1048II:=[]; 1049dimL:=Rank(Matrix(L)); 1050for g from 1 to nops(WW) do 1051testrank:=Rank(Matrix([op(L),WW[g]])); 1052if testrank=dimL 1053 then IIc:=[op(IIc),g]; 1054 else II:=[op(II),g]; 1055fi: 1056 1057od; 1058ASSERT(nops(IIc)=dimL,"decompositioninL_parallel is wrong"); 1059M:=Matrix([seq(Vector(WW[h]),h=1..nops(WW))]); 1060s_II_in_lattice_coord:=projectedvertexinbasislattice(WW,II,s); 1061st:=[seq(t*s[i],i=1..nops(s))]; 1062function_on_IIc:=functionI(st,WW,II,x); 1063#print("functionInt",function_on_IIc); 1064#from here express in terms of the basis lattice for projected cone. 1065 1066WW_projected:=projectedconeinbasislattice(WW,II): 1067 1068if WW_projected=[] then 1069out1:=1 else 1070newx:=changeofcoordinates(WW,II,x); 1071##print("newx",newx); 1072uni_cones:=cone_dec(WW_projected): 1073##print("unicones",WW,uni_cones); 1074out1:=0; 1075for j from 1 to nops(uni_cones) do 1076WWW:=uni_cones[j][3]; 1077signuni:=uni_cones[j][1]; 1078ASSERT(abs(uni_cones[j][2])=1, "decomposition not unimodular"); 1079newP:=MatrixInverse(Transpose(Matrix(WWW))): 1080news:=convert(Multiply(newP,Vector(s_II_in_lattice_coord)),list); 1081s_prime_II:=[seq(formal_ceil(t,news[f]),f=1..nops(news))]; 1082function_on_II:=functionS(s_prime_II,newx,WWW): 1083##print("function_on_II",function_on_II); 1084out1:=out1+ 1085signuni*function_on_II[1]/function_on_II[2]; 1086od: 1087fi; 1088out2:=out2+out1*function_on_IIc[1]/function_on_IIc[2]*signL; 1089od: 1090out2; 1091end: 1092 1093 1094#tfunction_SL(t,[1/2,1,1],[[-1,0,1],[-1,2,0],[0,0,1]],[[-1,2,0]],[x1,x2,x3]); 1095# Input: W a cone, L a linear space,x a variable. 1096# Output: a list of linear forms. 1097tfunction_SL(t,[1/2,1/2],[[0,1],[1,0]],[[1,0]],[x1,x2]); 1098tSLell:=proc(t,s,W,L,ell,reg) local xx,defell,ff; 1099#reg:=regularWL(W,L); #print("reg",reg); 1100xx:=[seq(x[i],i=1..nops(W))]; 1101defell:=[seq(delta*(ell[j]+epsilon*reg[j]),j=1..nops(W))]; 1102ff:=tfunction_SL(t,s,W,L,defell); 1103##print(ff,defell); 1104ff:=eval(subs({TODD=Todd,EXP=exp},ff)); 1105ff; 1106end: 1107#series(SLell([1/2,1/2],[[1,0],[1,2]],[[1,1]], [1,-1]),delta=0,3); 1108#function_SL([1/2,1/2],[[1,0],[0,1]],[[1,-1]], [x1,x2]); 1109ttruncatedSL:=proc(t,s,W,L,ell,reg,M) local SS,cc; 1110#SS:=subs({epsilon=0},tSLell(t,s,W,L,ell)); #print(SLell(s,W,L,ell)); 1111##print("SS",SS); 1112##print(series(SS,delta=0,M+nops(W)+2)); 1113cc:=convert(series(tSLell(t,s,W,L,ell,reg),delta=0,M+nops(W)+2),polynom); 1114coeff(series(cc,epsilon=0,nops(W)+2),epsilon,0); 1115 1116end: 1117#truncatedSL([1/2,1/2],[[1,0],[1,2]],[[1,1]],[1,1],4); 1118 1119#simplify(ttruncatedSL(t,[1/2,1/2],[[1,0],[0,1]],[[1,0]],[1,1],0)); 1120tfunction_SL_simplex_ell:=proc(t,S,L,ell,M) local F,W,i,reg; 1121F:=0; 1122reg:=regularSL(S,L); 1123for i from 1 to nops(S) do 1124W:=[seq(primitive_vector(S[j]-S[i]),j=1..i-1),seq(primitive_vector(S[j]-S[i]),j=i+1..nops(S))]; 1125F:=F+ttruncatedSL(t,S[i],W,L,ell,reg,M); 1126od: 1127simplify(coeff(F,delta,M)): 1128end: 1129#tfunction_SL_simplex_ell(t,S1,[[1,0]],[0,0],0); 1130checks:=proc(u); 1131[function_SL_simplex_ell([[0, 0], [u, 0], [u, 2*u]],[[1,0]],[1,1],1), 1132subs(t=u,tfunction_SL_simplex_ell(t,S1,[[1,0]],[1,1],1))];end: 1133 1134 1135dilS1:=proc(r); [[0, 0], [r, 0], [r, 2*r]];end: 1136 1137# Above is the special sum of a 1138#Srat2:=[[0, 0], [1/7*5/4, 0], [1/7*5/4, 1/7*5/2]]; 1139checksrat:=proc(u); 1140[function_SL_simplex_ell([[0, 0], [u*5/28, 0], [u*5/28, 5/14*u]],[[1,0]],[1,1],1), 1141subs(t=u,tfunction_SL_simplex_ell(t,Srat2,[[1,0]],[1,1],1))];end: 1142 1143 1144 1145 1146 1147# rho function and approximations 1148 1149