|
4 | 4 | module IteratorsMD
|
5 | 5 | import Base: eltype, length, size, start, done, next, last, in, getindex,
|
6 | 6 | setindex!, linearindexing, min, max, zero, one, isless, eachindex,
|
7 |
| - ndims, iteratorsize |
| 7 | + ndims, iteratorsize, convert |
8 | 8 |
|
9 | 9 | importall ..Base.Operators
|
10 | 10 | import Base: simd_outer_range, simd_inner_length, simd_index
|
@@ -88,6 +88,15 @@ module IteratorsMD
|
88 | 88 | CartesianRange{N}(rngs::NTuple{N,Union{Integer,AbstractUnitRange}}) =
|
89 | 89 | CartesianRange(CartesianIndex(map(first, rngs)), CartesianIndex(map(last, rngs)))
|
90 | 90 |
|
| 91 | + convert{N}(::Type{NTuple{N,UnitRange{Int}}}, R::CartesianRange{CartesianIndex{N}}) = |
| 92 | + map((f,l)->f:l, first(R).I, last(R).I) |
| 93 | + convert{N}(::Type{NTuple{N,UnitRange}}, R::CartesianRange) = |
| 94 | + convert(NTuple{N,UnitRange{Int}}, R) |
| 95 | + convert{N}(::Type{Tuple{Vararg{UnitRange{Int}}}}, R::CartesianRange{CartesianIndex{N}}) = |
| 96 | + convert(NTuple{N,UnitRange{Int}}, R) |
| 97 | + convert(::Type{Tuple{Vararg{UnitRange}}}, R::CartesianRange) = |
| 98 | + convert(Tuple{Vararg{UnitRange{Int}}}, R) |
| 99 | + |
91 | 100 | ndims(R::CartesianRange) = length(R.start)
|
92 | 101 | ndims{I<:CartesianIndex}(::Type{CartesianRange{I}}) = length(I)
|
93 | 102 |
|
|
0 commit comments