MCPcopy Create free account
hub / github.com/NGSolve/ngsolve / new_index_symbols

Function new_index_symbols

fem/tensorcoefficient.cpp:153–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 {

Callers 2

expand_ellipseFunction · 0.85
expand_einsum_partFunction · 0.85

Calls 3

beginFunction · 0.70
endFunction · 0.70
endMethod · 0.45

Tested by

no test coverage detected