Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "LinearOperatorCollection"
uuid = "a4a2c56f-fead-462a-a3ab-85921a5f2575"
authors = ["Tobias Knopp <tobias.knopp@tuhh.de> and contributors"]
version = "2.3.2"
version = "2.4"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down Expand Up @@ -31,7 +31,7 @@ KernelAbstractions = "0.9"
JLArrays = "0.2"
AbstractNFFTs = "0.9"
LinearAlgebra = "1"
LinearOperators = "2"
LinearOperators = "2.13"
OhMyThreads = "0.8"
NonuniformFFTs = "0.9"
NFFT = "0.14"
Expand All @@ -54,7 +54,7 @@ FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"
RadonKA = "86de8297-835b-47df-b249-c04e8db91db5"

[targets]
test = ["Test", "Aqua", "FFTW", "Wavelets", "NFFT", "NonuniformFFTs", "JLArrays", "RadonKA"]
test = ["Test", "Aqua", "FFTW", "Wavelets", "NFFT", "NonuniformFFTs", "RadonKA"]

[extensions]
LinearOperatorNFFTExt = ["AbstractNFFTs", "FFTW"]
Expand Down
33 changes: 15 additions & 18 deletions ext/LinearOperatorFFTWExt/DCTOp.jl
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
export DCTOpImpl

mutable struct DCTOpImpl{T} <: DCTOp{T}
nrow :: Int
ncol :: Int
symmetric :: Bool
hermitian :: Bool
prod! :: Function
tprod! :: Nothing
ctprod! :: Function
mutable struct DCTOpImpl{T, vecT, P} <: DCTOp{T}
const nrow :: Int
const ncol :: Int
const symmetric :: Bool
const hermitian :: Bool
const prod! :: Function
const tprod! :: Nothing
const ctprod! :: Function
nprod :: Int
ntprod :: Int
nctprod :: Int
args5 :: Bool
use_prod5! :: Bool
allocated5 :: Bool
Mv5 :: Vector{T}
Mtu5 :: Vector{T}
plan
dcttype::Int
Mv :: vecT
Mtu :: vecT
const plan :: P
const dcttype::Int
end

LinearOperators.storage_type(op::DCTOpImpl) = typeof(op.Mv5)
LinearOperators.storage_type(::DCTOpImpl{T, vecT}) where {T,vecT} = vecT

"""
DCTOpImpl(T::Type, shape::Tuple, dcttype=2)
Expand Down Expand Up @@ -50,9 +47,9 @@ function LinearOperatorCollection.DCTOp(T::Type; shape::Tuple, S = Array{T}, dct
error("DCT type $(dcttype) not supported")
end

return DCTOpImpl{T}(prod(shape), prod(shape), false, false,
return DCTOpImpl{T, S, typeof(plan)}(prod(shape), prod(shape), false, false,
prod!, nothing, tprod!,
0, 0, 0, true, false, true, T[], T[],
0, 0, 0, S(undef, 0), S(undef, 0),
plan, dcttype)
end

Expand Down
33 changes: 15 additions & 18 deletions ext/LinearOperatorFFTWExt/DSTOp.jl
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
export DSTOpImpl

mutable struct DSTOpImpl{T} <: DSTOp{T}
nrow :: Int
ncol :: Int
symmetric :: Bool
hermitian :: Bool
prod! :: Function
tprod! :: Nothing
ctprod! :: Function
mutable struct DSTOpImpl{T, vecT, P, IP} <: DSTOp{T}
const nrow :: Int
const ncol :: Int
const symmetric :: Bool
const hermitian :: Bool
const prod! :: Function
const tprod! :: Nothing
const ctprod! :: Function
nprod :: Int
ntprod :: Int
nctprod :: Int
args5 :: Bool
use_prod5! :: Bool
allocated5 :: Bool
Mv5 :: Vector{T}
Mtu5 :: Vector{T}
plan
iplan
Mv :: vecT
Mtu :: vecT
const plan :: P
const iplan :: IP
end

LinearOperators.storage_type(op::DSTOpImpl) = typeof(op.Mv5)
LinearOperators.storage_type(::DSTOpImpl{T, vecT}) where {T, vecT} = vecT

"""
DSTOp(T::Type, shape::Tuple)
Expand All @@ -39,11 +36,11 @@ function LinearOperatorCollection.DSTOp(T::Type; shape::Tuple, S = Array{T})

w = weights(shape, T)

return DSTOpImpl{T}(prod(shape), prod(shape), true, false
return DSTOpImpl{T, S, typeof(plan), typeof(iplan)}(prod(shape), prod(shape), true, false
, (res,x) -> dst_multiply!(res,plan,x,tmp,w)
, nothing
, (res,x) -> dst_bmultiply!(res,iplan,x,tmp,w)
, 0, 0, 0, true, false, true, T[], T[]
, 0, 0, 0, S(undef,0), S(undef, 0)
, plan
, iplan)
end
Expand Down
33 changes: 15 additions & 18 deletions ext/LinearOperatorFFTWExt/FFTOp.jl
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@
export FFTOpImpl

mutable struct FFTOpImpl{T, vecT, P <: AbstractFFTs.Plan{T}, IP <: AbstractFFTs.Plan{T}} <: FFTOp{T}
nrow :: Int
ncol :: Int
symmetric :: Bool
hermitian :: Bool
prod! :: Function
tprod! :: Nothing
ctprod! :: Function
const nrow :: Int
const ncol :: Int
const symmetric :: Bool
const hermitian :: Bool
const prod! :: Function
const tprod! :: Nothing
const ctprod! :: Function
nprod :: Int
ntprod :: Int
nctprod :: Int
args5 :: Bool
use_prod5! :: Bool
allocated5 :: Bool
Mv5 :: vecT
Mtu5 :: vecT
plan :: P
iplan :: IP
shift::Bool
unitary::Bool
Mv :: vecT
Mtu :: vecT
const plan :: P
const iplan :: IP
const shift::Bool
const unitary::Bool
end

LinearOperators.storage_type(op::FFTOpImpl) = typeof(op.Mv5)
LinearOperators.storage_type(::FFTOpImpl{T, vecT}) where {T,vecT} = vecT

"""
FFTOp(T::Type; shape::Tuple, shift=true, unitary=true)
Expand Down Expand Up @@ -60,7 +57,7 @@ function LinearOperatorCollection.FFTOp(T::Type; shape::NTuple{D,Int64}, shift::

return FFTOpImpl(prod(shape), prod(shape), false, false, (res, x) -> fun!(res, plan_, x, shape_, facF_, tmpVec_),
nothing, (res, x) -> fun!(res, iplan_, x, shape_, facB_, tmpVec_),
0, 0, 0, true, false, true, similar(tmpVec, 0), similar(tmpVec, 0), plan, iplan, shift, unitary)
0, 0, 0, similar(tmpVec, 0), similar(tmpVec, 0), plan, iplan, shift, unitary)
end
end

Expand Down
61 changes: 28 additions & 33 deletions ext/LinearOperatorNFFTExt/NFFTOp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,23 @@ function LinearOperatorCollection.NFFTOp(::Type{T};
end

mutable struct NFFTOpImpl{T, vecT, P} <: NFFTOp{T, P}
nrow :: Int
ncol :: Int
symmetric :: Bool
hermitian :: Bool
prod! :: Function
tprod! :: Nothing
ctprod! :: Function
const nrow :: Int
const ncol :: Int
const symmetric :: Bool
const hermitian :: Bool
const prod! :: Function
const tprod! :: Nothing
const ctprod! :: Function
nprod :: Int
ntprod :: Int
nctprod :: Int
args5 :: Bool
use_prod5! :: Bool
allocated5 :: Bool
Mv5 :: vecT
Mtu5 :: vecT
plan :: P
Mv :: vecT
Mtu :: vecT
const plan :: P
toeplitz :: Bool
end

LinearOperators.storage_type(op::NFFTOpImpl) = typeof(op.Mv5)
LinearOperators.storage_type(::NFFTOpImpl{T, vecT}) where {T, vecT} = vecT

function NFFTOpImpl(shape::Tuple, tr::AbstractMatrix{T}; toeplitz, oversamplingFactor, kernelSize, S = Vector{Complex{T}}, kargs...) where {T}

Expand All @@ -51,7 +48,7 @@ function NFFTOpImpl(shape::Tuple, tr::AbstractMatrix{T}; toeplitz, oversamplingF
, (res,x) -> produ!(res,plan,x)
, nothing
, (res,y) -> ctprodu!(res,plan,y)
, 0, 0, 0, false, false, false, S(undef, 0), S(undef, 0)
, 0, 0, 0, S(undef, 0), S(undef, 0)
, plan, toeplitz)
end

Expand All @@ -70,7 +67,7 @@ function Base.copy(S::NFFTOpImpl{T, vecT, P}) where {T, vecT, P}
, (res,x) -> produ!(res,plan,x)
, nothing
, (res,y) -> ctprodu!(res,plan,y)
, 0, 0, 0, false, false, false, vecT(undef, 0), vecT(undef, 0)
, 0, 0, 0, vecT(undef, 0), vecT(undef, 0)
, plan, S.toeplitz)
end

Expand All @@ -80,22 +77,19 @@ end
### Toeplitz Operator ###
#########################################################################

mutable struct NFFTToeplitzNormalOp{T,D,W, vecT <: AbstractVector{T}, matT <: AbstractArray{T, D}, P <: AbstractFFTs.Plan, IP <: AbstractFFTs.Plan} <: AbstractLinearOperator{T}
nrow :: Int
ncol :: Int
symmetric :: Bool
hermitian :: Bool
prod! :: Function
tprod! :: Nothing
ctprod! :: Nothing
mutable struct NFFTToeplitzNormalOp{T, vecT <: AbstractVector{T}, D,W, matT <: AbstractArray{T, D}, P <: AbstractFFTs.Plan, IP <: AbstractFFTs.Plan} <: AbstractLinearOperator{T}
const nrow :: Int
const ncol :: Int
const symmetric :: Bool
const hermitian :: Bool
const prod! :: Function
const tprod! :: Nothing
const ctprod! :: Nothing
nprod :: Int
ntprod :: Int
nctprod :: Int
args5 :: Bool
use_prod5! :: Bool
allocated5 :: Bool
Mv5 :: vecT
Mtu5 :: vecT
Mv :: vecT
Mtu :: vecT
shape::NTuple{D,Int}
weights::W
fftplan :: P
Expand All @@ -105,7 +99,7 @@ mutable struct NFFTToeplitzNormalOp{T,D,W, vecT <: AbstractVector{T}, matT <: Ab
xL2::matT
end

LinearOperators.storage_type(op::NFFTToeplitzNormalOp) = typeof(op.Mv5)
LinearOperators.storage_type(::NFFTToeplitzNormalOp{T, vecT}) where {T, vecT} = vecT

function LinearOperatorCollection.NFFTToeplitzNormalOp(shape, W, fftplan, ifftplan, λ, xL1::matT, xL2::matT) where {T, D, matT <: AbstractArray{T, D}}

Expand All @@ -126,14 +120,15 @@ function LinearOperatorCollection.NFFTToeplitzNormalOp(shape, W, fftplan, ifftpl
, (res,x) -> produ!(res, shape, fftplan, ifftplan, λ, xL1, xL2, x)
, nothing
, nothing
, 0, 0, 0, false, false, false, T[], T[]
, 0, 0, 0, T[], T[]
, shape, W, fftplan, ifftplan, λ, xL1, xL2)
end

# TODO: use vecT for toeplitz op
function LinearOperatorCollection.NFFTToeplitzNormalOp(nfft::NFFTOp{T}, W=nothing; kwargs...) where {T}
shape = size_in(nfft.plan)

tmpVec = similar(nfft.Mv5, (2 .* shape)...)
tmpVec = similar(nfft.Mv, (2 .* shape)...)
tmpVec .= zero(T)

# plan the FFTs
Expand Down Expand Up @@ -172,7 +167,7 @@ function LinearOperatorCollection.normalOperator(S::NFFTOpImpl{T}, W = nothing;
end
end

function Base.copy(A::NFFTToeplitzNormalOp{T,D,W}) where {T,D,W}
function Base.copy(A::NFFTToeplitzNormalOp{T,vecT,D,W}) where {T,vecT,D,W}
fftplan = plan_fft( zeros(T, 2 .* A.shape); flags=FFTW.MEASURE)
ifftplan = plan_ifft(zeros(T, 2 .* A.shape); flags=FFTW.MEASURE)
return LinearOperatorCollection.NFFTToeplitzNormalOp(A.shape, A.weights, fftplan, ifftplan, A.λ, copy(A.xL1), copy(A.xL2))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ module LinearOperatorNonuniformFFTsExt

using LinearOperatorCollection, AbstractNFFTs, NonuniformFFTs, NonuniformFFTs.Kernels, FFTW

function LinearOperatorCollection.NFFTToeplitzNormalOp(nfft::NFFTOp{T, P}, W=nothing; kwargs...) where {T, vecT, P <: NonuniformFFTs.NFFTPlan}
function LinearOperatorCollection.NFFTToeplitzNormalOp(nfft::NFFTOp{T, P}, W=nothing; kwargs...) where {T, P <: NonuniformFFTs.NFFTPlan}
shape = size_in(nfft.plan)

tmpVec = similar(nfft.Mv5, (2 .* shape)...)
tmpVec = similar(nfft.Mv, (2 .* shape)...)
tmpVec .= zero(T)

# plan the FFTs
Expand Down
31 changes: 14 additions & 17 deletions ext/LinearOperatorRadonKAExt/RadonOp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,24 @@ function LinearOperatorCollection.RadonOp(::Type{T}; shape::NTuple{N, Int}, angl
end

mutable struct RadonOpImpl{T, vecT <: AbstractVector{T}, vecT2, G, A} <: RadonOp{T}
nrow :: Int
ncol :: Int
symmetric :: Bool
hermitian :: Bool
prod! :: Function
tprod! :: Nothing
ctprod! :: Function
const nrow :: Int
const ncol :: Int
const symmetric :: Bool
const hermitian :: Bool
const prod! :: Function
const tprod! :: Nothing
const ctprod! :: Function
nprod :: Int
ntprod :: Int
nctprod :: Int
args5 :: Bool
use_prod5! :: Bool
allocated5 :: Bool
Mv5 :: vecT
Mtu5 :: vecT
angles :: vecT2
geometry :: G
μ :: A
Mv :: vecT
Mtu :: vecT
const angles :: vecT2
const geometry :: G
const μ :: A
end

LinearOperators.storage_type(op::RadonOpImpl) = typeof(op.Mv5)
LinearOperators.storage_type(::RadonOpImpl{T, vecT}) where {T, vecT} = vecT

function RadonOpImpl(T::Type; shape::NTuple{N, Int64}, angles, geometry, μ, S) where N
N_sinogram = length(geometry.in_height)
Expand All @@ -49,7 +46,7 @@ function RadonOpImpl(T::Type; shape::NTuple{N, Int64}, angles, geometry, μ, S)
(res, x) -> prod_radon!(res, x, shape, angles, geometry, μ),
nothing,
(res, x) -> ctprod_radon!(res, x, (N_sinogram, N_angles, d), angles, geometry, μ),
0, 0, 0, true, false, true, S(undef, 0), S(undef, 0), angles, geometry, μ)
0, 0, 0, S(undef, 0), S(undef, 0), angles, geometry, μ)
end

prod_radon!(res::vecT, x::vecT, shape, angles::vecT2, geometry::G, μ::A) where {vecT, vecT2, G, A} = copyto!(res, radon(reshape(x, shape), angles; geometry, μ))
Expand Down
Loading
Loading