Vectorize a function on a specific argument
If you're looking to extend functions where you want only the second arg vectorized, this should do it:
macro vectorize_on_2nd(S, f)
S = esc(S); f = esc(f); N = esc(:N)
quote
($f){$N}(a, x::AbstractArray{$S, $N}) =
reshape([($f)(a, x[i]) for i in eachindex(x)], size(x))
end
end
Used like this:
@vectorize_on_2nd Int64 myfunc
That should give you a myfunc{N}(::Any, ::AbstractArray{Int64,N})
method.