|
Archives
D Programming
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.ide
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger
D.gnu
D
C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows
digitalmars.empire
digitalmars.DMDScript
electronics
|
digitalmars.D.announce - RangeExtra 10^-20
RangeExtra version 10^-20 is officially out. It consists of a small and
hopefully growing number of ranges that didn't make it into the new Phobos
that I've gotten working reasonably well and I feel eventually belong in Phobos.
Docs / What's there:
http://cis.jhu.edu/~dsimcha/rangeextra.html
Code:
http://dsource.org/projects/scrapple/browser/trunk/rangeextra/rangeextra.d
License:
Dual licensed, Phobos license or BSD (Tango style).
dsimcha wrote:
RangeExtra version 10^-20 is officially out. It consists of a small and
hopefully growing number of ranges that didn't make it into the new
Phobos
that I've gotten working reasonably well and I feel eventually belong in
Phobos.
Docs / What's there:
http://cis.jhu.edu/~dsimcha/rangeextra.html
Code:
http://dsource.org/projects/scrapple/browser/trunk/rangeextra/rangeextra.d
License:
Dual licensed, Phobos license or BSD (Tango style).
I had hoped reindex would give me access to true 'random' access ranges, but it
seems this does not work:
auto b = reindex!( "uniform( 0, this.length )" )( [0,1,2,3,4].dup );
:p
Simen Kjaeraas wrote:
dsimcha wrote:
RangeExtra version 10^-20 is officially out. It consists of a small and
hopefully growing number of ranges that didn't make it into the new
Phobos
that I've gotten working reasonably well and I feel eventually belong
in Phobos.
Docs / What's there:
http://cis.jhu.edu/~dsimcha/rangeextra.html
Code:
http://dsource.org/projects/scrapple/browser/trunk/rangeextra/rangeextra.d
License:
Dual licensed, Phobos license or BSD (Tango style).
I had hoped reindex would give me access to true 'random' access ranges,
but it seems this does not work:
auto b = reindex!( "uniform( 0, this.length )" )( [0,1,2,3,4].dup );
:p
If I had to take a guess, I'd say it was because "uniform" isn't defined
in the context of reindex. Maybe this:
import std.random;
void foo()
{
auto b = reindex!((i){ return uniform(0,5); })( [0,1,2,3,40.dup );
}
I don't think there's any way to get the length.
-- Daniel
== Quote from Simen Kjaeraas (simen.kjaras gmail.com)'s article
dsimcha wrote:
RangeExtra version 10^-20 is officially out. It consists of a small and
hopefully growing number of ranges that didn't make it into the new
Phobos
that I've gotten working reasonably well and I feel eventually belong in
Phobos.
Docs / What's there:
http://cis.jhu.edu/~dsimcha/rangeextra.html
Code:
http://dsource.org/projects/scrapple/browser/trunk/rangeextra/rangeextra.d
License:
Dual licensed, Phobos license or BSD (Tango style).
auto b = reindex!( "uniform( 0, this.length )" )( [0,1,2,3,4].dup );
:p
Very cool idea. Nothing like what I had in mind as a use case for Reindex, but
half the fun of generic programming is seeing stuff get used for things you
hadn't
anticipated.
I spent some time trying, and for some reason I can't for the life of me get
this
example to work, or even the one where the length is hard-coded. It may be some
obscure compiler bug, because I'm just getting weird inscrutable error messages
and I can't really figure out where they're coming from.
On the other hand, I really like the idea of a with-replacement random sampling
primitive. This sounds like it belongs in RandomCover. Maybe Andrei can extend
RandomCover (which already samples w/o replacement) to include a replacement
parameter. RandomCover w/ replacement == false would do what it does now. If
replacement == true, it would be an infinite range that samples with
replacement.
== Quote from dsimcha (dsimcha yahoo.com)'s article
== Quote from Simen Kjaeraas (simen.kjaras gmail.com)'s article
dsimcha wrote:
RangeExtra version 10^-20 is officially out. It consists of a small and
hopefully growing number of ranges that didn't make it into the new
Phobos
that I've gotten working reasonably well and I feel eventually belong in
Phobos.
Docs / What's there:
http://cis.jhu.edu/~dsimcha/rangeextra.html
Code:
http://dsource.org/projects/scrapple/browser/trunk/rangeextra/rangeextra.d
License:
Dual licensed, Phobos license or BSD (Tango style).
auto b = reindex!( "uniform( 0, this.length )" )( [0,1,2,3,4].dup );
:p
On the other hand, I really like the idea of a with-replacement random sampling
primitive. This sounds like it belongs in RandomCover. Maybe Andrei can
extend
RandomCover (which already samples w/o replacement) to include a replacement
parameter. RandomCover w/ replacement == false would do what it does now. If
replacement == true, it would be an infinite range that samples with
replacement.
Here's a first attempt: I took Andrei's RandomCover, fixed bug 2865 (This
version
of RandomCover passes basic statistical tests for uniformity of the distribution
over the permutation space), and added a template overload to allow sampling
with
replacement. It's under the Phobos license to make it as easy as possible to
add
back to Phobos. I'll file an enhancement request.
http://dsource.org/projects/scrapple/browser/trunk/rangeextra/randomcover.d
在 Sat, 25 Apr 2009 23:40:03 +0800,dsimcha <dsimcha yahoo.com> 写道:
== Quote from dsimcha (dsimcha yahoo.com)'s article
== Quote from Simen Kjaeraas (simen.kjaras gmail.com)'s article
dsimcha wrote:
RangeExtra version 10^-20 is officially out. It consists of a
hopefully growing number of ranges that didn't make it into the new
Phobos
that I've gotten working reasonably well and I feel eventually
Phobos.
Docs / What's there:
http://cis.jhu.edu/~dsimcha/rangeextra.html
Code:
License:
Dual licensed, Phobos license or BSD (Tango style).
seems this does not work:
auto b = reindex!( "uniform( 0, this.length )" )( [0,1,2,3,4].dup );
:p
On the other hand, I really like the idea of a with-replacement random
sampling
primitive. This sounds like it belongs in RandomCover. Maybe Andrei
can extend
RandomCover (which already samples w/o replacement) to include a
replacement
parameter. RandomCover w/ replacement == false would do what it does
now. If
replacement == true, it would be an infinite range that samples with
replacement.
Here's a first attempt: I took Andrei's RandomCover, fixed bug 2865
(This version
of RandomCover passes basic statistical tests for uniformity of the
distribution
over the permutation space), and added a template overload to allow
sampling with
replacement. It's under the Phobos license to make it as easy as
possible to add
back to Phobos. I'll file an enhancement request.
http://dsource.org/projects/scrapple/browser/trunk/rangeextra/randomcover.d
Looking forward to it!
--
使用 Opera 革命性的电子邮件客户程序: http://www.opera.com/mail/
|
|