reform.red 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. module reform; % Reformulate expressions using C-constant substitution.
  2. % Authors: Mary Ann Moore and Arthur C. Norman.
  3. fluid '(!*trint cmap cval loglist ulist);
  4. exports logstosq,substinulist;
  5. imports prepsq,mksp,nth,multsq,addsq,domainp,invsq,plusdf;
  6. symbolic procedure substinulist ulst;
  7. % Substitutes for the C-constants in the values of the U's given in
  8. % ULST. Result is a D.F.
  9. if null ulst then nil
  10. else begin scalar temp,lcu;
  11. lcu:=lc ulst;
  12. temp:=evaluateuconst numr lcu;
  13. if null numr temp then temp:=nil
  14. else temp:=((lpow ulst) .*
  15. !*multsq(temp,!*invsq(denr lcu ./ 1))) .+ nil;
  16. return plusdf(temp,substinulist red ulst)
  17. end;
  18. symbolic procedure evaluateuconst coefft;
  19. % Substitutes for the C-constants into COEFFT (=S.F.). Result is S.Q.;
  20. if null coefft or domainp coefft then coefft ./ 1
  21. else begin scalar temp;
  22. if null(temp:=assoc(mvar coefft,cmap)) then
  23. temp:=(!*p2f lpow coefft) ./ 1
  24. else temp:=getv(cval,cdr temp);
  25. temp:=!*multsq(temp,evaluateuconst(lc coefft));
  26. % Next line had addsq previously
  27. return !*addsq(temp,evaluateuconst(red coefft))
  28. end;
  29. symbolic procedure logstosq;
  30. % Converts LOGLIST to sum of the log terms as a S.Q.;
  31. begin scalar lglst,logsq,i,temp;
  32. i:=1;
  33. lglst:=loglist;
  34. logsq:=nil ./ 1;
  35. loop: if null lglst then return logsq;
  36. temp:=cddr car lglst;
  37. %% if !*trint
  38. %% then <<printc "SF arg for log etc ="; printc temp>>;
  39. if not (caar lglst='iden) then <<
  40. temp:=prepsq temp; %convert to prefix form.
  41. temp:=list(caar lglst,temp); %function name.
  42. temp:=((mksp(temp,1) .* 1) .+ nil) ./ 1 >>;
  43. temp:=!*multsq(temp,getv(cval,i));
  44. % Next line had addsq previously
  45. logsq:=!*addsq(temp,logsq);
  46. lglst:=cdr lglst;
  47. i:=i+1;
  48. go to loop
  49. end;
  50. endmodule;
  51. end;