// pip_List_print(stdout,__pipv);
log.trace("param: " + __param);
log.trace("pipv: " + __pipv);
Expression result_pos;
Expression result_neg;
if (__pipv.get(nb_parameters + __new_param.size()).signum() >= 0) { // constant
// FIXME: Downcasting
int value = (int)__pipv.get(nb_parameters + __new_param.size()).value();
result_pos = new Expression(value);
result_neg = new Expression(0);
} else {
int value = (int)__pipv.get(nb_parameters + __new_param.size()).value();
result_pos = new Expression(0);
result_neg = new Expression(-1 * value);
}
for (int i = 0; i < nb_parameters; i++) { // handle old parameters
// FIXME: Downcasting
int coef = (int) __pipv.get(i).value();
// cout<<"\n i = "<<i<<" coef = "<<coef<<" nom param = "<<__param.operator[](i);
if (coef != 0) {
Expression param = new Expression(__param.get(i));
switch (coef) {
case 1:
result_pos = new Expression(result_pos, Expression.Operation.FADA_ADD, param);
break;
case -1:
result_neg = new Expression(result_neg, Expression.Operation.FADA_ADD, param);
break;
case 0:
break;
default: {
if (coef > 0) {
Expression __coef = new Expression(coef);
Expression __term = new Expression(__coef, Expression.Operation.FADA_MUL, param);
result_pos = new Expression(result_pos, Expression.Operation.FADA_ADD, __term);
} else {
Expression __coef = new Expression(-1 * coef);
Expression __term = new Expression(__coef, Expression.Operation.FADA_MUL, param);
result_neg = new Expression(result_pos, Expression.Operation.FADA_ADD, __term);
}
break;
}
}
}
}
// cout<<"\n\nhhhhhhhhhhhhhhhhh\n";
// Newparms handling
for (int i : __new_param.keySet()) {
Expression param = __new_param.get(i);
// FIXME: Downcasting
int coef = (int) __pipv.get(i).value();
switch (coef) {
case 0:
break;
case 1:
result_pos = new Expression(result_pos, Expression.Operation.FADA_ADD, param);
break;
case -1:
result_neg = new Expression(result_neg, Expression.Operation.FADA_ADD, param);
break;
default:
if (coef > 0) {
Expression __coef = new Expression(coef);
Expression __term = new Expression(__coef, Expression.Operation.FADA_MUL, param);
result_pos = new Expression(result_pos, Expression.Operation.FADA_ADD, __term);
} else {
Expression __coef = new Expression(-1 * coef);
Expression __term = new Expression(__coef, Expression.Operation.FADA_MUL, param);
result_neg = new Expression(result_pos, Expression.Operation.FADA_ADD, __term);
}
break;
}
}
result_pos = result_pos.Simplify();
// result_pos.Print();
Expression final_res = new Expression(result_pos.Simplify(), Expression.Operation.FADA_SUB, result_neg.Simplify());
// cout<<"\n\nhhhhhhhhhhhhhhhhh\n";
// final_res.Print();
return final_res;
}