intbasis.red 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. module intbasis;
  2. % Author: James H. Davenport.
  3. fluid '(!*tra !*trmin excoatespoles intvar previousbasis taylorasslist
  4. taylorvariable);
  5. exports completeplaces,completeplaces2,integralbasis;
  6. symbolic procedure deleteplace(a,b);
  7. if null b
  8. then nil
  9. else if equalplace(a,car b)
  10. then cdr b
  11. else (car b).deleteplace(a,cdr b);
  12. symbolic procedure completeplaces(places,mults);
  13. begin
  14. scalar current,cp,cm,op,om,ansp,ansm;
  15. if null places then return nil; %%% ACH
  16. loop:
  17. current:=basicplace car places;
  18. while places do <<
  19. if current = (basicplace car places)
  20. then <<
  21. cp:=(car places).cp;
  22. cm:=(car mults ).cm >>
  23. else <<
  24. op:=(car places).op;
  25. om:=(car mults ).om >>;
  26. places:=cdr places;
  27. mults:=cdr mults >>;
  28. cp:=completeplaces2(cp,cm,sqrtsinplaces cp);
  29. ansp:=append(car cp,ansp);
  30. ansm:=append(cdr cp,ansm);
  31. places:=op;
  32. mults:=om;
  33. cp:=op:=cm:=om:=nil;
  34. if places
  35. then go to loop
  36. else return ansp.ansm
  37. end;
  38. symbolic procedure completeplaces2(places,mults,sqrts);
  39. % Adds extra places with multiplicities of 0 as necessary.
  40. begin scalar b,p;
  41. sqrts:=sqrtsign(sqrts,intvar);
  42. b:=basicplace car places;
  43. p:=places;
  44. while p do <<
  45. if not(b = (basicplace car p))
  46. then interr "Multiple places not supported";
  47. sqrts:=deleteplace(extenplace car p,sqrts);
  48. p:=cdr p >>;
  49. mults:=nconc(nlist(0,length sqrts),mults);
  50. places:=nconc(mappend(sqrts,b),places);
  51. return places.mults
  52. end;
  53. symbolic procedure intbasisreduction(zbasis,places,mults);
  54. begin
  55. scalar i,m,n,v,w,substn,basis;
  56. substn:=list(intvar.intvar);
  57. % The X=X substitution.
  58. n:=upbv zbasis;
  59. basis:=copyvec(zbasis,n);
  60. taylorvariable:=intvar;
  61. v:=sqrtsinplaces places;
  62. for i:=0:n do
  63. w:=union(w,sqrtsinsq(getv(basis,i),intvar));
  64. m:=intersection(v,w); % Used to be INTERSECT
  65. v:=setdiff(v,m);
  66. w:=setdiff(w,m);
  67. for each u in v do <<
  68. if !*tra or !*trmin then <<
  69. prin2t u;
  70. prin2t "does not occur in the functions";
  71. mapvec(basis,function printsq) >>;
  72. m:=!*q2f simp argof u;
  73. i:=w;
  74. while i and not quotf(m,!*q2f simp argof car i)
  75. do i:=cdr i;
  76. if null i
  77. then interr
  78. "Unable to find equivalent representation of branches";
  79. i:=car i;
  80. w:=delete(i,w);
  81. places:=subst(i,u,places);
  82. if !*tra or !*trmin then <<
  83. prin2t "replaced by";
  84. prin2t i >> >>;
  85. if (length places) neq (iadd1 n) then <<
  86. if !*tra
  87. then prin2t "Too many functions";
  88. basis := shorten!-basis basis;
  89. n:=upbv basis >>;
  90. m:=mkvect n;
  91. for i:=0:n do
  92. putv(m,i,cl6roweval(basis.i,places,mults,substn));
  93. reductionloop:
  94. if !*tra then <<
  95. prin2t "Matrix before a reduction step:";
  96. mapvec(m,function prin2t) >>;
  97. v:=firstlinearrelation(m,iadd1 n);
  98. if null v
  99. then return replicatebasis(basis,(iadd1 upbv zbasis)/(n+1));
  100. i:=n;
  101. while null numr getv(v,i) do
  102. i:=isub1 i;
  103. w:=nil ./ 1;
  104. for j:=0:i do
  105. w:=!*addsq(w,!*multsq(getv(basis,j),getv(v,j)));
  106. w:=removecmsq multsq(w,1 ./ !*p2f mksp(intvar,1));
  107. if null numr w
  108. then <<
  109. mapvec(basis,function printsq);
  110. prin2t iadd1 i;
  111. interr "Basis collapses" >>;
  112. if !*tra then <<
  113. princ "Element ";
  114. princ iadd1 i;
  115. prin2t " of the basis replaced by ";
  116. if !*tra then
  117. printsq w >>;
  118. putv(basis,i,w);
  119. putv(m,i,cl6roweval(basis.i,places,mults,substn));
  120. goto reductionloop
  121. end;
  122. symbolic procedure integralbasis(basis,places,mults,x);
  123. begin
  124. scalar z,save,points,p,m,princilap!-part,m1;
  125. if null places
  126. then return basis;
  127. mults := for each u in mults collect min(u,0);
  128. % this makes sure that we impose constraints only on
  129. % poles, not on zeroes.
  130. points:=removeduplicates(for each j in places collect basicplace j);
  131. if points = list(x.x)
  132. then basis:=intbasisreduction(basis,places,mults)
  133. else if cdr points
  134. then go complex
  135. else <<
  136. substitutevec(basis,car points);
  137. if !*tra then <<
  138. prin2t "Integral basis reduction at";
  139. prin2t car points >>;
  140. basis:=intbasisreduction(basis,
  141. for each j in places collect extenplace j,
  142. mults);
  143. substitutevec(basis,antisubs(car points,x)) >>;
  144. join:
  145. save:=taylorasslist;
  146. % we will not need te taylorevaluates at gensym.
  147. z:=gensym();
  148. places:=mapcons(places,x.list('difference,x,z));
  149. z:=list(x . z);
  150. % basis:=intbasisreduction(basis,
  151. % places,
  152. % nlist(0,length places),
  153. % x,z);
  154. taylorasslist:=save;
  155. % ***time-hack-2***;
  156. if not excoatespoles
  157. then previousbasis:=copyvec(basis,upbv basis);
  158. % Save only if in COATES/FINDFUNCTION, not if in EXCOATES.
  159. return basis;
  160. complex:
  161. while points do <<
  162. p:=places;
  163. m:=mults;
  164. princilap!-part:=m1:=nil;
  165. while p do <<
  166. if (car points) = (basicplace car p)
  167. then <<
  168. princilap!-part:=(extenplace car p).princilap!-part;
  169. m1:=(car m).m1 >>;
  170. p:=cdr p;
  171. m:=cdr m >>;
  172. substitutevec(basis,car points);
  173. if !*tra then <<
  174. prin2t "Integral basis reduction at";
  175. prin2t car points >>;
  176. basis:=intbasisreduction(basis,princilap!-part,m1);
  177. substitutevec(basis,antisubs(car points,x));
  178. points:=cdr points >>;
  179. go to join
  180. end;
  181. symbolic procedure cl6roweval(basisloc,places,mults,x!-alpha);
  182. % Evaluates a row of the matrix in Coates lemma 6.
  183. begin
  184. scalar i,v,w,save,basiselement,taysave,mmults,flg;
  185. i:=isub1 length places;
  186. v:=mkvect i;
  187. taysave:=mkvect i;
  188. i:=0;
  189. basiselement:=getv(car basisloc,cdr basisloc);
  190. mmults:=mults;
  191. while places do <<
  192. w:=substitutesq(basiselement,car places);
  193. w:=taylorform substitutesq(w,x!-alpha);
  194. % The separation of these 2 is essential since the x->x-a
  195. % must occur after the places are chosen.
  196. save:=taylorasslist;
  197. if not flg
  198. then putv(taysave,i,w);
  199. w:=taylorevaluate(w,car mmults);
  200. tayshorten save;
  201. putv(v,i,w);
  202. i:=iadd1 i;
  203. flg:=flg or numr w;
  204. mmults:=cdr mmults;
  205. places:=cdr places >>;
  206. if flg
  207. then return v;
  208. % There was a non-zero element in this row.
  209. save:=0;
  210. loop:
  211. save:=iadd1 save;
  212. mmults:=mults;
  213. i:=0;
  214. while mmults do <<
  215. w:=taylorevaluate(getv(taysave,i),save + car mmults);
  216. flg:=flg or numr w;
  217. mmults:=cdr mmults;
  218. putv(v,i,w);
  219. i:=iadd1 i >>;
  220. if not flg
  221. then go to loop;
  222. % Another zero row.
  223. putv(car basisloc,cdr basisloc,multsq(basiselement,
  224. 1 ./ !*p2f mksp(intvar,save)));
  225. return v
  226. end;
  227. symbolic procedure replicatebasis(basis,n);
  228. if n = 1
  229. then basis
  230. else if n = 2
  231. then begin
  232. scalar b,sqintvar,len;
  233. len:=upbv basis;
  234. sqintvar:=!*kk2q intvar;
  235. b:=mkvect(2*len+1);
  236. for i:=0:len do <<
  237. putv(b,i,getv(basis,i));
  238. putv(b,i+len+1,multsq(sqintvar,getv(basis,i))) >>;
  239. return b
  240. end
  241. else interr "Unexpected replication request";
  242. symbolic procedure shorten!-basis v;
  243. begin
  244. scalar u,n,sfintvar;
  245. sfintvar:=!*kk2f intvar;
  246. n:=upbv v;
  247. for i:=0:n do begin
  248. scalar uu;
  249. uu:=getv(v,i);
  250. if not quotf(numr uu,sfintvar)
  251. then u:=uu.u
  252. end;
  253. return mkvec u
  254. end;
  255. endmodule;
  256. end;
  257. % ***time-hack-1***;
  258. % This is the version of CL6ROWEVAL which does not attempt to
  259. % make multiple steps. See $IMPLEM, item 2.
  260. symbolic procedure cl6roweval(basiselement,places,mults,x!-alpha);
  261. % Evaluates a row of the matrix in Coates lemma 6.
  262. begin
  263. scalar i,v,w,save;
  264. v:=mkvect isub1 length places;
  265. i:=0;
  266. basiselement:=getv(car basiselement,cdr basiselement);
  267. while places do <<
  268. w:=substitutesq(basiselement,car places);
  269. w:=substitutesq(w,x!-alpha);
  270. % The separation of these 2 is essential since the x->x-a
  271. % must occur after the places are chosen.
  272. save:=taylorasslist;
  273. w:=taylorevaluate(taylorform w,car mults);
  274. tayshorten save;
  275. putv(v,i,w);
  276. i:=iadd1 i;
  277. mults:=cdr mults;
  278. places:=cdr places >>;
  279. return v
  280. end;
  281. endmodule;
  282. end;