Skip to content

Commit

Permalink
Merge pull request #248 from JuliaReach/schillic/length
Browse files Browse the repository at this point in the history
Use eachindex instead of 1:length
  • Loading branch information
schillic authored Mar 19, 2024
2 parents 9356e6b + dceb7d7 commit d5b4d07
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/affine.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,18 @@ struct AffineIntervalMatrix{T,IT,MT0<:AbstractMatrix{T},MT<:AbstractMatrix{T},
end

IndexStyle(::Type{<:AffineIntervalMatrix}) = IndexLinear()

size(M::AffineIntervalMatrix) = size(M.A0)

function getindex(M::AffineIntervalMatrix, i::Int)
return getindex(M.A0, i) + sum(M.λ[k] * getindex(M.A[k], i) for k in eachindex(M.λ))
end

function setindex!(M::AffineIntervalMatrix{T}, X::T, inds...) where {T}
setindex!(M.A0, X, inds...)
@inbounds for k in 1:length(M.A)
@inbounds for k in eachindex(M.A)
setindex!(M.A[k], zero(T), inds...)
end
end

copy(M::AffineIntervalMatrix) = AffineIntervalMatrix(copy(M.A0), copy(M.A), M.λ)

0 comments on commit d5b4d07

Please sign in to comment.