Skip to content

Commit 29f9c1d

Browse files
committed
Change weight default for normalOperator for DiagOp and NFFTOp (Toeplitz)
1 parent 7da8dbc commit 29f9c1d

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

ext/LinearOperatorNFFTExt/NFFTOp.jl

+9-3
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ function NFFTToeplitzNormalOp(shape, W, fftplan, ifftplan, λ, xL1::matT, xL2::m
128128
, shape, W, fftplan, ifftplan, λ, xL1, xL2)
129129
end
130130

131-
function NFFTToeplitzNormalOp(nfft::NFFTOp{T}, W=opEye(eltype(nfft), size(nfft, 1), S= LinearOperators.storage_type(nfft)); kwargs...) where {T}
131+
function NFFTToeplitzNormalOp(nfft::NFFTOp{T}, W=nothing; kwargs...) where {T}
132132
shape = nfft.plan.N
133133

134134
tmpVec = similar(nfft.Mv5, (2 .* shape)...)
@@ -147,7 +147,13 @@ function NFFTToeplitzNormalOp(nfft::NFFTOp{T}, W=opEye(eltype(nfft), size(nfft,
147147
precompute=NFFT.POLYNOMIAL, fftflags=FFTW.ESTIMATE, blocking=true)
148148
tmpOnes = similar(tmpVec, size(nfft.plan.k, 2))
149149
tmpOnes .= one(T)
150-
eigMat = adjoint(p) * ( W * tmpOnes)
150+
151+
if !isnothing(W)
152+
eigMat = adjoint(p) * ( W * tmpOnes)
153+
else
154+
eigMat = adjoint(p) * (tmpOnes)
155+
end
156+
151157
λ = fftplan * fftshift(eigMat)
152158

153159
xL1 = tmpVec
@@ -156,7 +162,7 @@ function NFFTToeplitzNormalOp(nfft::NFFTOp{T}, W=opEye(eltype(nfft), size(nfft,
156162
return NFFTToeplitzNormalOp(shape, W, fftplan, ifftplan, λ, xL1, xL2)
157163
end
158164

159-
function LinearOperatorCollection.normalOperator(S::NFFTOpImpl{T}, W = opEye(eltype(S), size(S, 1), S= LinearOperators.storage_type(S)); copyOpsFn = copy, kwargs...) where T
165+
function LinearOperatorCollection.normalOperator(S::NFFTOpImpl{T}, W = nothing; copyOpsFn = copy, kwargs...) where T
160166
if S.toeplitz
161167
return NFFTToeplitzNormalOp(S,W; kwargs...)
162168
else

src/DiagOp.jl

+9-4
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,18 @@ function diagNormOpProd!(y, normalOps, idx, x)
134134
return y
135135
end
136136

137-
function LinearOperatorCollection.normalOperator(diag::DiagOp, W=opEye(eltype(diag), size(diag,1), S = LinearOperators.storage_type(diag)); copyOpsFn = copy, kwargs...)
138-
T = promote_type(eltype(diag), eltype(W))
139-
S = promote_type(LinearOperators.storage_type(diag), LinearOperators.storage_type(W))
137+
function LinearOperatorCollection.normalOperator(diag::DiagOp, W=nothing; copyOpsFn = copy, kwargs...)
138+
if !isnothing(W)
139+
T = promote_type(eltype(diag), eltype(W))
140+
S = promote_type(LinearOperators.storage_type(diag), LinearOperators.storage_type(W))
141+
else
142+
T = eltype(diag)
143+
S = LinearOperators.storage_type(diag)
144+
end
140145
isconcretetype(S) || throw(LinearOperatorException("Storage types cannot be promoted to a concrete type"))
141146
tmp = S(undef, diag.nrow)
142147
tmp .= one(eltype(diag))
143-
weights = W*tmp
148+
weights = isnothing(W) ? tmp : W * tmp
144149

145150

146151
if diag.equalOps

0 commit comments

Comments
 (0)