September 25, 2013 std.rational? | ||||
---|---|---|---|---|
| ||||
Does anybody happen to have a working rational number library in D? Any plans to add that to Phobos at some point?
Just wondering, because I'm working on some numerical code that would benefit from a custom number type that could be implemented in terms of rational numbers. I just don't feel like reinventing a rational library if one already exists. :)
T
--
GEEK = Gatherer of Extremely Enlightening Knowledge
|
September 25, 2013 Re: std.rational? | ||||
---|---|---|---|---|
| ||||
Posted in reply to H. S. Teoh | On Wednesday, 25 September 2013 at 16:59:15 UTC, H. S. Teoh wrote: > Does anybody happen to have a working rational number library in D? https://github.com/p0nce/gfm/blob/master/gfm/math/fraction.d disclaimer: I've never used it for anything except writing its unittest block. |
September 25, 2013 Re: std.rational? | ||||
---|---|---|---|---|
| ||||
Posted in reply to ponce | On Wednesday, 25 September 2013 at 17:15:25 UTC, ponce wrote: > On Wednesday, 25 September 2013 at 16:59:15 UTC, H. S. Teoh wrote: >> Does anybody happen to have a working rational number library in D? Also David Simcha wrote a better one: https://github.com/dsimcha/Rational/blob/master/rational.d |
September 26, 2013 Re: std.rational? | ||||
---|---|---|---|---|
| ||||
Posted in reply to ponce | On 25/09/13 19:21, ponce wrote:
> On Wednesday, 25 September 2013 at 17:15:25 UTC, ponce wrote:
>> On Wednesday, 25 September 2013 at 16:59:15 UTC, H. S. Teoh wrote:
>>> Does anybody happen to have a working rational number library in D?
>
> Also David Simcha wrote a better one:
> https://github.com/dsimcha/Rational/blob/master/rational.d
Why was this never incorporated into Phobos?
|
September 26, 2013 Re: std.rational? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Joseph Rushton Wakeling | Joseph Rushton Wakeling: > Why was this never incorporated into Phobos? First it needs the normal review process for Phobos modules :) It should go in the review queue, if it's good enough for Phobos. > Rational!(BigInt) getTerm(int termNumber) { I suggest to add inside that "rational.d" module an alias with Bigint, as: alias Fraction = Rational!BigInt; Because I don't think I want to use a rational type made with built-in integrals. Bye, bearophile |
September 26, 2013 Re: std.rational? | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | On 26/09/13 16:09, bearophile wrote: > First it needs the normal review process for Phobos modules :) It should go in > the review queue, if it's good enough for Phobos. Fair enough, I was wondering if there was any reason David never submitted it. > I suggest to add inside that "rational.d" module an alias with Bigint, as: > > alias Fraction = Rational!BigInt; > > Because I don't think I want to use a rational type made with built-in integrals. Good call. |
September 26, 2013 Re: std.rational? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Joseph Rushton Wakeling | On 9/26/13 7:00 AM, Joseph Rushton Wakeling wrote:
> On 25/09/13 19:21, ponce wrote:
>> On Wednesday, 25 September 2013 at 17:15:25 UTC, ponce wrote:
>>> On Wednesday, 25 September 2013 at 16:59:15 UTC, H. S. Teoh wrote:
>>>> Does anybody happen to have a working rational number library in D?
>>
>> Also David Simcha wrote a better one:
>> https://github.com/dsimcha/Rational/blob/master/rational.d
>
> Why was this never incorporated into Phobos?
Probably because it wasn't proposed for review. I'm favorable to integrating it.
Andrei
|
September 27, 2013 Re: std.rational? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On Thu, Sep 26, 2013 at 04:50:47PM -0700, Andrei Alexandrescu wrote: > On 9/26/13 7:00 AM, Joseph Rushton Wakeling wrote: > >On 25/09/13 19:21, ponce wrote: > >>On Wednesday, 25 September 2013 at 17:15:25 UTC, ponce wrote: > >>>On Wednesday, 25 September 2013 at 16:59:15 UTC, H. S. Teoh wrote: > >>>>Does anybody happen to have a working rational number library in D? > >> > >>Also David Simcha wrote a better one: https://github.com/dsimcha/Rational/blob/master/rational.d > > > >Why was this never incorporated into Phobos? > > Probably because it wasn't proposed for review. I'm favorable to integrating it. [...] Me too. T -- 2+2=4. 2*2=4. 2^2=4. Therefore, +, *, and ^ are the same operation. |
September 27, 2013 Re: std.rational? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Joseph Rushton Wakeling | On 9/26/2013 12:49 PM, Joseph Rushton Wakeling wrote:
> On 26/09/13 16:09, bearophile wrote:
>> First it needs the normal review process for Phobos modules :) It should go in
>> the review queue, if it's good enough for Phobos.
>
> Fair enough, I was wondering if there was any reason David never submitted it.
For things to happen, usually a self-appointed champion is needed that will relentless push it forward. Things tend to fall by the wayside otherwise.
|
September 27, 2013 Re: std.rational? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On 27/09/13 09:36, Walter Bright wrote:
> For things to happen, usually a self-appointed champion is needed that will
> relentless push it forward. Things tend to fall by the wayside otherwise.
In the past David has seemed like a pretty reliable champion of his own work -- quite a few of the parts of Phobos I use regularly are down to him!
I've written to him asking for his input on std.rational but if he doesn't have time/inclination to pursue it, I'll take a look at it.
At first glance what's there looks pretty good with the main issues being stylistic rather than content-related.
|
Copyright © 1999-2021 by the D Language Foundation