Skip to content

Commit 271e92c

Browse files
committed
Fix for abstract eltype
1 parent 094ed9e commit 271e92c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/cov.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,10 @@ function cor2cov!(C::AbstractMatrix, s::AbstractArray)
164164
n = length(s)
165165
size(C) == (n, n) || throw(DimensionMismatch("inconsistent dimensions"))
166166
@inbounds for i in CartesianIndices(size(C))
167+
Ci = C[i]
167168
si = s[i[1]] * s[i[2]]
168169
# the covariance is 0 when si==0, although C[i] is NaN in this case
169-
C[i] = iszero(si) ? zero(eltype(C)) : C[i] * si
170+
C[i] = iszero(si) ? zero(Ci) : Ci * si
170171
end
171172
return C
172173
end

0 commit comments

Comments
 (0)