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

Function validate_signature

fem/tensorcoefficient.cpp:969–999  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

967
968
969 string validate_signature(string signature)
970 {
971 const string arrow{"->"};
972 const string special{arrow + ","};
973
974 stringstream not_allowed;
975 for (char c : signature)
976 {
977 if (special.find(c) != string::npos)
978 continue;
979 if (c < 'A' || (c > 'Z' && c < 'a') || c > 'z')
980 not_allowed << c << ", ";
981 }
982 auto found_not_allowed = not_allowed.str();
983 if (!found_not_allowed.empty())
984 throw NG_EXCEPTION(string("index signature contains the following illegal characters: ")
985 + found_not_allowed);
986
987 // special shorthand for trace of a matrix
988 if (signature.size() == 2 && signature[0] == signature[1])
989 return signature;
990
991 if (signature.find(arrow) == string::npos)
992 throw NG_EXCEPTION(string("index signature must contain \"") + arrow + ("\""));
993
994 for (char c : arrow)
995 if (count(signature.begin(), signature.end(), c) > 1)
996 throw NG_EXCEPTION(string("index signature must contain only one \"") + c + ("\""));
997
998 return signature;
999 }
1000
1001 EinsumCoefficientFunction::EinsumCoefficientFunction(
1002 const string &aindex_signature,

Callers 1

Calls 3

findMethod · 0.80
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected