From efe35c9681f2ef854a4a3be1d7c49efc1b8eb99c Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Mon, 11 Mar 2024 12:35:47 -0400 Subject: [PATCH 1/9] add RCpair copy! for complex --- src/RFFT.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/RFFT.jl b/src/RFFT.jl index 8ff8194..100e2b4 100644 --- a/src/RFFT.jl +++ b/src/RFFT.jl @@ -28,6 +28,7 @@ RCpair(A::Array{T}, region=1:ndims(A)) where {T<:AbstractFloat} = copy!(RCpair{T real(RC::RCpair) = RC.R complex(RC::RCpair) = RC.C +copy!(RC::RCpair, A::AbstractArray{T}) where {T<:Complex} = (copy!(RC.C, A); RC) copy!(RC::RCpair, A::AbstractArray{T}) where {T<:Real} = (copy!(RC.R, A); RC) function copy(RC::RCpair{T,N}) where {T,N} C = copy(RC.C) From cc803725e8487698fe79ed3e784543a74a57b3c7 Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Mon, 11 Mar 2024 12:42:18 -0400 Subject: [PATCH 2/9] version bump --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index ea546e3..4af3085 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "RFFT" uuid = "3bd9afcd-55df-531a-9b34-dc642dce7b95" authors = ["Tim Holy "] -version = "0.1.0" +version = "0.1.1" [deps] FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341" From b4789c73f11a522735d2ca8e5e269610060e259e Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Mon, 11 Mar 2024 15:27:30 -0400 Subject: [PATCH 3/9] Update CI.yml --- .github/workflows/CI.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 1725041..c9146c5 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -13,10 +13,13 @@ jobs: fail-fast: false matrix: version: - - '1.1' -# - 'nightly' + - '1.6' + - '1' + - 'nightly' os: - ubuntu-latest + - windows-latest + - macOS-latest arch: - x64 steps: From e32a9e38790d30ea747bbe88e3f5fdebb45c9283 Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Fri, 15 Mar 2024 09:59:01 -0400 Subject: [PATCH 4/9] remove deprecated func --- src/RFFT.jl | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/RFFT.jl b/src/RFFT.jl index 100e2b4..ebcceb4 100644 --- a/src/RFFT.jl +++ b/src/RFFT.jl @@ -70,6 +70,4 @@ function irfft!(RC::RCpair{T}) where T return RC end -@deprecate RCpair(realtype::Type{T}, realsize, region=1:length(realsize)) where T<:AbstractFloat RCpair{T}(undef, realsize, region) - end From 0288603b964fe7879ae42ec0fd901cdd2291a61d Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Fri, 15 Mar 2024 10:00:07 -0400 Subject: [PATCH 5/9] `region` -> `dims` --- src/RFFT.jl | 32 ++++++++++++++++---------------- test/runtests.jl | 4 ++-- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/RFFT.jl b/src/RFFT.jl index ebcceb4..1a3ab59 100644 --- a/src/RFFT.jl +++ b/src/RFFT.jl @@ -9,21 +9,21 @@ import Base: real, complex, copy, copy! mutable struct RCpair{T<:AbstractFloat,N,RType<:AbstractArray{T,N},CType<:AbstractArray{Complex{T},N}} R::RType C::CType - region::Vector{Int} + dims::Vector{Int} end -function RCpair{T}(::UndefInitializer, realsize::Dims{N}, region=1:length(realsize)) where {T<:AbstractFloat,N} +function RCpair{T}(::UndefInitializer, realsize::Dims{N}, dims=1:length(realsize)) where {T<:AbstractFloat,N} sz = [realsize...] - firstdim = region[1] + firstdim = dims[1] sz[firstdim] = realsize[firstdim]>>1 + 1 sz2 = copy(sz) sz2[firstdim] *= 2 R = Array{T,N}(undef, (sz2...,)::Dims{N}) C = unsafe_wrap(Array, convert(Ptr{Complex{T}}, pointer(R)), (sz...,)::Dims{N}) # work around performance problems of reinterpretarray - RCpair(view(R, map(n->1:n, realsize)...), C, [region...]) + RCpair(view(R, map(n->1:n, realsize)...), C, [dims...]) end -RCpair(A::Array{T}, region=1:ndims(A)) where {T<:AbstractFloat} = copy!(RCpair{T}(undef, size(A), region), A) +RCpair(A::Array{T}, dims=1:ndims(A)) where {T<:AbstractFloat} = copy!(RCpair{T}(undef, size(A), dims), A) real(RC::RCpair) = RC.R complex(RC::RCpair) = RC.C @@ -33,16 +33,16 @@ copy!(RC::RCpair, A::AbstractArray{T}) where {T<:Real} = (copy!(RC.R, A); RC) function copy(RC::RCpair{T,N}) where {T,N} C = copy(RC.C) R = reshape(reinterpret(T, C), size(parent(RC.R))) - RCpair(view(R, RC.R.indices...), C, copy(RC.region)) + RCpair(view(R, RC.R.indices...), C, copy(RC.dims)) end # New API -rplan_fwd(R, C, region, flags, tlim) = - FFTW.rFFTWPlan{eltype(R),FFTW.FORWARD,true,ndims(R)}(R, C, region, flags, tlim) -rplan_inv(R, C, region, flags, tlim) = - FFTW.rFFTWPlan{eltype(R),FFTW.BACKWARD,true,ndims(R)}(R, C, region, flags, tlim) +rplan_fwd(R, C, dims, flags, tlim) = + FFTW.rFFTWPlan{eltype(R),FFTW.FORWARD,true,ndims(R)}(R, C, dims, flags, tlim) +rplan_inv(R, C, dims, flags, tlim) = + FFTW.rFFTWPlan{eltype(R),FFTW.BACKWARD,true,ndims(R)}(R, C, dims, flags, tlim) function plan_rfft!(RC::RCpair{T}; flags::Integer = FFTW.ESTIMATE, timelimit::Real = FFTW.NO_TIMELIMIT) where T - p = rplan_fwd(RC.R, RC.C, RC.region, flags, timelimit) + p = rplan_fwd(RC.R, RC.C, RC.dims, flags, timelimit) return Z::RCpair -> begin FFTW.assert_applicable(p, Z.R, Z.C) FFTW.unsafe_execute!(p, Z.R, Z.C) @@ -50,23 +50,23 @@ function plan_rfft!(RC::RCpair{T}; flags::Integer = FFTW.ESTIMATE, timelimit::Re end end function plan_irfft!(RC::RCpair{T}; flags::Integer = FFTW.ESTIMATE, timelimit::Real = FFTW.NO_TIMELIMIT) where T - p = rplan_inv(RC.C, RC.R, RC.region, flags, timelimit) + p = rplan_inv(RC.C, RC.R, RC.dims, flags, timelimit) return Z::RCpair -> begin FFTW.assert_applicable(p, Z.C, Z.R) FFTW.unsafe_execute!(p, Z.C, Z.R) - rmul!(Z.R, 1 / prod(size(Z.R)[Z.region])) + rmul!(Z.R, 1 / prod(size(Z.R)[Z.dims])) return Z end end function rfft!(RC::RCpair{T}) where T - p = rplan_fwd(RC.R, RC.C, RC.region, FFTW.ESTIMATE, FFTW.NO_TIMELIMIT) + p = rplan_fwd(RC.R, RC.C, RC.dims, FFTW.ESTIMATE, FFTW.NO_TIMELIMIT) FFTW.unsafe_execute!(p, RC.R, RC.C) return RC end function irfft!(RC::RCpair{T}) where T - p = rplan_inv(RC.C, RC.R, RC.region, FFTW.ESTIMATE, FFTW.NO_TIMELIMIT) + p = rplan_inv(RC.C, RC.R, RC.dims, FFTW.ESTIMATE, FFTW.NO_TIMELIMIT) FFTW.unsafe_execute!(p, RC.C, RC.R) - rmul!(RC.R, 1 / prod(size(RC.R)[RC.region])) + rmul!(RC.R, 1 / prod(size(RC.R)[RC.dims])) return RC end diff --git a/test/runtests.jl b/test/runtests.jl index 0bbfe8b..67ed555 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -2,9 +2,9 @@ import RFFT using Test, FFTW, LinearAlgebra @testset begin - for region in (1:2, 1, 2) + for dims in (1:2, 1, 2) for sz in ((5,6), (6,5)) - pair = RFFT.RCpair{Float64}(undef, sz, region) + pair = RFFT.RCpair{Float64}(undef, sz, dims) r = @inferred(real(pair)) c = @inferred(complex(pair)) b = rand(eltype(r), size(r)) From 4c363e5a2dc9ccb7de1e3449b51fab87627e259e Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Fri, 15 Mar 2024 10:00:59 -0400 Subject: [PATCH 6/9] breaking change version bump --- Project.toml | 2 +- REQUIRE | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) delete mode 100644 REQUIRE diff --git a/Project.toml b/Project.toml index 4af3085..643d33f 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "RFFT" uuid = "3bd9afcd-55df-531a-9b34-dc642dce7b95" authors = ["Tim Holy "] -version = "0.1.1" +version = "0.2.0" [deps] FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341" diff --git a/REQUIRE b/REQUIRE deleted file mode 100644 index 859ad46..0000000 --- a/REQUIRE +++ /dev/null @@ -1 +0,0 @@ -julia 0.7 From ecc00ba66923ff75a95289b06cdd9621177e9c88 Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Fri, 15 Mar 2024 10:43:16 -0400 Subject: [PATCH 7/9] fix PR coverage --- test/runtests.jl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/runtests.jl b/test/runtests.jl index 67ed555..f1fc32b 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,14 +1,16 @@ import RFFT using Test, FFTW, LinearAlgebra -@testset begin +@testset "RFFT.jl" begin for dims in (1:2, 1, 2) for sz in ((5,6), (6,5)) pair = RFFT.RCpair{Float64}(undef, sz, dims) + pair = RFFT.RCpair(pair, dims) # for coverage r = @inferred(real(pair)) c = @inferred(complex(pair)) b = rand(eltype(r), size(r)) copyto!(r, b) + copyto!(r, c) # for coverage RFFT.rfft!(pair) RFFT.irfft!(pair) @test r ≈ b From e04592d4263ee158b1159e58f0a932ab9c485fec Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Fri, 15 Mar 2024 11:00:00 -0400 Subject: [PATCH 8/9] fixes --- .gitignore | 2 ++ src/RFFT.jl | 2 +- test/runtests.jl | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1d1d02a --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ + +Manifest.toml diff --git a/src/RFFT.jl b/src/RFFT.jl index 1a3ab59..93eee73 100644 --- a/src/RFFT.jl +++ b/src/RFFT.jl @@ -28,8 +28,8 @@ RCpair(A::Array{T}, dims=1:ndims(A)) where {T<:AbstractFloat} = copy!(RCpair{T}( real(RC::RCpair) = RC.R complex(RC::RCpair) = RC.C -copy!(RC::RCpair, A::AbstractArray{T}) where {T<:Complex} = (copy!(RC.C, A); RC) copy!(RC::RCpair, A::AbstractArray{T}) where {T<:Real} = (copy!(RC.R, A); RC) +copy!(RC::RCpair, A::AbstractArray{T}) where {T<:Complex} = (copy!(RC.C, A); RC) function copy(RC::RCpair{T,N}) where {T,N} C = copy(RC.C) R = reshape(reinterpret(T, C), size(parent(RC.R))) diff --git a/test/runtests.jl b/test/runtests.jl index f1fc32b..e049cd2 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -5,12 +5,12 @@ using Test, FFTW, LinearAlgebra for dims in (1:2, 1, 2) for sz in ((5,6), (6,5)) pair = RFFT.RCpair{Float64}(undef, sz, dims) - pair = RFFT.RCpair(pair, dims) # for coverage r = @inferred(real(pair)) c = @inferred(complex(pair)) b = rand(eltype(r), size(r)) + pair = RFFT.RCpair(b, dims) copyto!(r, b) - copyto!(r, c) # for coverage + copy!(pair, c) # for coverage RFFT.rfft!(pair) RFFT.irfft!(pair) @test r ≈ b From 88907947b2ddcd65e6dd869a366d4d642e4ce515 Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Mon, 29 Apr 2024 09:12:54 -0400 Subject: [PATCH 9/9] suggestions --- .github/workflows/CI.yml | 1 - Project.toml | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index c9146c5..fe17277 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -15,7 +15,6 @@ jobs: version: - '1.6' - '1' - - 'nightly' os: - ubuntu-latest - windows-latest diff --git a/Project.toml b/Project.toml index 643d33f..b874d36 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "RFFT" uuid = "3bd9afcd-55df-531a-9b34-dc642dce7b95" authors = ["Tim Holy "] -version = "0.2.0" +version = "1.0.0" [deps] FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"