To reuse `num-rational` or not
lemmih opened this issue · 3 comments
Hi Jacob,
What are your plans regarding dashu-rational
? Do you want to implement Ratio
in dashu or reuse the one in num-rational
?
Advantages of a re-write:
- No forced dependency on
num-integer
. - Better performance (
num-rational
does a lot of unnecessary clones).
Disadvantages of a re-write:
- More work.
Hi David, thanks for your interest. My current plan will be to implement num_integer::Integer
for dashu_int::UBig/IBig
first, so that they can be used as the base types for num_rational::Ratio
, which should be fairly easy. Then I'm going to implement dashu_rational
from scratch, because it's relatively easy to implement the rational library.
Specifically, I'm planning to implement two types of rational numbers. One is a rational number with numerator and denominator always normalized (with GCD ripped off), the other is a number without normalization forced during operations, because GCD is the costliest step for rational numbers.
num_integer::Integer
is implemented for UBig
/IBig
in version 0.2.1, so it can be used with num-rational
. I'm going to implement a rational number library in the next big release. Close it for now, if you met any problems with num-rational
+ IBig
, please create new issues.
v0.3 has been published and it contains a library for rational numbers. Feel free to have a look and any feedback are welcome!