| 527 | } |
| 528 | |
| 529 | pair<string, Array<shared_ptr<CoefficientFunction>>> |
| 530 | expand_higher_order_identities(string signature, |
| 531 | const Array<shared_ptr<CoefficientFunction>>& cfs, |
| 532 | [[maybe_unused]] const map<string, bool> &options) { |
| 533 | |
| 534 | Array<shared_ptr<CoefficientFunction>> new_cfs; |
| 535 | new_cfs.SetAllocSize(cfs.Size()); |
| 536 | |
| 537 | cout << IM(5) << "EinsumCF: expand higher-order identities" << endl; |
| 538 | auto parts = split_signature(signature); |
| 539 | |
| 540 | for (auto i : Range(cfs)) |
| 541 | if (is_identity(cfs[i])) |
| 542 | { |
| 543 | auto dims = cfs[i]->Dimensions(); |
| 544 | stringstream new_part{}; |
| 545 | for (auto j : Range(dims.Size() / 2)) { |
| 546 | new_cfs.Append(IdentityCF(dims[j])); |
| 547 | new_part << (j > 0 ? "," : "") |
| 548 | << parts[i][j] << parts[i][j + dims.Size() / 2]; |
| 549 | } |
| 550 | parts[i] = new_part.str(); |
| 551 | } |
| 552 | else |
| 553 | { |
| 554 | new_cfs.Append(cfs[i]); |
| 555 | } |
| 556 | |
| 557 | |
| 558 | return {form_index_signature(parts), std::move(new_cfs)}; |
| 559 | } |
| 560 | |
| 561 | |
| 562 | pair<string, Array<shared_ptr<CoefficientFunction>>> |
no test coverage detected