From e5c3c925e710844a67b84f464163f56a500e879e Mon Sep 17 00:00:00 2001 From: Tianyi Pu <912396513@qq.com> Date: Tue, 30 Jan 2024 18:04:05 +0000 Subject: [PATCH] try to work on julia 1.2 --- .github/workflows/CI.yml | 1 + src/StencilRecurrences.jl | 32 +++++++++++++++++++++----------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index ae2ff18..fe8f44a 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -23,6 +23,7 @@ jobs: fail-fast: false matrix: version: + - '1.2' - '1.3' - '1.10' - 'nightly' diff --git a/src/StencilRecurrences.jl b/src/StencilRecurrences.jl index 50d436e..85c53a0 100644 --- a/src/StencilRecurrences.jl +++ b/src/StencilRecurrences.jl @@ -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. @@ -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