On Saturday, 29 February 2020 at 19:04:12 UTC, p.shkadzko wrote:
On Friday, 28 February 2020 at 16:51:10 UTC, AB wrote:
On Thursday, 27 February 2020 at 14:15:26 UTC, p.shkadzko
wrote:
[...]
Your Example with a minimal 2D array.
module test2;
import std.random : Xorshift,
On Friday, 28 February 2020 at 16:51:10 UTC, AB wrote:
On Thursday, 27 February 2020 at 14:15:26 UTC, p.shkadzko wrote:
[...]
Your Example with a minimal 2D array.
module test2;
import std.random : Xorshift, unpredictableSeed, uniform;
import std.range : generate, take, chunks;
On Friday, 28 February 2020 at 16:51:10 UTC, AB wrote:
See https://dlang.org/spec/operatoroverloading.html#array-ops
for a better overview of the required operators or mir.ndslice
for an nD implementation.
Here's an old version of some of the things I've been using:
On Thursday, 27 February 2020 at 14:15:26 UTC, p.shkadzko wrote:
I'd like to sum 2D arrays. Let's create 2 random 2D arrays and
sum them.
```
import std.random : Xorshift, unpredictableSeed, uniform;
import std.range : generate, take, chunks;
import std.array : array;
static T[][]
On Thursday, 27 February 2020 at 23:15:28 UTC, p.shkadzko wrote:
And it works effortlessly!
Sum of two 5000 x 6000 int arrays is just 0.105 sec! (on a
Windows machine though but with weaker CPU).
I bet using mir.ndslice instead of D arrays would be even
faster.
Yes, the output for the
On Thursday, 27 February 2020 at 15:48:53 UTC, bachmeier wrote:
On Thursday, 27 February 2020 at 14:15:26 UTC, p.shkadzko wrote:
[...]
This works but it does not look very efficient considering we
flatten and then calling array twice. It will get even worse
with 3D arrays. Is there a better
On Thursday, 27 February 2020 at 16:31:07 UTC, 9il wrote:
On Thursday, 27 February 2020 at 14:15:26 UTC, p.shkadzko wrote:
Is there a better way without relying on mir.ndslice?
ndslice Poker Face
/+dub.sdl:
dependency "mir-algorithm" version="~>3.7.17"
dependency "mir-random"
On Thursday, 27 February 2020 at 16:39:15 UTC, 9il wrote:
[snip]
Few performances nitpick for your example to be fair with
benchmarking againt the test:
1. Random (default) is slower then Xorfish.
2. double is twice larger then int and requires twice more
memory, so it would be twice slower
On Thursday, 27 February 2020 at 14:15:26 UTC, p.shkadzko wrote:
void main() {
int[][] m1 = rndMatrix(10, 2, 3);
int[][] m2 = rndMatrix(10, 2, 3);
auto c = m1[] + m2[];
}
I think you're trying to do this:
int[][] m1 = rndMatrix(10, 2, 3);
int[][] m2 = rndMatrix(10, 2, 3);
On Thursday, 27 February 2020 at 16:31:49 UTC, jmh530 wrote:
On Thursday, 27 February 2020 at 15:28:01 UTC, p.shkadzko wrote:
On Thursday, 27 February 2020 at 14:15:26 UTC, p.shkadzko
wrote:
This works but it does not look very efficient considering we
flatten and then calling array twice. It
On Thursday, 27 February 2020 at 15:28:01 UTC, p.shkadzko wrote:
On Thursday, 27 February 2020 at 14:15:26 UTC, p.shkadzko wrote:
This works but it does not look very efficient considering we
flatten and then calling array twice. It will get even worse
with 3D arrays.
And yes, benchmarks
On Thursday, 27 February 2020 at 14:15:26 UTC, p.shkadzko wrote:
Is there a better way without relying on mir.ndslice?
ndslice Poker Face
/+dub.sdl:
dependency "mir-algorithm" version="~>3.7.17"
dependency "mir-random" version="~>2.2.10"
+/
import mir.ndslice;
import mir.random: threadLocal;
On Thursday, 27 February 2020 at 14:15:26 UTC, p.shkadzko wrote:
[...]
This works but it does not look very efficient considering we
flatten and then calling array twice. It will get even worse
with 3D arrays. Is there a better way without relying on
mir.ndslice?
Is there a reason you
On Thursday, 27 February 2020 at 14:15:26 UTC, p.shkadzko wrote:
This works but it does not look very efficient considering we
flatten and then calling array twice. It will get even worse
with 3D arrays.
And yes, benchmarks show that summing 2D arrays like in the
example above is
I'd like to sum 2D arrays. Let's create 2 random 2D arrays and
sum them.
```
import std.random : Xorshift, unpredictableSeed, uniform;
import std.range : generate, take, chunks;
import std.array : array;
static T[][] rndMatrix(T)(T max, in int rows, in int cols)
{
Xorshift rnd;
15 matches
Mail list logo