Skip to content

Commit 2ea43f3

Browse files
committed
Generalise dual2array/array2dual for strided
1 parent aff09fa commit 2ea43f3

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

ext/AbstractFFTsForwardDiffExt.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import AbstractFFTs: Plan, mul!, dualplan, dual2array
99

1010
AbstractFFTs._fftfloat(::Type{Dual{T,V,N}}) where {T,V,N} = Dual{T,AbstractFFTs._fftfloat(V),N}
1111

12-
dual2array(x::Array{<:Dual{Tag,T}}) where {Tag,T} = reinterpret(reshape, T, x)
13-
dual2array(x::Array{<:Complex{<:Dual{Tag, T}}}) where {Tag,T} = complex.(dual2array(real(x)), dual2array(imag(x)))
14-
array2dual(DT::Type{<:Dual}, x::Array{T}) where T = reinterpret(reshape, DT, real(x))
15-
array2dual(DT::Type{<:Dual}, x::Array{<:Complex{T}}) where T = complex.(array2dual(DT, real(x)), array2dual(DT, imag(x)))
12+
dual2array(x::StridedArray{<:Dual{Tag,T}}) where {Tag,T} = reinterpret(reshape, T, x)
13+
dual2array(x::StridedArray{<:Complex{<:Dual{Tag, T}}}) where {Tag,T} = complex.(dual2array(real(x)), dual2array(imag(x)))
14+
array2dual(DT::Type{<:Dual}, x::StridedArray{T}) where T = reinterpret(reshape, DT, real(x))
15+
array2dual(DT::Type{<:Dual}, x::StridedArray{<:Complex{T}}) where T = complex.(array2dual(DT, real(x)), array2dual(DT, imag(x)))
1616

1717

1818
########

test/abstractfftsforwarddiff.jl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ complexpartials(x, k) = partials(real(x), k) + im*partials(imag(x), k)
3737
# emperical from Mathematical
3838
@test ForwardDiff.derivative-> fft(exp.(ω .* cos.(θ)))[1]/n, 1) 0.565159103992485
3939

40-
# c = x -> dct([x; 0; 0])[1]
41-
# @test derivative(c,0.1) ≈ 1
42-
4340
@testset "matrix" begin
4441
A = x1 * (1:10)'
4542
@test value.(fft(A)) == fft(value.(A))

0 commit comments

Comments
 (0)