red2cvit.red 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. module red2cvit;
  2. % COPYRIGHT (C) 1988,1990,INSTITUTE OF NUCLEAR PHYSICS,MOSCOW STATE
  3. % UNIV.
  4. % PURPOSE INTERFACE BETWEEN REDUCE AND CVITANOVICH ALGORITHM.
  5. % AUTHOR A.KRYUKOV
  6. % VERSION 2.1
  7. % RELEASE 11-MAR-90
  8. exports isimp1,replace_by_vector,replace_by_vectorp,gamma5p$
  9. imports calc_spur,isimp2$
  10. switch cvit$ % CVITANOVICH ALGORITHM SWITCH
  11. !*cvit := t$ % DEFAULT ON
  12. %************ ISIMP1 REDEFINITION ************************
  13. remflag('(isimp1),'lose)$
  14. symbolic procedure isimp1(u,i,v,w,x)$
  15. if null u then nil
  16. else if domainp u
  17. then if x then multd(u,if !*cvit
  18. then calc_spurx (i,v,w,x)
  19. else spur0 (car x,i,v,w,cdr x)
  20. )
  21. else if v then multd(u,index_simp (1,i,v,w))
  22. else if w then multfs(emult w,isimp1(u,i,v,nil,nil))
  23. else u
  24. else addfs(isimp2(car u,i,v,w,x),isimp1(cdr u,i,v,w,x))$
  25. flag('(isimp1),'lose)$
  26. %************* INDEX_SIMP *******************************
  27. symbolic procedure index_simp (u,i,v,w)$
  28. if v then index_simp (multf(mksprod(caar v,cdar v),u),
  29. update_index (i,car v),cdr v,w)
  30. else isimp1(u,i,nil,w,nil)$
  31. symbolic procedure mksprod(x,y)$
  32. mkdot(if indexp x then replace_by_vector x else x,
  33. if indexp y then replace_by_vector y else y)$
  34. symbolic procedure update_index (i,v)$
  35. % I - LIST OF UNMATCH INDICES
  36. % V - PAIR: (I/V . I/V)
  37. % VALUE - UPDATE LIST OF INDICES
  38. delete(cdr v,delete(car v,i))$
  39. %************ CALC_SPURX - MAIN PROCEDURE ***************
  40. symbolic procedure calc_spurx (i,v,w,x)$
  41. % I - LIST OF INDICES
  42. % V - LIST OF SCALAR PRODUCT:(<I/V> . <I/V>)
  43. % W - EPS-EXPR
  44. % X - LIST OF SPURS
  45. % VALUE - CALCULATED SPUR(S.F.)
  46. begin scalar u, % SPUR: (LNAME G5SWITCH I/V I/V ... )
  47. x1, % (UN ... U1)
  48. dindices!*,% A-LIST OF DUMMY INDICES: (I . NIL/T)
  49. c$ % COEFFICIENT GENERATIED BY GX*GX
  50. if numberp ndims!* and null evenp ndims!*
  51. then cviterr list('calc_spur,":",ndims!*,
  52. "is not even dimension of G-matrix space")$
  53. c := 1$ % INITIAL VALUE
  54. while x
  55. do << if nospurp caar x
  56. then cviterr list "Nospur not yet implemented"$
  57. u := cdar x$
  58. x := cdr x$
  59. if car u
  60. then if evenp ndims!*
  61. then u := next_gamma5() . reverse cdr u
  62. else cviterr
  63. {"G5 invalid for non even dimension"}
  64. else u := reverse cdr u$
  65. if null u then nil % SP()
  66. else if null evenp
  67. length(if gamma5p car u and cdr u then cdr u
  68. else u)
  69. then x := c := nil % ODD - VALUE=0
  70. else << u := remove_gx!*gx u$
  71. c := multf(car u,c)$
  72. u := replace_vector(cdr u,i,v,w)$
  73. i := cadr u$
  74. v := caddr u$
  75. w := cadddr u$
  76. if u then x1 := car u . x1
  77. >>
  78. >>$
  79. x1 := if null c then nil ./ 1 % ZERO
  80. else if x1 then multsq(c ./ 1,calc_spur x1)
  81. else c ./ 1$
  82. if denr x1 neq 1 then cviterr list('calc_spurx,":",x1,
  83. "has non unit denominator")$
  84. clear_windices ()$
  85. clear_gamma5 ()$
  86. return isimp1(numr x1,i,v,w,nil)
  87. end$
  88. symbolic procedure third_eq_indexp i$
  89. begin scalar z$
  90. if null(z := assoc(i,dindices!*))
  91. then dindices!* := (i . nil) . dindices!*
  92. else if null cdr z
  93. then dindices!* := (i . t) . delete(z,dindices!*)$
  94. return if z then cdr z else nil
  95. end$
  96. symbolic procedure replace_vector(u,i,v,w)$
  97. % U - SPUR (INVERSE)
  98. % I - LIST OF UNMATCH INDICES
  99. % V - A-LIST OF SCALAR PRODUCT
  100. % W - EPS-EXPRESION
  101. % VALUE - LIST(U,UPDATE I,UPDATE V,UPDATE W)
  102. begin scalar z,y,x, % WORK VARIABLES
  103. u1$ % SPUR WITHOUT VECTOR
  104. while u
  105. do << z := car u$
  106. u := cdr u$
  107. if indexp z
  108. then << % REMOVE DUMMY INDICES
  109. while (y := bassoc(z,v))
  110. do << i := delete(z,i)$
  111. v := delete(y,v)$
  112. % W := ....
  113. x := if z eq car y then cdr y
  114. else car y$
  115. if indexp x then z := x
  116. else if gamma5p x
  117. then cviterr
  118. list "G5 bad structure"
  119. else replace_by_index (x,z)
  120. >>$
  121. u1 := z . u1
  122. >>
  123. else if gamma5p z then u1 := z . u1
  124. else << z := replace_by_index (z,next_windex())$
  125. u1 := z . u1
  126. >>
  127. >>$
  128. return list(reverse u1,i,v,w)
  129. end$
  130. symbolic procedure replace_by_index (v,y)$
  131. begin scalar z$
  132. if (z := replace_by_vectorp y) eq v
  133. then cviterr list('replace_by_index,":",y,
  134. "is already defined for vector",z)$
  135. put(y,'replace_by_vector ,v)$
  136. return y
  137. end$
  138. symbolic procedure remove_gx!*gx u$
  139. begin scalar x,c$
  140. integer l,l1$
  141. c := 1$
  142. l1 := l := length u$
  143. u := for each z in u % MAKE COPY
  144. collect << if indexp z then
  145. if third_eq_indexp z
  146. then cviterr
  147. list("Three indices have name",z)
  148. else nil
  149. else if null hvectorp z then
  150. if cvitdeclp(z,'vector)
  151. then vector1 list z
  152. else cviterr nil
  153. else nil$
  154. z
  155. >>$
  156. if l < 2 then return u$
  157. x := u$
  158. while cdr x do x := cdr x$
  159. rplacd(x,u)$ % MAKE CYCLE
  160. while l1 > 0
  161. do if car u eq cadr u % EQUAL ?
  162. then << c := multf(if indexp car u then ndims!*
  163. else mkdot(car u,car u)
  164. ,c)$
  165. rplaca(u,caddr u)$ % YES - DELETE
  166. rplacd(u,cdddr u)$
  167. l1 := l := l - 2
  168. >>
  169. else << u := cdr u$ % NO - CHECK NEXT PAIR
  170. l1 := l1 - 1
  171. >>$
  172. x := cdr u$
  173. rplacd(u,nil)$ % CUT CYCLE
  174. return (c . if cdr x and car x eq cadr x then nil else x)
  175. end$
  176. %************* ERROR,MESSAGE *****************************
  177. symbolic procedure cviterr u$
  178. << clear_windices()$
  179. clear_gamma5()$
  180. if u then rederr u else error(0,nil) >>$
  181. symbolic procedure cvitdeclp(u,v)$
  182. if null !*msg then nil
  183. else if terminalp()
  184. then yesp list("Declare",u,v,"?")
  185. else << lprim list(u,"Declare",v)$ t >>$
  186. %*********** WORK INDICES & VECTOR ***********************
  187. symbolic procedure clear_windices ()$
  188. while car windices!*
  189. do begin scalar z$
  190. z := caar windices!*$
  191. windices!* := cdar windices!* . z . cdr windices!*$
  192. remprop(z,'replace_by_vector)$
  193. indices!* := delete(z,indices!*)$
  194. end$
  195. symbolic procedure next_windex()$
  196. begin scalar i$
  197. windices!* := if null cdr windices!*
  198. then (intern gensym() . car windices!*) .
  199. cdr windices!*
  200. else (cadr windices!* . car windices!*) .
  201. cddr windices!*$
  202. i := caar windices!*$
  203. vector1 list i$
  204. indices!* := i . indices!*$
  205. return i
  206. end$
  207. symbolic procedure next_gamma5()$
  208. begin scalar v$
  209. cviterr list "GAMMA5 is not yet implemented. use OFF CVIT";
  210. gamma5!* := if null cdr gamma5!*
  211. then (intern gensym() . car gamma5!*) .
  212. cdr gamma5!*
  213. else (cadr gamma5!* . car gamma5!*) .
  214. cddr gamma5!*$
  215. v := list caar gamma5!*$
  216. vector1 v$
  217. return car v
  218. end$
  219. %************ END ****************************************
  220. %prin2t "_Cvitanovich_algorithm_is_ready"$
  221. endmodule;
  222. end;