Skip to content

Commit de33244

Browse files
committed
Add parent-type as parameter of normal operator
Change default weights to nothing, s.t. we can dispatch on them. opEye is just LinearOperator
1 parent e54bba2 commit de33244

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

src/LinearOperatorCollection.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ abstract type DCTOp{T} <: AbstractLinearOperatorFromCollection{T} end
3939
abstract type DSTOp{T} <: AbstractLinearOperatorFromCollection{T} end
4040
abstract type NFFTOp{T} <: AbstractLinearOperatorFromCollection{T} end
4141
abstract type SamplingOp{T} <: AbstractLinearOperatorFromCollection{T} end
42-
abstract type NormalOp{T} <: AbstractLinearOperatorFromCollection{T} end
42+
abstract type NormalOp{T,S} <: AbstractLinearOperatorFromCollection{T} end
4343
abstract type GradientOp{T} <: AbstractLinearOperatorFromCollection{T} end
4444
abstract type RadonOp{T} <: AbstractLinearOperatorFromCollection{T} end
4545

src/NormalOp.jl

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,15 @@ Computes `adjoint(parent) * weights * parent`.
1616
* `weights` - Optional weights for normal operator. Must already be of form `weights = adjoint.(w) .* w`
1717
1818
"""
19-
function LinearOperatorCollection.NormalOp(::Type{T}; parent, weights = opEye(eltype(parent), size(parent, 1), S = storage_type(parent))) where T <: Number
19+
function LinearOperatorCollection.NormalOp(::Type{T}; parent, weights = nothing) where T <: Number
2020
return NormalOp(T, parent, weights)
2121
end
2222

23-
function NormalOp(::Type{T}, parent, ::Nothing) where T
24-
weights = opEye(eltype(parent), size(parent, 1), S = storage_type(parent))
25-
return NormalOp(T, parent, weights)
26-
end
2723
NormalOp(::Union{Type{T}, Type{Complex{T}}}, parent, weights::AbstractVector{T}) where T = NormalOp(T, parent, WeightingOp(weights))
2824

2925
NormalOp(::Union{Type{T}, Type{Complex{T}}}, parent, weights::AbstractLinearOperator{T}; kwargs...) where T = NormalOpImpl(parent, weights)
3026

31-
mutable struct NormalOpImpl{T,S,D,V} <: NormalOp{T}
27+
mutable struct NormalOpImpl{T,S,D,V} <: NormalOp{T, S}
3228
nrow :: Int
3329
ncol :: Int
3430
symmetric :: Bool
@@ -63,6 +59,11 @@ function NormalOpImpl(parent, weights, tmp)
6359
mul!(tmp, weights, tmp) # This can be dangerous. We might need to create two tmp vectors
6460
return mul!(y, adjoint(parent), tmp)
6561
end
62+
function produ!(y, parent, weights::Nothing, tmp, x)
63+
mul!(tmp, parent, x)
64+
return mul!(y, adjoint(parent), tmp)
65+
end
66+
6667

6768
return NormalOpImpl{eltype(parent), typeof(parent), typeof(weights), typeof(tmp)}(size(parent,2), size(parent,2), false, false
6869
, (res,x) -> produ!(res, parent, weights, tmp, x)
@@ -81,6 +82,6 @@ end
8182
8283
Constructs a normal operator of the parent in an opinionated way, i.e. it tries to apply optimisations to the resulting operator.
8384
"""
84-
function normalOperator(parent, weights=opEye(eltype(parent), size(parent, 1), S= storage_type(parent)); kwargs...)
85+
function normalOperator(parent, weights=nothing; kwargs...)
8586
return NormalOp(eltype(storage_type((parent))); parent = parent, weights = weights)
8687
end

src/ProdOp.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ end
126126
Fuses weights of `ẀeightingOp` by computing `adjoint.(weights) .* weights`
127127
"""
128128
normalOperator(S::ProdOp{T, <:WeightingOp, matT}; kwargs...) where {T, matT} = normalOperator(S.B, WeightingOp(adjoint.(S.A.weights) .* S.A.weights); kwargs...)
129-
function normalOperator(S::ProdOp, W=opEye(eltype(S),size(S,1), S = storage_type(S)); kwargs...)
129+
function normalOperator(S::ProdOp, W=nothing; kwargs...)
130130
arrayType = storage_type(S)
131131
tmp = arrayType(undef, size(S.A, 2))
132132
return ProdNormalOp(S.B, normalOperator(S.A, W; kwargs...), tmp)

0 commit comments

Comments
 (0)