I'd argue that this should work:

julia> rand(4,4)*(1:4)
ERROR: MethodError: `A_mul_B!` has no method matching 
A_mul_B!(::Array{Float64,1}, ::Array{Float64,2}, ::UnitRange{Int64})

i.e. ranges should be equivalent to column vectors.  But others more
knowledgeable on the linear algebra code may have a different opinion.
If you don't get more feedback here then please file an issue.

Not sure whether there should also be a row-range, instead of:

julia> (1:4)'
1x4 Array{Int64,2}:
 1  2  3  4


On Tue, 2015-10-20 at 19:49, Gabriel Gellner <gabrielgell...@gmail.com> wrote:
> I find the way that you need to use `linspace` and `range` objects a bit
> jarring for when you want to write vectorized code, or when I want to pass
> an array to a function that requires an Array. I get how nice the iterators
> are when writing loops and that you can use `collect(iter)` to get a array
> (and that it is possible to write polymorphic code that takes LinSpace
> types and uses them like Arrays … but this hurts my small brain). But I
> find I that I often want to write code that uses an actual array and having
> to use `collect` all the time seems like a serious wart for an otherwise
> stunning language for science. (
> https://github.com/JuliaLang/julia/issues/9637 gives the evolution I think
> of making these iterators)
>
>
>
> For example recently the following code was posted/refined on this mailing
> list:
>
>
>
> function Jakes_Flat( fd, Ts, Ns, t0 = 0, E0 = 1, phi_N = 0 )
>
> # Inputs:
>
> #
>
> # Outputs:
>
>   N0  = 8;                  # As suggested by Jakes
>
>   N   = 4*N0+2;             # An accurate approximation
>
>   wd  = 2*pi*fd;            # Maximum Doppler frequency
>
>   t   = t0 + [0:Ns-1;]*Ts;
>
>   tf  = t[end] + Ts;
>
>   coswt = [ sqrt(2)*cos(wd*t'); 2*cos(wd*cos(2*pi/N*[1:N0;])*t') ]
>
>   temp = zeros(1,N0+1)
>
>   temp[1,2:end] = pi/(N0+1)*[1:N0;]'
>
>   temp[1,1] = phi_N
>
>   h = E0/sqrt(2*N0+1)*exp(im*temp ) * coswt
>
>   return h, tf;
>
> end
>
>
>
> From <https://groups.google.com/forum/#!topic/julia-users/_lIVpV0e_WI>
>
>
>
> Notice all the horrible [<blah>;] notations to make these arrays … and it
> seems like the devs want to get rid of this notation as well (which they
> should it is way too subtle in my opinion). So imagine the above code with
> `collect` statements. Is this the way people work? I find the `collect`
> statements in mathematical expressions to really break me out of the
> abstraction (that I am just writing math).
>
>
>
> I get that this could be written as an explicit loop, and this would likely
> make it faster as well (man I love looping in Julia). That being said in
> this case I don't find the vectorized version a performance issue, rather I
> prefer how this reads as it feels closer to the math to me.
>
>
>
> So my question: what is the Juilan way of making explicit arrays using
> either `range (:)` or `linspace`? Is it to pollute everything with
> `collect`? Would it be worth having versions of linspace that return an
> actual array? (something like alinspace or whatnot)
>
>
> Thanks for any tips, comments etc

Reply via email to