entry.red 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. module entry; % Entry points for self-loading modules.
  2. % Author: Anthony C. Hearn.
  3. % Using a modified version of the defautoload function of Eric Benson
  4. % and Martin L. Griss.
  5. % Extended for algebraic operators and values by Herbert Melenk.
  6. fluid '(varstack!*);
  7. if getd 'create!-package then create!-package('(entry),'(build));
  8. symbolic procedure safe!-putd(name,type,body);
  9. % So that stubs will not clobber REAL entries preloaded.
  10. if getd name then lprim list("Autoload stub for",name,"not defined")
  11. else putd(name,type,body);
  12. smacro procedure mkfunction u; list('function,u);
  13. symbolic macro procedure defautoload u;
  14. % (defautoload name), (defautoload name loadname),
  15. % (defautoload name loadname fntype), or
  16. % (defautoload name loadname fntype numargs)
  17. % Default is 1 Arg EXPR in module of same name.
  18. begin scalar name,numargs,loadname,fntype;
  19. u := cdr u;
  20. name := car u;
  21. u := cdr u;
  22. if u then <<loadname := car u; u :=cdr u>> else loadname := name;
  23. if eqcar(name, 'quote) then name := cadr name;
  24. if atom loadname then loadname := list loadname
  25. else if car loadname eq 'quote then loadname := cadr loadname;
  26. if u then <<fntype := car u; u := cdr u>> else fntype := 'expr;
  27. if u then numargs := car u else numargs := 1;
  28. u := if numargs=0 then nil
  29. else if numargs=1 then '(x1)
  30. else if numargs=2 then '(x1 x2)
  31. else if numargs=3 then '(x1 x2 x3)
  32. else if numargs=4 then '(x1 x2 x3 x4)
  33. else error(99,list(numargs,"too large in DEFAUTOLOAD"));
  34. name := mkquote name;
  35. return
  36. list('progn,
  37. list('put,name,mkquote 'number!-of!-args,numargs),
  38. list('safe!-putd,
  39. name,
  40. mkquote fntype,
  41. mkfunction
  42. list('lambda, u,
  43. 'progn .
  44. aconc(for each j in loadname
  45. collect
  46. list('load!-package,mkquote j),
  47. list('lispapply,name,'list . u)))))
  48. end;
  49. % Autoload support for algebraic operators and values.
  50. %
  51. % defautoload_operator(opname,package);
  52. % defautoload_value(varname,package);
  53. %
  54. symbolic macro procedure defautoload_operator u;
  55. begin scalar name,package;
  56. name := cadr u; package := caddr u;
  57. return subla(list('name.name,'package.package),
  58. '(progn
  59. (flag '(name) 'full)
  60. (put 'name 'simpfn
  61. '(lambda(x)(autoload_operator!* 'name 'package x)))))
  62. end;
  63. symbolic procedure autoload_operator!*(o,p,x);
  64. begin scalar varstack!*;
  65. remflag(list o,'full);
  66. remprop(o,'simpfn);
  67. if pairp p then for each pp in p do load!-package pp
  68. else load!-package p;
  69. return simp x;
  70. end;
  71. symbolic macro procedure defautoload_value u;
  72. begin scalar name,package;
  73. u:=cdr u; name := car u; u:=cdr u; package := car u;
  74. return subla(list('name.name,'package.package),
  75. '(progn
  76. (put 'name 'avalue
  77. '(autoload_value!* name package))))
  78. end;
  79. symbolic procedure autoload_value!*(u,v);
  80. begin scalar name,p,x,varstack!*;
  81. x:=get(u,'avalue);
  82. name := cadr x; p := caddr x;
  83. remprop(name,'avalue);
  84. load!-package p;
  85. return reval1(name,v);
  86. end;
  87. put('autoload_value!*,'evfn,'autoload_value!*);
  88. comment Actual Entry Point Definitions;
  89. % Compiler and LAP entry points.
  90. defautoload(compile,compiler);
  91. if 'csl memq lispsystem!* then defautoload(faslout,compiler)
  92. else defautoload(lap,compiler);
  93. % Cross-reference module entry points.
  94. remd 'crefon; % don't use PSL version
  95. put('cref,'simpfg,'((t (crefon)) (nil (crefoff))));
  96. defautoload(crefon,rcref,expr,0);
  97. % Input editor entry points.
  98. defautoload cedit;
  99. defautoload(display,cedit);
  100. put('display,'stat,'rlis);
  101. defautoload(editdef,cedit);
  102. put('editdef,'stat,'rlis);
  103. % Factorizer module entry points.
  104. switch trfac, trallfac;
  105. remprop('factor,'stat);
  106. defautoload(ezgcdf,ezgcd,expr,2);
  107. defautoload(factorize!-primitive!-polynomial,factor);
  108. defautoload(pfactor,factor,expr,2);
  109. defautoload(simpnprimitive,factor);
  110. put('nprimitive,'simpfn,'simpnprimitive);
  111. put('factor,'stat,'rlis);
  112. % FASL module entry points.
  113. flag('(faslout),'opfn);
  114. flag('(faslout),'noval);
  115. % High energy physics module entry points.
  116. remprop('index,'stat); remprop('mass,'stat);
  117. remprop('mshell,'stat); remprop('vecdim,'stat);
  118. remprop('vector,'stat);
  119. defautoload(index,hephys);
  120. defautoload(mass,hephys);
  121. defautoload(mshell,hephys);
  122. defautoload(vecdim,hephys);
  123. defautoload(vector,hephys);
  124. put('index,'stat,'rlis);
  125. put('mshell,'stat,'rlis);
  126. put('mass,'stat,'rlis);
  127. put('vecdim,'stat,'rlis);
  128. put('vector,'stat,'rlis);
  129. % Integrator module entry points.
  130. fluid '(!*trint);
  131. switch trint;
  132. defautoload(simpint,int);
  133. put('int,'simpfn,'simpint);
  134. put('algint,'simpfg,'((t (load!-package 'algint))));
  135. % Matrix module entry points.
  136. switch cramer;
  137. put('cramer,'simpfg,
  138. '((t (put 'mat 'lnrsolvefn 'clnrsolve)
  139. (put 'mat 'inversefn 'matinv))
  140. (nil (put 'mat 'lnrsolvefn 'lnrsolve)
  141. (put 'mat 'inversefn 'matinverse))));
  142. defautoload(detq,'(matrix)); % Used by high energy physics package.
  143. defautoload(matp,'(matrix));
  144. defautoload(matrix,'(matrix));
  145. put('matrix,'stat,'rlis);
  146. flag('(mat),'struct);
  147. put('mat,'formfn,'formmat);
  148. defautoload(formmat,'(matrix),expr,3);
  149. defautoload(generateident,'(matrix));
  150. defautoload(lnrsolve,'(matrix),expr,2);
  151. defautoload(simpresultant,'(matrix));
  152. defautoload(resultant,'(matrix),expr,3);
  153. put('resultant,'simpfn,'simpresultant);
  154. defautoload(nullspace!-eval,matrix);
  155. put('nullspace,'psopfn,'nullspace!-eval);
  156. % Plot entry point.
  157. put('plot,'psopfn,'(lambda(u) (load!-package 'gnuplot) (ploteval u)));
  158. % Prettyprint module entry point (built into CSL).
  159. if null('csl memq lispsystem!*) then defautoload(prettyprint,pretty);
  160. % Print module entry point.
  161. % defautoload(horner,scope);
  162. % global '(!*horner);
  163. % switch horner;
  164. % Rprint module entry point.
  165. defautoload rprint;
  166. % SOLVE module entry points.
  167. defautoload(solveeval,solve);
  168. defautoload(solve0,solve,expr,2);
  169. % defautoload(solvelnrsys,solve,expr,2); % Used by matrix routines.
  170. % defautoload(!*sf2ex,solve,expr,2); % Used by matrix routines.
  171. put('solve,'psopfn,'solveeval);
  172. switch allbranch,arbvars,fullroots,multiplicities,nonlnr,solvesingular;
  173. % varopt;
  174. % Default values.
  175. !*allbranch := t;
  176. !*arbvars := t;
  177. !*solvesingular := t;
  178. put('arbint,'simpfn,'simpiden);
  179. % Since the following three switches are set on in the solve module,
  180. % they must first load that module if they are initially turned off.
  181. put('nonlnr,'simpfg,'((nil (load!-package 'solve))));
  182. put('allbranch,'simpfg,'((nil (load!-package 'solve))));
  183. put('solvesingular,'simpfg,'((nil (load!-package 'solve))));
  184. % Root finding package entry points.
  185. defautoload roots;
  186. defautoload(gfnewt,roots);
  187. defautoload(gfroot,roots);
  188. defautoload(root_val,roots);
  189. defautoload(firstroot,roots);
  190. defautoload(rlrootno,roots2);
  191. defautoload(realroots,roots2);
  192. defautoload(isolater,roots2);
  193. defautoload(nearestroot,roots2);
  194. defautoload(sturm0,roots2);
  195. defautoload(multroot1,roots2);
  196. for each n in '(roots rlrootno realroots isolater firstroot
  197. nearestroot gfnewt gfroot root_val)
  198. do put(n,'psopfn,n);
  199. put('sturm,'psopfn,'sturm0);
  200. switch trroot,rootmsg;
  201. put('multroot,'psopfn,'multroot1);
  202. switch fullprecision,compxroots;
  203. % Limits entry points.
  204. for each c in '(limit limit!+ limit!-) do
  205. <<put(c,'simpfn,'simplimit);
  206. put(c,'number!-of!-args,3);
  207. flag({c},'full)>>;
  208. defautoload(simplimit,limits);
  209. % Partial fractions entry point.
  210. defautoload(pf,pf,expr,2);
  211. symbolic operator pf;
  212. % Sum entry points.
  213. defautoload(simp!-sum,sum);
  214. defautoload(simp!-sum0,sum,expr,2);
  215. put('sum,'simpfn,'simp!-sum);
  216. defautoload(simp!-prod,sum);
  217. put('prod,'simpfn,'simp!-prod);
  218. switch zeilberg;
  219. % Taylor entry points
  220. put('taylor,'simpfn,'simptaylor);
  221. defautoload(simptaylor,taylor);
  222. % Trigsimp entry points
  223. put('trigsimp,'psopfn,'trigsimp!*);
  224. defautoload(trigsimp!*,trigsimp);
  225. % Specfn entry points
  226. defautoload_operator(besselj,(specfn specbess));
  227. defautoload_operator(bessely,(specfn specbess));
  228. defautoload_operator(besseli,(specfn specbess));
  229. defautoload_operator(besselk,(specfn specbess));
  230. defautoload_operator(hankel1,(specfn specbess));
  231. defautoload_operator(gamma,(specfn sfgamma));
  232. defautoload_operator(binomial,specfn);
  233. % Debug module entry points.
  234. % if not(systemname!* eq 'ibm) then defautoload(embfn,debug,expr,3);
  235. % Specfn entry points.
  236. defautoload_operator(lambert_w,(specfn specbess));
  237. endmodule;
  238. end;