diff --git a/j/abstractarray.j b/j/abstractarray.j index 0a0e3465cd0c4..313683138e262 100644 --- a/j/abstractarray.j +++ b/j/abstractarray.j @@ -325,7 +325,7 @@ function hcat{T}(V::AbstractVector{T}...) for j = 2:length(V) if length(V[j]) != height; error("hcat: mismatched dimensions"); end end - [ V[j][i] | i=1:length(V[1]), j=1:length(V) ] + [ V[j][i]::T | i=1:length(V[1]), j=1:length(V) ] end function vcat{T}(V::AbstractVector{T}...) diff --git a/j/signal.j b/j/signal.j index f417ed13dba45..66c06990d0cb6 100644 --- a/j/signal.j +++ b/j/signal.j @@ -73,6 +73,22 @@ function conv{T}(u::Vector{T}, v::Vector{T}) return y end +function conv2{T}(y::Vector{T}, x::Vector{T}, A::Matrix{T}) + m = length(y)+size(A,1)-1 + n = length(x)+size(A,2)-1 + B = zeros(T, m, n) + B[1:size(A,1),1:size(A,2)] = A + y = fft([y;zeros(T,m-length(y))])./m + Y = repmat(reshape(y,m,1), 1, n) + x = fft([x;zeros(T,n-length(x))])./n + X = repmat(reshape(x,1,n), m, 1) + C = ifft2(fft(fft(B,(),2).*X,(),1).*Y) + if T <: Real + return real(C) + end + return C +end + function xcorr(u, v) su = size(u,1); sv = size(v,1) if su < sv