Skip to content

Commit

Permalink
implement complex division
Browse files Browse the repository at this point in the history
  • Loading branch information
dours committed Jul 31, 2022
1 parent 0f386d5 commit 737ca34
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions transpiler/src/main/eo/preface/pycomplex.eo
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,16 @@
pycomplex (pyfloat 0.0) (pyfloat 0.0)
p.fst.pow (p.snd)

[x] > div
[x] > float-div
fakeclasses.convert (pycomplex xreal ximag) x > p
seq > @
if.
(fakeclasses.has-type x (fakeclasses.pyComplexClass))
return (pycomplex (pyfloat 0.0) (pyfloat 0.0))
p.fst.div (p.snd)
[]
p.fst.mul (pycomplex (x.xreal) (x.ximag.neg)) > num
((x.xreal.mul (x.xreal)).add (x.ximag.mul (x.ximag))) > denom
return (pycomplex ((num.xreal.float-div denom).result) ((num.ximag.float-div denom).result)) > @
p.fst.float-div (p.snd)

[x] > add
fakeclasses.convert (pycomplex xreal ximag) x > p
Expand Down

0 comments on commit 737ca34

Please sign in to comment.