Skip to content

Commit 537ba15

Browse files
committed
Include alpha for determining scalartype of linear combination
1 parent cd34d31 commit 537ba15

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/indexnotation/instantiators.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,9 @@ function instantiate_linearcombination(
167167
)
168168
out = Expr(:block)
169169
if alloc (NewTensor, TemporaryTensor)
170-
if scaltype === nothing
171-
scaltype = instantiate_scalartype(ex)
172-
end
170+
scaltype = @something(
171+
scaltype, instantiate_scalartype=== One() ? ex : Expr(:call, :*, α, ex))
172+
)
173173
push!(
174174
out.args,
175175
instantiate(dst, β, ex.args[2], α, leftind, rightind, alloc, scaltype)

test/tensor.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,4 +581,15 @@ end
581581
@test isblascontractable(pA, p)
582582
@test isblascontractable(conj(pA), p)
583583
end
584+
585+
@testset "Issue 220" begin
586+
A = rand(2, 2)
587+
B = rand(2, 2)
588+
C = rand(2, 2)
589+
D = rand(2, 2)
590+
c = 1im
591+
@tensor E[a; c] := c * (A[a b] * B[b c] + C[a b] * D[b c])
592+
@test scalartype(E) == ComplexF64
593+
@test E c * (A * B + C * D)
594+
end
584595
end

0 commit comments

Comments
 (0)