JuliaLang/julia

Unconsistent result when using sum or mean function on Complex{Int8} array

Aberta

#15.523 aberto em 15 de mar. de 2016

 (8 comentários) (0 reação) (0 responsável)Julia (5.773 forks)batch import
complexfoldgood first issuemaths

Métricas do repositório

Stars
 (48.709 estrelas)
Métricas de merge de PR
 (Mesclagem média 20d 6h) (157 fundiu PRs em 30d)

Description

When using Complex{Int8} arrays, the functions sum and mean do not make proper type conversion to avoid nasty things :

julia> b = ones(Complex{Int8}, 100000) ;

julia> sum(b)
-96 + 0im

julia> mean(b)
-0.00096 + 0.0im

That seems unconsistent with the behaviour of the same functions on Int8 arrays :

julia> a = ones(Int8, 100000) ;

julia> sum(a)
100000

julia> mean(a)
1.0

Guia do colaborador