camal.red 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. module camal; % Package for calculations in celestial mechanics.
  2. % Author: John P. Fitch <jpff@maths.bath.ac.uk>
  3. create!-package('(camal fourdom fourplus makefour hsub hdiff),
  4. '(contrib camal));
  5. %% This section is to define macros and simple functions to handle the
  6. %% data structures for harmonic forms.
  7. %% The structure is a vector:
  8. %% Coeff | FN | Angle | Next
  9. %
  10. %% This version only allows 8 angles. Consider extending this later.
  11. switch fourier;
  12. %% A vector and counter to record link between angle names and index
  13. global '(next!-angle!* fourier!-name!*);
  14. next!-angle!* := 0;
  15. if vectorp fourier!-name!* then <<
  16. for i :=0:7 do remprop(getv(fourier!-name!*, i),'fourier!-angle)
  17. >>;
  18. fourier!-name!* := mkvect 7;
  19. %% For non Cambridge LISP add
  20. smacro procedure putv!.unsafe(x,y,z); putv(x,y,z);
  21. smacro procedure getv!.unsafe(x,y); getv(x,y);
  22. %% Data abtraction says that we should define macros for access to
  23. %% the parts of the Fourier structure
  24. smacro procedure fs!:set!-next(f,p); putv!.unsafe(f, 3, p);
  25. smacro procedure fs!:next(f); getv!.unsafe(f,3);
  26. smacro procedure fs!:set!-coeff(f,p); putv!.unsafe(f, 0, p);
  27. smacro procedure fs!:coeff(f); getv!.unsafe(f, 0);
  28. smacro procedure fs!:set!-fn(f,p); putv!.unsafe(f, 1, p);
  29. smacro procedure fs!:fn(f); getv!.unsafe(f, 1);
  30. smacro procedure fs!:set!-angle(f,p); putv!.unsafe(f, 2, p);
  31. smacro procedure fs!:angle(f); getv!.unsafe(f, 2);
  32. %% Some support functions for angle expressions
  33. symbolic procedure fs!:make!-nullangle();
  34. begin scalar ans;
  35. ans := mkvect 7;
  36. for i:=0:7 do putv!.unsafe(ans,i,0);
  37. return ans;
  38. end;
  39. symbolic procedure fs!:null!-angle!: u;
  40. fs!:null!-angle cdr u;
  41. symbolic procedure fs!:null!-angle u;
  42. begin scalar ans, i, x;
  43. x := fs!:angle u;
  44. ans := t;
  45. i := 0;
  46. top:
  47. if not(getv!.unsafe(x,i)=0) then return nil;
  48. i := i+1;
  49. if (i<8) then go to top;
  50. return ans;
  51. end;
  52. endmodule;
  53. end;