Just another update

This commit is contained in:
Ingy döt Net 2015-02-20 00:35:01 -05:00
parent a25938f123
commit 00a190b0a6
6591 changed files with 94363 additions and 23227 deletions

View file

@ -1,12 +1,9 @@
import std.stdio, std.typecons, std.math, std.algorithm,
std.random, std.traits, std.range, std.complex;
//auto bfClosestPair(T)(in T[] points) pure nothrow {
auto bruteForceClosestPair(T)(in T[] points) pure nothrow @nogc {
// return pairwise(points.length.iota, points.length.iota)
// .reduce!(min!((i, j) => abs(points[i] - points[j])));
//}
auto bruteForceClosestPair(T)(in T[] points) pure nothrow {
auto minD = Unqual!(typeof(T.re)).infinity;
T minI, minJ;
foreach (immutable i, const p1; points.dropBackOne)
@ -21,7 +18,7 @@ auto bruteForceClosestPair(T)(in T[] points) pure nothrow {
return tuple(minD, minI, minJ);
}
auto closestPair(T)(T[] points) /*pure nothrow*/ {
auto closestPair(T)(T[] points) pure nothrow {
static Tuple!(typeof(T.re), T, T) inner(in T[] xP, /*in*/ T[] yP)
pure nothrow {
if (xP.length <= 3)

View file

@ -2,7 +2,7 @@ import std.stdio, std.random, std.math, std.typecons, std.complex,
std.traits;
Nullable!(Tuple!(size_t, size_t))
bfClosestPair2(T)(in Complex!T[] points) pure nothrow {
bfClosestPair2(T)(in Complex!T[] points) pure nothrow @nogc {
auto minD = Unqual!(typeof(points[0].re)).infinity;
if (points.length < 2)
return typeof(return)();