{"action":"created","comment":{"url":"https://api.github.com/repos/JuliaLang/julia/pulls/comments/31392471","id":31392471,"diff_hunk":"@@ -0,0 +1,103 @@\n+# This file is a part of Julia. License is MIT: http://julialang.org/license\n+\n+# (This is part of the FFTW module.)\n+\n+export dct, idct, dct!, idct!, plan_dct, plan_idct, plan_dct!, plan_idct!\n+\n+# Discrete cosine transforms (type II/III) via FFTW's r2r transforms;\n+# we follow the Matlab convention and adopt a unitary normalization here.\n+# Unlike Matlab we compute the multidimensional transform by default,\n+# similar to the Julia fft functions.\n+\n+type DCTPlan{T<:fftwNumber,K,inplace} <: Plan{T}\n+    plan::r2rFFTWPlan{T}\n+    r::Array{UnitRange{Int}} # array of indices for rescaling\n+    nrm::Float64 # normalization factor\n+    region::Dims # dimensions being transformed\n+    pinv::DCTPlan{T}\n+    DCTPlan(plan,r,nrm,region) = new(plan,r,nrm,region)\n+end\n+\n+size(p::DCTPlan) = size(p.plan)\n+\n+function show{T,K,inplace}(io::IO, p::DCTPlan{T,K,inplace})\n+    print(io, inplace ? \"FFTW in-place \" : \"FFTW \",\n+          K == REDFT10 ? \"DCT (DCT-II)\" : \"IDCT (DCT-III)\", \" plan for \")\n+    showfftdims(io, p.plan.sz, p.plan.istride, eltype(p))\n+end\n+\n+for (pf, pfr, K, inplace) in ((:plan_dct, :plan_r2r, REDFT10, false),\n+                              (:plan_dct!, :plan_r2r!, REDFT10, true),\n+                              (:plan_idct, :plan_r2r, REDFT01, false),\n+                              (:plan_idct!, :plan_r2r!, REDFT01, true))\n+    @eval function $pf{T<:fftwNumber}(X::StridedArray{T}, region; kws...)\n+        r = [1:n for n in size(X)]\n+        nrm = sqrt(0.5^length(region) * normalization(X,region))\n+        DCTPlan{T,$K,$inplace}($pfr(X, $K, region; kws...), r, nrm,\n+                               ntuple(length(region), i -> int(region[i])))","path":"base/fft/dct.jl","position":37,"original_position":37,"commit_id":"1962796452f85a01f66fa9715bba04eb2ef69704","original_commit_id":"1962796452f85a01f66fa9715bba04eb2ef69704","user":{"login":"simonster","id":470884,"avatar_url":"https://avatars.githubusercontent.com/u/470884?v=3","gravatar_id":"","url":"https://api.github.com/users/simonster","html_url":"https://github.com/simonster","followers_url":"https://api.github.com/users/simonster/followers","following_url":"https://api.github.com/users/simonster/following{/other_user}","gists_url":"https://api.github.com/users/simonster/gists{/gist_id}","starred_url":"https://api.github.com/users/simonster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simonster/subscriptions","organizations_url":"https://api.github.com/users/simonster/orgs","repos_url":"https://api.github.com/users/simonster/repos","events_url":"https://api.github.com/users/simonster/events{/privacy}","received_events_url":"https://api.github.com/users/simonster/received_events","type":"User","site_admin":false},"body":"Also deprecated","created_at":"2015-05-31T17:32:14Z","updated_at":"2015-05-31T17:32:14Z","html_url":"https://github.com/JuliaLang/julia/pull/6193#discussion_r31392471","pull_request_url":"https://api.github.com/repos/JuliaLang/julia/pulls/6193","_links":{"self":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/comments/31392471"},"html":{"href":"https://github.com/JuliaLang/julia/pull/6193#discussion_r31392471"},"pull_request":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/6193"}}},"pull_request":{"url":"https://api.github.com/repos/JuliaLang/julia/pulls/6193","id":13666438,"html_url":"https://github.com/JuliaLang/julia/pull/6193","diff_url":"https://github.com/JuliaLang/julia/pull/6193.diff","patch_url":"https://github.com/JuliaLang/julia/pull/6193.patch","issue_url":"https://api.github.com/repos/JuliaLang/julia/issues/6193","number":6193,"state":"open","locked":false,"title":"WIP: new DFT api","user":{"login":"stevengj","id":2913679,"avatar_url":"https://avatars.githubusercontent.com/u/2913679?v=3","gravatar_id":"","url":"https://api.github.com/users/stevengj","html_url":"https://github.com/stevengj","followers_url":"https://api.github.com/users/stevengj/followers","following_url":"https://api.github.com/users/stevengj/following{/other_user}","gists_url":"https://api.github.com/users/stevengj/gists{/gist_id}","starred_url":"https://api.github.com/users/stevengj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stevengj/subscriptions","organizations_url":"https://api.github.com/users/stevengj/orgs","repos_url":"https://api.github.com/users/stevengj/repos","events_url":"https://api.github.com/users/stevengj/events{/privacy}","received_events_url":"https://api.github.com/users/stevengj/received_events","type":"User","site_admin":false},"body":"This is not quite ready to merge yet, but I wanted to bring it to your attention to see what you think.  It is a rewritten DFT API that provides:\r\n\r\n* `p = plan_fft(x)` (and similar) now returns a subtype of `Base.DFT.Plan`.  It acts like a linear operator: you can apply it to an existing array with `p * x`, and apply it to a preallocated output array with `A_mul_B!(y, p, x)`.  You can apply the inverse plan with `p \\ x` or `inv(p) * x`.\r\n* It is easy to add new FFT algorithm implementations for specific numeric and array types...\r\n\r\nPartly since we have discussed moving FFTW to a module at some point for licensing reasons, and partly to support numeric types like `BigFloat`, the patch also includes a pure-Julia FFT implementation, with the following features.\r\n\r\n* One-dimensional transforms of arbitrary `AbstractVector`s of arbitrary `Complex` types (including `BigFloat`), with fast algorithms for all sizes (including prime sizes).  Multidimensional transforms of arbitrary `StridedArray` subtypes.\r\n* Uses code generation (a baby version of the FFTW code generator) in Julia to generate kernels for use as base cases of the transforms; algorithms in general are FFTW1-like.\r\n* Performance is reasonable. For moderate-power-of-two sizes, it is within a factor of 2 or so of FFTW, with the difference mainly due to the lack of SIMD.   ~~For non-power-of-two sizes, the performance is several times worse, but I suspect that there may be some fixable compiler problem there (a good stress test for the compiler).~~ (Non-power-of-two sizes seem fine with latest Julia).\r\n* `import FFTW` is enough to automatically switch over to the FFTW algorithms for supported types.\r\n\r\nMajor to-do items:\r\n- [x] Documentation\r\n- [x] More test cases (implemented a self-test algorithm by Funda Ergün)\r\n\r\nMinor to-do items (will eventually be needed to move the FFTW code out to an external module, but should not block merge):\r\n- [ ] Native Julia `rfft` support.\r\n- [ ] Native Julia in-place transforms. (The 1d FFT algorithm here is out-of-place, but it could act \"in-place\" via a buffer.  The multi-dim FFTs only need a buffer of length `maximum(size(x))`.)\r\n- [ ] Performance improvements in non-power-of-two transforms — these underwent a major performance regression at some point (possibly due to the inlining heuristics changing); the right thing is ultimately to change the generator to spit out kernels in terms of real rather than complex arithmetic (or just to use FFTW's generator).\r\n\r\ncc: @JeffBezanson, @timholy","created_at":"2014-03-18T02:09:53Z","updated_at":"2015-05-31T17:32:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4f21481242be4b87194ad8841b820d67ee0e64c7","assignee":null,"milestone":{"url":"https://api.github.com/repos/JuliaLang/julia/milestones/14","html_url":"https://github.com/JuliaLang/julia/milestones/0.5","labels_url":"https://api.github.com/repos/JuliaLang/julia/milestones/14/labels","id":868319,"number":14,"title":"0.5","description":"Release-defining items for v0.5.","creator":{"login":"vtjnash","id":330950,"avatar_url":"https://avatars.githubusercontent.com/u/330950?v=3","gravatar_id":"","url":"https://api.github.com/users/vtjnash","html_url":"https://github.com/vtjnash","followers_url":"https://api.github.com/users/vtjnash/followers","following_url":"https://api.github.com/users/vtjnash/following{/other_user}","gists_url":"https://api.github.com/users/vtjnash/gists{/gist_id}","starred_url":"https://api.github.com/users/vtjnash/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vtjnash/subscriptions","organizations_url":"https://api.github.com/users/vtjnash/orgs","repos_url":"https://api.github.com/users/vtjnash/repos","events_url":"https://api.github.com/users/vtjnash/events{/privacy}","received_events_url":"https://api.github.com/users/vtjnash/received_events","type":"User","site_admin":false},"open_issues":21,"closed_issues":1,"state":"open","created_at":"2014-11-16T16:16:12Z","updated_at":"2015-05-29T15:03:25Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/JuliaLang/julia/pulls/6193/commits","review_comments_url":"https://api.github.com/repos/JuliaLang/julia/pulls/6193/comments","review_comment_url":"https://api.github.com/repos/JuliaLang/julia/pulls/comments{/number}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/6193/comments","statuses_url":"https://api.github.com/repos/JuliaLang/julia/statuses/1962796452f85a01f66fa9715bba04eb2ef69704","head":{"label":"stevengj:dftnew","ref":"dftnew","sha":"1962796452f85a01f66fa9715bba04eb2ef69704","user":{"login":"stevengj","id":2913679,"avatar_url":"https://avatars.githubusercontent.com/u/2913679?v=3","gravatar_id":"","url":"https://api.github.com/users/stevengj","html_url":"https://github.com/stevengj","followers_url":"https://api.github.com/users/stevengj/followers","following_url":"https://api.github.com/users/stevengj/following{/other_user}","gists_url":"https://api.github.com/users/stevengj/gists{/gist_id}","starred_url":"https://api.github.com/users/stevengj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stevengj/subscriptions","organizations_url":"https://api.github.com/users/stevengj/orgs","repos_url":"https://api.github.com/users/stevengj/repos","events_url":"https://api.github.com/users/stevengj/events{/privacy}","received_events_url":"https://api.github.com/users/stevengj/received_events","type":"User","site_admin":false},"repo":{"id":7264997,"name":"julia","full_name":"stevengj/julia","owner":{"login":"stevengj","id":2913679,"avatar_url":"https://avatars.githubusercontent.com/u/2913679?v=3","gravatar_id":"","url":"https://api.github.com/users/stevengj","html_url":"https://github.com/stevengj","followers_url":"https://api.github.com/users/stevengj/followers","following_url":"https://api.github.com/users/stevengj/following{/other_user}","gists_url":"https://api.github.com/users/stevengj/gists{/gist_id}","starred_url":"https://api.github.com/users/stevengj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stevengj/subscriptions","organizations_url":"https://api.github.com/users/stevengj/orgs","repos_url":"https://api.github.com/users/stevengj/repos","events_url":"https://api.github.com/users/stevengj/events{/privacy}","received_events_url":"https://api.github.com/users/stevengj/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/stevengj/julia","description":"The Julia Language: A fresh approach to technical computing.","fork":true,"url":"https://api.github.com/repos/stevengj/julia","forks_url":"https://api.github.com/repos/stevengj/julia/forks","keys_url":"https://api.github.com/repos/stevengj/julia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/stevengj/julia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/stevengj/julia/teams","hooks_url":"https://api.github.com/repos/stevengj/julia/hooks","issue_events_url":"https://api.github.com/repos/stevengj/julia/issues/events{/number}","events_url":"https://api.github.com/repos/stevengj/julia/events","assignees_url":"https://api.github.com/repos/stevengj/julia/assignees{/user}","branches_url":"https://api.github.com/repos/stevengj/julia/branches{/branch}","tags_url":"https://api.github.com/repos/stevengj/julia/tags","blobs_url":"https://api.github.com/repos/stevengj/julia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/stevengj/julia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/stevengj/julia/git/refs{/sha}","trees_url":"https://api.github.com/repos/stevengj/julia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/stevengj/julia/statuses/{sha}","languages_url":"https://api.github.com/repos/stevengj/julia/languages","stargazers_url":"https://api.github.com/repos/stevengj/julia/stargazers","contributors_url":"https://api.github.com/repos/stevengj/julia/contributors","subscribers_url":"https://api.github.com/repos/stevengj/julia/subscribers","subscription_url":"https://api.github.com/repos/stevengj/julia/subscription","commits_url":"https://api.github.com/repos/stevengj/julia/commits{/sha}","git_commits_url":"https://api.github.com/repos/stevengj/julia/git/commits{/sha}","comments_url":"https://api.github.com/repos/stevengj/julia/comments{/number}","issue_comment_url":"https://api.github.com/repos/stevengj/julia/issues/comments{/number}","contents_url":"https://api.github.com/repos/stevengj/julia/contents/{+path}","compare_url":"https://api.github.com/repos/stevengj/julia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/stevengj/julia/merges","archive_url":"https://api.github.com/repos/stevengj/julia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/stevengj/julia/downloads","issues_url":"https://api.github.com/repos/stevengj/julia/issues{/number}","pulls_url":"https://api.github.com/repos/stevengj/julia/pulls{/number}","milestones_url":"https://api.github.com/repos/stevengj/julia/milestones{/number}","notifications_url":"https://api.github.com/repos/stevengj/julia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/stevengj/julia/labels{/name}","releases_url":"https://api.github.com/repos/stevengj/julia/releases{/id}","created_at":"2012-12-20T21:59:35Z","updated_at":"2014-06-25T02:32:49Z","pushed_at":"2015-05-31T12:27:20Z","git_url":"git://github.com/stevengj/julia.git","ssh_url":"git@github.com:stevengj/julia.git","clone_url":"https://github.com/stevengj/julia.git","svn_url":"https://github.com/stevengj/julia","homepage":"http://julialang.org/","size":68302,"stargazers_count":0,"watchers_count":0,"language":"Julia","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"JuliaLang:master","ref":"master","sha":"11310e6be88bd97ff973a0b9027b21a3c4a04852","user":{"login":"JuliaLang","id":743164,"avatar_url":"https://avatars.githubusercontent.com/u/743164?v=3","gravatar_id":"","url":"https://api.github.com/users/JuliaLang","html_url":"https://github.com/JuliaLang","followers_url":"https://api.github.com/users/JuliaLang/followers","following_url":"https://api.github.com/users/JuliaLang/following{/other_user}","gists_url":"https://api.github.com/users/JuliaLang/gists{/gist_id}","starred_url":"https://api.github.com/users/JuliaLang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JuliaLang/subscriptions","organizations_url":"https://api.github.com/users/JuliaLang/orgs","repos_url":"https://api.github.com/users/JuliaLang/repos","events_url":"https://api.github.com/users/JuliaLang/events{/privacy}","received_events_url":"https://api.github.com/users/JuliaLang/received_events","type":"Organization","site_admin":false},"repo":{"id":1644196,"name":"julia","full_name":"JuliaLang/julia","owner":{"login":"JuliaLang","id":743164,"avatar_url":"https://avatars.githubusercontent.com/u/743164?v=3","gravatar_id":"","url":"https://api.github.com/users/JuliaLang","html_url":"https://github.com/JuliaLang","followers_url":"https://api.github.com/users/JuliaLang/followers","following_url":"https://api.github.com/users/JuliaLang/following{/other_user}","gists_url":"https://api.github.com/users/JuliaLang/gists{/gist_id}","starred_url":"https://api.github.com/users/JuliaLang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JuliaLang/subscriptions","organizations_url":"https://api.github.com/users/JuliaLang/orgs","repos_url":"https://api.github.com/users/JuliaLang/repos","events_url":"https://api.github.com/users/JuliaLang/events{/privacy}","received_events_url":"https://api.github.com/users/JuliaLang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/JuliaLang/julia","description":"The Julia Language: A fresh approach to technical computing.","fork":false,"url":"https://api.github.com/repos/JuliaLang/julia","forks_url":"https://api.github.com/repos/JuliaLang/julia/forks","keys_url":"https://api.github.com/repos/JuliaLang/julia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/JuliaLang/julia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/JuliaLang/julia/teams","hooks_url":"https://api.github.com/repos/JuliaLang/julia/hooks","issue_events_url":"https://api.github.com/repos/JuliaLang/julia/issues/events{/number}","events_url":"https://api.github.com/repos/JuliaLang/julia/events","assignees_url":"https://api.github.com/repos/JuliaLang/julia/assignees{/user}","branches_url":"https://api.github.com/repos/JuliaLang/julia/branches{/branch}","tags_url":"https://api.github.com/repos/JuliaLang/julia/tags","blobs_url":"https://api.github.com/repos/JuliaLang/julia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/JuliaLang/julia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/JuliaLang/julia/git/refs{/sha}","trees_url":"https://api.github.com/repos/JuliaLang/julia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/JuliaLang/julia/statuses/{sha}","languages_url":"https://api.github.com/repos/JuliaLang/julia/languages","stargazers_url":"https://api.github.com/repos/JuliaLang/julia/stargazers","contributors_url":"https://api.github.com/repos/JuliaLang/julia/contributors","subscribers_url":"https://api.github.com/repos/JuliaLang/julia/subscribers","subscription_url":"https://api.github.com/repos/JuliaLang/julia/subscription","commits_url":"https://api.github.com/repos/JuliaLang/julia/commits{/sha}","git_commits_url":"https://api.github.com/repos/JuliaLang/julia/git/commits{/sha}","comments_url":"https://api.github.com/repos/JuliaLang/julia/comments{/number}","issue_comment_url":"https://api.github.com/repos/JuliaLang/julia/issues/comments{/number}","contents_url":"https://api.github.com/repos/JuliaLang/julia/contents/{+path}","compare_url":"https://api.github.com/repos/JuliaLang/julia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/JuliaLang/julia/merges","archive_url":"https://api.github.com/repos/JuliaLang/julia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/JuliaLang/julia/downloads","issues_url":"https://api.github.com/repos/JuliaLang/julia/issues{/number}","pulls_url":"https://api.github.com/repos/JuliaLang/julia/pulls{/number}","milestones_url":"https://api.github.com/repos/JuliaLang/julia/milestones{/number}","notifications_url":"https://api.github.com/repos/JuliaLang/julia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/JuliaLang/julia/labels{/name}","releases_url":"https://api.github.com/repos/JuliaLang/julia/releases{/id}","created_at":"2011-04-21T07:01:50Z","updated_at":"2015-05-31T17:10:29Z","pushed_at":"2015-05-31T14:45:35Z","git_url":"git://github.com/JuliaLang/julia.git","ssh_url":"git@github.com:JuliaLang/julia.git","clone_url":"https://github.com/JuliaLang/julia.git","svn_url":"https://github.com/JuliaLang/julia","homepage":"http://julialang.org/","size":215190,"stargazers_count":5612,"watchers_count":5612,"language":"Julia","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1178,"mirror_url":null,"open_issues_count":1292,"forks":1178,"open_issues":1292,"watchers":5612,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/6193"},"html":{"href":"https://github.com/JuliaLang/julia/pull/6193"},"issue":{"href":"https://api.github.com/repos/JuliaLang/julia/issues/6193"},"comments":{"href":"https://api.github.com/repos/JuliaLang/julia/issues/6193/comments"},"review_comments":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/6193/comments"},"review_comment":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/6193/commits"},"statuses":{"href":"https://api.github.com/repos/JuliaLang/julia/statuses/1962796452f85a01f66fa9715bba04eb2ef69704"}}}}