Skip to content

Commit 7bea16a

Browse files
committed
Move 'reshape' for clarity
1 parent 29d3818 commit 7bea16a

2 files changed

Lines changed: 30 additions & 30 deletions

File tree

src/simplify.jl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,36 @@ function get_diag_delta(arg)
5454
return nothing
5555
end
5656

57+
function reshape(term::Monomial, indices::LowerOrUpperIndex...)
58+
return Monomial(term.id, indices...)
59+
end
60+
61+
function reshape(term::Zero, indices::LowerOrUpperIndex...)
62+
return Zero(indices...)
63+
end
64+
65+
function reshape(term::KrD, indices::LowerOrUpperIndex...)
66+
return KrD(indices...)
67+
end
68+
69+
function reshape(term::UnaryOperation{Op}, indices::LowerOrUpperIndex...) where {Op}
70+
return UnaryOperation{Op}(reshape(term.arg, indices...))
71+
end
72+
73+
function reshape(
74+
term::BinaryOperation{Op},
75+
indices::LowerOrUpperIndex...,
76+
) where {Op<:AdditiveOperation}
77+
return BinaryOperation{Op}(
78+
reshape(term.arg1, indices...),
79+
reshape(term.arg2, indices...),
80+
)
81+
end
82+
83+
function reshape(arg::BinaryOperation{Pow}, indices::LowerOrUpperIndex...)
84+
return BinaryOperation{Pow}(reshape(arg.arg1, indices...), arg.arg2)
85+
end
86+
5787
function get_last_letter(indices::IndexList)
5888
current_last = Upper(0)
5989

src/std.jl

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -568,36 +568,6 @@ function is_trace(arg)
568568
return all(length.(get_free_indices.(terms)) .== 2) && isempty(get_free_indices(arg))
569569
end
570570

571-
function reshape(term::Monomial, indices::LowerOrUpperIndex...)
572-
return Monomial(term.id, indices...)
573-
end
574-
575-
function reshape(term::Zero, indices::LowerOrUpperIndex...)
576-
return Zero(indices...)
577-
end
578-
579-
function reshape(term::KrD, indices::LowerOrUpperIndex...)
580-
return KrD(indices...)
581-
end
582-
583-
function reshape(term::UnaryOperation{Op}, indices::LowerOrUpperIndex...) where {Op}
584-
return UnaryOperation{Op}(reshape(term.arg, indices...))
585-
end
586-
587-
function reshape(
588-
term::BinaryOperation{Op},
589-
indices::LowerOrUpperIndex...,
590-
) where {Op<:AdditiveOperation}
591-
return BinaryOperation{Op}(
592-
reshape(term.arg1, indices...),
593-
reshape(term.arg2, indices...),
594-
)
595-
end
596-
597-
function reshape(arg::BinaryOperation{Pow}, indices::LowerOrUpperIndex...)
598-
return BinaryOperation{Pow}(reshape(arg.arg1, indices...), arg.arg2)
599-
end
600-
601571
function to_standard(term::UnaryOperation{Op}) where {Op}
602572
return UnaryOperation{Op}(to_standard(term.arg))
603573
end

0 commit comments

Comments
 (0)