Skip to content

Commit 6b9d2cc

Browse files
Apply suggestions from code review
Co-authored-by: David Widmann <[email protected]>
1 parent 77e4cd1 commit 6b9d2cc

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/signalcorr.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,23 +63,23 @@ function autocov!(
6363
r::AbstractVector,
6464
x::AbstractVector,
6565
lags::AbstractVector{<:Integer},
66-
z=Vector{typeof(zero(eltype(x)) / 1)}(undef, size(x, 1));
66+
z::Vector=Vector{typeof(zero(eltype(x)) / 1)}(undef, length(x));
6767
demean::Bool=true
68-
)
68+
)
6969
lx = length(x)
7070
m = length(lags)
71-
length(r) == m || throw(DimensionMismatch())
71+
length(r) == length(z) == m || throw(DimensionMismatch())
7272
check_lags(lx, lags)
7373
demean ? z .= x .- mean(x) : copyto!(z, x)
74-
for k = 1 : m # foreach lag value
75-
r[k] = _autodot(z, lx, lags[k]) / lx
74+
@inbounds for (k, lags_k) in zip(eachindex(r), lags) # foreach lag value
75+
r[k] = _autodot(z, lx, lags_k) / lx
7676
end
7777
return r
7878
end
7979

8080
function autocov!(
8181
r::AbstractMatrix, x::AbstractMatrix, lags::AbstractVector{<:Integer}; demean::Bool=true
82-
)
82+
)
8383
T = typeof(zero(eltype(x)) / 1)
8484
z = Vector{T}(undef, size(x, 1))
8585
for n in 1:size(x, 2)

0 commit comments

Comments
 (0)