degform.red 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. module degform;
  2. % Author: Eberhard Schruefer;
  3. fluid '(frlis!*);
  4. global '(dimex!*);
  5. symbolic procedure deg!*farg u;
  6. %Calculates the sum of degrees of the elements of the list u;
  7. if null cdr u then deg!*form car u else
  8. begin scalar z;
  9. for each j in u do z := addf(deg!*form j,z);
  10. return z
  11. end;
  12. symbolic procedure deg!*form u;
  13. %U is a prefix expression. Result is the degree of u;
  14. if atom u then get!*fdeg u
  15. else (if flagp(x,'indexvar) then get!*ifdeg u
  16. else if x eq 'wedge then deg!*farg cdr u
  17. else if x eq 'd then addd(1,deg!*form cadr u)
  18. else if x eq 'hodge then addf(dimex!*,negf deg!*form cadr u)
  19. else if x eq 'partdf then if cddr u then nil else -1
  20. else if x eq 'liedf then deg!*form caddr u
  21. else if x eq 'innerprod then addd(-1,deg!*form caddr u)
  22. else if x memq '(plus minus difference quotient) then
  23. deg!*form cadr u
  24. else if x eq 'times then deg!*farg cdr u
  25. else nil) where x = car u;
  26. symbolic procedure simpexdegree u;
  27. !*f2q deg!*form prepsq simp!* car u;
  28. put('exdegree,'simpfn,'simpexdegree);
  29. symbolic procedure exformp u;
  30. %test for exterior forms and vectors in prefix expressions;
  31. if null u or numberp u then nil
  32. else if atom u and u memq frlis!* then t
  33. else if atom u then get(u,'fdegree)
  34. else if flagp(car u,'indexvar)
  35. then assoc(length cdr u,get(car u,'ifdegree))
  36. else if car u eq '!*sq then exformp prepsq cadr u
  37. else if car u memq '(wedge d partdf hodge innerprod liedf) then t
  38. else if get(car u,'dname) then nil
  39. else lexformp cdr u or exformp car u;
  40. symbolic procedure lexformp u;
  41. u and (exformp car u or lexformp cdr u);
  42. endmodule;
  43. end;