On 4/8/16 3:18 AM, Nordlöw wrote:
On Thursday, 7 April 2016 at 13:09:22 UTC, Andrei Alexandrescu wrote:
if (less(r[0], r[1])) r.swapAt(0, 2);
if (less(r[1], r[3])) r.swapAt(1, 3);

Shouldn't it be

if (less(r[0], r[2])) r.swapAt(0, 2);
if (less(r[1], r[3])) r.swapAt(1, 3);

?

Yah, sorry for the mistake.

Could you elaborate a bit on how this is used to express sorting?
AFAICT, to become a full sorting network we need

if (less(r[0], r[2])) r.swapAt(0, 2);
if (less(r[1], r[3])) r.swapAt(1, 3);
if (less(r[0], r[1])) r.swapAt(0, 1);
if (less(r[2], r[3])) r.swapAt(2, 3);

right?

Right, was just giving a quick example involving two arbitrary pairs of indexes.


Andrei

Reply via email to