on master help sign in
Fix addition and subtraction of Complex Float.
commit90aa3d84bea5116495f9de9ff069ab83c7dda44a authorMatus Tejiscak <ziman@functor.sk> dateSun 27 Apr 2014, 16:33 (13 years ago) parente07c13d
1 file changed+2−2
libs/base/Data/Complex.idr+2−2
libs/base/Data/Complex.idr+2−2
@@ -62,8 +62,8 @@ conjugate (r:+i) = (r :+ (0-i))
6262-- We can't do "instance Num a => Num (Complex a)" because
6363-- we need "abs" which needs "magnitude" which needs "sqrt" which needs Float
6464instance Num (Complex Float) where
65− (+) (a:+b) (c:+d) = ((a+b):+(c+d))
66− (-) (a:+b) (c:+d) = ((a-b):+(c-d))
65+ (+) (a:+b) (c:+d) = ((a+c):+(b+d))
66+ (-) (a:+b) (c:+d) = ((a-c):+(b-d))
6767 (*) (a:+b) (c:+d) = ((a*c-b*d):+(b*c+a*d))
6868 fromInteger x = (fromInteger x:+0)
6969 abs (a:+b) = (magnitude (a:+b):+0)