Bleh. I submitted my answer many hours ago, but since it was my first post 
ever, it had to go through an approval process. So now I look like some 
johnny-come-lately with my code :/

Mauro: This looks a lot like a bug to me. For example:
    julia> ones(4)' * (1:4)
    1-element Array{Float64,1}:
    10.0
But
    julia> x = ones(4)'; x * (1:4)
    ERROR: MethodError: `A_mul_B!` has no method matching 
    A_mul_B!(::Array{Float64,1}, ::Array{Float64,2}, ::UnitRange{Int64})

They should clearly give the same result. There is something seriously 
wrong with how ones(1,4)*(1:4) is dispatched, it even tries to call the 
mutating 3-arg version, A_mul_B!(!!)

If you feel strongly that you need a concrete Vector you can define
linvec(xs...) = collect(linspace(xs...))
and use that instead.

On the other hand, I do wish that Julia had kept the name 'linrange' and 
then defined linspace to be the vector version.

On Wednesday, October 21, 2015 at 7:03:05 PM UTC+2, DNF wrote:
>
> There is no need for doing collect or [  ;] most of the time. Whenever you 
> use a range as input to a vectorized function, like sin, it returns a 
> vector as expected.
>
> This code should do the same as the one you posted:
>
> function jakes_flat(fd, Ts, Ns, t0 = 0.0, E0 = 1.0, phi_N = 0.0)
>     N0 = 8
>     N = 4N0 + 2
>     wd = 2π * fd
>     t = t0 + (0:Ns-1) * Ts
>     tf = t[end] + Ts
>     coswt = [√2cos(wd*t)' ; 2cos(wd*cos(2π*(1:N0)/N)*t')]'
>     temp = [phi_N; π*(1:N0)/(N0+1)]
>     h = E0/√(2N0+1) * coswt * exp(im*temp)
>     return (h, tf)
> end
>
>
>

Reply via email to