Skip to content

Commit

Permalink
Add support for constructing complex rationals.
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanKarpinski committed Jul 19, 2011
1 parent cef72df commit 42e5048
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
/julia-release-*

/libjulia*
/webserver

/sys.ji
/boot.j.inc
8 changes: 8 additions & 0 deletions j/rational.j
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ Rational(n::Int) = Rational(n, one(n))
//(n::Int, d::Int) = Rational(n,d)
//(x::Rational, y::Int) = x.num // (x.den*y)
//(x::Int, y::Rational) = (x*y.den) // y.num
//(x::Complex, y::Real) = complex(real(x)//y, imag(x)//y)
//(x::Real, y::Complex) = x*y'//real(y*y')

function //(x::Complex, y::Complex)
xy = x*y'
yy = real(y*y')
complex(real(xy)//yy, imag(xy)//yy)
end

function show(x::Rational)
show(num(x))
Expand Down

0 comments on commit 42e5048

Please sign in to comment.