Yeah Julia wins¡¡  :) Thanks for fast reply and the amazing open-source
language

pd : Is hard to reset the brain for devectorization ¡¡

pd2 : This part of code is the implementation of this paper(if anyone is
interested):

http://mortari.tamu.edu/k-vector/AAS%2000-128.pdf






2014-04-17 12:36 GMT-03:00 Steven G. Johnson <[email protected]>:

>
>
> On Thursday, April 17, 2014 11:24:44 AM UTC-4, El suisse wrote:
>>
>> function k_vector(s :: Array{Float64,1}, z :: Array{Float64,1})
>>     n = length(s)
>>     k = Int64[sum(s .< z[i]) for i = 2:n-1]
>>
>
>  This allocates a temporary array (to hold s .< z[i]) for each i.    To
> optimize this sort of code in Julia, you usually want to devectorize it and
> just write a loop:
>
> function k_vector2(s, z)
>     n = length(s)
>     k = Array(Int64, n-2)
>     for i = 2:n-1
>         c = 0
>         for j = 1:n
>             c += s[j] < z[i]
>         end
>         k[i-1] = c
>     end
>     return k
> end
>
> However, when benchmarking against Matlab, there is another thing to be
> careful of.  By default, many Matlab operations will use multiple threads
> if you have a multi-core machine.  To perform an apples-to-apples
> comparison of serial performance you should launch Matlab with the
> -singleCompThread option.
>
>
>

Reply via email to