gbsc.red 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. % ----------------------------------------------------------------------
  2. % $Id: gbsc.red,v 1.2 2003/10/21 16:07:17 gilch Exp $
  3. % ----------------------------------------------------------------------
  4. % Copyright (c) 2003 Andreas Dolzmann and Lorenz Gilch
  5. % ----------------------------------------------------------------------
  6. % $Log: gbsc.red,v $
  7. % Revision 1.2 2003/10/21 16:07:17 gilch
  8. % Added fluid declartions.
  9. %
  10. % Revision 1.1 2003/10/21 10:24:10 gilch
  11. % Moved from rlprojects/rrcqe to gb.
  12. % Changed module name to gbsc.
  13. % Changed accordingly prefix to gbsc.
  14. % Removed unused procedures betastat, rrcmatlcm, rrcmatgcd and
  15. % related switches.
  16. % Changed rlverbose to cgbverbose.
  17. % Removed switch rlrqverbose and used cgbverbose instead.
  18. % Removed switch rrcfast.
  19. %
  20. % Revision 1.7 2003/06/28 15:24:12 gilch
  21. % Added verbose messages.
  22. %
  23. % Revision 1.6 2003/06/25 13:07:59 gilch
  24. % Removed unnecessary local variables.
  25. %
  26. % Revision 1.5 2003/05/02 09:05:11 gilch
  27. % Changed prrc_strconst, so it can handle Groebner Bases, which needn't be
  28. % reduced.
  29. %
  30. % Revision 1.4 2003/04/29 14:41:12 gilch
  31. % Imported structure constants procedure from prrc and prrcbeta.
  32. %
  33. % Revision 1.3 2003/04/22 14:11:32 gilch
  34. % Fixed a bug in strconst_strconst.
  35. %
  36. % Revision 1.2 2003/04/22 14:10:15 gilch
  37. % Fixed a bug in strconst_reduce.
  38. %
  39. % Revision 1.1 2003/04/16 11:33:05 gilch
  40. % Initial check-in.
  41. %
  42. % ----------------------------------------------------------------------
  43. lisp <<
  44. fluid '(gbsc_rcsid!* gbsc_copyright!*);
  45. gbsc_rcsid!* := "$Id: gbsc.red,v 1.2 2003/10/21 16:07:17 gilch Exp $";
  46. gbsc_copyright!* := "Copyright (c) 2003 by A. Dolzmann and L. Gilch"
  47. >>;
  48. module gbsc;
  49. % Groebner bases combined structure constants.
  50. fluid '(!*cgbverbose cgb_hashsize!*);
  51. procedure gbsc_strconst(rt,gb,n);
  52. % Parametric real root counting structure constant. [rt] is a list
  53. % of TERM's; [gb] is a list of VDP's; [n] is an integer. Returns a
  54. % BETA, containing the generalized combined structure constants.
  55. begin scalar w,g,ul,beta; integer l;
  56. ul := reversip vdp_lsort gbsc_vdpsetprod(rt,n);
  57. beta := gbsc_betainit();
  58. if !*cgbverbose then <<
  59. l := length ul;
  60. ioto_tprin2t "Combined structure constants:"
  61. >>;
  62. for each u in ul do <<
  63. if !*cgbverbose then <<
  64. if remainder(l,10) = 0 then
  65. ioto_prin2 {"[",l,"] "};
  66. l := l - 1
  67. >>;
  68. if u member rt then
  69. for each v in rt do
  70. beta := gbsc_betaset(beta,u,v,if u=v then simp 1 else simp 0)
  71. else if (w := gbsc_hmmember(u,gb)) then <<
  72. %g := car w;
  73. g := gb_reduce(u,gb);
  74. for each v in rt do
  75. beta := gbsc_betaset(beta,u,v,
  76. %negsq quotsq(gbsc_getlincombc(v,g),vdp_lbc g))
  77. gbsc_getlincombc(v,g))
  78. >>
  79. else <<
  80. w := gbsc_goodfctr(u,rt);
  81. for each v in rt do
  82. beta := gbsc_betaset(beta,u,v,
  83. gbsc_sumbeta(beta,car w,cdr w,v,rt))
  84. >>
  85. >>;
  86. if !*cgbverbose then
  87. ioto_prin2t "done";
  88. return beta
  89. end;
  90. procedure gbsc_vdpsetprod(vdpl,n);
  91. % Parametric real root countig VDP set product. [vdpl] is a list of
  92. % VDP's. Returns a list of VDP's $v_1 v_2... v_n$ with $v_i$ in
  93. % $[vdpl]$.
  94. begin scalar prodl;
  95. if n = 1 then
  96. return vdpl;
  97. for each x in gbsc_vdpsetprod(vdpl,n-1) do
  98. for each y in vdpl do
  99. prodl := lto_insert(vdp_prod(x,y),prodl);
  100. return prodl
  101. end;
  102. procedure gbsc_hmmember(u,gb);
  103. % Parametric real root counting head monomial member. [u] is a VDP
  104. % representing a monomial; [gb] is a list of VDP's. Returns [nil],
  105. % if there is no $f$ in [gb] with $[u]=HM(f)$ else returns a list
  106. % of VDP's such that $[u]=HM(g)$ for the first VDP $g$.
  107. begin scalar htu;
  108. htu := vdp_evlmon u;
  109. while gb and vdp_evlmon car gb neq htu do
  110. gb := cdr gb;
  111. return gb
  112. end;
  113. procedure gbsc_getlincombc(b,p);
  114. % Parametric real root counting get linear combination coefficient.
  115. % [b] is a TERM an element of a basis of $K[X_1,...,X_n]/I$; [p] is
  116. % a VDP, an eleemnt of $K[X_1,...,X_n]/I$. Returns an SQ, the
  117. % coefficient of [b] in [p].
  118. begin scalar bt;
  119. b := vdp_poly b;
  120. p := vdp_poly p;
  121. bt := dip_evlmon b;
  122. while not null p and dip_evlmon p neq bt do
  123. p := dip_mred p;
  124. if null p then
  125. return simp 0;
  126. return bc_2sq dip_lbc p
  127. end;
  128. procedure gbsc_goodfctr(u,rt);
  129. % Parametric real root counting good factorization. [u] is a VDP
  130. % representing a term; [rt] is a list of VDP's representing terms,
  131. % too. Write $[u]=u'X_i$ such that $u'$ is not in [rt]. Returns a
  132. % pair $(u' . X_i ) with $u'$ and $X_i$ are VDP's.
  133. begin scalar htu,fctr,cand,candt,n,i;
  134. htu := vdp_evlmon u;
  135. n := length htu;
  136. i := 1;
  137. while i <= n do <<
  138. candt := for each x in htu collect x; % TODO: Muesste nach EV.
  139. if nth(candt,i) > 0 then <<
  140. nth(candt,i) := nth(candt,i) - 1; % TODO; Muesste nach EV.
  141. cand := vdp_fmon(simp 1,candt);
  142. if not (cand member rt) then <<
  143. fctr := cand . vdp_fmon(simp 1,gbsc_mkvar(i,n)); % TODO Abbruch
  144. i := n + 1
  145. >>
  146. >>;
  147. i := i + 1
  148. >>;
  149. if i neq n + 2 then rederr {"bug in gbsc_goodfctr"};
  150. return fctr
  151. end;
  152. procedure gbsc_mkvar(i,n); % TODO nach EV.
  153. % Parametric real root counting make variable. [i] and [n] are
  154. % integers, such that [i] is between 1 and [n]. Returns an EV,
  155. % representing $X_1$ in the polynomial ring $K[X_1,...,X_n]$.
  156. begin scalar m;
  157. for j := 1:i-1 do
  158. m := 0 . m;
  159. m := 1 . m;
  160. for j := i+1:n do
  161. m := 0 . m;
  162. return reversip m
  163. end;
  164. procedure gbsc_sumbeta(beta,up,xi,v,rt);
  165. % Parametric real root counting sum beta. [beta] is a BETA; [up],
  166. % [xi], and [a] are VDP's; [rt] is a list of VDP's. Returns a SQ,
  167. % the sum $sum_{w\in [rt], w<[up]}
  168. % \beta_{[up]w}}beta_{(w[xi])[v]}$.
  169. begin scalar res,betaupline;
  170. res := simp 0;
  171. betaupline := gbsc_betagetline(beta,up);
  172. for each w in rt do
  173. if ev_compless!?(vdp_evlmon w,vdp_evlmon up) then
  174. res := addsq(res,multsq(gbsc_betalineget(betaupline,w),
  175. gbsc_betaget(beta,vdp_prod(w,xi),v)));
  176. return res
  177. end;
  178. % endmodule;
  179. % module prrcbeta;
  180. % Parametric real root counting beta. Implements an efficient data structue for
  181. % storing generalized combined structure constants.
  182. %DS BETA
  183. % BETA represents a $m\times n% matrix indexed by TERM's. We organize
  184. % BETA as an hashtable for all lines of beta. Each hash table entry is
  185. % an alist mapping the line index to a matrix line. The matrix lines
  186. % are simply organized as ALISTS, mapping the column index to the
  187. % entry. All entries are SQ's. Note that in our case $m$ is
  188. % $|RT(I)|^3$ and $n$ is $|RT(I)|$, and therefore we have in general
  189. % $m>>n$.
  190. procedure gbsc_betainit();
  191. % Parametric real root counting beta init. [m], [n] are INTEGERS;
  192. % Returns an empty BETA $\beta$.
  193. mkvect(cgb_hashsize!* - 1);
  194. procedure gbsc_betaset(beta,u,v,sc);
  195. % Parametric real root counting beta set. [beta] is a BETA; [u] and
  196. % [v] are VDP's; [sc] is a SQ. Returns a BETA, the updated and
  197. % inplace modiefied [beta]. Stores the generalized combined
  198. % structure constant [sc] of [u] and [v] in [beta]. It is forbidden
  199. % to overwrite an existing entry in [beta].
  200. begin scalar w,i,slot;
  201. i := gbsc_hashfunction u;
  202. slot := getv(beta,i);
  203. if null slot then <<
  204. putv(beta,i,{u . {v . sc}});
  205. return beta
  206. >>;
  207. w := assoc(u,slot);
  208. if null w then <<
  209. putv(beta,i,(u . {v . sc}) . slot);
  210. return beta
  211. >>;
  212. if not assoc(v,cdr w) then
  213. cdr w := (v . sc) . cdr w
  214. else
  215. rederr "bug in gbsc_betaset (gbsc_strconst)";
  216. return beta
  217. end;
  218. procedure gbsc_hashfunction(term);
  219. % Parametric real root counting hash functions. [term] is a TERM.
  220. % Returns an integer between 0 and [cgb_hashsize!*].
  221. begin integer w;
  222. for each x in vdp_evlmon term do
  223. w := 10*w + x; % TODO: remainder
  224. return remainder(w,cgb_hashsize!*)
  225. end;
  226. procedure gbsc_betagetline(beta,u);
  227. % Parametric real root counting beta getline. [beta] is a BETA; [u]
  228. % is a VDP. Returns the line of [beta] which is indexed by [u].
  229. begin scalar w;
  230. w := assoc(u,getv(beta,gbsc_hashfunction u));
  231. if null w then rederr "bug in gbsc_betagetline";
  232. return cdr w
  233. end;
  234. procedure gbsc_betalineget(betaline,v);
  235. % Parametric real root counting beta line get. [betaline] is a line
  236. % of a BETA; [v] is a VDP. Returns a SQ, the entry of betaline
  237. % indexed by [v].
  238. begin scalar w;
  239. w := atsoc(v,betaline);
  240. if null w then rederr "bug in gbsc_betalineget";
  241. return cdr w
  242. end;
  243. procedure gbsc_betaget(beta,u,v);
  244. % Parametric real root counting betaget. [beta] is a BETA; [u] and
  245. % [v] are VDP's. Returns a SQ the entry of [beta] indexed by [u]
  246. % and [v].
  247. begin scalar w;
  248. w := assoc(u,getv(beta,gbsc_hashfunction u));
  249. if null w then rederr "bug in gbsc_betaget (1)";
  250. w := atsoc(v,cdr w);
  251. if null w then rederr "bug in gbsc_betaget (2)";
  252. return cdr w
  253. end;
  254. endmodule; [gbsc]
  255. end; % of file