aboutsummaryrefslogtreecommitdiff
path: root/src/input/plotlist.input.pamphlet
blob: 7dd581ef6a5f61515ab230e05cad6cae6c814fb2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
\documentclass{article}
\usepackage{axiom}
\begin{document}
\title{\$SPAD/src/input plotlist.input}
\author{The Axiom Team}
\maketitle
\begin{abstract}
\end{abstract}
\eject
\tableofcontents
\eject
\section{License}
<<license>>=
--Copyright The Numerical Algorithms Group Limited 1996.
@
<<*>>=
)clear all
<<license>>

--draws x**i for i in 1..5, x=-1..1

makePoint(x:DoubleFloat,y:DoubleFloat):(Point DoubleFloat) ==
  point(l :List DoubleFloat := [x,y])$(Point DoubleFloat)

drawFun(fn:DoubleFloat->DoubleFloat, seg:Segment Float):List(List(Point DoubleFloat)) ==
  fp := (t:DoubleFloat):Point DoubleFloat +-> makePoint(t, fn(t))
  plot := pointPlot(fp, segment(convert(lo seg)@DoubleFloat, convert(hi seg)@DoubleFloat))$PLOT
  lp := listBranches(plot)$PLOT

drawFuns(fl:List(DoubleFloat->DoubleFloat), seg:SegmentBinding Float):VIEW2D ==
  v := viewport2D()$VIEW2D
  i : PositiveInteger := 1
  for f in fl repeat
    g := graphImage()$GRIMAGE
    s : Segment Float := segment seg
    llp : List(List(Point DoubleFloat)) := drawFun(f, s)
    g :GRIMAGE := graphCurves(llp)$VIEW
    putGraph(v,g,i)$VIEW2D
    i := i + 1
  makeViewport2D(v)$VIEW2D

makeListFuns(fl:List(Expression Integer),_
             seg:SegmentBinding Float):List(DoubleFloat->DoubleFloat) ==
  lfuns:List(DoubleFloat->DoubleFloat) := empty()
  for f in fl repeat
    ff : (DoubleFloat->DoubleFloat) := makeFloatFunction(f, variable seg)$MakeFloatCompiledFunction(Expression Integer)
    lfuns := cons(ff, lfuns)
  lfuns

drawFuns(makeListFuns([x**i for i in 1..5], x=-1..1), x=-1..1)

@
\eject
\begin{thebibliography}{99}
\bibitem{1} nothing
\end{thebibliography}
\end{document}