On 18/04/12 18:54, Dmitry Olshansky wrote:
I can't comment very much, being myself quite noob, but I think you can
do this, for style as well as performance:
- add pure nothrow everywhere you can.
Yup, unless it's a template as its properties are deduced anyway.
I really don't see anywhere I
On 18.04.2012 19:03, Somedude wrote:
[snip]
Tweaked version, an revision of RandomSample from std.random, is
available from
https://github.com/WebDrake/RandomSample
Feedback on code details and on tests would be very welcome. It seems
about 10% slower than the original code I wrote, which I gu
On 18/04/12 17:03, Somedude wrote:
This looks very C++ ish.
Yea, it's a rewrite of code originally in C (not even ++ ... !).
I can't comment very much, being myself quite noob, but I think you can
do this, for style as well as performance:
- add pure nothrow everywhere you can.
I think th
Le 18/04/2012 05:15, Joseph Rushton Wakeling a écrit :
> On 13/04/12 10:04, Dmitry Olshansky wrote:
>>> OK, I'll see what I can do. I'd like to discuss and refine the design a
>>> bit further before making any pull request -- should I take things over
>>> to the Phobos mailing list for this ... ?
>
On 13/04/12 10:04, Dmitry Olshansky wrote:
OK, I'll see what I can do. I'd like to discuss and refine the design a
bit further before making any pull request -- should I take things over
to the Phobos mailing list for this ... ?
I'm no authority but there is this d.D newsgroup which is perfectl
On 13/04/12 19:49, Ali Çehreli wrote:
This is a complicated issue that touches how in contracts are not inherited. I
think your issue is because the interface does not define any in contracts,
effectively allowing every call to select(). Please start reading here: :)
You're absolutely right. I
On 04/13/2012 02:41 AM, Joseph Rushton Wakeling wrote:
> On 13/04/12 01:44, bearophile wrote:
>> final size_t select(ref UniformRNG urng)
>> in {
>> assert(_recordsRemaining> 0);
>> assert(_sampleRemaining> 0);
>> } body {
>> ...
>> }
>
> OK. I'm confused by these asserts, because if I go beyond w
On 13/04/12 13:10, bearophile wrote:
What's confusing? I don't understand. It's contract-based programming, the code
is essentially the same as before:
http://dlang.org/dbc.html
No, I understand the principle; I just don't understand why the code is running
without errors being displayed when
Joseph Rushton Wakeling:
> > final size_t select(ref UniformRNG urng)
> > in {
> > assert(_recordsRemaining> 0);
> > assert(_sampleRemaining> 0);
> > } body {
> > ...
> > }
>
> OK. I'm confused by these asserts,
What's confusing? I don't understand. It's contract-based programm
Dmitry Olshansky:
> I believe it's something that reasonable people may disagree on.
> To me it's perfectly easy to see what return x++; does.
I agree that "return x++;" is not too bad for a human reader, but code with
mutation inside expressions (mostly written by other people) has caused me to
On 13/04/12 01:44, bearophile wrote:
final size_t select(ref UniformRNG urng)
in {
assert(_recordsRemaining> 0);
assert(_sampleRemaining> 0);
} body {
...
}
OK. I'm confused by these asserts, because if I go beyond what is acceptable by
calling select() even after I've collec
On 13.04.2012 2:50, Joseph Rushton Wakeling wrote:
On 12/04/12 23:34, Dmitry Olshansky wrote:
Aye, and in general community does appreciate any enhancements via
pull requests
on github:
https://github.com/D-Programming-Language
OK, I'll see what I can do. I'd like to discuss and refine the des
On 13.04.2012 1:48, Joseph Rushton Wakeling wrote:
On 12/04/12 21:54, bearophile wrote:
for( t=recordsRemaining-1; t>=limit; --t)
y2 *= top--/bottom--;
Generally packing mutation of variables inside expressions is quite
bad style. It makes code less easy to understand and translate, and
curr
Joseph Rushton Wakeling:
> >> final size_t select(ref UniformRNG urng)
> >> {
> >> assert(_recordsRemaining > 0);
> >> assert(_sampleRemaining > 0);
> >
> > Probably it's better to move those asserts in preconditions/postconditions
> > or in
> > class/struct invariants.
>
> Those asserts are del
On 13/04/12 00:48, bearophile wrote:
final size_t select(ref UniformRNG urng)
{
assert(_recordsRemaining > 0);
assert(_sampleRemaining > 0);
Probably it's better to move those asserts in preconditions/postconditions or in
class/struct invariants.
Those asserts are deliberately intended for th
On 12/04/12 23:34, Dmitry Olshansky wrote:
Aye, and in general community does appreciate any enhancements via pull requests
on github:
https://github.com/D-Programming-Language
OK, I'll see what I can do. I'd like to discuss and refine the design a bit
further before making any pull request -
Joseph Rushton Wakeling:
Thanks ever so much for the extensive review.
They are shallow comments, mostly about syntax, etc. So writing
them requires little time.
Is this advised for all D modules, or just for stuff using the
C standard library?
I have said "there is also the syntax" ins
On 12/04/12 21:54, bearophile wrote:
sampling_test_simple!(VitterA!Random,Random)(100,5,urng);
Currently your code doesn't work if you want to use a Xorshift generator.
Ahhh, I see what you mean now -- the sampler classes are fine, but the way the
main() function is written means you ca
On 12/04/12 21:54, bearophile wrote:
Some comments on the details of your code:
Thanks ever so much for the extensive review.
import std.c.time;
In D there there is also the syntax:
import std.c.time: foo, bar, baz;
That tells the person that reads the code what names are used.
Is this
On 12.04.2012 20:59, Joseph Rushton Wakeling wrote:
On 12/04/12 16:45, Joseph Rushton Wakeling wrote:
What I thought I'd do is implement some clever algorithms for random
sampling
which I've already done in a C based on the GNU Scientific Library.
I noticed that there is already a randomSample
On Thursday, 12 April 2012 at 16:59:31 UTC, Joseph Rushton
Wakeling wrote:
On 12/04/12 16:45, Joseph Rushton Wakeling wrote:
What I thought I'd do is implement some clever algorithms for
random sampling
which I've already done in a C based on the GNU Scientific
Library.
I noticed that there i
Joseph Rushton Wakeling:
> https://github.com/WebDrake/SampleD
Some comments on the details of your code:
> import std.c.time;
In D there there is also the syntax:
> import std.c.time: foo, bar, baz;
That tells the person that reads the code what names are used.
--
> inte
On 12/04/12 16:45, Joseph Rushton Wakeling wrote:
What I thought I'd do is implement some clever algorithms for random sampling
which I've already done in a C based on the GNU Scientific Library.
I noticed that there is already a randomSample class in std.random, which by the
look of it is usi
On 12/04/12 18:26, James Miller wrote:
There is support for fully all 4 types of intervals using
std.random.uniform. You just specify the type of interval using a
template parameter.
The default is this: uniform!("[)")(a,b);
And you want this: uniform!("[]")(a,b);
You can also do "()" and "(]
* Joseph Rushton Wakeling [2012-04-12 16:45:34
+0200]:
> (3) Uniform random number on (0,1)
>
> The algorithms' specification explicitly refers to uniform random
> numbers on the open interval, which I take to mean (0,1) i.e.
> excluding zero. Phobos currently provides only a half-open uni
Hi Dmitry,
Thanks for your thoughts and for pointing me at some aspects of D I'd not come
across before.
I think that if you like function pointer thing, you'd love D's delegates and
lambdas. If templates are too pervasive it might be better just use little bit
of dynamic stuff.
I was not t
On 12.04.2012 18:45, Joseph Rushton Wakeling wrote:
Hello all,
Hello there,
[snip]
So, introduction away, here are the main questions I came up with in
creating the code.
(1) Effective handling of random numbers.
The design concept was for the sampler classes to use a specified
unifor
27 matches
Mail list logo