Skip to content

Commit

Permalink
Close issue #285.
Browse files Browse the repository at this point in the history
Allocate the result of the right shape where it is allocated in
the fftw_transpose itself, as Jeff suggested.
  • Loading branch information
Viral B. Shah committed Dec 6, 2011
1 parent f9bc9e2 commit 6cd4d36
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion j/array.j
Expand Up @@ -110,7 +110,7 @@ convert{T,n,S}(::Type{Array{T,n}}, x::Array{S,n}) = copy_to(similar(x,T), x)

function transpose{T<:Union(Float64,Float32,Complex128,Complex64)}(A::Matrix{T})
if numel(A) > 50000
return _jl_fftw_transpose(reshape(A, size(A, 2), size(A, 1)))
return _jl_fftw_transpose(A)
else
return [ A[j,i] | i=1:size(A,2), j=1:size(A,1) ]
end
Expand Down
4 changes: 2 additions & 2 deletions j/signal_fftw.j
Expand Up @@ -235,8 +235,8 @@ end
macro jl_transpose_real_macro(libname, fname, eltype)
quote
function _jl_fftw_transpose(X::Matrix{$eltype})
P = similar(X)
(n1, n2) = size(X)
P = similar(X, n2, n1)
plan = ccall(dlsym($libname, $fname), Ptr{Void},
(Int32, Ptr{Int32}, Int32, Ptr{Int32}, Ptr{$eltype}, Ptr{$eltype}, Ptr{Int32}, Uint32),
int32(0), C_NULL, int32(2),int32([n1,n2,1,n2,1,n1]), X, P, [_jl_FFTW_HC2R], _jl_FFTW_ESTIMATE | _jl_FFTW_PRESERVE_INPUT)
Expand All @@ -253,8 +253,8 @@ end
macro jl_transpose_complex_macro(libname, fname, celtype)
quote
function _jl_fftw_transpose(X::Matrix{$celtype})
P = similar(X)
(n1, n2) = size(X)
P = similar(X, n2, n1)
plan = ccall(dlsym($libname, $fname), Ptr{Void},
(Int32, Ptr{Int32}, Int32, Ptr{Int32}, Ptr{$celtype}, Ptr{$celtype}, Int32, Uint32),
int32(0), C_NULL, int32(2),int32([n1,n2,1,n2,1,n1]), X, P, _jl_FFTW_FORWARD, _jl_FFTW_ESTIMATE | _jl_FFTW_PRESERVE_INPUT)
Expand Down

0 comments on commit 6cd4d36

Please sign in to comment.