| 151 | } |
| 152 | |
| 153 | string new_index_symbols(string existing, size_t nnew) { |
| 154 | char new_char = 'A'; |
| 155 | auto target_size = existing.size() + nnew; |
| 156 | |
| 157 | while (existing.size() < target_size) { |
| 158 | if (new_char > 'Z') |
| 159 | break; |
| 160 | if (find(begin(existing), end(existing), new_char) != end(existing)) |
| 161 | ++new_char; |
| 162 | else |
| 163 | existing += new_char; |
| 164 | } |
| 165 | |
| 166 | new_char = 'a'; |
| 167 | while (existing.size() < target_size) { |
| 168 | if (new_char > 'z') |
| 169 | throw OutOfIndices("Did not find any unused symbol in A-Z and a-z. Consider using 'optimize_path' and disabling 'einsum_expansion' at some point."); |
| 170 | if (find(begin(existing), end(existing), new_char) != end(existing)) |
| 171 | ++new_char; |
| 172 | else |
| 173 | existing += new_char; |
| 174 | } |
| 175 | |
| 176 | return string{existing.end() - nnew, existing.end()}; |
| 177 | } |
| 178 | |
| 179 | string form_index_signature(const vector<string>& parts) |
| 180 | { |
no test coverage detected