June 10, 2012
On 10/06/12 00:52, Stewart Gordon wrote:
> By using an integer type to store pitches in such a way that the semitone is the
> basic unit.
>
> Do you compose music that makes use of demisemitones, thirds of tones, and so on?

Yes, I use quarter-tones.  Other people use other intervals (e.g. in Turkish music there are intervals of 1/9, 4/9, 5/9 and 8/9 of a tone; and let's not even get into what Harry Partch and his compositional descendants have used).  I'd like to support all those options.  A straightforward rational number seems the easiest way to do so.
June 10, 2012
A long time ago, this was discussed on this forum.  I wrote the current candidate for std.rational, and there was talk of Don Clugston integrating the GCD function into std.bigint to take advantage of knowing BigInt's internals.  According to Don, using a general algorithm here results in terrible performance.  As of now, that hasn't happened, though.

On 6/7/2012 1:49 PM, Joseph Rushton Wakeling wrote:
> Sorry for the double-post -- I already asked this in d-learn, but this
> may be a better place to ask.
>
> What's the current state of affairs and roadmap for inclusion of
> rational number support in D?  I've come across David Simcha's work:
> http://cis.jhu.edu/~dsimcha/d/phobos/std_rational.html
>
> .... and a feature request on the bugzilla:
> http://d.puremagic.com/issues/show_bug.cgi?id=7885
>
> .... but this isn't mentioned at all in the review queue:
> http://prowiki.org/wiki4d/wiki.cgi?ReviewQueue
>
> What's the status of work/planning for this feature and is there any
> kind of ETA for when it might land in Phobos?
>
> Thanks and best wishes,
>
>      -- Joe


June 10, 2012
On 10/06/12 03:01, dsimcha wrote:
> A long time ago, this was discussed on this forum. I wrote the current candidate
> for std.rational, and there was talk of Don Clugston integrating the GCD
> function into std.bigint to take advantage of knowing BigInt's internals.
> According to Don, using a general algorithm here results in terrible
> performance. As of now, that hasn't happened, though.

I saw that Bearophile has contributed some code for this:
http://d.puremagic.com/issues/show_bug.cgi?id=7102#c3
June 10, 2012
On 10/06/12 13:17, Joseph Rushton Wakeling wrote:
> I saw that Bearophile has contributed some code for this:
> http://d.puremagic.com/issues/show_bug.cgi?id=7102#c3

Ooops, not code, just a spec.  If people are interested I'll see if I can write something based on this.

June 10, 2012
On Sunday, 10 June 2012 at 14:34:17 UTC, Joseph Rushton Wakeling wrote:
> On 10/06/12 13:17, Joseph Rushton Wakeling wrote:
>> I saw that Bearophile has contributed some code for this:
>> http://d.puremagic.com/issues/show_bug.cgi?id=7102#c3
>
> Ooops, not code, just a spec.  If people are interested I'll see if I can write something based on this.

This is not quite ready for prime time, but I have implemented a fixed-size integer module which includes a gcd algorithm. It limited to unsigned integers at the moment:

https://github.com/andersonpd/decimal/blob/master/decimal/unsigned.d

The gcd algorithm is base on Algorithm 1.18, BinaryGcd, p. 31, from Modern Computer Arithmetic, Richard Brent and Paul Zimmermann, Cambridge University Press, 2010.

An online PDF version is found at http://www.loria.fr/~zimmerma/mca/pub226.html

I don't know that it is particularly efficient but with small integers (< 1000 bits) it should be competitive.

Paul
June 10, 2012
It seems like we ought to have rational numbers in Phobos along with other number types. Something like this:

std.number.rational;
std.number.decimal;
std.number.integer; (fixed-size signed and unsigned integers, "safe" integers that throw on overflow or rollover, like Andrei's CheckedInt module, etc.
std.number.complex; (I know, I know)
std.number.quaternion;
std.number.fixedpoint;
std.number.interval (Interval arithmetic on floating-point numbers)

We also need compatible scalar, vector, matrix, multiarray modules, etc.

Many of these exist, but aren't incorporated in Phobos. I think we need to be more aggressive in recruiting functionality for Phobos. There are a lot of talented coders out there.

Paul




June 10, 2012
On Sunday, June 10, 2012 21:05:18 Paul D. Anderson wrote:
> It seems like we ought to have rational numbers in Phobos along with other number types. Something like this:
> 
> std.number.rational;
> std.number.decimal;
> std.number.integer; (fixed-size signed and unsigned integers,
> "safe" integers that throw on overflow or rollover, like Andrei's
> CheckedInt module, etc.
> std.number.complex; (I know, I know)
> std.number.quaternion;
> std.number.fixedpoint;
> std.number.interval (Interval arithmetic on floating-point
> numbers)
> 
> We also need compatible scalar, vector, matrix, multiarray modules, etc.
> 
> Many of these exist, but aren't incorporated in Phobos. I think we need to be more aggressive in recruiting functionality for Phobos. There are a lot of talented coders out there.

I am frequently amazed at what other programmers find useful or not. Personally, I don't think that I would ever have any use for _any_ of these modules. That's not to say that they wouldn't be worth having. I just find it interesting what others think would be useful (especially what they think are "must haves") - particularly when it's stuff that I'd never use.

- Jonathan M Davis
June 10, 2012
On 10.06.2012 23:05, Paul D. Anderson wrote:
> It seems like we ought to have rational numbers in Phobos along with
> other number types. Something like this:
>
> std.number.rational;
> std.number.decimal;
> std.number.integer; (fixed-size signed and unsigned integers, "safe"
> integers that throw on overflow or rollover, like Andrei's CheckedInt
> module, etc.
> std.number.complex; (I know, I know)
> std.number.quaternion;
> std.number.fixedpoint;
> std.number.interval (Interval arithmetic on floating-point numbers)

Let's turn numeric into a package. Then
std.numeric.algorithms - existing std.numeric
std.numeric.decimal
std.numeric.integer (or even better - fixnum)
std.numeric.quaternion
...
I'd argue even std.complex should go there.

>
> We also need compatible scalar, vector, matrix, multiarray modules, etc.
>
> Many of these exist, but aren't incorporated in Phobos. I think we need
> to be more aggressive in recruiting functionality for Phobos. There are
> a lot of talented coders out there.
>

Right. If anything people around here lack time not talent or dedication.



-- 
Dmitry Olshansky
June 11, 2012
On 10/06/2012 02:17, Joseph Rushton Wakeling wrote:
> On 10/06/12 00:52, Stewart Gordon wrote:
>> By using an integer type to store pitches in such a way that the semitone is the
>> basic unit.
>>
>> Do you compose music that makes use of demisemitones, thirds of tones, and so on?
>
> Yes, I use quarter-tones.  Other people use other intervals (e.g. in Turkish music there
> are intervals of 1/9, 4/9, 5/9 and 8/9 of a tone; and let's not even get into what Harry
> Partch and his compositional descendants have used).
<snip>

Are you not getting into that because his system uses irrational multiples of tones?

Supporting just intonation as well as equal temperament would be a good long-term plan. One way to achieve this would be to give the user the choice of rational numbers representing multiples of tones (or semitones or octaves) and rational numbers representing frequency ratios.  But you might be only worrying about supporting the former at the moment.

Stewart.
June 11, 2012
Joseph Rushton Wakeling:

> ... so, I can lend my voice to support inclusion of your module :-)

It's not fit for Phobos...

Bye,
bearophile
1 2 3
Top | Discussion index | About this forum | D home