exdf.red 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. module exdf;
  2. % Author: Eberhard Schruefer;
  3. fluid '(subfg!*);
  4. global '(naturalframe2coframe dbaseform2base2form basisforml!* dimex!*);
  5. put('d,'simpfn,'simpexdf);
  6. put('d,'rtypefn,'getrtypecar);
  7. put('d,'partitfn,'partitexdf);
  8. symbolic procedure partitexdf u;
  9. exdfpf partitop car u;
  10. symbolic procedure simpexdf u;
  11. !*pf2sq partitexdf u;
  12. symbolic procedure mkexdf u;
  13. begin scalar x,y;
  14. return if x := opmtch(y := list('d,u))
  15. then partitop x
  16. else mkupf y
  17. end;
  18. symbolic procedure exdfpf u;
  19. if null u then nil
  20. else addpf(if ldpf u = 1
  21. then exdf0 lc u
  22. else addpf(multpfsq(exdfk ldpf u,lc u),
  23. mkuniquewedge wedgepf2(exdf0 lc u,
  24. !*k2pf list ldpf u)),
  25. exdfpf red u);
  26. symbolic procedure exdfk u;
  27. if u = 1 or eqcar(u,'d) or dim!<!=deg u
  28. or flagp(lid u,'closed) then nil
  29. else if flagp('d,'noxpnd) or lftshftp u then mkexdf u
  30. else if atomf u then
  31. if (not flagp('partdf,'noxpnd)) and
  32. flagp(lid u,'impfun)
  33. then dimpfun(u,get!-impfun!-args lid u)
  34. else if coordp u then
  35. if subfg!*
  36. then !*pfsq2pf cdr atsoc(u,naturalframe2coframe)
  37. else mkexdf u
  38. else if basisformp u and dbaseform2base2form then
  39. !*pfsq2pf cdr atsoc(u,dbaseform2base2form)
  40. else mkexdf u
  41. else if (car u eq 'wedge) then dwedge cdr u
  42. else if car u memq '(hodge innerprod liedf) then mkexdf u
  43. else if car u eq 'partdf then
  44. if not flagp('partdf,'noxpnd) and atomf cadr u
  45. then dimpfun(u,get!-impfun!-args lid cadr u)
  46. else mkexdf u
  47. else begin scalar x,y,z;
  48. if null(x := get(car u,dfn_prop u)) then return mkexdf u;
  49. z := cdr u;
  50. for each j in
  51. for each k in z collect partitexdf list k do
  52. <<if j then
  53. y := addpf(multpfsq(j,simp subla(pair(caar x,z),cdar x)),
  54. y);
  55. x := cdr x>>;
  56. return y
  57. end;
  58. symbolic procedure lid u;
  59. if atom u then u else car u;
  60. symbolic procedure atomf u;
  61. atom u or flagp(car u,'indexvar);
  62. symbolic procedure dim!<!=deg u;
  63. (null x or (fixp x and x<=0))
  64. where x = addf(dimex!*,negf deg!*form u);
  65. symbolic procedure dim!<deg u;
  66. begin scalar x;
  67. x := addf(dimex!*,negf deg!*farg u);
  68. return if numberp x and minusp x then t
  69. else nil
  70. end;
  71. symbolic procedure dimpfun(u,v);
  72. if null v then nil
  73. else addpf(multpfsq(exdfp0(car v . 1),partdfsq(simp u,car v)),
  74. dimpfun(u,cdr v));
  75. symbolic procedure exdf0 u;
  76. multpfsq(addpf(exdff0 numr u,multpfsq(exdff0 negf denr u,u)),
  77. 1 ./ denr u);
  78. symbolic procedure exdff0 u;
  79. if domainp u then nil
  80. else addpf(addpf(multsqpf(!*p2q lpow u,exdff0 lc u),
  81. multpfsq(exdfp0 lpow u,lc u ./ 1)),
  82. exdff0 red u);
  83. symbolic procedure exdfp0 u; %weighted vars ??
  84. begin scalar pv,n,z;
  85. pv := car u;
  86. n := pdeg u;
  87. return if (sfp pv or exformp pv or null subfg!*)
  88. and (z := if sfp pv then exdff0 pv
  89. else exdfk pv)
  90. then if n = 1 then z
  91. else multpfsq(z,!*t2q((pv to (n - 1)) .* n))
  92. else nil
  93. end;
  94. symbolic procedure dwedge u;
  95. %u is a wedge argument, result is a pf.
  96. mkuniquewedge dwedge1(u,nil);
  97. symbolic procedure dwedge1(u,v);
  98. if null rwf u
  99. then mkunarywedge multpfsq(exdfk lwf u,mksgnsq v)
  100. else addpf(wedgepf2(!*k2pf lwf u,
  101. dwedge1(rwf u,addf(v,deg!*form lwf u))),
  102. multpfsq(wedgepf2(exdfk lwf u,!*k2pf rwf u),mksgnsq v));
  103. symbolic procedure exdfprn u;
  104. <<prin2!* "d"; rembras cadr u>>;
  105. put('d,'prifn,'exdfprn);
  106. symbolic procedure xexdfprn u;
  107. begin scalar w;
  108. w := fancy!-prin2!*("\,d\,",2);
  109. return fancy!-maprint(cadr u,0)
  110. end;
  111. put('d,'fancy!-prifn,'xexdfprn);
  112. endmodule;
  113. end;