My code has many operations on small matrices and vectors.  In Julia 0.4, 
carrying these out with subvector operations causes a needless heap 
allocation, so I've done them all with loops.  In other words, instead of 
    nr = norm(x[p:p+2])

I write

    nr = 0.0
    for j = p : p + 2
        nr += x[j]^2
    end
    nr = sqrt(nr)

I've also used the Einsum.jl macro package, which implicitly writes the 
loops.

My question is: do the new broadcast and generator-comprehension operations 
available in 0.5 or 0.6 make it possible to accomplish these small 
operations using one-line solutions that don't allocate heap memory? 

Here are some other examples of operations for which I would like efficient 
one-liners:
    
     t = dot(v[p:p+3], w[p:p+3]) 
     c += A[p:p+2, q:q+2] * v[q:q+2]  # "gaxpy"; c is a length-3 vector

Thanks,
Steve Vavasis

Reply via email to