use of com.sri.ai.grinder.sgdpllt.library.number.Exponentiation in project aic-expresso by aic-sri-international.
the class DefaultMonomial method computeInnerExpression.
//
// PROTECTED
//
@Override
protected Expression computeInnerExpression() {
Expression result;
if (isNumericConstant()) {
result = numericConstantFactorExpression;
} else {
List<Expression> args = new ArrayList<>(1 + orderedNonNumericFactors.size());
if (!getNumericConstantFactor().equals(Rational.ONE)) {
args.add(numericConstantFactorExpression);
}
args.addAll(zipWith((base, power) -> {
Expression arg;
if (power.equals(Rational.ONE)) {
// No need to include exponentiation
arg = base;
} else {
arg = Exponentiation.make(base, power);
}
return arg;
}, orderedNonNumericFactors, orderedNonNumericFactorPowers));
if (args.size() == 1) {
// simplified to a single argument
// (i.e. numeric constant was 1 as we know we have at least one
// non-numeric constant term here).
result = args.get(0);
} else {
result = new DefaultFunctionApplication(MONOMIAL_FUNCTOR, args);
}
}
return result;
}
Aggregations