Commit eba99148 authored by sof's avatar sof
Browse files

[project @ 1999-01-23 18:07:42 by sof]

updates and tweaks
parent c88ecf9a
......@@ -56,7 +56,7 @@ u `quo` v = Bin Quo u v
term0,term1,term2 :: Term
term0 = Con 6 `mul` Con 9
term1 = (Con 4 `mul` Con 13) `add` Con 2
term2 = (Con 1 `quo` Con 0) `add` Con 2
term2 = (Con 1 `quo` Con 2) `add` Con 2
term3 = ((((((((((((((((((((((((((((((((
((((((((((((((((((((((((((((((
Con 7777 `mul` Con 13) `quo` Con 13)
......
......@@ -223,8 +223,7 @@ makeWin st wid sig =
nullWindow
in PieceContRep wins
instance Signal BasicSignal where
toSig Overshoot{start_delay,pulse_width,
ringing,oscillation,damp_fac} =
toSig (Overshoot start_delay pulse_width ringing oscillation damp_fac) =
let ring = sine ringing oscillation 0.0
cond = asTypeOf (expc damp_fac) ring
sig = temp ring cond
......@@ -237,8 +236,16 @@ instance Signal BasicSignal where
Window LocalZero (TimeEvent (fromPhysical pulse_width)) sig |>
nullWindow
in PieceContRep wins
toSig Pulse_dc{start_delay,rise_time,pulse_width,fall_time,
dc_offset,period,amplitude,over,under} =
toSig Pulse_dc{ start_delay = start_delay
, rise_time = rise_time
, pulse_width = pulse_width
, fall_time = fall_time
, dc_offset = dc_offset
, period = period
, amplitude = amplitude
, over = over
, under = under
} =
let pul = trap start_delay rise_time pulse_width fall_time amplitude
so = toPhysical ((fromPhysical start_delay) + (fromPhysical rise_time))
su = toPhysical ((fromPhysical so) + (fromPhysical pulse_width) + (fromPhysical fall_time))
......
......@@ -46,7 +46,7 @@ fromVector :: Vector a -> Array Int a
fromVector (Vector x) = x
instance Functor (Vector) where
map fn x = toVector (map fn (fromVector x))
fmap fn x = toVector (fmap fn (fromVector x))
{-instance Eq a => Eq (Vector a) where
-- (Vector x) == (Vector y) = x == y
......@@ -62,11 +62,11 @@ instance Read a => Read (Vector a) where
instance Num b => Num (Vector b) where
(+) = zipVector "+" (+)
(-) = zipVector "-" (-)
negate = map negate
abs = map abs
signum = map signum
negate = fmap negate
abs = fmap abs
signum = fmap signum
-- (*) = matMult -- works only for matrices!
-- fromInteger = map fromInteger
-- fromInteger = fmap fromInteger
\end{code}
......@@ -88,7 +88,7 @@ zipVector s f (Vector a) (Vector b)
| otherwise = error ("zipVector: " ++ s ++ ": unconformable arrays")
scaleVector :: Num a => a -> Vector a -> Vector a
scaleVector a = map (* a)
scaleVector a = fmap (* a)
sumVector :: Num a => Vector a -> a
sumVector = sum . elems . fromVector
......@@ -113,7 +113,7 @@ fromMatrix :: Matrix a -> Array (Int, Int) a
fromMatrix (Matrix x) = x
instance Functor (Matrix) where
map fn x = toMatrix (map fn (fromMatrix x))
fmap fn x = toMatrix (fmap fn (fromMatrix x))
--instance Eq a => Eq (Matrix a) where
-- (Matrix x) == (Matrix y) = x == y
......@@ -133,11 +133,11 @@ instance Read a => Read (Matrix a) where
instance Num b => Num (Matrix b) where
(+) = zipMatrix "+" (+)
(-) = zipMatrix "-" (-)
negate = map negate
abs = map abs
signum = map signum
negate = fmap negate
abs = fmap abs
signum = fmap signum
x * y = toMatrix (matMult (fromMatrix x) (fromMatrix y)) -- works only for matrices!
-- fromInteger = map fromInteger
-- fromInteger = fmap fromInteger
\end{code}
Convert a nested list to a matrix.
......@@ -159,7 +159,7 @@ zipMatrix s f (Matrix a) (Matrix b)
| otherwise = error ("zipMatrix: " ++ s ++ ": unconformable arrays")
scaleMatrix :: Num a => a -> Matrix a -> Matrix a
scaleMatrix a = map (* a)
scaleMatrix a = fmap (* a)
sumMatrix :: Num a => Matrix a -> a
sumMatrix = sum . elems . fromMatrix
......@@ -204,9 +204,9 @@ Overload arithmetical operators to work on lists.
instance Num a => Num [a] where
(+) = safezipWith "+" (+)
(-) = safezipWith "-" (-)
negate = map negate
abs = map abs
signum = map signum
negate = fmap negate
abs = fmap abs
signum = fmap signum
-- (*) = undefined
-- fromInteger = undefined
\end{code}
......@@ -219,8 +219,8 @@ sum1 = foldl1 (+)
\end{code}
\begin{code}
map2 f = map (map f)
map3 f = map (map2 f)
map2 f = fmap (fmap f)
map3 f = fmap (map2 f)
\end{code}
Map function f at position n only. Out of range indices are silently
......@@ -260,16 +260,16 @@ Overload arithmetical operators to work on arrays.
instance (Ix a, Show a, Num b) => Num (Array a b) where
(+) = zipArr "+" (+)
(-) = zipArr "-" (-)
negate = map negate
abs = map abs
signum = map signum
negate = fmap negate
abs = fmap abs
signum = fmap signum
-- (*) = matMult -- works only for matrices!
-- fromInteger = map fromInteger
\end{code}
\begin{xcode}
scaleArr :: (Ix i, Num a) => a -> Array i a -> Array i a
scaleArr a = map (*a)
scaleArr a = fmap (*a)
sumArr :: (Ix i, Num a) => Array i a -> a
sumArr = sum . elems
......@@ -362,23 +362,23 @@ padleft n x | n <= length x = x
\begin{code}
padMatrix :: RealFloat a => Int -> Matrix a -> Matrix String
padMatrix n x = let ss = map (\a -> showFFloat (Just n) a "") x
maxw = maximum (map length (elems (fromMatrix ss)))
in map (padleft maxw) ss
padMatrix n x = let ss = fmap (\a -> showFFloat (Just n) a "") x
maxw = maximum (fmap length (elems (fromMatrix ss)))
in fmap (padleft maxw) ss
\end{code}
\begin{xcode}
showsVector :: (RealFloat a) => Int -> Vector a -> ShowS
showsVector n x z1 = let x' = padArr n x
(l,u) = bounds x' in
concat (map (\ (i, s) -> if i == u then s ++ "\n" else s ++ " ") (assocs x')) ++ z1
concat (fmap (\ (i, s) -> if i == u then s ++ "\n" else s ++ " ") (assocs x')) ++ z1
\end{xcode}
\begin{xcode}
showsMatrix :: RealFloat a => Int -> Matrix a -> ShowS
showsMatrix n x z1 = let x' = padMatrix n x
((l,l'),(u,u')) = bounds x' in
concat (map (\ ((i,j), s) -> if j == u' then s ++ "\n" else s ++ " ") (assocs x')) ++ z1
concat (fmap (\ ((i,j), s) -> if j == u' then s ++ "\n" else s ++ " ") (assocs x')) ++ z1
\end{xcode}
{-
......
......@@ -9,7 +9,7 @@ type DF a = Vector a -> Vector a
\end{code}
\begin{code}
data (Eval a) => ScgData a = ScgData {k :: !Int, err :: !a,
data {-(Eval a) =>-} ScgData a = ScgData {k :: !Int, err :: !a,
w, p, r :: !(Vector a),
delta, pnorm2, lambda, lambdabar :: !a,
success :: !Bool}
......
[-0.5105811455265337, -0.7565080326002654]
[-0.5105811455265337,-0.7565080326002654]
......@@ -33,7 +33,7 @@ blank line, etc.
> let
> vs = readVectors bs
> in
> putStr (display vs)
> putStrLn (display vs)
>
> _ -> error " need a binary file name"
......
......@@ -2,7 +2,10 @@ TOP = ..
include $(TOP)/mk/boilerplate.mk
SRC_RUNTEST_OPTS += test_data
SRC_HC_OPTS += -cpp -syslib hbc
SRC_HC_OPTS += -cpp -syslib misc
EXTRA_LD_OPTS += -syslib misc
OBJS = $(HS_OBJS)
all :: runtest
......
3
[1.00000000, 2.00000000, 3.00000000]
[1.0,2.0,3.0]
2
[1.00000000, 2.00000000]
[1.0,2.0]
4
[1.00000000, 2.00000000, 3.00000000, 4.00000000]
[1.0,2.0,3.0,4.0]
TOP = ..
include $(TOP)/mk/boilerplate.mk
SRC_HC_OPTS += -cpp -syslib hbc
SRC_HC_OPTS += -cpp -syslib misc
all :: runtest
......
......@@ -6,7 +6,7 @@
land_i, lnot_i, lor_i, lshift_i, rshift_i,
descr,
destr_update, indassoc, lowbound, tabulate, upbound, update, valassoc) where {
import Word;
import Word2;
import Complex; -- 1.3
import Array; -- 1.3
type Complex_type = Complex Double;
......
......@@ -7,7 +7,7 @@ module Word2 (
byteToInt, shortToInt, wordToInt
) where
import GHC
import PrelGHC
import PrelBase
infixl 8 `bitLsh`, `bitRsh`
......@@ -32,10 +32,10 @@ instance Bits Word where
bitXor (Word x) (Word y) = error "later..." -- Word (XOR x y)
bitCompl (Word x) = case not# x of x' -> Word x'
bitLsh (Word x) (I# y) = case shiftL# x y of z -> Word z
bitRsh (Word x) (I# y) = case shiftRA# x y of z -> Word z
bitRsh (Word x) (I# y) = case shiftRL# x y of z -> Word z
bitSwap (Word x) = --Word (OR (LSH x 16) (AND (RSH x 16) 65535))
case shiftL# x 16# of { a# ->
case shiftRA# x 16# of { b# ->
case shiftRL# x 16# of { b# ->
case and# b# (i2w 65535#) of { c# ->
case or# a# c# of { r# ->
Word r# }}}}
......@@ -46,9 +46,9 @@ w2i x = word2Int# x
i2w x = int2Word# x
instance Num Word where
Word x + Word y = case plusInt# (w2i x) (w2i y) of z -> Word (i2w z)
Word x - Word y = case minusInt# (w2i x) (w2i y) of z -> Word (i2w z)
Word x * Word y = case timesInt# (w2i x) (w2i y) of z -> Word (i2w z)
Word x + Word y = case (w2i x) +# (w2i y) of z -> Word (i2w z)
Word x - Word y = case (w2i x) -# (w2i y) of z -> Word (i2w z)
Word x * Word y = case (w2i x) *# (w2i y) of z -> Word (i2w z)
negate (Word x) = case negateInt# (w2i x) of z -> Word (i2w z)
fromInteger (J# a# s# d#)
= case integer2Int# a# s# d# of { z# ->
......@@ -56,7 +56,7 @@ instance Num Word where
instance Show Word where
showsPrec _ (Word w) =
let i = toInteger (I# (w2i w)) + (if geWord# w (i2w 0#) then 0 else 2*(toInteger maxBound + 1))
let i = toInteger (I# (w2i w)) + (if geWord# w (i2w 0#) then 0 else 2*(toInteger (maxBound::Int) + 1))
in showString (conv 8 i)
conv :: Int -> Integer -> String
......
--!!! Defines functions as an instance of Num
-- !!! Defines functions as an instance of Num
module Main where
......@@ -20,4 +20,4 @@ cc = cos * cos
tt = ss + cc
-- sin**2 + cos**2 = 1
main = putStr ((show (tt 0.4))++ " "++(show (tt 1.652)))
main = putStrLn ((show (tt 0.4))++ " "++(show (tt 1.652)))
--!!! a performance-problem test from Jules.
-- !!! a performance-problem test from Jules.
-- further comment at the end
--
module Main where
......@@ -40,7 +40,7 @@ avAdd (ABranch l yk yv r hy) xk xv
--==========================================================--
-- ==========================================================--
--
{-
avLookup :: Ord a => ATree a b ->
......@@ -56,7 +56,7 @@ avLookup (ABranch l k v r _) kk
--==========================================================--
-- ==========================================================--
--
avCombine :: ATree a b ->
Int ->
......@@ -86,9 +86,9 @@ avCombine t1 h1 t2 h2 t3 h3 ak av ck cv
max1 n m = 1 + (if n > m then n else m)
--==========================================================--
--=== end AVLTree.hs ===--
--==========================================================--
-- ==========================================================--
-- === end AVLTree.hs ===--
-- ==========================================================--
......@@ -99,7 +99,7 @@ xref stab lineno [] = stab
xref stab lineno ('\n':cs) = xref stab (lineno+1) cs
xref stab lineno (c:cs)
= if isAlpha c then
let (word, rest) = span isAlphanum cs
let (word, rest) = span isAlphaNum cs
in xref (avAdd stab (c:word) lineno) lineno rest
else xref stab lineno cs
......
["module", "Graph", "where", "import", "Parse", "import", "StdLib", "import", "PSlib", "import", "GRIP", "paperX", "=", "280", "::", "Int", "paperY", "=", "190", "::", "Int", "fromInt", "::", "Num", "a", "=>", "Int", "->", "a", "fromInt", "=", "fromInteger", ".", "toInteger", "gspostscript", "str", "=", "initialise", "stdheader", "++", "portrait", "++", "str", "++", "\"showpage\\n\"", "postscript", "str", "=", "initialise", "stdheader", "++", "landscape", "++", "str", "++", "\"showpage\\n\"", "ePostscript", "(", "reqdx", ",", "reqdy", ")", "str", "=", "initialise", "(", "stdheader", "++", "\"%%BoundingBox: 0 0 \"", "++", "show", "(", "cms2pts", "reqdx", ")", "++", "\" \"", "++", "show", "(", "cms2pts", "reqdy", ")", "++", "\"\\n\"", "++", "\"%%EndComments\\n\"", ")", "++", "scale", "(", "fromInt", "reqdx", "*", "10", "/", "fromInt", "paperX", ")", "(", "fromInt", "reqdy", "*", "10", "/", "fromInt", "paperY", ")", "++", "str", "++", "showpage", "initGraph", "title", "pedata", "(", "topX", ",", "topY", ")", "(", "xlabel", ",", "ylabel", ")", "keys", "=", "drawBox", "(", "Pt", "0", "0", ")", "paperX", "paperY", "++", "drawBox", "(", "Pt", "1", "1", ")", "(", "paperX", "-", "2", ")", "5", "++", "drawBox", "(", "Pt", "1", "(", "paperY", "-", "7", ")", ")", "(", "paperX", "-", "2", ")", "6", "++", "setfont", "\"BOLD\"", "++", "moveto", "(", "Pt", "(", "paperX", "`", "div", "`", "2", ")", "(", "paperY", "-", "6", ")", ")", "++", "cjustify", "(", "title", ")", "++", "setfont", "\"NORM\"", "++", "placePEs", "pedata", "++", "translate", "20", "25", "++", "newpath", "++", "moveto", "(", "Pt", "0", "(", "-", "5", ")", ")", "++", "lineto", "(", "Pt", "0", "dimY", ")", "++", "moveto", "(", "Pt", "(", "-", "5", ")", "0", ")", "++", "lineto", "(", "Pt", "dimX", "0", ")", "++", "stroke", "++", "setfont", "\"SMALL\"", "++", "markXAxis", "dimX", "topX", "++", "markYAxis", "dimY", "topY", "++", "moveto", "(", "Pt", "0", "(", "dimY", "+", "4", ")", ")", "++", "rjustify", "ylabel", "++", "stroke", "++", "moveto", "(", "Pt", "dimX", "(", "-", "8", ")", ")", "++", "rjustify", "xlabel", "++", "stroke", "++", "setfont", "\"NORM\"", "++", "dokeys", "dimX", "keys", "placePEs", "(", "pes", ",", "on", ")", "|", "checkPEs", "(", "tail", "pes", ")", "on", "=", "showActive", "(", "length", "pes", ")", "(", "length", "used", ")", "++", "showUsed", "pes", "used", "++", "setfont", "\"NORM\"", "where", "used", "=", "if", "on", "==", "[", "]", "then", "tail", "pes", "else", "on", "cms2pts", "::", "Int", "->", "Int", "cms2pts", "x", "=", "round", "(", "28.4584", "*", "fromInt", "x", ")", "plotCurve", "::", "Int", "->", "[", "Point", "]", "->", "Postscript", "plotCurve", "x", "pts", "=", "setgray", "x", "++", "fillObject", "pts", "plot", "::", "[", "Point", "]", "->", "Postscript", "plot", "points", "=", "plotCurve", "5", "(", "Pt", "0", "0", ":", "points", ")", "dokeys", "left", "keys", "=", "concat", "(", "map2", "format", "(", "places", "0", ")", "keys", ")", "where", "format", "pt", "@", "(", "Pt", "x", "y", ")", "(", "col", ",", "tex", ",", "pc", ")", "=", "fillBox", "pt", "16", "9", "col", "++", "stroke", "++", "moveto", "(", "Pt", "(", "x", "+", "17", ")", "(", "y", "+", "3", ")", ")", "++", "text", "tex", "++", "stroke", "++", "moveto", "(", "Pt", "(", "x", "+", "8", ")", "(", "y", "+", "3", ")", ")", "++", "inv", "col", "++", "setfont", "\"BOLD\"", "++", "cjustify", "(", "pc", ")", "++", "stroke", "++", "setfont", "\"NORM\"", "++", "setgray", "10", "no", "=", "left", "`", "div", "`", "length", "keys", "places", "n", "|", "n", "==", "no", "=", "[", "]", "places", "n", "=", "(", "Pt", "(", "n", "*", "no", ")", "(", "-", "17", ")", ")", ":", "places", "(", "n", "+", "1", ")", "showActive", "t", "f", "=", "setfont", "\"LARGE\"", "++", "moveto", "(", "Pt", "10", "16", ")", "++", "cjustify", "(", "show", "f", ")", "++", "setfont", "\"SMALL\"", "++", "moveto", "(", "Pt", "10", "12", ")", "++", "cjustify", "\"PE(s)\"", "++", "stroke", "++", "setfont", "\"SMALL\"", "++", "moveto", "(", "Pt", "10", "8", ")", "++", "cjustify", "\"displayed\"", "++", "stroke", "++", "setfont", "\"NORM\"", "showUsed", "(", "m", ":", "pes", ")", "on", "=", "moveto", "(", "Pt", "2", "2", ")", "++", "setfont", "\"SMALL\"", "++", "text", "\"Configuration:\"", "++", "dopes", "(", "paperX", "-", "27", ")", "(", "(", "\"SMALLITALIC\"", ",", "showPE", "m", ")", ":", "map", "f", "pes", ")", "++", "stroke", "where", "f", "pe", "|", "elem", "pe", "on", "=", "(", "\"SMALLBOLD\"", ",", "showPE", "pe", ")", "|", "otherwise", "=", "(", "\"SMALL\"", ",", "showPE", "pe", ")", "dopes", "left", "pes", "=", "concat", "(", "map2", "format", "(", "places", "0", ")", "pes", ")", "where", "format", "pt", "@", "(", "Pt", "x", "y", ")", "(", "font", ",", "tex", ")", "=", "setfont", "font", "++", "moveto", "pt", "++", "text", "tex", "++", "stroke", "no", "=", "left", "`", "div", "`", "(", "(", "length", "pes", "*", "2", ")", "+", "1", ")", "f", "x", "=", "(", "no", "*", "(", "(", "x", "*", "2", ")", "+", "1", ")", ")", "+", "27", "places", "n", "|", "n", ">", "2", "*", "no", "=", "[", "]", "places", "n", "=", "(", "Pt", "(", "f", "n", ")", "2", ")", ":", "places", "(", "n", "+", "1", ")", "checkPEs", "pes", "[", "]", "=", "True", "checkPEs", "pes", "(", "p", ":", "ps", ")", "|", "elem", "p", "pes", "=", "checkPEs", "pes", "ps", "|", "otherwise", "=", "error", "(", "\"Attempt to gather information from inactive PE - \"", "++", "showPE", "p", ")", "showPE", "::", "PElement", "->", "String", "showPE", "(", "PE", "str", "no", ")", "=", "str", "++", "\".\"", "++", "show", "no", "inv", "x", "|", "x", ">=", "5", "=", "setgray", "0", "|", "otherwise", "=", "setgray", "10", "dimX", "=", "paperX", "-", "30", "dimY", "=", "paperY", "-", "40", "markXAxis", "::", "Int", "->", "Int", "->", "Postscript", "markXAxis", "dimX", "maxX", "=", "label", "10", "++", "markOnX", "100", "where", "label", "0", "=", "\"\"", "label", "x", "=", "newpath", "++", "moveto", "(", "Pt", "(", "notch", "x", ")", "0", ")", "++", "rlineto", "0", "(", "-", "2", ")", "++", "moveto", "(", "Pt", "(", "notch", "x", ")", "(", "-", "5", ")", ")", "++", "cjustify", "(", "printFloat", "(", "t", "x", ")", ")", "++", "stroke", "++", "label", "(", "x", "-", "1", ")", "t", "x", "=", "fromInt", "x", "*", "(", "fromInt", "maxX", "/", "fromInt", "10", ")", "notch", "x", "=", "x", "*", "(", "dimX", "`", "div", "`", "10", ")", "markOnX", "n", "=", "mapcat", "notches", "[", "1", "..", "n", "]", "++", "stroke", "where", "notches", "n", "=", "movetofloat", "(", "m", "*", "fromInt", "n", ")", "0", "++", "(", "rlineto", "0", "(", "-", "1", ")", ")", "++", "stroke", "m", "=", "fromInt", "dimX", "/", "fromInt", "n", "markYAxis", "::", "Int", "->", "Int", "->", "Postscript", "markYAxis", "dimY", "maxY", "=", "label", "10", "++", "markOnY", "(", "calibrate", "maxY", ")", "where", "label", "0", "=", "\"\"", "label", "x", "=", "newpath", "++", "moveto", "(", "Pt", "0", "(", "notch", "x", ")", ")", "++", "rlineto", "(", "-", "2", ")", "0", "++", "moveto", "(", "Pt", "(", "-", "3", ")", "(", "notch", "x", ")", ")", "++", "rjustify", "(", "printFloat", "(", "t", "x", ")", ")", "++", "stroke", "++", "label", "(", "x", "-", "1", ")", "t", "x", "=", "fromInt", "x", "*", "(", "fromInt", "maxY", "/", "fromInt", "10", ")", "notch", "x", "=", "x", "*", "(", "dimY", "`", "div", "`", "10", ")", "calibrate", "x", "|", "x", "<=", "1", "=", "1", "|", "x", "<=", "100", "=", "x", "|", "otherwise", "=", "calibrate", "(", "x", "`", "div", "`", "10", ")", "markOnY", "n", "=", "mapcat", "notches", "[", "1", "..", "n", "]", "++", "stroke", "where", "notches", "n", "=", "movetofloat", "0", "(", "m", "*", "fromInt", "n", ")", "++", "(", "rlineto", "(", "-", "1", ")", "0", ")", "m", "=", "fromInt", "dimY", "/", "fromInt", "n", "movetofloat", "x", "y", "=", "show", "x", "++", "\" \"", "++", "show", "y", "++", "\" moveto\\n\"", "determineScale", "::", "[", "Point", "]", "->", "(", "Int", ",", "Int", ")", "determineScale", "pts", "=", "(", "axisScale", "x", ",", "axisScale", "y", ")", "where", "(", "min", ",", "Pt", "x", "y", ")", "=", "minandmax", "pts", "axisScale", "::", "Int", "->", "Int", "axisScale", "x", "=", "axisScale'", "x", "1", "axisScale'", "x", "m", "|", "x", "<=", "m", "=", "m", "|", "x", "<=", "m", "*", "2", "=", "m", "*", "2", "|", "x", "<=", "m", "*", "5", "=", "m", "*", "5", "|", "x", "<=", "m", "*", "10", "=", "m", "*", "10", "|", "otherwise", "=", "axisScale'", "x", "(", "m", "*", "10", ")", "minandmax", "::", "[", "Point", "]", "->", "(", "Point", ",", "Point", ")", "minandmax", "[", "]", "=", "error", "\"No points\"", "minandmax", "(", "p", ":", "ps", ")", "=", "f", "(", "p", ",", "p", ")", "ps", "where", "f", "p", "[", "]", "=", "p", "f", "(", "Pt", "minx", "miny", ",", "Pt", "maxx", "maxy", ")", "(", "Pt", "x", "y", ":", "ps", ")", "=", "f", "(", "Pt", "minx'", "miny'", ",", "Pt", "maxx'", "maxy'", ")", "ps", "where", "minx'", "=", "min", "x", "minx", "miny'", "=", "min", "y", "miny", "maxx'", "=", "max", "x", "maxx", "maxy'", "=", "max", "y", "maxy", "printFloat", "::", "Float", "->", "String", "printFloat", "x", "=", "f", "(", "show", "(", "round", "(", "x", "*", "10", ")", ")", ")", "where", "f", "\"0\"", "=", "\"0\"", "f", "r", "|", "x", "<", "1", "=", "\"0.\"", "++", "r", "f", "(", "r", ":", "\"0\"", ")", "|", "x", "<", "10", "=", "[", "r", "]", "f", "(", "r", ":", "m", ")", "|", "x", "<", "10", "=", "r", ":", "'.'", ":", "m", "f", "_", "=", "show", "(", "round", "x", ")", ""]
["module","Graph","where","import","Parse","import","StdLib","import","PSlib","import","GRIP","paperX","=","280","::","Int","paperY","=","190","::","Int","fromInt","::","Num","a","=>","Int","->","a","fromInt","=","fromInteger",".","toInteger","gspostscript","str","=","initialise","stdheader","++","portrait","++","str","++","\"showpage\\n\"","postscript","str","=","initialise","stdheader","++","landscape","++","str","++","\"showpage\\n\"","ePostscript","(","reqdx",",","reqdy",")","str","=","initialise","(","stdheader","++","\"%%BoundingBox: 0 0 \"","++","show","(","cms2pts","reqdx",")","++","\" \"","++","show","(","cms2pts","reqdy",")","++","\"\\n\"","++","\"%%EndComments\\n\"",")","++","scale","(","fromInt","reqdx","*","10","/","fromInt","paperX",")","(","fromInt","reqdy","*","10","/","fromInt","paperY",")","++","str","++","showpage","initGraph","title","pedata","(","topX",",","topY",")","(","xlabel",",","ylabel",")","keys","=","drawBox","(","Pt","0","0",")","paperX","paperY","++","drawBox","(","Pt","1","1",")","(","paperX","-","2",")","5","++","drawBox","(","Pt","1","(","paperY","-","7",")",")","(","paperX","-","2",")","6","++","setfont","\"BOLD\"","++","moveto","(","Pt","(","paperX","`","div","`","2",")","(","paperY","-","6",")",")","++","cjustify","(","title",")","++","setfont","\"NORM\"","++","placePEs","pedata","++","translate","20","25","++","newpath","++","moveto","(","Pt","0","(","-","5",")",")","++","lineto","(","Pt","0","dimY",")","++","moveto","(","Pt","(","-","5",")","0",")","++","lineto","(","Pt","dimX","0",")","++","stroke","++","setfont","\"SMALL\"","++","markXAxis","dimX","topX","++","markYAxis","dimY","topY","++","moveto","(","Pt","0","(","dimY","+","4",")",")","++","rjustify","ylabel","++","stroke","++","moveto","(","Pt","dimX","(","-","8",")",")","++","rjustify","xlabel","++","stroke","++","setfont","\"NORM\"","++","dokeys","dimX","keys","placePEs","(","pes",",","on",")","|","checkPEs","(","tail","pes",")","on","=","showActive","(","length","pes",")","(","length","used",")","++","showUsed","pes","used","++","setfont","\"NORM\"","where","used","=","if","on","==","[","]","then","tail","pes","else","on","cms2pts","::","Int","->","Int","cms2pts","x","=","round","(","28.4584","*","fromInt","x",")","plotCurve","::","Int","->","[","Point","]","->","Postscript","plotCurve","x","pts","=","setgray","x","++","fillObject","pts","plot","::","[","Point","]","->","Postscript","plot","points","=","plotCurve","5","(","Pt","0","0",":","points",")","dokeys","left","keys","=","concat","(","map2","format","(","places","0",")","keys",")","where","format","pt","@","(","Pt","x","y",")","(","col",",","tex",",","pc",")","=","fillBox","pt","16","9","col","++","stroke","++","moveto","(","Pt","(","x","+","17",")","(","y","+","3",")",")","++","text","tex","++","stroke","++","moveto","(","Pt","(","x","+","8",")","(","y","+","3",")",")","++","inv","col","++","setfont","\"BOLD\"","++","cjustify","(","pc",")","++","stroke","++","setfont","\"NORM\"","++","setgray","10","no","=","left","`","div","`","length","keys","places","n","|","n","==","no","=","[","]","places","n","=","(","Pt","(","n","*","no",")","(","-","17",")",")",":","places","(","n","+","1",")","showActive","t","f","=","setfont","\"LARGE\"","++","moveto","(","Pt","10","16",")","++","cjustify","(","show","f",")","++","setfont","\"SMALL\"","++","moveto","(","Pt","10","12",")","++","cjustify","\"PE(s)\"","++","stroke","++","setfont","\"SMALL\"","++","moveto","(","Pt","10","8",")","++","cjustify","\"displayed\"","++","stroke","++","setfont","\"NORM\"","showUsed","(","m",":","pes",")","on","=","moveto","(","Pt","2","2",")","++","setfont","\"SMALL\"","++","text","\"Configuration:\"","++","dopes","(","paperX","-","27",")","(","(","\"SMALLITALIC\"",",","showPE","m",")",":","map","f","pes",")","++","stroke","where","f","pe","|","elem","pe","on","=","(","\"SMALLBOLD\"",",","showPE","pe",")","|","otherwise","=","(","\"SMALL\"",",","showPE","pe",")","dopes","left","pes","=","concat","(","map2","format","(","places","0",")","pes",")","where","format","pt","@","(","Pt","x","y",")","(","font",",","tex",")","=","setfont","font","++","moveto","pt","++","text","tex","++","stroke","no","=","left","`","div","`","(","(","length","pes","*","2",")","+","1",")","f","x","=","(","no","*","(","(","x","*","2",")","+","1",")",")","+","27","places","n","|","n",">","2","*","no","=","[","]","places","n","=","(","Pt","(","f","n",")","2",")",":","places","(","n","+","1",")","checkPEs","pes","[","]","=","True","checkPEs","pes","(","p",":","ps",")","|","elem","p","pes","=","checkPEs","pes","ps","|","otherwise","=","error","(","\"Attempt to gather information from inactive PE - \"","++","showPE","p",")","showPE","::","PElement","->","String","showPE","(","PE","str","no",")","=","str","++","\".\"","++","show","no","inv","x","|","x",">=","5","=","setgray","0","|","otherwise","=","setgray","10","dimX","=","paperX","-","30","dimY","=","paperY","-","40","markXAxis","::","Int","->","Int","->","Postscript","markXAxis","dimX","maxX","=","label","10","++","markOnX","100","where","label","0","=","\"\"","label","x","=","newpath","++","moveto","(","Pt","(","notch","x",")","0",")","++","rlineto","0","(","-","2",")","++","moveto","(","Pt","(","notch","x",")","(","-","5",")",")","++","cjustify","(","printFloat","(","t","x",")",")","++","stroke","++","label","(","x","-","1",")","t","x","=","fromInt","x","*","(","fromInt","maxX","/","fromInt","10",")","notch","x","=","x","*","(","dimX","`","div","`","10",")","markOnX","n","=","mapcat","notches","[","1.",".","n","]","++","stroke","where","notches","n","=","movetofloat","(","m","*","fromInt","n",")","0","++","(","rlineto","0","(","-","1",")",")","++","stroke","m","=","fromInt","dimX","/","fromInt","n","markYAxis","::","Int","->","Int","->","Postscript","markYAxis","dimY","maxY","=","label","10","++","markOnY","(","calibrate","maxY",")","where","label","0","=","\"\"","label","x","=","newpath","++","moveto","(","Pt","0","(","notch","x",")",")","++","rlineto","(","-","2",")","0","++","moveto","(","Pt","(","-","3",")","(","notch","x",")",")","++","rjustify","(","printFloat","(","t","x",")",")","++","stroke","++","label","(","x","-","1",")","t","x","=","fromInt","x","*","(","fromInt","maxY","/","fromInt","10",")","notch","x","=","x","*","(","dimY","`","div","`","10",")","calibrate","x","|","x","<=","1","=","1","|","x","<=","100","=","x","|","otherwise","=","calibrate","(","x","`","div","`","10",")","markOnY","n","=","mapcat","notches","[","1.",".","n","]","++","stroke","where","notches","n","=","movetofloat","0","(","m","*","fromInt","n",")","++","(","rlineto","(","-","1",")","0",")","m","=","fromInt","dimY","/","fromInt","n","movetofloat","x","y","=","show","x","++","\" \"","++","show","y","++","\" moveto\\n\"","determineScale","::","[","Point","]","->","(","Int",",","Int",")","determineScale","pts","=","(","axisScale","x",",","axisScale","y",")","where","(","min",",","Pt","x","y",")","=","minandmax","pts","axisScale","::","Int","->","Int","axisScale","x","=","axisScale'","x","1","axisScale'","x","m","|","x","<=","m","=","m","|","x","<=","m","*","2","=","m","*","2","|","x","<=","m","*","5","=","m","*","5","|","x","<=","m","*","10","=","m","*","10","|","otherwise","=","axisScale'","x","(","m","*","10",")","minandmax","::","[","Point","]","->","(","Point",",","Point",")","minandmax","[","]","=","error","\"No points\"","minandmax","(","p",":","ps",")","=","f","(","p",",","p",")","ps","where","f","p","[","]","=","p","f","(","Pt","minx","miny",",","Pt","maxx","maxy",")","(","Pt","x","y",":","ps",")","=","f","(","Pt","minx'","miny'",",","Pt","maxx'","maxy'",")","ps","where","minx'","=","min","x","minx","miny'","=","min","y","miny","maxx'","=","max","x","maxx","maxy'","=","max","y","maxy","printFloat","::","Float","->","String","printFloat","x","=","f","(","show","(","round","(","x","*","10",")",")",")","where","f","\"0\"","=","\"0\"","f","r","|","x","<","1","=","\"0.\"","++","r","f","(","r",":","\"0\"",")","|","x","<","10","=","[","r","]","f","(","r",":","m",")","|","x","<","10","=","r",":","'.'",":","m","f","_","=","show","(","round","x",")",""]
......@@ -8,7 +8,7 @@
# Link step
$(TEST_PROG) : $(OBJS)
$(HC) $(HC_FLAGS) $(OBJS) -o $(TEST_PROG)
$(HC) $(HC_OPTS) $(OBJS) -o $(TEST_PROG)
# Run test
runtest : $(TEST_PROG)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment