{"id":19093703,"url":"https://github.com/juliaarrays/fftviews.jl","last_synced_at":"2025-09-16T16:56:21.280Z","repository":{"id":47666581,"uuid":"65333826","full_name":"JuliaArrays/FFTViews.jl","owner":"JuliaArrays","description":"Julia package for fast fourier transforms and periodic views","archived":false,"fork":false,"pushed_at":"2023-09-04T19:58:11.000Z","size":51,"stargazers_count":21,"open_issues_count":5,"forks_count":8,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-05-08T21:14:09.645Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Julia","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JuliaArrays.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-08-09T23:00:18.000Z","updated_at":"2024-03-17T06:13:51.000Z","dependencies_parsed_at":"2024-11-09T03:28:20.545Z","dependency_job_id":"052042a0-107d-47a0-9713-b4fd4fcf1e43","html_url":"https://github.com/JuliaArrays/FFTViews.jl","commit_stats":{"total_commits":35,"total_committers":7,"mean_commits":5.0,"dds":0.3142857142857143,"last_synced_commit":"d603d6eb6bc460acb7a9b70d16d6c7cdf2dc0d78"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuliaArrays%2FFFTViews.jl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuliaArrays%2FFFTViews.jl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuliaArrays%2FFFTViews.jl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuliaArrays%2FFFTViews.jl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JuliaArrays","download_url":"https://codeload.github.com/JuliaArrays/FFTViews.jl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240142863,"owners_count":19754640,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T03:25:46.767Z","updated_at":"2025-09-16T16:56:16.232Z","avatar_url":"https://github.com/JuliaArrays.png","language":"Julia","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FFTViews\n\n[![Build Status](https://travis-ci.org/JuliaArrays/FFTViews.jl.svg?branch=master)](https://travis-ci.org/JuliaArrays/FFTViews.jl)\n\n[![codecov.io](http://codecov.io/github/JuliaArrays/FFTViews.jl/coverage.svg?branch=master)](http://codecov.io/github/JuliaArrays/FFTViews.jl?branch=master)\n\nA package for simplifying operations that involve Fourier\ntransforms. An FFTView of an array uses periodic boundary conditions\nfor indexing, and shifts all indices of the array downward by 1.\n\n# Usage\n\nLet's create a random signal:\n```julia\n\n\njulia\u003e using FFTViews\n\njulia\u003e a = rand(8)\n8-element Array{Float64,1}:\n 0.720657\n 0.42337\n 0.207867\n 0.959567\n 0.371366\n 0.907781\n 0.852526\n 0.689934\n```\n\nNow let's take its Fourier transform, and wrap the result as an `FFTView`:\n```julia\njulia\u003e afft = fft(a)\n8-element Array{Complex{Float64},1}:\n   5.13307+0.0im\n -0.183898+0.796529im\n   0.03163+0.31835im\n   0.88248-0.492787im\n -0.828236+0.0im\n   0.88248+0.492787im\n   0.03163-0.31835im\n -0.183898-0.796529im\n\njulia\u003e v = FFTView(afft)\nFFTViews.FFTView{Complex{Float64},1,Array{Complex{Float64},1}} with indices FFTViews.URange(0,7):\n   5.13307+0.0im\n -0.183898+0.796529im\n   0.03163+0.31835im\n   0.88248-0.492787im\n -0.828236+0.0im\n   0.88248+0.492787im\n   0.03163-0.31835im\n -0.183898-0.796529im\n```\n\nNow we can easily look at the zero-frequency bin:\n```julia\njulia\u003e v[0]\n5.133068739504999 + 0.0im\n\njulia\u003e sum(a)\n5.133068739504998\n```\nor negative as well as positive frequencies:\n```julia\njulia\u003e v[-4:3]\n8-element Array{Complex{Float64},1}:\n -0.828236+0.0im\n   0.88248+0.492787im\n   0.03163-0.31835im\n -0.183898-0.796529im\n   5.13307+0.0im\n -0.183898+0.796529im\n   0.03163+0.31835im\n   0.88248-0.492787im\n```\n\nPerhaps even more interestingly, one can also simplify the process of\nconvolution. Let's create a \"delta-function\" signal:\n```julia\njulia\u003e b = zeros(8); b[3] = 1; b  # the signal\n8-element Array{Float64,1}:\n 0.0\n 0.0\n 1.0\n 0.0\n 0.0\n 0.0\n 0.0\n 0.0\n```\nand then create the kernel using an `FFTView`:\n\n```julia\njulia\u003e kernel = FFTView(zeros(8))\nFFTViews.FFTView{Float64,1,Array{Float64,1}} with indices FFTViews.URange(0,7):\n 0.0\n 0.0\n 0.0\n 0.0\n 0.0\n 0.0\n 0.0\n 0.0\n\njulia\u003e kernel[-1:1] = rand(3)\n3-element Array{Float64,1}:\n 0.16202\n 0.446872\n 0.649135\n\njulia\u003e kernel\nFFTViews.FFTView{Float64,1,Array{Float64,1}} with indices FFTViews.URange(0,7):\n 0.446872\n 0.649135\n 0.0\n 0.0\n 0.0\n 0.0\n 0.0\n 0.16202\n```\n\nNow compute the convolution via the FFT:\n```julia\njulia\u003e real(ifft(fft(b).*fft(kernel)))\n8-element Array{Float64,1}:\n  0.0\n  0.16202\n  0.446872\n  0.649135\n  0.0\n -5.55112e-17\n  0.0\n -6.93889e-17\n```\nor alternatively\n```julia\njulia\u003e irfft(rfft(b).*rfft(kernel),8)\n8-element Array{Float64,1}:\n  0.0\n  0.16202\n  0.446872\n  0.649135\n  0.0\n -2.77556e-17\n  0.0\n -5.55112e-17\n```\nThis simplifies the process of remembering how to pack your kernel.\n\n## Caution: FFTViews are not composable\n\nIn Julia, almost all other view types are composable: you can make a\n`ReshapedArray` of a `SubArray` of a `StaticArray` of a .... In\ncontrast, `FFTViews` are *not safe* when placed inside other\ncontainers. The reason is that the `*fft` methods are specialized for\n`FFTViews`, and strip off the outer container; this does not happen if\nyou wrap an `FFTView` inside of some other array type.  If you do wrap\n`FFTViews`, you might see strange off-by-1 bugs due to the FFTView\ntranslating the indices.\n\nAnother way of saying the same thing is the following: for a general vector `x`, its FFT is defined as\n\n![eq1](docs/eq1.png)\n\nHere `x[n]` is defined with periodic boundary conditions, so that if the indices of `x` are not naturally from 1 to N, this formula still holds.\n\nHowever, if `y = FFTView(x)`, then in terms of `y` we have\n\n![eq1](docs/eq2.png)\n\nwhich is shifted by 1. Since `FFTView`s use a different definition of\nthe FFT compared to all other array types, they need to be used with\ncaution. It's recommended that the FFTView wrapper be applied only for\nthe process of setting up or analyzing the result of the transform;\nfor all other operations, pass the `parent` array (obtainable from\n`parent(y)` or just by reference to `x` itself).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliaarrays%2Ffftviews.jl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjuliaarrays%2Ffftviews.jl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliaarrays%2Ffftviews.jl/lists"}