Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Normally, languages implement SIMD compilation for a specific set of data types/structures and even then you have to really make sure to ask the compiler nicely. Julia is able to vectorize any generic, user-defined data types/operators/functions. This comes at the cost of pretty horrid syntax. It needs extra syntax to give the compiler the information, for sure, but you can argue that it could have been chosen better.

  X .= f.(2 .* X.^2 .+ 6 .* X.^3 .- sqrt.(X))


Or just use @.

julia> X = [1.,2.,3.]; f=sin;

julia> @. X = f(2 * X^2 + 6 * X^3 - sqrt(X))




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: