Using D and std.ndslice as a Numpy Replacement

Ilya Yaroshenko via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Sat Jan 2 16:17:23 PST 2016


On Sunday, 3 January 2016 at 00:09:33 UTC, Jack Stouffer wrote:
> On Saturday, 2 January 2016 at 23:51:09 UTC, Ilya Yaroshenko 
> wrote:
>> This benchmark is _not_ lazy, so ndslice faster than Numpy 
>> only 3.5 times.
>
> I don't know what you mean here, I made sure to call 
> std.array.array to force allocation.

In the article:
     auto means = 100_000.iota <---- 100_000.iota is lazy range
         .sliced(100, 1000)
         .transposed
         .map!(r => sum(r) / r.length)
         .array;               <---- allocation of the result

In GitHub:
     means = data           <---- data is allocated array, it is 
fair test for real world
         .sliced(100, 1000)
         .transposed
         .map!(r => sum(r, 0L) / cast(double) r.length)
         .array;             <---- allocation of the result
  -- Ilya


More information about the Digitalmars-d-announce mailing list