File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3535 cart2pol,
3636 sph2cart,
3737 pol2cart,
38- getnodes
38+ getnodes,
39+ increment_index,
40+ decrement_index
3941
4042"""
4143 svector(f,n)
@@ -432,4 +434,27 @@ function weight(x::T) where {T}
432434 end
433435end
434436
437+ """
438+ increment_index(I::CartesianIndex,k[,n=1])
439+
440+ Increment `I` by `n` along the dimension `k`. This is equivalent to `I +=
441+ n*eₖ`, where `eₖ` is a vector with with `1` at the `k`-th coordinate and zeros elsewhere.
442+ """
443+ function increment_index (I:: CartesianIndex ,dim:: Integer ,nb:: Integer = 1 )
444+ N = length (I)
445+ @assert 1 ≤ dim ≤ length (I)
446+ return I + CartesianIndex (ntuple (i -> i== dim ? nb : 0 ,N))
447+ end
448+
449+ """
450+ decrement_index(I::CartesianIndex,k[,n=1])
451+
452+ Equivalent to [`increment_index`](@ref)(I,k,-n)
453+ """
454+ function decrement_index (I:: CartesianIndex ,dim:: Integer ,nb:: Integer = 1 )
455+ N = length (I)
456+ @assert 1 ≤ dim ≤ length (I)
457+ return I + CartesianIndex (ntuple (i -> i== dim ? - nb : 0 ,N))
458+ end
459+
435460end # module
You can’t perform that action at this time.
0 commit comments