| 509 | } |
| 510 | |
| 511 | bool is_identity(const shared_ptr<CoefficientFunction> cf) { |
| 512 | if (dynamic_pointer_cast<IdentityCoefficientFunction>(cf)) |
| 513 | return true; |
| 514 | |
| 515 | if (auto dims = cf->Dimensions(); dims.Size() % 2 == 0 |
| 516 | && dynamic_pointer_cast<cl_UnaryOpCF<GenericIdentity>>(cf) |
| 517 | && is_identity(cf->InputCoefficientFunctions()[0])) |
| 518 | { |
| 519 | auto N = size_t(dims.Size() / 2); |
| 520 | for (auto j : Range(N)) |
| 521 | if (dims[j] != dims[j + N]) |
| 522 | return false; |
| 523 | return true; |
| 524 | } |
| 525 | |
| 526 | return false; |
| 527 | } |
| 528 | |
| 529 | pair<string, Array<shared_ptr<CoefficientFunction>>> |
| 530 | expand_higher_order_identities(string signature, |
no test coverage detected