On 12/23/10 6:22 AM, spir wrote:
On Wed, 22 Dec 2010 20:16:45 -0600
Andrei Alexandrescu<seewebsiteforem...@erdani.org>  wrote:

Thanks for posting the numbers. That's a long time, particularly
considering that the two map instances don't do anything. So the bulk of
the computation is:

auto L = iota(0.0, 10000000.0);
auto V = reduce!"a + b"(L3);

There is one inherent problem that affects the speed of iota: in iota,
the value at position i is computed as 0.0 + i * step, where step is
computed from the limits. That's one addition and a multiplication for
each pass through iota. Given that the actual workload of the loop is
only one addition, we are doing a lot more work. I suspect that that's
the main issue there.

The reason for which iota does that instead of the simpler increment is
that iota must iterate the same values forward and backward. Using ++
may interact with floating-point vagaries, so the code is currently
conservative.

There is a point I don't understand here: Iota is a range-struct template, with
     void popFront()
     {
         current += step;
     }

You need to look at this specialization:

http://www.dsource.org/projects/phobos/browser/trunk/phobos/std/range.d#L3800

and keep in mind Simen's explanation.


Andrei

Reply via email to