30#include <unordered_map>
38#pragma optimize("",off)
265static std::unordered_map<std::string, void *>
gClingFunctions = std::unordered_map<std::string, void * >();
272 for (
int i = 0; i < nobjects; ++i) {
273 if (fromv5[i] && target[i]) {
274 TFormula fnew(fromv5[i]->GetName(), fromv5[i]->GetExpFormula());
290 const static std::set<char> ops {
'+',
'^',
'-',
'/',
'*',
'<',
'>',
'|',
'&',
'!',
'=',
'?',
'%'};
291 return ops.end() != ops.find(
c);
298 char brackets[] = {
')',
'(',
'{',
'}'};
299 Int_t bracketsLen =
sizeof(brackets)/
sizeof(
char);
300 for(
Int_t i = 0; i < bracketsLen; ++i)
322 if ( (formula[i] ==
'e' || formula[i] ==
'E') && (i > 0 && i < formula.
Length()-1) ) {
324 if ( (isdigit(formula[i-1]) || formula[i-1] ==
'.') && ( isdigit(formula[i+1]) || formula[i+1] ==
'+' || formula[i+1] ==
'-' ) )
334 if ( (formula[i] ==
'x' || formula[i] ==
'X') && (i > 0 && i < formula.
Length()-1) && formula[i-1] ==
'0') {
335 if (isdigit(formula[i+1]) )
337 static char hex_values[12] = {
'a',
'A',
'b',
'B',
'c',
'C',
'd',
'D',
'e',
'E',
'f',
'F'};
338 for (
int jjj = 0; jjj < 12; ++jjj) {
339 if (formula[i+1] == hex_values[jjj])
356 Bool_t foundOpenParenthesis =
false;
357 if (pos == 0 || pos == formula.
Length()-1)
return false;
358 for (
int i = pos-1; i >=0; i--) {
359 if (formula[i] ==
']' )
return false;
360 if (formula[i] ==
'[' ) {
361 foundOpenParenthesis =
true;
365 if (!foundOpenParenthesis )
return false;
368 for (
int i = pos+1; i < formula.
Length(); i++) {
369 if (formula[i] ==
']' )
return true;
382 TRegexp numericPattern(
"p?[0-9]+");
385 int patternStart = numericPattern.
Index(
a, &len);
386 bool aNumeric = (patternStart == 0 && len ==
a.Length());
388 patternStart = numericPattern.
Index(
b, &len);
389 bool bNumeric = (patternStart == 0 && len ==
b.Length());
391 if (aNumeric && !bNumeric)
393 else if (!aNumeric && bNumeric)
395 else if (!aNumeric && !bNumeric)
398 int aInt = (
a[0] ==
'p') ?
TString(
a(1,
a.Length())).
Atoi() :
a.Atoi();
399 int bInt = (
b[0] ==
'p') ?
TString(
b(1,
b.Length())).
Atoi() :
b.Atoi();
410 for (
int i = 0; i < formula.
Length(); i++) {
413 if (isalpha(formula[i]) || formula[i] ==
'{' || formula[i] ==
'[') {
417 || (formula[i] ==
'{' && formula[j] ==
'}'));
425 if (substitutions.find(
name) != substitutions.end()) {
429 }
else if (isalpha(formula[i])) {
432 i +=
name.Length() - 1;
457 if (strlen(
name)!=1)
return false;
458 for (
auto const & specialName : {
"x",
"y",
"z",
"t"}){
459 if (strcmp(
name,specialName)==0)
return true;
472 gROOT->GetListOfFunctions()->Remove(
this);
477 for (
int i = 0; i < nLinParts; ++i)
delete fLinearParts[i];
484 fClingInput(formula),fFormula(formula)
493#ifndef R__HAS_VECCORE
509 if (addToGlobList &&
gROOT) {
514 gROOT->GetListOfFunctions()->Remove(old);
516 Error(
"TFormula",
"The name %s is reserved as a TFormula variable name.\n",
name);
518 gROOT->GetListOfFunctions()->Add(
this);
530 fClingInput(formula),fFormula(formula)
543 for (
int i = 0; i < npar; ++i) {
547 assert (
fNpar == npar);
557 if (addToGlobList &&
gROOT) {
562 gROOT->GetListOfFunctions()->Remove(old);
564 Error(
"TFormula",
"The name %s is reserved as a TFormula variable name.\n",
name);
566 gROOT->GetListOfFunctions()->Add(
this);
571 Error(
"TFormula",
"Syntax error in building the lambda expression %s", formula );
576 TNamed(formula.GetName(),formula.GetTitle())
584 gROOT->GetListOfFunctions()->Remove(old);
587 Error(
"TFormula",
"The name %s is reserved as a TFormula variable name.\n",formula.
GetName());
589 gROOT->GetListOfFunctions()->Add(
this);
609 std::string lambdaExpression = formula;
633 TString lineExpr =
TString::Format(
"std::function<double(double*,double*)> %s = %s ;",lambdaName.
Data(), lambdaExpression.c_str() );
660 if (formula.
IsNull() )
return -1;
672 return (ret) ? 0 : 1;
682 return (ret) ? 0 : 1;
711 for (
int i = 0; i < nLinParts; ++i)
delete fnew.
fLinearParts[i];
718 for (
int i = 0; i < nLinParts; ++i) {
722 linearOld->
Copy(*linearNew);
747 Error(
"TFormula",
"Syntax error in building the lambda expression %s",
fFormula.
Data() );
793 for (
int i = 0; i < nLinParts; ++i)
delete fLinearParts[i];
800static std::unique_ptr<TMethodCall>
802 bool IsVectorized,
bool AddCladArrayRef =
false) {
803 std::unique_ptr<TMethodCall>
804 Method = std::unique_ptr<TMethodCall>(
new TMethodCall());
806 TString prototypeArguments =
"";
807 if (HasVariables || HasParameters) {
809 prototypeArguments.
Append(
"ROOT::Double_v*");
811 prototypeArguments.
Append(
"Double_t*");
813 auto AddDoublePtrParam = [&prototypeArguments]() {
814 prototypeArguments.
Append(
",");
815 prototypeArguments.
Append(
"Double_t*");
821 if (AddCladArrayRef) {
822 prototypeArguments.
Append(
",");
823 prototypeArguments.
Append(
"clad::array_ref<Double_t>");
828 Method->InitWithPrototype(FuncName, prototypeArguments);
829 if (!Method->IsValid()) {
830 Error(
"prepareMethod",
831 "Can't compile function %s prototype with arguments %s", FuncName,
832 prototypeArguments.
Data());
840 if (!method)
return nullptr;
844 Error(
"prepareFuncPtr",
"Callfunc retuned from Cling is not valid");
851 Error(
"prepareFuncPtr",
"Compiled function pointer is null");
887 TString triggerAutoparsing =
"namespace ROOT_TFormula_triggerAutoParse {\n"; triggerAutoparsing +=
fClingInput +
"\n}";
906 const TString defvars[] = {
"x",
"y",
"z",
"t"};
907 const pair<TString, Double_t> defconsts[] = {{
"pi",
TMath::Pi()},
925 const pair<TString,TString> funShortcuts[] =
926 { {
"sin",
"TMath::Sin" },
927 {
"cos",
"TMath::Cos" }, {
"exp",
"TMath::Exp"}, {
"log",
"TMath::Log"}, {
"log10",
"TMath::Log10"},
928 {
"tan",
"TMath::Tan"}, {
"sinh",
"TMath::SinH"}, {
"cosh",
"TMath::CosH"},
929 {
"tanh",
"TMath::TanH"}, {
"asin",
"TMath::ASin"}, {
"acos",
"TMath::ACos"},
930 {
"atan",
"TMath::ATan"}, {
"atan2",
"TMath::ATan2"}, {
"sqrt",
"TMath::Sqrt"},
931 {
"ceil",
"TMath::Ceil"}, {
"floor",
"TMath::Floor"}, {
"pow",
"TMath::Power"},
932 {
"binomial",
"TMath::Binomial"},{
"abs",
"TMath::Abs"},
933 {
"min",
"TMath::Min"},{
"max",
"TMath::Max"},{
"sign",
"TMath::Sign" },
937 std::vector<TString> defvars2(10);
938 for (
int i = 0; i < 9; ++i)
941 for (
const auto &var : defvars) {
942 int pos =
fVars.size();
955 for (
auto con : defconsts) {
956 fConsts[con.first] = con.second;
961 for (
auto fun : funShortcuts) {
974 const pair<TString,TString> vecFunShortcuts[] =
975 { {
"sin",
"vecCore::math::Sin" },
976 {
"cos",
"vecCore::math::Cos" }, {
"exp",
"vecCore::math::Exp"}, {
"log",
"vecCore::math::Log"}, {
"log10",
"vecCore::math::Log10"},
977 {
"tan",
"vecCore::math::Tan"},
979 {
"asin",
"vecCore::math::ASin"},
980 {
"acos",
"TMath::Pi()/2-vecCore::math::ASin"},
981 {
"atan",
"vecCore::math::ATan"},
982 {
"atan2",
"vecCore::math::ATan2"}, {
"sqrt",
"vecCore::math::Sqrt"},
983 {
"ceil",
"vecCore::math::Ceil"}, {
"floor",
"vecCore::math::Floor"}, {
"pow",
"vecCore::math::Pow"},
984 {
"cbrt",
"vecCore::math::Cbrt"},{
"abs",
"vecCore::math::Abs"},
985 {
"min",
"vecCore::math::Min"},{
"max",
"vecCore::math::Max"},{
"sign",
"vecCore::math::Sign" }
989 for (
auto fun : vecFunShortcuts) {
1009 Bool_t defaultVariable =
false;
1011 Int_t openingBracketPos = formula.
Index(
'(', polPos);
1012 Bool_t defaultCounter = openingBracketPos ==
kNPOS;
1013 Bool_t defaultDegree =
true;
1014 Int_t degree, counter;
1016 if (!defaultCounter) {
1019 sdegree = formula(polPos + 3, openingBracketPos - polPos - 3);
1021 defaultCounter =
true;
1023 if (!defaultCounter) {
1024 degree = sdegree.
Atoi();
1025 counter =
TString(formula(openingBracketPos + 1, formula.
Index(
')', polPos) - openingBracketPos)).
Atoi();
1027 Int_t temp = polPos + 3;
1028 while (temp < formula.
Length() && isdigit(formula[temp])) {
1029 defaultDegree =
false;
1032 degree =
TString(formula(polPos + 3, temp - polPos - 3)).
Atoi();
1037 if (polPos - 1 < 0 || !
IsFunctionNameChar(formula[polPos - 1]) || formula[polPos - 1] ==
':') {
1039 defaultVariable =
true;
1041 Int_t tmp = polPos - 1;
1045 variable = formula(tmp + 1, polPos - (tmp + 1));
1047 Int_t param = counter + 1;
1049 while (tmp <= degree) {
1059 replacement.
Insert(0,
'(');
1063 if (defaultCounter && !defaultDegree) {
1065 }
else if (defaultCounter && defaultDegree) {
1068 pattern =
TString::Format(
"%spol%d(%d)", (defaultVariable ?
"" : variable.
Data()), degree, counter);
1072 Error(
"HandlePolN",
"Error handling polynomial function - expression is %s - trying to replace %s with %s ",
1076 if (formula == pattern) {
1082 polPos = formula.
Index(
"pol");
1108 map< pair<TString,Int_t> ,pair<TString,TString> > functions;
1111 map<TString,Int_t> functionsNumbers;
1112 functionsNumbers[
"gaus"] = 100;
1113 functionsNumbers[
"bigaus"] = 102;
1114 functionsNumbers[
"landau"] = 400;
1115 functionsNumbers[
"expo"] = 200;
1116 functionsNumbers[
"crystalball"] = 500;
1127 formula.
ReplaceAll(
"xylandau",
"landau[x,y]");
1130 const char * defaultVariableNames[] = {
"x",
"y",
"z"};
1132 for (map<pair<TString, Int_t>, pair<TString, TString>>::iterator it = functions.begin(); it != functions.end();
1135 TString funName = it->first.first;
1136 Int_t funDim = it->first.second;
1146 Int_t iposBefore = funPos - 1;
1149 if (iposBefore >= 0) {
1150 assert(iposBefore < formula.
Length());
1155 funPos = formula.
Index(funName, lastFunPos);
1160 Bool_t isNormalized =
false;
1161 if (lastFunPos < formula.
Length()) {
1163 isNormalized = (formula[lastFunPos] ==
'n');
1166 if (lastFunPos < formula.
Length()) {
1167 char c = formula[lastFunPos];
1170 if (isalnum(
c) || (!
IsOperator(
c) &&
c !=
'(' &&
c !=
')' &&
c !=
'[' &&
c !=
']')) {
1172 funPos = formula.
Index(funName, lastFunPos);
1181 std::vector<TString> variables;
1184 Bool_t defaultVariables =
false;
1187 Int_t openingBracketPos = funPos + funName.
Length() + (isNormalized ? 1 : 0);
1189 if (openingBracketPos > formula.
Length() || formula[openingBracketPos] !=
'[') {
1191 variables.resize(dim);
1192 for (
Int_t idim = 0; idim < dim; ++idim)
1193 variables[idim] = defaultVariableNames[idim];
1194 defaultVariables =
true;
1197 closingBracketPos = formula.
Index(
']', openingBracketPos);
1198 varList = formula(openingBracketPos + 1, closingBracketPos - openingBracketPos - 1);
1200 variables.resize(dim);
1205 varName.
Append(varList[i]);
1207 if (varList[i] ==
',') {
1208 variables[Nvar] = varName;
1215 variables[Nvar] = varName;
1220 if (dim != funDim) {
1221 pair<TString, Int_t> key = make_pair(funName, dim);
1222 if (functions.find(key) == functions.end()) {
1223 Error(
"PreProcessFormula",
"Dimension of function %s is detected to be of dimension %d and is not "
1224 "compatible with existing pre-defined function which has dim %d",
1225 funName.
Data(), dim, funDim);
1229 funPos = formula.
Index(funName, lastFunPos);
1234 Int_t openingParenthesisPos = (closingBracketPos ==
kNPOS) ? openingBracketPos : closingBracketPos + 1;
1235 bool defaultCounter = (openingParenthesisPos > formula.
Length() || formula[openingParenthesisPos] !=
'(');
1240 if (defaultCounter) {
1246 TRegexp counterPattern(
"([0-9]+)");
1248 if (counterPattern.
Index(formula, &len, openingParenthesisPos) == -1) {
1249 funPos = formula.
Index(funName, funPos + 1);
1253 TString(formula(openingParenthesisPos + 1, formula.
Index(
')', funPos) - openingParenthesisPos - 1))
1259 TString body = (isNormalized ? it->second.second : it->second.first);
1260 if (isNormalized && body ==
"") {
1261 Error(
"PreprocessFormula",
"%d dimension function %s has no normalized form.", it->first.second,
1265 for (
int i = 0; i < body.
Length(); ++i) {
1266 if (body[i] ==
'{') {
1270 TString variable = variables[num];
1274 i += variable.
Length() - 1;
1275 }
else if (body[i] ==
'[') {
1278 while (tmp < body.
Length() && body[tmp] !=
']') {
1285 body.
Replace(i + 1, tmp - 1 - i, replacement, replacement.
Length());
1286 i += replacement.
Length() + 1;
1290 if (defaultCounter && defaultVariables) {
1293 if (!defaultCounter && defaultVariables) {
1294 pattern =
TString::Format(
"%s%s(%d)", funName.
Data(), (isNormalized ?
"n" :
""), counter);
1296 if (defaultCounter && !defaultVariables) {
1299 if (!defaultCounter && !defaultVariables) {
1307 fNumber = functionsNumbers[funName] + 10 * (dim - 1);
1314 funPos = formula.
Index(funName);
1324 TRegexp rangePattern(
"\\[[0-9]+\\.\\.[0-9]+\\]");
1327 while ((matchIdx = rangePattern.
Index(formula, &len, matchIdx)) != -1) {
1328 int startIdx = matchIdx + 1;
1329 int endIdx = formula.
Index(
"..", startIdx) + 2;
1333 if (endCnt <= startCnt)
1334 Error(
"HandleParamRanges",
"End parameter (%d) <= start parameter (%d) in parameter range", endCnt, startCnt);
1337 for (
int cnt = startCnt; cnt < endCnt; cnt++)
1342 formula.
Replace(matchIdx, formula.
Index(
"]", matchIdx) + 1 - matchIdx, newString);
1344 matchIdx += newString.
Length();
1358 std::map<std::pair<TString, Int_t>, std::pair<TString, TString>> parFunctions;
1366 if (formula[i] ==
'[') {
1367 while (formula[i] !=
']')
1372 if (formula[i] ==
'\"') {
1375 while (formula[i] !=
'\"');
1389 if (isalpha(formula[i]) && !
IsOperator(formula[i])) {
1402 std::vector<int> argSeparators;
1403 argSeparators.push_back(j);
1405 for (k = j + 1; depth >= 1 && k < formula.
Length(); k++) {
1406 if (formula[k] ==
',' && depth == 1) {
1408 argSeparators.push_back(k);
1409 }
else if (formula[k] ==
'(')
1411 else if (formula[k] ==
')')
1414 argSeparators.push_back(k - 1);
1425 TF1 *
f1 =
dynamic_cast<TF1 *
>(obj);
1433 bool nameRecognized = (
f !=
nullptr);
1440 ndim =
f->GetNdim();
1441 npar =
f->GetNpar();
1442 replacementFormula =
f->GetExpFormula();
1446 for (
const auto &keyval : parFunctions) {
1448 const pair<TString, Int_t> &name_ndim = keyval.first;
1450 const pair<TString, TString> &formulaPair = keyval.second;
1453 if (
name == name_ndim.first)
1454 replacementFormula = formulaPair.first;
1455 else if (
name == name_ndim.first +
"n" && formulaPair.second !=
"")
1456 replacementFormula = formulaPair.second;
1461 ndim = name_ndim.second;
1466 while ((idx = replacementFormula.
Index(
'[', idx)) !=
kNPOS) {
1467 npar = max(npar, 1 +
TString(replacementFormula(idx + 1, replacementFormula.
Length())).
Atoi());
1468 idx = replacementFormula.
Index(
']', idx);
1470 Error(
"HandleFunctionArguments",
"Square brackets not matching in formula %s",
1471 (
const char *)replacementFormula);
1478 if (nArguments == ndim + npar || nArguments == npar || nArguments == ndim) {
1479 nameRecognized =
true;
1484 if (nameRecognized && ndim > 4)
1485 Error(
"HandleFunctionArguments",
"Number of dimensions %d greater than 4. Cannot parse formula.", ndim);
1488 if (nameRecognized && j < formula.
Length() && formula[j] ==
'(') {
1493 map<TString, TString> argSubstitutions;
1495 const char *defaultVariableNames[] = {
"x",
"y",
"z",
"t"};
1498 bool canReplace =
false;
1499 if (nArguments == ndim + npar) {
1501 for (
int argNr = 0; argNr < nArguments; argNr++) {
1505 TString(formula(argSeparators[argNr] + 1, argSeparators[argNr + 1] - argSeparators[argNr] - 1));
1512 argSubstitutions[oldName] = newName;
1515 argSubstitutions[defaultVariableNames[argNr]] = newName;
1518 int parNr = argNr - ndim;
1521 argSubstitutions[oldName] = newName;
1524 if (
f && oldName == newName)
1530 }
else if (nArguments == npar) {
1535 bool varsImplicit =
true;
1536 for (
int argNr = 0; argNr < nArguments && varsImplicit; argNr++) {
1537 int openIdx = argSeparators[argNr] + 1;
1538 int closeIdx = argSeparators[argNr + 1] - 1;
1541 if (formula[openIdx] !=
'[' || formula[closeIdx] !=
']' || closeIdx <= openIdx + 1)
1542 varsImplicit =
false;
1545 for (
int idx = openIdx + 1; idx < closeIdx && varsImplicit; idx++)
1547 varsImplicit =
false;
1550 Warning(
"HandleFunctionArguments",
1551 "Argument %d is not a parameter. Cannot assume variables are implicit.", argNr);
1558 for (
int dim = 0; dim < ndim; dim++) {
1559 argSubstitutions[
TString::Format(
"{V%d}", dim)] = defaultVariableNames[dim];
1563 for (
int argNr = 0; argNr < nArguments; argNr++) {
1567 TString(formula(argSeparators[argNr] + 1, argSeparators[argNr + 1] - argSeparators[argNr] - 1));
1571 argSubstitutions[oldName] = newName;
1574 if (
f && oldName == newName)
1581 if (!canReplace && nArguments == ndim) {
1585 for (
int argNr = 0; argNr < nArguments; argNr++) {
1588 TString(formula(argSeparators[argNr] + 1, argSeparators[argNr + 1] - argSeparators[argNr] - 1));
1592 argSubstitutions[oldName] = newName;
1595 argSubstitutions[defaultVariableNames[argNr]] = newName;
1600 for (
int parNr = 0; parNr < npar; parNr++)
1614 formula.
Replace(i, k - i, replacementFormula);
1615 i += replacementFormula.
Length() - 1;
1618 Warning(
"HandleFunctionArguments",
"Unable to make replacement. Number of parameters doesn't work : "
1619 "%d arguments, %d dimensions, %d parameters",
1620 nArguments, ndim, npar);
1643 Int_t temp = caretPos;
1646 if (formula[temp] ==
')') {
1649 while (depth != 0 && temp > 0) {
1650 if (formula[temp] ==
')')
1652 if (formula[temp] ==
'(')
1667 assert(temp + 1 >= 0);
1668 Int_t leftPos = temp + 1;
1669 left = formula(leftPos, caretPos - leftPos);
1675 if (temp >= formula.
Length()) {
1676 Error(
"HandleExponentiation",
"Invalid position of operator ^");
1679 if (formula[temp] ==
'(') {
1682 while (depth != 0 && temp < formula.
Length()) {
1683 if (formula[temp] ==
')')
1685 if (formula[temp] ==
'(')
1692 if (formula[temp] ==
'-' || formula[temp] ==
'+')
1698 while (temp < formula.
Length() && ((depth > 0) || !
IsOperator(formula[temp]))) {
1704 if (temp < formula.
Length() && formula[temp] ==
'(')
1706 if (temp < formula.
Length() && formula[temp] ==
')') {
1714 right = formula(caretPos + 1, (temp - 1) - caretPos);
1724 caretPos = formula.
Last(
'^');
1734 if(formula.
Length() == 0)
return;
1736 if(terms.size() <= 1)
return;
1740 int delimeterPos = 0;
1741 for(std::size_t iTerm = 0; iTerm < terms.size(); ++iTerm) {
1743 delimeterPos += terms[iTerm].size() + (iTerm == 0);
1746 expandedFormula += terms[iTerm];
1747 expandedFormula += formula(delimeterPos, formula.
Length() - (delimeterPos + 1));
1751 auto termName = std::string(
"__linear") + std::to_string(iTerm+1);
1753 std::stringstream ss;
1754 ss <<
"([" << iTerm <<
"]*(" << terms[iTerm] <<
"))";
1755 expandedFormula += ss.str();
1756 if(iTerm < terms.size() - 1) expandedFormula +=
"+";
1758 formula = expandedFormula;
1840 if (formula[i] ==
'[') {
1844 while (i < formula.
Length() && formula[i] !=
']') {
1845 param.
Append(formula[i++]);
1850 int paramIndex = -1;
1852 paramIndex = param.
Atoi();
1856 for (
int idx = 0; idx <= paramIndex; ++idx) {
1876 formula.
Replace(tmp, i - tmp, replacement, replacement.
Length());
1880 int deltai = replacement.
Length() - (i-tmp);
1886 if (formula[i] ==
'\"') {
1890 }
while (formula[i] !=
'\"');
1908 if (isalpha(formula[i]) &&
1916 if (formula[i] ==
':' && ((i + 1) < formula.
Length())) {
1917 if (formula[i + 1] ==
':') {
1926 name.Append(formula[i++]);
1929 if (formula[i] ==
'(') {
1931 if (formula[i] ==
')') {
1938 while (depth != 0 && i < formula.
Length()) {
1939 switch (formula[i]) {
1940 case '(': depth++;
break;
1941 case ')': depth--;
break;
1949 body.
Append(formula[i++]);
1954 formula.
Replace(i - originalBodyLen, originalBodyLen, body, body.
Length());
1955 i += body.
Length() - originalBodyLen;
1973 TF1 *
f1 =
dynamic_cast<TF1 *
>(obj);
1983 TString replacementFormula =
f->GetExpFormula();
1996 std::vector<TString> newNames;
1999 newNames.resize(
f->GetNpar());
2001 for (
int jpar =
f->GetNpar() - 1; jpar >= 0; --jpar) {
2009 replacementFormula.
ReplaceAll(oldName, newName);
2010 newNames[jpar] = newName;
2012 newNames[jpar] =
f->GetParName(jpar);
2020 for (
int jpar = 0; jpar <
f->GetNpar(); ++jpar) {
2021 if (nparOffset > 0) {
2023 assert((
int)newNames.size() ==
f->GetNpar());
2030 replacementFormula.
Insert(0,
'(');
2031 replacementFormula.
Insert(replacementFormula.
Length(),
')');
2034 i += replacementFormula.
Length() -
name.Length();
2078 for (list<TFormulaFunction>::iterator funcsIt =
fFuncs.begin(); funcsIt !=
fFuncs.end(); ++funcsIt) {
2095 while (index !=
kNPOS) {
2099 if ((index > 0) && (isalpha(formula[index - 1]) || formula[index - 1] ==
':')) {
2100 index = formula.
Index(shortcut, i2);
2103 if (i2 < formula.
Length() && formula[i2] !=
'(') {
2104 index = formula.
Index(shortcut, i2);
2109 Ssiz_t inext = index + full.Length();
2110 index = formula.
Index(shortcut, inext);
2117#ifdef TFORMULA_CHECK_FUNCTIONS
2123 size_t index =
name.rfind(
"::");
2124 assert(index != std::string::npos);
2132 TIter next(methodList);
2134 while ((p = (
TMethod *)next())) {
2135 if (strcmp(p->
GetName(), functionName.
Data()) == 0 &&
2150 if (
f && fun.
GetNargs() <=
f->GetNargs() && fun.
GetNargs() >=
f->GetNargs() -
f->GetNargsOpt()) {
2158 Info(
"TFormula",
"Could not find %s function with %d argument(s)", fun.
GetName(), fun.
GetNargs());
2181 map<TString, TFormulaVariable>::iterator varsIt =
fVars.find(fun.
GetName());
2182 if (varsIt !=
fVars.end()) {
2185 Double_t value = (*varsIt).second.fValue;
2191 int varDim = (*varsIt).second.fArrayPos;
2192 if (varDim >=
fNdim) {
2197 if (
v.second.fArrayPos < varDim && !
v.second.fFound) {
2199 v.second.fFound =
true;
2220 int digit = sdigit.
Atoi();
2221 if (digit >=
fNdim) {
2224 for (
int j = 0; j <
fNdim; ++j) {
2228 fVars[vname].fFound =
true;
2243 if (paramsIt !=
fParams.end()) {
2260 map<TString, Double_t>::iterator constIt =
fConsts.find(fun.
GetName());
2261 if (constIt !=
fConsts.end()) {
2280 if (!hasParameters) {
2294 if (inputIntoCling) {
2297 std::string inputFormula(formula.
Data());
2301 std::string inputFormulaVecFlag = inputFormula;
2303 inputFormulaVecFlag +=
" (vectorized)";
2308 TString argumentsPrototype =
TString::Format(
"%s%s%s", ( (hasVariables || hasParameters) ? (argType +
" *x").Data() :
""),
2309 (hasParameters ?
"," :
""), (hasParameters ?
"Double_t *p" :
""));
2326 inputIntoCling =
false;
2336 argumentsPrototype.
Data(), inputFormula.c_str());
2355 if (inputIntoCling) {
2381 for (list<TFormulaFunction>::iterator it =
fFuncs.begin(); it !=
fFuncs.end(); ++it) {
2383 if (!it->fFound && !it->IsFuncCall()) {
2385 if (it->GetNargs() == 0)
2386 Error(
"ProcessFormula",
"\"%s\" has not been matched in the formula expression", it->GetName());
2388 Error(
"ProcessFormula",
"Could not find %s function with %d argument(s)", it->GetName(), it->GetNargs());
2399 auto itvar =
fVars.begin();
2402 if (!itvar->second.fFound) {
2404 itvar =
fVars.erase(itvar);
2407 }
while (itvar !=
fVars.end());
2418 make_pair(make_pair(
"gaus", 1), make_pair(
"[0]*exp(-0.5*(({V0}-[1])/[2])*(({V0}-[1])/[2]))",
2419 "[0]*exp(-0.5*(({V0}-[1])/[2])*(({V0}-[1])/[2]))/(sqrt(2*pi)*[2])")));
2420 functions.insert(make_pair(make_pair(
"landau", 1), make_pair(
"[0]*TMath::Landau({V0},[1],[2],false)",
2421 "[0]*TMath::Landau({V0},[1],[2],true)")));
2422 functions.insert(make_pair(make_pair(
"expo", 1), make_pair(
"exp([0]+[1]*{V0})",
"")));
2424 make_pair(make_pair(
"crystalball", 1), make_pair(
"[0]*ROOT::Math::crystalball_function({V0},[3],[4],[2],[1])",
2425 "[0]*ROOT::Math::crystalball_pdf({V0},[3],[4],[2],[1])")));
2427 make_pair(make_pair(
"breitwigner", 1), make_pair(
"[0]*ROOT::Math::breitwigner_pdf({V0},[2],[1])",
2428 "[0]*ROOT::Math::breitwigner_pdf({V0},[2],[4],[1])")));
2430 functions.insert(make_pair(make_pair(
"cheb0", 1), make_pair(
"ROOT::Math::Chebyshev0({V0},[0])",
"")));
2431 functions.insert(make_pair(make_pair(
"cheb1", 1), make_pair(
"ROOT::Math::Chebyshev1({V0},[0],[1])",
"")));
2432 functions.insert(make_pair(make_pair(
"cheb2", 1), make_pair(
"ROOT::Math::Chebyshev2({V0},[0],[1],[2])",
"")));
2433 functions.insert(make_pair(make_pair(
"cheb3", 1), make_pair(
"ROOT::Math::Chebyshev3({V0},[0],[1],[2],[3])",
"")));
2435 make_pair(make_pair(
"cheb4", 1), make_pair(
"ROOT::Math::Chebyshev4({V0},[0],[1],[2],[3],[4])",
"")));
2437 make_pair(make_pair(
"cheb5", 1), make_pair(
"ROOT::Math::Chebyshev5({V0},[0],[1],[2],[3],[4],[5])",
"")));
2439 make_pair(make_pair(
"cheb6", 1), make_pair(
"ROOT::Math::Chebyshev6({V0},[0],[1],[2],[3],[4],[5],[6])",
"")));
2441 make_pair(make_pair(
"cheb7", 1), make_pair(
"ROOT::Math::Chebyshev7({V0},[0],[1],[2],[3],[4],[5],[6],[7])",
"")));
2442 functions.insert(make_pair(make_pair(
"cheb8", 1),
2443 make_pair(
"ROOT::Math::Chebyshev8({V0},[0],[1],[2],[3],[4],[5],[6],[7],[8])",
"")));
2444 functions.insert(make_pair(make_pair(
"cheb9", 1),
2445 make_pair(
"ROOT::Math::Chebyshev9({V0},[0],[1],[2],[3],[4],[5],[6],[7],[8],[9])",
"")));
2447 make_pair(make_pair(
"cheb10", 1),
2448 make_pair(
"ROOT::Math::Chebyshev10({V0},[0],[1],[2],[3],[4],[5],[6],[7],[8],[9],[10])",
"")));
2451 make_pair(make_pair(
"gaus", 2), make_pair(
"[0]*exp(-0.5*(({V0}-[1])/[2])^2 - 0.5*(({V1}-[3])/[4])^2)",
"")));
2453 make_pair(make_pair(
"landau", 2),
2454 make_pair(
"[0]*TMath::Landau({V0},[1],[2],false)*TMath::Landau({V1},[3],[4],false)",
"")));
2455 functions.insert(make_pair(make_pair(
"expo", 2), make_pair(
"exp([0]+[1]*{V0})",
"exp([0]+[1]*{V0}+[2]*{V1})")));
2458 make_pair(make_pair(
"gaus", 3), make_pair(
"[0]*exp(-0.5*(({V0}-[1])/[2])^2 - 0.5*(({V1}-[3])/[4])^2 - 0.5*(({V2}-[5])/[6])^2)",
"")));
2461 make_pair(make_pair(
"bigaus", 2), make_pair(
"[0]*ROOT::Math::bigaussian_pdf({V0},{V1},[2],[4],[5],[1],[3])",
2462 "[0]*ROOT::Math::bigaussian_pdf({V0},{V1},[2],[4],[5],[1],[3])")));
2554 if (i < 0 || i >=
n ) {
2555 Error(
"GetLinearPart",
"Formula %s has only %d linear parts - requested %d",
GetName(),
n,i);
2601 Bool_t anyNewVar =
false;
2604 const TString &vname = vars[i];
2614 Int_t multiplier = 2;
2615 if (
fFuncs.size() > 100) {
2640 Error(
"SetName",
"The name \'%s\' is reserved as a TFormula variable name.\n"
2641 "\tThis function will not be renamed.",
2646 auto listOfFunctions =
gROOT->GetListOfFunctions();
2647 TObject* thisAsFunctionInList =
nullptr;
2649 if (listOfFunctions){
2650 thisAsFunctionInList = listOfFunctions->
FindObject(
this);
2651 if (thisAsFunctionInList) listOfFunctions->Remove(thisAsFunctionInList);
2654 if (thisAsFunctionInList) listOfFunctions->Add(thisAsFunctionInList);
2672 fVars[
v.first].fValue =
v.second;
2675 Error(
"SetVariables",
"Variable %s is not defined.",
v.first.Data());
2686 if (
fVars.end() == nameIt) {
2687 Error(
"GetVariable",
"Variable %s is not defined.",
name);
2690 return nameIt->second.fValue;
2699 if (
fVars.end() == nameIt) {
2700 Error(
"GetVarNumber",
"Variable %s is not defined.",
name);
2703 return nameIt->second.fArrayPos;
2711 if (ivar < 0 || ivar >=
fNdim)
return "";
2714 for (
auto &
v :
fVars) {
2715 if (
v.second.fArrayPos == ivar)
return v.first;
2717 Error(
"GetVarName",
"Variable with index %d not found !!",ivar);
2728 Error(
"SetVariable",
"Variable %s is not defined.",
name.Data());
2767 auto ret =
fParams.insert(std::make_pair(
name, pos));
2773 if (ret.first ==
fParams.begin())
2776 auto previous = (ret.first);
2778 pos = previous->second + 1;
2786 Warning(
"inserting parameter %s at pos %d when vector size is %d \n",
name.Data(), pos,
2796 for (
auto it = ret.first; it !=
fParams.end(); ++it) {
2806 if (processFormula) {
2834 Error(
"GetParameter",
"Parameter %s is not defined.",
name);
2849 Error(
"GetParameter",
"wrong index used - use GetParameter(name)");
2858 if (ipar < 0 || ipar >=
fNpar)
return "";
2862 if (p.second == ipar)
return p.first.Data();
2864 Error(
"GetParName",
"Parameter with index %d not found !!",ipar);
2897 Error(
"SetParameter",
"Parameter %s is not defined.",
name.Data());
2904 for (map<TString, TFormulaVariable>::iterator it =
fParams.begin(); it !=
fParams.end(); ++it) {
2905 if (!it->second.fFound) {
2926 pair<TString, Double_t> p = params[i];
2928 Error(
"SetParameters",
"Parameter %s is not defined", p.first.Data());
2931 fParams[p.first].fValue = p.second;
2932 fParams[p.first].fFound =
true;
2936 for (map<TString, TFormulaVariable>::iterator it =
fParams.begin(); it !=
fParams.end(); ++it) {
2937 if (!it->second.fFound) {
2948 if(!params || size < 0 || size >
fNpar)
return;
3000 if (param < 0 || param >=
fNpar)
return;
3009 const char *name4,
const char *name5,
const char *name6,
const char *name7,
3010 const char *name8,
const char *name9,
const char *name10)
3040 if (ipar < 0 || ipar >
fNpar) {
3041 Error(
"SetParName",
"Wrong Parameter index %d ",ipar);
3047 if (it.second == ipar) {
3055 Error(
"SetParName",
"Parameter %d is not existing.",ipar);
3068 if (!formula.
IsNull() ) {
3070 for(list<TFormulaFunction>::iterator it =
fFuncs.begin(); it !=
fFuncs.end(); ++it)
3072 if (oldName == it->GetName()) {
3079 Error(
"SetParName",
"Parameter %s is not defined.", oldName.
Data());
3095#ifdef R__HAS_VECCORE
3097 Info(
"SetVectorized",
"Cannot vectorized a function of zero dimension");
3102 Error(
"SetVectorized",
"Cannot set vectorized to %d -- Formula is missing", vectorized);
3120 Warning(
"SetVectorized",
"Cannot set vectorized -- try building with option -Dbuiltin_veccore=On");
3130#ifdef R__HAS_VECCORE
3134 return vecCore::Get( ret, 0 );
3141 Info(
"EvalPar",
"Function is vectorized - converting Double_t into ROOT::Double_v and back");
3144 const int maxDim = 4;
3145 std::array<ROOT::Double_v, maxDim> xvec;
3146 for (
int i = 0; i <
fNdim; i++)
3150 return vecCore::Get(ans, 0);
3153 std::vector<ROOT::Double_v> xvec(
fNdim);
3154 for (
int i = 0; i <
fNdim; i++)
3158 return vecCore::Get(ans, 0);
3163 Error(
"EvalPar",
"Formula is vectorized (even though VECCORE is disabled!)");
3175 if (!IsCladRuntimeIncluded) {
3176 IsCladRuntimeIncluded =
true;
3177 gInterpreter->Declare(
"#include <Math/CladDerivator.h>\n#pragma clad OFF");
3183 std::string &GenerationInput) {
3184 std::string ReqFuncName = FuncName +
"_req";
3186 GenerationInput = std::string(
"#pragma cling optimize(2)\n") +
3187 "#pragma clad ON\n" +
3188 "void " + ReqFuncName +
"() {\n" +
3189 CladStatement +
"\n " +
3198 Bool_t hasParameters = (Npar > 0);
3199 Bool_t hasVariables = (Ndim > 0);
3200 std::unique_ptr<TMethodCall>
3201 method =
prepareMethod(hasParameters, hasVariables, FuncName.c_str(),
3223 (*FuncPtr)(0, 2, args,
nullptr);
3238 struct array_ref_interface {
3243 array_ref_interface ari{result,
static_cast<size_t>(result_size)};
3245 (*FuncPtr)(0, 3, args,
nullptr);
3265 std::string GradientCall
3266 (
"clad::gradient(" + std::string(
fClingName.
Data()) +
", \"p\");");
3283 Error(
"GradientPar",
"Could not initialize the formula!");
3288 Error(
"GradientPar",
"Could not generate a gradient for the formula %s!",
3293 if ((
int)result.size() <
fNpar) {
3295 "The size of gradient result is %zu but %d is required. Resizing.",
3296 result.size(),
fNpar);
3297 result.resize(
fNpar);
3325 std::string indexes = (
fNpar - 1 == 0) ?
"0" : std::string(
"0:")
3326 + std::to_string(
fNpar - 1);
3327 std::string HessianCall
3329 + indexes +
"]\" );");
3345 Error(
"HessianPar",
"Could not initialize the formula!");
3350 Error(
"HessianPar",
"Could not generate a hessian for the formula %s!",
3355 if ((
int)result.size() <
fNpar) {
3357 "The size of hessian result is %zu but %d is required. Resizing.",
3371#ifdef R__HAS_VECCORE
3381 return DoEvalVec(
x, params);
3384 return DoEval(
nullptr, params);
3389 Info(
"EvalPar",
"Function is not vectorized - converting ROOT::Double_v into Double_t and back");
3391 const int vecSize = vecCore::VectorSize<ROOT::Double_v>();
3392 std::vector<Double_t> xscalars(vecSize*
fNdim);
3394 for (
int i = 0; i < vecSize; i++)
3395 for (
int j = 0; j <
fNdim; j++)
3396 xscalars[i*
fNdim+j] = vecCore::Get(
x[j],i);
3399 for (
int i = 0; i < vecSize; i++)
3400 vecCore::Set(answers, i,
DoEval(&xscalars[i*
fNdim], params));
3411 double xxx[4] = {
x,
y,z,t};
3420 double xxx[3] = {
x,
y,z};
3429 double xxx[2] = {
x,
y};
3452 Error(
"Eval",
"Formula is invalid and not ready to execute ");
3453 for (
auto it =
fFuncs.begin(); it !=
fFuncs.end(); ++it) {
3456 printf(
"%s is unknown.\n", fun.
GetName());
3468 auto thisFormula =
const_cast<TFormula*
>(
this);
3472 Error(
"DoEval",
"Formula has error and it is not properly initialized ");
3478 std::function<
double(
double *,
double *)> & fptr = * ( (std::function<
double(
double *,
double *)> *)
fLambdaPtr);
3481 double *
v =
const_cast<double*
>(
x);
3482 double * p = (params) ?
const_cast<double*
>(params) :
const_cast<double*
>(
fClingParameters.data());
3489 double * vars = (
x) ?
const_cast<double*
>(
x) :
const_cast<double*
>(
fClingVariables.data());
3492 (*fFuncPtr)(0, 1, args, &result);
3494 double *pars = (params) ?
const_cast<double *
>(params) :
const_cast<double *
>(
fClingParameters.data());
3496 (*fFuncPtr)(0, 2, args, &result);
3503#ifdef R__HAS_VECCORE
3507 Error(
"Eval",
"Formula is invalid and not ready to execute ");
3508 for (
auto it =
fFuncs.begin(); it !=
fFuncs.end(); ++it) {
3511 printf(
"%s is unknown.\n", fun.
GetName());
3523 auto thisFormula =
const_cast<TFormula*
>(
this);
3527 Error(
"DoEval",
"Formula has error and it is not properly initialized ");
3539 (*fFuncPtr)(0, 1, args, &result);
3541 double *pars = (params) ?
const_cast<double *
>(params) :
const_cast<double *
>(
fClingParameters.data());
3543 (*fFuncPtr)(0, 2, args, &result);
3560 Info(
"ReInitializeEvalMethod",
"compile now lambda expression function using Cling");
3567 if (!
fLazyInitialization)
Warning(
"ReInitializeEvalMethod",
"Formula is NOT properly initialized - try calling again TFormula::PrepareEvalMethod");
3626 std::size_t found = clingFunc.find(
"return");
3627 std::size_t found2 = clingFunc.rfind(
";");
3628 if (found == std::string::npos || found2 == std::string::npos) {
3629 Error(
"GetExpFormula",
"Invalid Cling expression - return default formula expression");
3634 if (!opt.
Contains(
"P"))
return clingFormula;
3637 while (i < clingFormula.
Length()-2 ) {
3639 if (clingFormula[i] ==
'p' && clingFormula[i+1] ==
'[' && isdigit(clingFormula[i+2]) ) {
3641 while ( isdigit(clingFormula[j]) ) { j++;}
3642 if (clingFormula[j] !=
']') {
3643 Error(
"GetExpFormula",
"Parameters not found - invalid expression - return default cling formula");
3644 return clingFormula;
3646 TString parNumbName = clingFormula(i+2,j-i-2);
3647 int parNumber = parNumbName.
Atoi();
3648 assert(parNumber <
fNpar);
3650 clingFormula.
Replace(i,j-i+1, replacement );
3651 i += replacement.
Length();
3655 return clingFormula;
3661 while (i < expFormula.
Length()-2 ) {
3663 if (expFormula[i] ==
'[') {
3665 while ( expFormula[j] !=
']' ) { j++;}
3666 if (expFormula[j] !=
']') {
3667 Error(
"GetExpFormula",
"Parameter names not found - invalid expression - return default formula");
3670 TString parName = expFormula(i+1,j-i-1);
3672 expFormula.
Replace(i,j-i+1, replacement );
3673 i += replacement.
Length();
3679 Warning(
"GetExpFormula",
"Invalid option - return default formula expression");
3684 std::unique_ptr<TInterpreterValue>
v =
gInterpreter->MakeInterpreterValue();
3685 std::string s(
"(void (&)(Double_t *, Double_t *, clad::array_ref<Double_t>)) ");
3688 return v->ToString();
3692 std::unique_ptr<TInterpreterValue>
v =
gInterpreter->MakeInterpreterValue();
3694 return v->ToString();
3703 printf(
" Formula expression: \n");
3712 printf(
"List of Variables: \n");
3714 for (
int ivar = 0; ivar <
fNdim ; ++ivar) {
3719 printf(
"List of Parameters: \n");
3724 for (
int ipar = 0; ipar <
fNpar ; ++ipar) {
3728 printf(
"Expression passed to Cling:\n");
3731 printf(
"Generated Gradient:\n");
3736 printf(
"Generated Hessian:\n");
3743 Warning(
"Print",
"Formula is not ready to execute. Missing parameters/variables");
3744 for (list<TFormulaFunction>::const_iterator it =
fFuncs.begin(); it !=
fFuncs.end(); ++it) {
3747 printf(
"%s is unknown.\n", fun.
GetName());
3770 if (
b.IsReading() ) {
3774 if (v <= 8 && v > 3 &&
v != 6) {
3778 fold->
Streamer(
b,
v, R__s, R__c, TFormula::Class());
3787 Error(
"Streamer",
"Old formula read from file is NOT valid");
3795 b.ReadClassBuffer(TFormula::Class(),
this,
v, R__s, R__c);
3840 if (
fNpar != (
int) parValues.size() ) {
3841 Error(
"Streamer",
"number of parameters computed (%d) is not same as the stored parameters (%d)",
fNpar,
int(parValues.size()) );
3844 if (
v > 11 &&
fNdim != ndim) {
3845 Error(
"Streamer",
"number of dimension computed (%d) is not same as the stored value (%d)",
fNdim, ndim );
3860 assert(
fNpar == (
int) parValues.size() );
3863 if (
fParams.size() != paramMap.size() ) {
3864 Warning(
"Streamer",
"number of parameters list found (%zu) is not same as the stored one (%zu) - use re-created list",
fParams.size(),paramMap.size()) ;
3880 gROOT->GetListOfFunctions()->Add(
this);
3883 Error(
"Streamer",
"Formula read from file is NOT ready to execute");
3891 Error(
"Streamer",
"Reading version %d is not supported",
v);
3897 b.WriteClassBuffer(TFormula::Class(),
this);
typedef void(GLAPIENTRYP _GLUfuncptr)(void)
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
void GetParameters(TFitEditor::FuncParams_t &pars, TF1 *func)
Stores the parameters of the given function into pars.
R__EXTERN TInterpreter * gCling
R__EXTERN TVirtualMutex * gROOTMutex
#define R__LOCKGUARD(mutex)
Buffer base class used for serializing objects.
TClass instances represent classes, structs and namespaces in the ROOT type system.
const TList * GetListOfAllPublicMethods(Bool_t load=kTRUE)
Returns a list of all public methods of this class and its base classes.
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
virtual TFormula * GetFormula()
Global functions class (global functions are obtained from CINT).
Int_t GetNargsOpt() const
Number of function optional (default) arguments.
Int_t GetNargs() const
Number of function arguments.
virtual Bool_t Declare(const char *code)=0
virtual Longptr_t ProcessLine(const char *line, EErrorCode *error=0)=0
virtual Bool_t CallFunc_IsValid(CallFunc_t *) const
virtual CallFuncIFacePtr_t CallFunc_IFacePtr(CallFunc_t *) const
Method or function calling interface.
CallFunc_t * GetCallFunc() const
Each ROOT class (see TClass) has a linked list of methods.
The TNamed class is the base class for all named ROOT classes.
virtual void Copy(TObject &named) const
Copy this to obj.
virtual void SetName(const char *name)
Set the name of the TNamed.
virtual const char * GetTitle() const
Returns title of object.
virtual const char * GetName() const
Returns name of object.
Mother of all ROOT objects.
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual TObject * FindObject(const char *name) const
Must be redefined in derived classes.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Regular expression class.
Ssiz_t Index(const TString &str, Ssiz_t *len, Ssiz_t start=0) const
Find the first occurrence of the regexp in string and return the position, or -1 if there is no match...
TString & Insert(Ssiz_t pos, const char *s)
Int_t Atoi() const
Return integer value of string.
TString & Replace(Ssiz_t pos, Ssiz_t n, const char *s)
const char * Data() const
Bool_t IsDigit() const
Returns true if all characters in string are digits (0-9) or white spaces, i.e.
TString & ReplaceAll(const TString &s1, const TString &s2)
Ssiz_t Last(char c) const
Find last occurrence of a character c.
void ToUpper()
Change string to upper case.
Int_t CountChar(Int_t c) const
Return number of times character c occurs in the string.
TString & Append(const char *cs)
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
std::vector< std::string > Split(std::string_view str, std::string_view delims, bool skipEmpty=false)
Splits a string at each character in delims.
constexpr Double_t G()
Gravitational constant in: .
constexpr Double_t C()
Velocity of light in .
Short_t Max(Short_t a, Short_t b)
Double_t QuietNaN()
Returns a quiet NaN as defined by IEEE 754
Double_t Floor(Double_t x)
constexpr Double_t K()
Boltzmann's constant in .
constexpr Double_t Sqrt2()
constexpr Double_t E()
Base of natural log:
constexpr Double_t Sigma()
Stefan-Boltzmann constant in .
constexpr Double_t H()
Planck's constant in .
constexpr Double_t LogE()
Base-10 log of e (to convert ln to log)
constexpr Double_t Ln10()
Natural log of 10 (to convert log to ln)
constexpr Double_t EulerGamma()
Euler-Mascheroni Constant.
constexpr Double_t R()
Universal gas constant ( ) in
Double_t Log10(Double_t x)
Double_t Infinity()
Returns an infinity as defined by the IEEE standard.
void(* Generic_t)(void *, int, void **, void *)