Using `Rational` with `Poly`

119 views
Skip to first unread message

Fengyang Wang

unread,
Feb 6, 2016, 7:51:46 PM2/6/16
to julia-users
I was looking for a Julia package to handle rational functions, when I noticed that the `Polynomials` package implements `gcd`, `div`, and `rem`. So it would be possible to simply use `Rational{Poly}`... or so I thought. Unfortunately, the type `Rational` prevents this use, since it requires its type parameter to derive from `Integer`.

I think it would be more in line with Julia's goal of polymorphism if `Rational` "just worked" with any Euclidean domain. Is there some justification for the current behaviour, or should I file this as a issue (or make a pull request)?

Stefan Karpinski

unread,
Feb 7, 2016, 11:21:17 AM2/7/16
to julia...@googlegroups.com
There are various assumptions baked into the rational code that may or may not be satisfied by non-integer numeric types. I would suggest taking the code from Base and trying it out without that restriction and seeing how it goes.

Fengyang Wang

unread,
Feb 12, 2016, 4:59:41 PM2/12/16
to julia-users
You are right; it did not work. I made some modifications to fix it, but they required a significant rethinking of many of the methods, so it would be a different type entirely. Nemo supports rational functions in any case, and I think that's a better idea.

Stefan Karpinski

unread,
Feb 12, 2016, 5:09:34 PM2/12/16
to Julia Users
Interesting. If the changes don't hurt the original use case of the type, they may be reasonable to make.
Reply all
Reply to author
Forward
0 new messages