本文整理汇总了C++中ExpressionPtr::set方法的典型用法代码示例。如果您正苦于以下问题:C++ ExpressionPtr::set方法的具体用法?C++ ExpressionPtr::set怎么用?C++ ExpressionPtr::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExpressionPtr
的用法示例。
在下文中一共展示了ExpressionPtr::set方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runTests9
void runTests9 (int argc, char* argv[])
{
ExpressionListPtr pRowPermutations = Util::quickPerm(5);
ExpressionListPtr pColPermutations = Util::quickPerm(2);
ExpressionListPtr pVarPermutations = Util::quickPerm(1);
ilog("row permutations");
pRowPermutations->print();
ilog("col permutations");
pColPermutations->print();
ilog("outcome permutations");
pVarPermutations->print();
ilog("---- p: ----");
ExpressionPtr p = new Expression;
p->set(0, 0, 0, 1);
p->set(0, 1, 0, 1);
p->set(1, 0, 0, 1);
p->set(1, 1, 0, -1);
p->set(2, 0, 0, 0);
p->set(2, 1, 0, 0);
p->set(3, 0, 0, -1);
p->set(3, 1, 0, 1);
p->set(4, 0, 0, -1);
p->set(4, 1, 0, -1);
p->printMatrix();
//-1 -1 1 1 -1 1 1 -1 0 0
ExpressionPtr p2 = new Expression;
p2->set(0, 0, 0, -1);
p2->set(0, 1, 0, 1);
p2->set(1, 0, 0, 1);
p2->set(1, 1, 0, 1);
p2->set(2, 0, 0, -1);
p2->set(2, 1, 0, 1);
p2->set(3, 0, 0, 1);
p2->set(3, 1, 0, -1);
p2->set(4, 0, 0, 0);
p2->set(4, 1, 0, 0);
ilog("---- p2: ----");
p2->printMatrix();
p2->isBetter(p);
ExpressionPtr pExp = p->findSpecialEquivalent(pRowPermutations, pColPermutations, pVarPermutations);
ilog("---- result: ----");
pExp->printMatrix();
ilog("--------");
}
示例2: parsePorta
bool parsePorta(ExpressionList* pList, N32 preparations, N32 measurements)
{
char str[0x10000];
FILE* pF = fopen("porta.poi.ieq", "r");
if (!pF)
{
errorExit("must have a porta.poi.ieq in the folder");
}
int dim = 0;
while(fgets(str, sizeof(str), pF))
{
#ifdef _PARSE_LOG
ilog("");
#endif
int nLen = strlen(str);
char* p = str;
XK(str[nLen - 1] == '\n');
str[nLen - 1] = 0;
char* pDim = strstr(p, "DIM = ");
if (pDim)
{
pDim += 6;
readNumber(pDim, dim);
#ifdef _PARSE_LOG
log("Dimension is %d:", dim);
#endif
continue;
}
if (!readChar(p, '('))
continue;
int nVertex;
if (!readNumber(p, nVertex))
errorExit("couldn't find a vertex number");
if (!readChar(p, ')'))
continue;
#ifdef _PARSE_LOG
log("%d:", nVertex);
#endif
N32 a[256];
for (int n = 0; n < 256; ++n)
a[n] = 0;
ExpressionPtr pIneq = new Expression();
pList->pushBack(pIneq);
int varIndexMax = -1;
while(true)
{
int sign;
int ine;
int rhs;
if(!readBlks(p))
errorExit("incomplet");
if (readIne(p, ine))
{
if (!readNumber(p, rhs))
errorExit("couldn't find lrs");
#ifdef _PARSE_LOG
log(" rhs: %d .... %s", rhs, str);
#endif
pIneq->setRHS(rhs);
pIneq->setIne(ine);
pIneq->setPortaExp(str);
break;
}
if (!readSign(p, sign))
errorExit("couldn't find a sign (+/-)");
int factor = 1;
readNumber(p, factor);
if (!readChar(p, 'x'))
errorExit("couldn't find a x");
int varIndex;
if (!readNumber(p, varIndex))
errorExit("couldn't find a >");
if (varIndex > varIndexMax)
//.........这里部分代码省略.........
示例3: parseLRS
static bool parseLRS(ExpressionList* pList, N32 preparations, N32 measurements)
{
static char szRepresentation[] = "H-representation";
bool bFoundRepresentation = false;
bool bBegin = false;
char str[0x10000];
FILE* pF = fopen("lrs.hf", "r");
if (!pF)
{
errorExit("This program uses always uses lrs.hf as input which I couldn't find");
}
while(fgets(str, sizeof(str), pF))
{
#ifdef _PARSE_LOG
ilog("");
#endif
int nLen = strlen(str);
char* p = str;
if(str[nLen - 1] == '\n')
str[nLen - 1] = 0;
if (*p == '#' || *p == '*')
continue;
if (!bFoundRepresentation)
{
char* pPresentation = strstr(p, szRepresentation);
if (pPresentation)
bFoundRepresentation = true;
continue;
}
if (!bBegin)
{
char* pBegin = strstr(p, "begin");
if (pBegin)
bBegin = true;
continue;
}
char* pEnd = strstr(p, "end");
if (pEnd)
break;
#ifdef _PARSE_LOG
ilog("");
#endif
N32 a[256];
for (int n = 0; n < 256; ++n)
a[n] = 0;
ExpressionPtr pIneq = new Expression();
pList->pushBack(pIneq);
int dPlusOne = 0;
while(true)
{
int ine;
int rhs;
N32 v = 0;
if(!readBlks(p))
break;
if (*p == 0)
break;
if (!readNumber2(p, v))
errorExit("error");
a[dPlusOne] = v;
++dPlusOne;
}
// in lrs the const is in LHS we need to change it to RHS
pIneq->setRHS(a[0]);
pIneq->setIne(-1);
for (int i = 1; i < dPlusOne; ++i)
{
TermPtr p = new Term();
p->setState(a[i]);
int n = i - 1;
//.........这里部分代码省略.........