本文整理汇总了C++中StringParser::setVariables方法的典型用法代码示例。如果您正苦于以下问题:C++ StringParser::setVariables方法的具体用法?C++ StringParser::setVariables怎么用?C++ StringParser::setVariables使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringParser
的用法示例。
在下文中一共展示了StringParser::setVariables方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main (int argc, char** argv)
{
StringParser sp;
sp.setVariables({"x", "y", "z"});
//Pol p1 = sp.parseMultivariatePolynomial<Rational>("x^2*y^4*z^5*3 + x^3*10*y^4 + 20*z^6*y^2 + 21*x^9*z^2 + 4*x*y");
Pol p1 = sp.parseMultivariatePolynomial<Rational>("x*y + x*z + 2*x");
//Pol p1 = sp.parseMultivariatePolynomial<Rational>("12*x +13*x^2+3*x ");
//Pol p1 = sp.parseMultivariatePolynomial<Rational>("2184*x^17+15708*z+(-126672)*x^2+643384*z^3+(-2306444)*z^4+4162512*x^13+(-10186920)*z^12+18820800*x^11+(-27118448)*x^10+31123477*x^9+6199788*x^5+(-12956461)*x^6+21524503*x^7+(-28784511)*x^8+(-1226048)*x^14+245224*y^15+(-31192)*y^16+(-924)");
std::set<Variable> allVarInPolynome;
p1.gatherVariables(allVarInPolynome);
std::map<Variable, Interval<double>> map;
for(auto i : allVarInPolynome) {
if (i.getId() == 1)
{
Interval<double> ix (-2, 2);
map[i] = ix;
}
if (i.getId() == 2)
{
Interval<double> iy (0, 1);
map[i] = iy;
}
if (i.getId() == 3)
{
Interval<double> iz (0, 1);
map[i] = iz;
}
}
std::cout << "\n Polynom :" << p1 << std::endl;
MultivariateHorner< Pol, strategy > peterPolynom (std::move(p1));
//MultivariateHorner< Pol, GREEDY_IIs > peterPolynom2 (p1,map);
std::cout << "\n GREEDY_Is :" << peterPolynom << std::endl;
//std::cout << " GREEDY_IIs :" << peterPolynom2 << std::endl;
Interval<double> testInterval = IntervalEvaluation::evaluate(peterPolynom ,map);
//Interval<Rational> testInterval2 = evaluate(peterPolynom2 , map);
std::cout << "\n Evaluate Horner :" << testInterval << std::endl;
//std::cout << " Evaluate Horner2:" << testInterval2 << std::endl;
/*
Rational u_a;
Rational l_a;
Rational u_b;
Rational l_b;
Rational u_c;
Rational l_c;
std::map<Variable, Interval<Rational>> map;
VariablePool& vpool = VariablePool::getInstance();
Variable a = vpool.getFreshVariable();
vpool.setName(a, "a");
Variable b = vpool.getFreshVariable();
vpool.setName(b, "b");
Variable c = vpool.getFreshVariable();
vpool.setName(c, "c");
int l = 0;
int n = 0;
for (int i = 1; i <= 6; i++)
{
switch (i)
{
case 1 : l_a = -200; u_a = -100;
break;
case 2 : l_a = -100; u_a = 0;
break;
case 3 : l_a = -100; u_a = 100;
break;
case 4 : l_a = 0; u_a = 0;
break;
case 5 : l_a = 0; u_a = 100;
break;
case 6 : l_a = 100; u_a = 200;
break;
}
for (int j = 1; j <= 6; j++)
{
switch (j)
{
case 1 : l_b = -201; u_b = -101;
break;
case 2 : l_b = -101; u_b = 0;
break;
case 3 : l_b = -101; u_b = 101;
break;
case 4 : l_b = 0; u_b = 0;
break;
case 5 : l_b = 0; u_b = 101;
break;
//.........这里部分代码省略.........