55 |
* Orders EIN, normalizes it, then cleans the summation |
* Orders EIN, normalizes it, then cleans the summation |
56 |
*) |
*) |
57 |
fun doNormalize e' = let |
fun doNormalize e' = let |
58 |
val _ =print(String.concat["\n\n\n do normalize:", EinPP.toString(e')]) |
(*DEBUG* val _ =print(String.concat["\n\n\n do normalize:", EinPP.toString(e')]) *) |
59 |
val ordered = Reorder.transform e' |
val ordered = Reorder.transform e' |
60 |
in |
in |
61 |
case NormalizeEin.transform ordered |
case NormalizeEin.transform ordered |
62 |
of NONE => ordered |
of NONE => ordered |
63 |
| SOME e => (print(String.concat["\n transform :=>", EinPP.toString(e)]) ; EinSums.clean e) |
| SOME e => EinSums.clean e |
64 |
(* end case *) |
(* end case *) |
65 |
end |
end |
66 |
|
|
79 |
| _ => let |
| _ => let |
80 |
val rtnArgs = done @ newArgs |
val rtnArgs = done @ newArgs |
81 |
val (c, subst) = Apply.apply(orig, place, newE) |
val (c, subst) = Apply.apply(orig, place, newE) |
82 |
val _ =print(String.concat["\n\n\n after substition:", EinPP.toString(subst)]) |
(*DEBUG* val _ =print(String.concat["\n\n\n after substition:", EinPP.toString(subst)]) *) |
83 |
in |
in |
84 |
if c |
if c |
85 |
then (true, subst, place + length newArgs, rtnArgs) |
then (true, subst, place + length newArgs, rtnArgs) |
99 |
* Keeps track of the place of the argument in substitution. |
* Keeps track of the place of the argument in substitution. |
100 |
*) |
*) |
101 |
fun doRHS (lhs, IR.EINAPP(ein, args)) = let |
fun doRHS (lhs, IR.EINAPP(ein, args)) = let |
102 |
val _ =print(String.concat["\n\n\n doRHS:", EinPP.toString(ein)]) |
(*DEBUG* val _ =print(String.concat["\n\n\n doRHS:", EinPP.toString(ein)]) *) |
103 |
fun rewrite (false, _, _, [], _) = NONE |
fun rewrite (false, _, _, [], _) = NONE |
104 |
| rewrite (true, orig, _, [], args') = |
| rewrite (true, orig, _, [], args') = |
105 |
SOME[(lhs, IR.EINAPP(doNormalize orig, args'))] |
SOME[(lhs, IR.EINAPP(doNormalize orig, args'))] |