Mercurial > repos > public > sbplib_julia
comparison RegionIndices/src/RegionIndices.jl @ 277:21e5c1dd6794 boundary_conditions
Add getindex-function for region indices. Update LazyArray tests. NOTE: Not sure if this is the way to go.
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Mon, 06 Jan 2020 12:08:00 +0100 |
parents | 11010bb74260 |
children |
comparison
equal
deleted
inserted
replaced
276:e3611c2181bc | 277:21e5c1dd6794 |
---|---|
29 Base.convert(::Type{T}, i::Index{R,T} where R) where T = i.i | 29 Base.convert(::Type{T}, i::Index{R,T} where R) where T = i.i |
30 Base.convert(::Type{CartesianIndex}, I::NTuple{N,Index} where N) = CartesianIndex(convert.(Int, I)) | 30 Base.convert(::Type{CartesianIndex}, I::NTuple{N,Index} where N) = CartesianIndex(convert.(Int, I)) |
31 | 31 |
32 Base.Int(I::Index) = I.i | 32 Base.Int(I::Index) = I.i |
33 Base.to_index(I::Index) = Int(I) #How to get this to work for all cases?? | 33 Base.to_index(I::Index) = Int(I) #How to get this to work for all cases?? |
34 Base.getindex(A::AbstractArray{T,N}, I::NTuple{N,Index}) where {T,N} = A[I...] #Is this ok?? | |
34 | 35 |
35 function Index(i::Integer, boundary_width::Integer, dim_size::Integer) | 36 function Index(i::Integer, boundary_width::Integer, dim_size::Integer) |
36 return Index{getregion(i,boundary_width,dim_size)}(i) | 37 return Index{getregion(i,boundary_width,dim_size)}(i) |
37 end | 38 end |
38 | 39 |