Skip to content

Commit 27188c6

Browse files
committed
Add LinearOperatorException for non-concrete S in Diag, Normal and ProdOps
1 parent ee3b3fb commit 27188c6

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

src/DiagOp.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ function DiagOp(ops)
4343
ncol += size(ops[i], 2)
4444
S = promote_type(S, LinearOperators.storage_type(ops[i]))
4545
end
46+
isconcretetype(S) || throw(LinearOperatorException("Storage types cannot be promoted to a concrete type"))
4647

4748
xIdx = cumsum(vcat(1,[size(ops[i], 2) for i=1:length(ops)]))
4849
yIdx = cumsum(vcat(1,[size(ops[i], 1) for i=1:length(ops)]))
@@ -136,6 +137,7 @@ end
136137
function LinearOperatorCollection.normalOperator(diag::DiagOp, W=opEye(eltype(diag), size(diag,1), S = LinearOperators.storage_type(diag)); copyOpsFn = copy, kwargs...)
137138
T = promote_type(eltype(diag), eltype(W))
138139
S = promote_type(LinearOperators.storage_type(diag), LinearOperators.storage_type(W))
140+
isconcretetype(S) || throw(LinearOperatorException("Storage types cannot be promoted to a concrete type"))
139141
tmp = S(undef, diag.nrow)
140142
tmp .= one(eltype(diag))
141143
weights = W*tmp

src/NormalOp.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ LinearOperators.storage_type(op::NormalOpImpl) = typeof(op.Mv5)
3939

4040
function NormalOpImpl(parent, weights)
4141
S = promote_type(storage_type(parent), storage_type(weights))
42+
isconcretetype(S) || throw(LinearOperatorException("Storage types cannot be promoted to a concrete type"))
4243
tmp = S(undef, size(parent, 1))
4344
return NormalOpImpl(parent, weights, tmp)
4445
end

src/ProdOp.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ composition/product of two Operators. Differs with * since it can handle normal
3636
function ProdOp(A, B)
3737
nrow = size(A, 1)
3838
ncol = size(B, 2)
39-
S = promote_type(storage_type(A), storage_type(B))
39+
S = promote_type(LinearOperators.storage_type(A), LinearOperators.storage_type(B))
40+
isconcretetype(S) || throw(LinearOperatorException("Storage types cannot be promoted to a concrete type"))
4041
tmp_ = S(undef, size(B, 1))
4142

4243
function produ!(res, x::AbstractVector{T}, tmp) where T<:Union{Real,Complex}

0 commit comments

Comments
 (0)