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,5 +1,5 @@
import std.stdio, std.numeric;
void main() {
import std.stdio, std.numeric;
[1.0, 1, 1, 1, 0, 0, 0, 0].fft.writeln;
}

View file

@ -1,6 +1,6 @@
import std.stdio, std.algorithm, std.range, std.math;
const(creal)[] fft(in creal[] x) /*pure nothrow*/ {
const(creal)[] fft(in creal[] x) pure /*nothrow*/ @safe {
immutable N = x.length;
if (N <= 1) return x;
const ev = x.stride(2).array.fft;
@ -10,6 +10,6 @@ const(creal)[] fft(in creal[] x) /*pure nothrow*/ {
return l.chain(r).array;
}
void main() {
void main() @safe {
[1.0L+0i, 1, 1, 1, 0, 0, 0, 0].fft.writeln;
}

View file

@ -1,13 +1,13 @@
import std.stdio, std.algorithm, std.range, std.math, std.complex;
auto fft(T)(in T[] x) /*pure nothrow*/ {
auto fft(T)(in T[] x) pure /*nothrow @safe*/ {
immutable N = x.length;
if (N <= 1) return x;
const ev = x.stride(2).array.fft;
const od = x[1 .. $].stride(2).array.fft;
alias E = std.complex.expi;
auto l = iota(N / 2).map!(k=> ev[k] + cast(T)E(-2*PI*k/N) * od[k]);
auto r = iota(N / 2).map!(k=> ev[k] - cast(T)E(-2*PI*k/N) * od[k]);
auto l = iota(N / 2).map!(k => ev[k] + T(E(-2* PI * k/N)) * od[k]);
auto r = iota(N / 2).map!(k => ev[k] - T(E(-2* PI * k/N)) * od[k]);
return l.chain(r).array;
}