Skip to content

Commit 8a82d79

Browse files
improve inuffts by factorizing Toeplitz before entering into cg
1 parent ae31986 commit 8a82d79

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/inufft.jl

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ Pre-computes an inverse nonuniform fast Fourier transform of type `N`.
33
44
For best performance, choose the right number of threads by `FFTW.set_num_threads(4)`, for example.
55
"""
6-
struct iNUFFTPlan{N,T,S,PT} <: Plan{T}
6+
struct iNUFFTPlan{N,T,S,PT,TF} <: Plan{T}
77
pt::PT
8-
TP::Toeplitz{T}
8+
TP::TF
99
r::Vector{T}
1010
p::Vector{T}
1111
Ap::Vector{T}
@@ -24,12 +24,12 @@ function plan_inufft1(ω::AbstractVector{T}, ϵ::T) where T<:AbstractFloat
2424
avg = (r[1]+c[1])/2
2525
r[1] = avg
2626
c[1] = avg
27-
TP = Toeplitz(c, r)
27+
TP = factorize(Toeplitz(c, r))
2828
r = zero(c)
2929
p = zero(c)
3030
Ap = zero(c)
3131

32-
iNUFFTPlan{1, eltype(TP), typeof(ϵ), typeof(pt)}(pt, TP, r, p, Ap, ϵ)
32+
iNUFFTPlan{1, eltype(TP), typeof(ϵ), typeof(pt), typeof(TP)}(pt, TP, r, p, Ap, ϵ)
3333
end
3434

3535
"""
@@ -43,12 +43,12 @@ function plan_inufft2(x::AbstractVector{T}, ϵ::T) where T<:AbstractFloat
4343
avg = (r[1]+c[1])/2
4444
r[1] = avg
4545
c[1] = avg
46-
TP = Toeplitz(c, r)
46+
TP = factorize(Toeplitz(c, r))
4747
r = zero(c)
4848
p = zero(c)
4949
Ap = zero(c)
5050

51-
iNUFFTPlan{2, eltype(TP), typeof(ϵ), typeof(pt)}(pt, TP, r, p, Ap, ϵ)
51+
iNUFFTPlan{2, eltype(TP), typeof(ϵ), typeof(pt), typeof(TP)}(pt, TP, r, p, Ap, ϵ)
5252
end
5353

5454

@@ -80,10 +80,8 @@ Computes an inverse nonuniform fast Fourier transform of type II.
8080
"""
8181
inufft2(c::AbstractVector, x::AbstractVector{T}, ϵ::T) where {T<:AbstractFloat} = plan_inufft2(x, ϵ)*c
8282

83-
function cg_for_inufft(A::ToeplitzMatrices.AbstractToeplitz{T}, x::AbstractVector{T}, b::AbstractVector{T}, r::AbstractVector{T}, p::AbstractVector{T}, Ap::AbstractVector{T}, max_it::Integer, tol::Real) where T
83+
function cg_for_inufft(A::ToeplitzMatrices.ToeplitzFactorization{T}, x::AbstractVector{T}, b::AbstractVector{T}, r::AbstractVector{T}, p::AbstractVector{T}, Ap::AbstractVector{T}, max_it::Integer, tol::Real) where T
8484
n = length(b)
85-
n1, n2 = size(A)
86-
n == n1 == n2 || throw(DimensionMismatch(""))
8785
nrmb = norm(b)
8886
if nrmb == 0 nrmb = one(typeof(nrmb)) end
8987
copyto!(x, b)

0 commit comments

Comments
 (0)