JuliaLang/julia

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

开放

#15,523 创建于 2016年3月15日

 (8 条评论) (0 个反应) (0 位负责人)Julia (5,773 个派生)batch import
complexfoldgood first issuemaths

仓库指标

星标
 (48,709 个星标)
PR 合并指标
 (平均合并 20天 6小时) (30 天内合并 157 个 PR)

描述

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

贡献者指南