Skip to content

Commit f4030a8

Browse files
committed
some unification of scaltype determination
1 parent 4864971 commit f4030a8

File tree

1 file changed

+7
-18
lines changed

1 file changed

+7
-18
lines changed

src/indexnotation/instantiators.jl

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,9 @@ function instantiate_generaltensor(
124124
if alloc (NewTensor, TemporaryTensor)
125125
TC = gensym("T_" * string(dst))
126126
istemporary = Val(alloc === TemporaryTensor)
127-
if scaltype === nothing
128-
TCval = α === One() ? instantiate_scalartype(src) :
129-
instantiate_scalartype(Expr(:call, :*, α, src))
130-
else
131-
TCval = scaltype
132-
end
127+
TCval = @something(
128+
scaltype, instantiate_scalartype=== One() ? src : Expr(:call, :*, α, src))
129+
)
133130
push!(out.args, Expr(:(=), TC, TCval))
134131
push!(
135132
out.args,
@@ -275,18 +272,10 @@ function instantiate_contraction(
275272
end
276273
if alloc (NewTensor, TemporaryTensor)
277274
TCsym = gensym("T_" * string(dst))
278-
if scaltype === nothing
279-
Atype = instantiate_scalartype(A)
280-
Btype = instantiate_scalartype(B)
281-
TCval = Expr(:call, :promote_contract, Atype, Btype)
282-
if α !== One()
283-
TCval = Expr(
284-
:call, :(Base.promote_op), :*, instantiate_scalartype(α), TCval
285-
)
286-
end
287-
else
288-
TCval = scaltype
289-
end
275+
TCval = @something(
276+
scaltype,
277+
instantiate_scalartype=== One() ? :($A * $B) : :($α * $A * $B))
278+
)
290279
istemporary = Val(alloc === TemporaryTensor)
291280
initC = Expr(
292281
:block, Expr(:(=), TCsym, TCval),

0 commit comments

Comments
 (0)