Hi Simon,
Simon Danisch writes:
> There is a speed difference, which you can see beautifully like this:
>
> function _sum{T}(::Type{T}, A)
> r = zero(T)
> @inbounds for i in eachindex(A)
> r += T(A[i])
> end
> r
> end
>
great, thanks. My machine seems to be way slower that yours or either I
run
There is a speed difference, which you can see beautifully like this:
function _sum{T}(::Type{T}, A)
r = zero(T)
@inbounds for i in eachindex(A)
r += T(A[i])
end
r
end
@code_llvm _sum(Int, rand(Int64, 10^6)) -> uses <4,Int64> vectors
@code_llvm _sum(Int, rand(Int32, 10^6)
Hi,
Ismael Venegas Castelló writes:
> julia> Base.sum{T<:Real, S<:Real}(::Type{T}, xs::Range{S})::T = sum(xs)
> julia> r = 1:100; sum(r), sum(Int32, r)
thanks for this, but as I understand it, for my particular case in which
I'm interested in working with 32bits Integers this would be similar t
You can do something like this:
C:\Users\Ismael
λ julia5
_
Hi Simon,
Simon Danisch writes:
> I'm guessing that is done to prevent overflow.
> So you need to use your own implementation.
> Here are the promote rules defining this behavior:
> https://github.com/JuliaLang/julia/blob/master/base/reduce.jl#L32
> So in theory you could also implement your ow
I'm guessing that is done to prevent overflow.
So you need to use your own implementation.
Here are the promote rules defining this behavior:
https://github.com/JuliaLang/julia/blob/master/base/reduce.jl#L32
So in theory you could also implement your own Int type, that has a
different promote beh