Skip to content

Commit 5cead92

Browse files
committed
Simplify to_binary_operation
1 parent b01f375 commit 5cead92

2 files changed

Lines changed: 9 additions & 19 deletions

File tree

src/simplify.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,15 @@ function get_last_letter(indices::IndexList)
9696
return current_last
9797
end
9898

99+
100+
function to_binary_operation(op::Op, terms::AbstractArray) where {Op}
101+
if length(terms) == 1
102+
return first(terms)
103+
end
104+
105+
return BinaryOperation{Op}(to_binary_operation(op, terms[1:(end-1)]), terms[end])
106+
end
107+
99108
function simplify(::Mult, arg1::BinaryOperation{Mult}, arg2::KrD)
100109
if is_diag(arg1)
101110
d = get_diag_delta(arg1)

src/std.jl

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -601,25 +601,6 @@ function to_standard(arg::Real)
601601
return arg
602602
end
603603

604-
function to_binary_operation(op::Op, terms::AbstractArray) where {Op}
605-
binop = nothing
606-
607-
for t terms
608-
if isnothing(binop)
609-
binop = t
610-
continue
611-
end
612-
613-
binop = BinaryOperation{Op}(binop, t)
614-
end
615-
616-
return binop
617-
end
618-
619-
function to_binary_operation(op::Op, term) where {Op}
620-
return term
621-
end
622-
623604
# Recursive adjoint
624605
function radjoint(arg::T) where {T<:UnaryOperation}
625606
return T(arg.arg')

0 commit comments

Comments
 (0)