@@ -126,11 +126,12 @@ function mul!(
126126 increase_nprod! (p)
127127 end
128128 conj! (res)
129+ vc = eltype (v) <: Real ? v : conj .(v) # avoid unnecessary allocations if v has real elements
129130 if hasmethod (tprod!, Tuple{typeof (res), typeof (v), typeof (α), typeof (β)})
130- tprod! (res, conj .(v) , conj (α), conj (β))
131+ tprod! (res, vc , conj (α), conj (β))
131132 else
132133 iszero (β) || ! isempty (p. Mtu) || allocate_vectors_args3! (p)
133- prod3! (res, tprod!, conj .(v) , conj (α), conj (β), p. Mtu)
134+ prod3! (res, tprod!, vc , conj (α), conj (β), p. Mtu)
134135 end
135136 conj! (res)
136137end
@@ -193,11 +194,12 @@ function mul!(
193194 increase_nprod! (p)
194195 end
195196 conj! (res)
197+ vc = eltype (v) <: Real ? v : conj .(v) # avoid unnecessary allocations when v has real elements
196198 if hasmethod (ctprod!, Tuple{typeof (res), typeof (v), typeof (α), typeof (β)})
197- ctprod! (res, conj .(v) , conj (α), conj (β))
199+ ctprod! (res, vc , conj (α), conj (β))
198200 else
199201 iszero (β) || ! isempty (p. Mtu) || allocate_vectors_args3! (p)
200- prod3! (res, ctprod!, conj .(v) , conj (α), conj (β), p. Mtu)
202+ prod3! (res, ctprod!, vc , conj (α), conj (β), p. Mtu)
201203 end
202204 conj! (res)
203205end
@@ -229,7 +231,20 @@ function mul!(
229231 β,
230232) where {T, S}
231233 p = op. parent
232- mul! (res, p, conj .(v), α, β)
234+ vc = eltype (v) <: Real ? v : conj .(v) # avoid unnecessary allocations if v has real elements
235+ mul! (res, p, vc, α, β)
236+ conj! (res)
237+ end
238+
239+ function mul! (
240+ res:: AbstractVector ,
241+ op:: ConjugateLinearOperator{T, S} ,
242+ v:: AbstractVector{<:Real} ,
243+ α,
244+ β,
245+ ) where {T, S}
246+ p = op. parent
247+ mul! (res, p, v, α, β) # we can skip `conj.(v)` since it has real elements (this avoids unnecessary allocations)
233248 conj! (res)
234249end
235250
0 commit comments