Skip to content

Commit

Permalink
try to work on julia 1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
putianyi889 committed Jan 30, 2024
1 parent 1590104 commit e5c3c92
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
1 change: 1 addition & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
fail-fast: false
matrix:
version:
- '1.2'
- '1.3'
- '1.10'
- 'nightly'
Expand Down
32 changes: 21 additions & 11 deletions src/StencilRecurrences.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,36 @@ export StencilRecurrence, StencilRecurrencePlan
# Properties
For `coef` and `slicesupport`, tt's suggested to use lazy arrays for performance.
- `stencil::NTuple{S, CartesianIndex{N}}`: The relative index of the stencil. Can contain `(0,0)` (see `coef`)
- `coef::COEF<:NTuple{S,AbstractArray{T,N}}`: The coefficient associated with each relative index. The one associated with `CartesianIndex(0,0)` refers to a constant added to that entry. It's suggested to use lazy arrays for performance.
- `buffer::CircularArray{T,N,TB<:AbstractArray{T,N}}`: a buffer to store temp results.
- `coef::COEF`: The coefficient associated with each relative index. The one associated with `CartesianIndex(0,0)` refers to a constant added to that entry. It's suggested to use lazy arrays for performance.
- `buffer::CircularArray{T,N,TB}`: a buffer to store temp results.
- `slicestart::MVector{N, Int}` and `sliceend::MVector{N, Int}`: marks the current range of entries to be determined. Technically `NTuple{N-1, Int}` should work, but `Julia` doesn't support computed type parameters.
- `lastslice::Int`: marks the index of the slice where the recurrence terminates.
"""
struct StencilRecurrence{N, T, S, COEF<:NTuple{S,AbstractArray{T}}, TB<:AbstractArray{T,N}} <: AbstractLinearRecurrence{slicetype(TB)}
stencil::NTuple{S, CartesianIndex{N}}
coef::COEF
buffer::CircularArray{T,N,TB}
slicestart::MVector{N, Int}
sliceend::MVector{N, Int}
lastind::Int
if VERSION >= v"1.3"
struct StencilRecurrence{N, T, S, COEF<:NTuple{S,AbstractArray{T}}, TB<:AbstractArray{T,N}} <: AbstractLinearRecurrence{slicetype(TB)}
stencil::NTuple{S, CartesianIndex{N}}
coef::COEF
buffer::CircularArray{T,N,TB}
slicestart::MVector{N, Int}
sliceend::MVector{N, Int}
lastind::Int
end
else
struct StencilRecurrence{COEF<:NTuple{S,AbstractArray{T}}, TB<:AbstractArray{T,N}} <: AbstractLinearRecurrence{slicetype(TB)}
stencil::NTuple{S, CartesianIndex{N}}
coef::COEF
buffer::CircularArray{T,N,TB}
slicestart::MVector{N, Int}
sliceend::MVector{N, Int}
lastind::Int
end
end

"""
StencilRecurrencePlan{N, S, COEF<:NTuple{S,Function}, INIT<:Function} <: AbstractLinearRecurrencePlan
# Properties
- `stencil::SVector{S, CartesianIndex{N}}`: The relative index of the stencil. Can contain `(0,0)` (see `coef`)
- `stencil::NTuple{S, CartesianIndex{N}}`: The relative index of the stencil. Can contain `(0,0)` (see `coef`)
- `coef::COEF<:NTuple{S,Function}`: The coefficient associated with each relative index. The one associated with `CartesianIndex(0,0)` refers to a constant added to that entry. The functions should be in the form `f(I..., T)` where `I` is the index of the stencil and `T` is the suggested return type. Coefficients should be at least as accurate as `T`. Exact-value types such as `Irrational`, `Rational` or `Integer` would do the job, and if that's not possible, `BigFloat` would work as well.
- `init::INIT<:Function`: the function used for initial values. The functions should be in the form `f(I..., T)` where `I` is the size of the array and `T` is the eltype.
- `size::Dims{N}`: the size of the whole array.
Expand All @@ -45,7 +56,6 @@ struct StencilRecurrencePlan{N, S, COEF<:NTuple{S,Function}, INIT<:Function} <:
size::Dims{N}
offset::NTuple{N,Int}
end
#StencilRecurrencePlan(stencil::SVector{S, CartesianIndex{N}}, coef::SVector{S, Function}, init, size::Dims{N}, offset::CartesianIndex{N}) where {N,S} = StencilRecurrencePlan{N, S, typeof(init)}(stencil, coef, init, size, offset)
StencilRecurrencePlan(stencil, coef, init, size) = StencilRecurrencePlan(stencil, coef, init, size, -minimum(stencil))

size(P::StencilRecurrencePlan) = P.size
Expand Down

0 comments on commit e5c3c92

Please sign in to comment.