digitalmars.D.bugs - [Issue 5240] New: Faster std.random.uniform() for [0.0, 1.0) range
- d-bugmail puremagic.com (34/34) Nov 19 2010 http://d.puremagic.com/issues/show_bug.cgi?id=5240
- d-bugmail puremagic.com (7/7) Nov 19 2010 http://d.puremagic.com/issues/show_bug.cgi?id=5240
- d-bugmail puremagic.com (13/13) Nov 21 2010 http://d.puremagic.com/issues/show_bug.cgi?id=5240
- d-bugmail puremagic.com (11/11) Nov 21 2010 http://d.puremagic.com/issues/show_bug.cgi?id=5240
- d-bugmail puremagic.com (10/12) Nov 22 2010 http://d.puremagic.com/issues/show_bug.cgi?id=5240
- d-bugmail puremagic.com (10/10) Nov 22 2010 http://d.puremagic.com/issues/show_bug.cgi?id=5240
- d-bugmail puremagic.com (9/14) Nov 22 2010 http://d.puremagic.com/issues/show_bug.cgi?id=5240
- d-bugmail puremagic.com (10/10) Jan 09 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5240
http://d.puremagic.com/issues/show_bug.cgi?id=5240 Summary: Faster std.random.uniform() for [0.0, 1.0) range Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: enhancement Priority: P2 Component: Phobos AssignedTo: nobody puremagic.com ReportedBy: bearophile_hugs eml.cc std.random.uniform() is a powerful and flexible function, but some tests show that it's slow. It also calls nextafter() that is not fast. A very common use case is the generation of random doubles in the [0.0, 0.1[ range (open on the right). So I suggest to speed up this special case. This special case is present in the Python standard module "random" too, it is just named random(). A way to support it is just to add a uniform() that takes no arguments (and hopefully it doesn't need to call nextafter() inside): import std.random: uniform; void main() { double d = uniform(); // equivalent to uniform(0.0, 1.0) but faster } This function that takes no arguments may also have a name like "uniform01()" or "random()". Another special case that may be worth supporting is the generation of a random size_t. This is useful because it avoids using floating point values at all, and probably minimizes other operations too to generate it, so it may be faster still than the uniform() with no arguments. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 19 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5240 A specialized overload/function like this is useful in Phobos even if it's not faster. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 19 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5240 Denis Derman <denis.spir gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |denis.spir gmail.com --- I would vote for uniform01(). Having it called random() would implicitely promote to the default random function, from which all other forms of random would/should be computed. Denis -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 21 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5240 strtr despam.it changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |strtr despam.it I am probably missing something, but what is wrong with uniform!(0,1) ? Then you can add optimizations for all the special cases you want. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 21 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5240I am probably missing something, but what is wrong with uniform!(0,1) ? Then you can add optimizations for all the special cases you want.Currently uniform() uses run-time arguments, not template ones. -------------------------------------- See also: http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=122634 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 22 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5240 I was commenting on the suggested name uniform01. Templating the function seemed obvious to me and I was also surprised you didn't suggest doing that so I thought I was missing something there. As for speed, as tn mentioned on the newsgroup, subnormal numbers considerately slow down calculations. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 22 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5240I was commenting on the suggested name uniform01. Templating the function seemed obvious to me and I was also surprised you didn't suggest doing that so I thought I was missing something there.I don't like the idea of a templated ranged uniform. In most cases is not what I need or what's better.As for speed, as tn mentioned on the newsgroup, subnormal numbers considerately slow down calculations.It's in the link of Comment 4 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 22 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5240 Andrei Alexandrescu <andrei metalanguage.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED CC| |andrei metalanguage.com AssignedTo|nobody puremagic.com |andrei metalanguage.com -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 09 2011