Hey!
I started having a deeper look at the code. I tried this first fix:
function xcorr_fix(u, v)
su = size(u, 1)
sv = size(v, 1)
if su < sv
# if u is a SubArray this will changes its type:
# u = [u; zeros(eltype(u),sv-su)]
# This avoids type instability, but forces array copy:
U = [u; zeros(eltype(u), sv - su)]
elseif sv < su
# See above:
V = [v; zeros(eltype(v), su - sv)]
else
U = collect(u)
V = collect(v)
end
flipdim(conv(flipdim(U, 1), V), 1)
end
This appears to be somewhat effective, but there are few problems:
- It defeats the purpose of passing views to the function, as a copy of
the parent arrays is performed. Is that right?
- Passing SubArrays to conv() seems to produce type instability of p and
y variables.
Which makes me think that first conv() should be fixed (maybe adding a
method for the Real signals case?). Second, I feel like views should be
allowed to go all the way to fft() in order to have a performance boost by
using them. Is there any way to append elements through SubArrays? I tried
append!(), insert!() and push!() but none worked... Maybe I could overwrite
to the input SubArrays new SubArrays of this kind?
sub([u.parent; zeros(whatever_pad_length)], :, 1)
I guess I will make more experiments to get comfortable with SubArrays. Any
suggestion is welcome!