use of org.matheclipse.core.interfaces.IComplex in project symja_android_library by axkr.
the class PolynomialHomogenization method replaceTimes.
private IExpr replaceTimes(final IAST ast, final IExpr base, IExpr exp) {
IExpr first = exp.first();
if (first.isComplex() && ((IComplex) first).reRational().isZero()) {
IRational imPart = ((IComplex) first).imRational();
int exponent = imPart.toIntDefault();
if (exponent == Integer.MIN_VALUE) {
return replaceExpression(ast).orElse(ast);
} else if (exponent > 0) {
IASTMutable restExponent = ((IAST) exp).setAtCopy(1, F.CI);
return F.Power(replaceExpression(base.power(restExponent)), exponent);
}
return replaceExpression(ast);
}
int exponent = first.toIntDefault();
if (exponent == Integer.MIN_VALUE) {
return replaceExpression(ast);
} else if (exponent > 0) {
IExpr rest = exp.rest().oneIdentity1();
return F.Power(replaceExpression(base.power(rest)), exponent);
}
return replaceExpression(ast).orElse(ast);
}
use of org.matheclipse.core.interfaces.IComplex in project symja_android_library by axkr.
the class PolynomialHomogenization method determineTimes.
private void determineTimes(final IAST ast, final IExpr base, IAST timesExponent) {
IExpr first = timesExponent.first();
if (first.isComplex() && ((IComplex) first).reRational().isZero()) {
IRational pureImPart = ((IComplex) first).imRational();
int exponent = pureImPart.toIntDefault();
if (exponent == Integer.MIN_VALUE) {
replaceExpressionLCM(ast, F.C1);
return;
} else if (exponent > 0) {
IASTMutable restExponent = timesExponent.setAtCopy(1, F.CI);
replaceExpressionLCM(base.power(restExponent), F.C1);
return;
}
replaceExpressionLCM(ast, F.C1);
return;
}
int exponent = first.toIntDefault();
if (exponent == Integer.MIN_VALUE) {
replaceExpressionLCM(ast, F.C1);
return;
} else if (exponent > 0) {
IExpr rest = timesExponent.rest().oneIdentity1();
replaceExpressionLCM(base.power(rest), F.C1);
return;
}
replaceExpressionLCM(ast, F.C1);
}
Aggregations