{"id":"polychromatist/fftfy","name":"fftfy","scope":"polychromatist","platform":"roblox","description":"fft for roblox","version":"0.1.1","latest":"0.1.1","versions":["0.1.0","0.1.1"],"license":"Apache-2.0","licenseRating":"safe","licenseCaveats":["Modified files must carry a notice of changes. If the package ships a NOTICE file, its attributions must be preserved."],"licenseVerified":true,"dependencies":{},"integrity":"a3574fe73245a8ad5d176e1a1a40eeb96b514dbe1dd1a8c37c3fb8a34413f16f","likes":0,"downloads":0,"install":"forest install polychromatist/fftfy","url":"https://forest.dev/p/roblox/polychromatist/fftfy","files":"https://api.forest.dev/ai/package/roblox/polychromatist/fftfy/files","readme":"## Fast Fourier That For You\r\n\r\nThis is an in-place, radix 2 implementation of the Cooley-Tukey FFT algorithm.\r\n\r\n## Usage\r\n\r\n```lua\r\nlocal fft = require(\"fft\")\r\n\r\nlocal SIZE = 32\r\n\r\nlocal sine = {r = table.create(SIZE, 0), c = table.create(SIZE, 0) }\r\nfor i = 1, SIZE do\r\n  sine.r[i] = math.sin(4*math.pi*i / SIZE)\r\nend\r\n\r\nlocal X = fft(sine)\r\n\r\nlocal out = {}\r\nfor i = 1, SIZE do\r\n  out[i] = string.format(\"(%.2f,%.2f)\", X.r[i], X.c[i]) .. (if i % 8 == 0 then \"\\n\" else \"\")\r\nend\r\nprint(\"{\" .. table.concat(out, \",\") .. \"}\")\r\n\r\nlocal x = fft(X, true, false, -1)\r\n\r\nprint(\"R: recovered input; I: initial input\")\r\nfor i = 1, SIZE do\r\n  out[i] = string.format(\"R:%.2f, I:%.2f\", x.r[i], sine.r[i]) .. (if i % 2 == 0 then \"\\n\" else \"\")\r\nend\r\nprint(table.concat(out, \"; \"))\r\n\r\n--[=[\r\n{(-0.00,0.00),(-0.00,-16.00),(0.00,-0.00),(-0.00,-0.00),(-0.00,-0.00),(-0.00,-0.00),(0.00,-0.00),(0.00,-0.00)\r\n,(0.00,0.00),(0.00,-0.00),(-0.00,0.00),(0.00,-0.00),(0.00,0.00),(-0.00,0.00),(-0.00,0.00),(-0.00,0.00)\r\n,(-0.00,-0.00),(-0.00,-0.00),(0.00,-0.00),(0.00,0.00),(-0.00,-0.00),(0.00,0.00),(0.00,-0.00),(0.00,0.00)\r\n,(0.00,0.00),(-0.00,0.00),(-0.00,0.00),(-0.00,0.00),(0.00,0.00),(-0.00,16.00),(-0.00,-0.00),(-0.00,0.00)\r\n}\r\nR: recovered input; I: initial input\r\nR:0.38, I:0.38; R:0.71, I:0.71\r\n; R:0.92, I:0.92; R:1.00, I:1.00\r\n; R:0.92, I:0.92; R:0.71, I:0.71\r\n; R:0.38, I:0.38; R:0.00, I:0.00\r\n; R:-0.38, I:-0.38; R:-0.71, I:-0.71\r\n; R:-0.92, I:-0.92; R:-1.00, I:-1.00\r\n; R:-0.92, I:-0.92; R:-0.71, I:-0.71\r\n; R:-0.38, I:-0.38; R:-0.00, I:-0.00\r\n; R:0.38, I:0.38; R:0.71, I:0.71\r\n; R:0.92, I:0.92; R:1.00, I:1.00\r\n; R:0.92, I:0.92; R:0.71, I:0.71\r\n; R:0.38, I:0.38; R:0.00, I:0.00\r\n; R:-0.38, I:-0.38; R:-0.71, I:-0.71\r\n; R:-0.92, I:-0.92; R:-1.00, I:-1.00\r\n; R:-0.92, I:-0.92; R:-0.71, I:-0.71\r\n; R:-0.38, I:-0.38; R:-0.00, I:-0.00\r\n]=]\r\n```\r\n\r\n## Documentation\r\n\r\nInput should be of the form: `type zvec = { r: { number }, c: { number } }`\r\n\r\nInput & output vector size will be zero-padded to the next power of two wrt real input vector size.\r\n\r\nThere are no dependencies.\r\n\r\n### Arguments to `fft`\r\n\r\n- `zvec x`: The discrete sample domain.\r\n\r\n- `boolean? invert`: Inverse DFT is computed by passing `true`.\r\n\r\n- `boolean? keep_revert`: The FFT algorithm produces the DFT in reverse, and then re-reverses it later. You can avoid that small overhead by passing `true`. The output zvec will be backwards.\r\n\r\n- `number? scale_pow`: This parameter controls the exponent of a scalar that is multiplied on the output. The base is the output size. Passing `-1` normalizes the output with `1/N`, and `-0.5` with `1/sqrt(N)`.\r\n\r\n\r\n","readmeTruncated":false}