This adds a potential preprocessor that takes an equation and converts it into a minimal form with the following simplifications:
All indices which only appear on a single input (and not the output) are summed over.
All indices which appear multiple times on the same term are traced.
All scalars are multiplied into the smallest other term
All terms with the same indices are multiplied (hamadard product / elementwise) into a single term ('de-duplication').
along with a function, that transforms input arrays into the inputs for the new simplified eq. It is a function so that it could be part of a contract 'expression'.
This would address (#114, #99, #112, #167, #189, ...).
Notable points that this PR has either accomplished or will accomplish.
[ ] when and how should this be called?
[ ] return a partial path rather than a 'simplifier'?
[ ] should shape information (size_dict) be used and propagated for use with a contraction expression (and so that the smallest tensor to multiply scalars into can be most accurately chosen)?
[ ] other simplifications are possible (e.g. hadamard deduplication up to transpose, performing all non-rank increasing contractions)...
[x] ~currently the parsing is a single sweep, should it iteratively sweep til no more changes? E.g. currently examples like ab,ab-> transform to ab-> but if processed again could transform to ->~
Description
This adds a potential preprocessor that takes an equation and converts it into a minimal form with the following simplifications:
along with a function, that transforms input arrays into the inputs for the new simplified
eq
. It is a function so that it could be part of a contract 'expression'.This would address (#114, #99, #112, #167, #189, ...).
Example from the docstring:
Todos
Notable points that this PR has either accomplished or will accomplish.
size_dict
) be used and propagated for use with a contraction expression (and so that the smallest tensor to multiply scalars into can be most accurately chosen)?ab,ab->
transform toab->
but if processed again could transform to->
~Status