-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExComplex.hs
58 lines (44 loc) · 1021 Bytes
/
ExComplex.hs
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
module ExComplex
( complex
, conjugate
, toRect
, toTrig
, magnitude
, arg
) where
type RePart = Double
type ImPart = Double
type Magnitude = Double
type Angle = Double -- in rads!
data Complex = Rect RePart ImPart
| Trig Magnitude Angle
instance Show Complex where
show = undefined
instance Eq Complex where
(==) = undefined
instance Num Complex where
(+) = undefined
(*) = undefined
negate = undefined
abs = undefined
signum = undefined
fromInteger = undefined
complex :: RePart -> ImPart -> Complex
complex = undefined
conjugate :: Complex -> Complex
conjugate = undefined
toRect :: Complex -> Complex
toRect = undefined
toTrig :: Complex -> Complex
toTrig = undefined
magnitude :: Complex -> Magnitude
magnitude = undefined
-- arg should be a number in (-pi, pi]
arg :: Complex -> Angle
arg = undefined
-- real part
re :: Complex -> RePart
re = undefined
-- imaginary part
im :: Complex -> ImPart
im = undefined