Skip to content

Commit 2ae27cf

Browse files
committed
More inferrability & performance work
1 parent 19426c6 commit 2ae27cf

4 files changed

Lines changed: 23 additions & 9 deletions

File tree

src/abstract.jl

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ function CompositeLinearOperator(
128128
prod!::F,
129129
tprod!::Ft,
130130
ctprod!::Fct,
131-
args5::Bool;
132-
S::Type = Vector{T},
133-
) where {I <: Integer, F, Ft, Fct}
131+
args5::Bool,
132+
::Type{S},
133+
) where {S, I <: Integer, F, Ft, Fct}
134134
Mv5, Mtu5 = S(undef, 0), S(undef, 0)
135135
allocated5 = true
136136
use_prod5! = true
@@ -153,6 +153,20 @@ function CompositeLinearOperator(
153153
)
154154
end
155155

156+
# backward compatibility (not inferrable)
157+
CompositeLinearOperator(
158+
T::Type,
159+
nrow::I,
160+
ncol::I,
161+
symmetric::Bool,
162+
hermitian::Bool,
163+
prod!::F,
164+
tprod!::Ft,
165+
ctprod!::Fct,
166+
args5::Bool;
167+
S::Type = Vector{T}) where {I <: Integer, F, Ft, Fct} =
168+
CompositeLinearOperator(T, nrow, ncol, symmetric, hermitian, prod!, tprod!, ctprod!, args5, S)
169+
156170
nprod(op::AbstractLinearOperator) = op.nprod
157171
ntprod(op::AbstractLinearOperator) = op.ntprod
158172
nctprod(op::AbstractLinearOperator) = op.nctprod

src/cat.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function hcat(A::AbstractLinearOperator, B::AbstractLinearOperator)
4848
S = promote_type(storage_type(A), storage_type(B))
4949
isconcretetype(S) ||
5050
throw(LinearOperatorException("storage types cannot be promoted to a concrete type"))
51-
CompositeLinearOperator(T, nrow, ncol, false, false, prod!, tprod!, ctprod!, args5, S = S)
51+
CompositeLinearOperator(T, nrow, ncol, false, false, prod!, tprod!, ctprod!, args5, S)
5252
end
5353

5454
function hcat(ops::AbstractLinearOperator...)
@@ -107,7 +107,7 @@ function vcat(A::AbstractLinearOperator, B::AbstractLinearOperator)
107107
S = promote_type(storage_type(A), storage_type(B))
108108
isconcretetype(S) ||
109109
throw(LinearOperatorException("storage types cannot be promoted to a concrete type"))
110-
CompositeLinearOperator(T, nrow, ncol, false, false, prod!, tprod!, ctprod!, args5, S = S)
110+
CompositeLinearOperator(T, nrow, ncol, false, false, prod!, tprod!, ctprod!, args5, S)
111111
end
112112

113113
function vcat(ops::AbstractLinearOperator...)

src/operations.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ function *(op1::AbstractLinearOperator, op2::AbstractLinearOperator)
150150
tprod! = @closure (res, u, α, β) -> prod_op!(res, transpose(op2), transpose(op1), utmp, u, α, β)
151151
ctprod! = @closure (res, w, α, β) -> prod_op!(res, adjoint(op2), adjoint(op1), wtmp, w, α, β)
152152
args5 = (has_args5(op1) && has_args5(op2))
153-
CompositeLinearOperator(T, m1, n2, false, false, prod!, tprod!, ctprod!, args5, S = S)
153+
CompositeLinearOperator(T, m1, n2, false, false, prod!, tprod!, ctprod!, args5, S)
154154
end
155155

156156
## Matrix times operator.
@@ -213,7 +213,7 @@ function +(op1::AbstractLinearOperator, op2::AbstractLinearOperator)
213213
S = promote_type(storage_type(op1), storage_type(op2))
214214
isconcretetype(S) ||
215215
throw(LinearOperatorException("storage types cannot be promoted to a concrete type"))
216-
return CompositeLinearOperator(T, m1, n1, symm, herm, prod!, tprod!, ctprod!, args5, S = S)
216+
return CompositeLinearOperator(T, m1, n1, symm, herm, prod!, tprod!, ctprod!, args5, S)
217217
end
218218

219219
# Operator + matrix.

src/special-operators.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ function opDiagonal(nrow::I, ncol::I, d::AbstractVector{T}) where {T, I <: Integ
165165
end
166166

167167
function mulRestrict!(res, I, v, α, β)
168-
res .= v[I]
168+
res .= view(v, I)
169169
end
170170

171171
function multRestrict!(res, I, u, α, β)
@@ -291,5 +291,5 @@ function BlockDiagonalOperator(ops...; S = promote_type(storage_type.(ops)...))
291291
symm = all((issymmetric(op) for op ops))
292292
herm = all((ishermitian(op) for op ops))
293293
args5 = all((has_args5(op) for op ops))
294-
CompositeLinearOperator(T, nrow, ncol, symm, herm, prod!, tprod!, ctprod!, args5, S = S)
294+
CompositeLinearOperator(T, nrow, ncol, symm, herm, prod!, tprod!, ctprod!, args5, S)
295295
end

0 commit comments

Comments
 (0)