Data update
This commit is contained in:
parent
8e4e15fa56
commit
72eb4943cb
1853 changed files with 35514 additions and 9441 deletions
|
|
@ -0,0 +1,51 @@
|
|||
module CreateLibComplexPack {
|
||||
prototype {
|
||||
class ComplexPack {
|
||||
function final complexPolar(a, b) {
|
||||
method .m, "cxPolar", a, b as ret
|
||||
=ret
|
||||
}
|
||||
function final complex(a, b) {
|
||||
method .m, "cxNew", a, b as ret
|
||||
=ret
|
||||
}
|
||||
function final mul(a, b) {
|
||||
method .m, "cxMul", a, b as ret
|
||||
=ret
|
||||
}
|
||||
function final add(a, b) {
|
||||
method .m, "cxAdd", a, b as ret
|
||||
=ret
|
||||
}
|
||||
function final sub(a, b) {
|
||||
method .m, "cxSub", a, b as ret
|
||||
=ret
|
||||
}
|
||||
Module final FFT(buf, out, begin as Long, stp as Long, N as Long) {
|
||||
If stp < N Then
|
||||
call .FFT, out, buf, begin, 2 * stp, N
|
||||
call .FFT, out, buf, begin + stp, 2 * stp, N
|
||||
var i as long, t as variant
|
||||
for i=0 to N-1 step 2*stp
|
||||
t= .mul(.complexPolar(1, -pi* i / N), out[begin + i + stp])
|
||||
buf[begin + i div 2]= .add(out[begin + i], t)
|
||||
buf[begin + (i + N) div 2]= .sub(out[begin + i], t)
|
||||
next
|
||||
End If
|
||||
}
|
||||
private:
|
||||
declare m math2
|
||||
public:
|
||||
property zero {value}
|
||||
class:
|
||||
module ComplexPack{
|
||||
method .m,"cxzero" as z
|
||||
.[zero]<=z
|
||||
}
|
||||
}
|
||||
} as ComplexPack
|
||||
const UTF8=2&
|
||||
document Export$=ComplexPack
|
||||
Save.Doc Export$, "ComplexPack.gsb", UTF8
|
||||
}
|
||||
CreateLibComplexPack
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
module FFT {
|
||||
load "ComplexPack"
|
||||
cp=ComplexPack()
|
||||
variant buf[7]=cp.zero, out[7]=cp.zero
|
||||
buf[0]|r = 1: buf[1]|r = 1: buf[2]|r = 1: buf[3]|r = 1
|
||||
showArr(buf, "Input")
|
||||
cp.FFT out, buf, 0, 1, 8
|
||||
ShowArr(out, "Output")
|
||||
|
||||
Sub ShowArr(m, mes as string)
|
||||
local n, mx=len(m)
|
||||
Print mes;": (real+imag)"
|
||||
while n<mx
|
||||
print round(m[n]|r), round(m[n]|i, 4)
|
||||
n++
|
||||
end while
|
||||
End Sub
|
||||
}
|
||||
FFT
|
||||
|
|
@ -1,24 +1,24 @@
|
|||
//cmd: +w0 +h0 -F -D
|
||||
//Stockham algorithm
|
||||
//Inspiration: http://wwwa.pikara.ne.jp/okojisan/otfft-en/optimization1.html
|
||||
// cmd: +w0 +h0 -F -D
|
||||
// Stockham algorithm
|
||||
// Inspiration: http://wwwa.pikara.ne.jp/okojisan/otfft-en/optimization1.html
|
||||
|
||||
#version 3.7;
|
||||
global_settings{ assumed_gamma 1.0 }
|
||||
#default{ finish{ ambient 1 diffuse 0 emission 0}}
|
||||
|
||||
#macro Cstr(Comp)
|
||||
concat("<",vstr(2, Comp,", ",0,-1),"j>")
|
||||
concat("<",vstr(2, Comp,", ",0,-1),"j> ")
|
||||
#end
|
||||
|
||||
#macro CdebugArr(data)
|
||||
#for(i,0, dimension_size(data, 1)-1)
|
||||
#debug concat(Cstr(data[i]), "\n")
|
||||
#debug concat(Cstr(data[i]), " ", str(Abs(data[i]),-1,-1),"\n")
|
||||
#end
|
||||
#end
|
||||
|
||||
#macro R2C(Real) <Real, 0> #end
|
||||
|
||||
#macro CmultC(C1, C2) <C1.x * C2.x - C1.y * C2.y, C1.y * C2.x + C1.x * C2.y>#end
|
||||
#macro CmultC(C1, C2) <C1.x * C2.x - C1.y * C2.y, C1.y * C2.x + C1.x * C2.y> #end
|
||||
|
||||
#macro Conjugate(Comp) <Comp.x, -Comp.y> #end
|
||||
|
||||
|
|
@ -26,6 +26,8 @@ global_settings{ assumed_gamma 1.0 }
|
|||
bitwise_and((X > 0), (bitwise_and(X, (X - 1)) = 0))
|
||||
#end
|
||||
|
||||
#macro Abs(C) sqrt(C.x * C.x + C.y * C.y) #end
|
||||
|
||||
#macro _FFT0(X, Y, N, Stride, EO)
|
||||
#local M = div(N, 2);
|
||||
#local Theta = 2 * pi / N;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
function fft(x: array of complex): array of complex;
|
||||
begin
|
||||
var n := x.length;
|
||||
if n = 0 then exit;
|
||||
|
||||
setlength(result, n);
|
||||
|
||||
if n = 1 then
|
||||
begin
|
||||
result[0] := x[0];
|
||||
exit;
|
||||
end;
|
||||
|
||||
var evens := x.Where((x, i) -> i mod 2 = 0).ToArray;
|
||||
var odds := x.Where((x, i) -> i mod 2 = 1).ToArray;
|
||||
var (even, odd) := (fft(evens), fft(odds));
|
||||
|
||||
var halfn := n div 2;
|
||||
|
||||
for var k := 0 to halfn - 1 do
|
||||
begin
|
||||
var a := exp(new Complex(0.0, -2 * Pi * k / n)) * odd[k];
|
||||
result[k] := even[k] + a;
|
||||
result[k + halfn] := even[k] - a;
|
||||
end;
|
||||
end;
|
||||
|
||||
begin
|
||||
var test := |1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0|;
|
||||
foreach var x in fft(test.select(x -> new Complex(x, 0)).ToArray) do
|
||||
println(x)
|
||||
end.
|
||||
|
|
@ -5,7 +5,7 @@ typealias Complex = Numerics.Complex<Double>
|
|||
|
||||
extension Complex {
|
||||
var exp: Complex {
|
||||
Complex(cos(imaginary), sin(imaginary)) * Complex(cosh(real), sinh(real))
|
||||
Complex(cos(imaginary), sin(imaginary)) * Complex(cosh(real) + sinh(real), 0)
|
||||
}
|
||||
|
||||
var pretty: String {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue