Skip to content

Commit

Permalink
Compat annotation for #29890 (broadcasting CartesianIndices).
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikekre committed Dec 1, 2018
1 parent 9d24268 commit 1f09597
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions base/multidimensional.jl
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,28 @@ module IteratorsMD
CartesianIndex(1, 2)
```
## Broadcasting
`CartesianIndices` support broadcasting arithmetic (+ and -) with a `CartesianIndex`.
!!! compat "Julia 1.1"
Broadcasting of CartesianIndices requires at least Julia 1.1.
```jldoctest
julia> CIs = CartesianIndices((2:3, 5:6))
2×2 CartesianIndices{2,Tuple{UnitRange{Int64},UnitRange{Int64}}}:
CartesianIndex(2, 5) CartesianIndex(2, 6)
CartesianIndex(3, 5) CartesianIndex(3, 6)
julia> CI = CartesianIndex(3, 4)
CartesianIndex(3, 4)
julia> CIs .+ CI
2×2 CartesianIndices{2,Tuple{UnitRange{Int64},UnitRange{Int64}}}:
CartesianIndex(5, 9) CartesianIndex(5, 10)
CartesianIndex(6, 9) CartesianIndex(6, 10)
```
For cartesian to linear index conversion, see [`LinearIndices`](@ref).
"""
struct CartesianIndices{N,R<:NTuple{N,AbstractUnitRange{Int}}} <: AbstractArray{CartesianIndex{N},N}
Expand Down

0 comments on commit 1f09597

Please sign in to comment.