use of edu.jas.poly.AlgebraicNumber in project symja_android_library by axkr.
the class JASConvert method logIntegral2Expr.
/**
* Convert a jas <code>LogIntegral</code> into a matheclipse expression
*
* @param logIntegral the JAS LogIntegral
* @return
*/
public IAST logIntegral2Expr(LogIntegral<BigRational> logIntegral) {
List<BigRational> cfactors = logIntegral.cfactors;
List<GenPolynomial<BigRational>> cdenom = logIntegral.cdenom;
List<AlgebraicNumber<BigRational>> afactors = logIntegral.afactors;
List<GenPolynomial<AlgebraicNumber<BigRational>>> adenom = logIntegral.adenom;
IASTAppendable plus = F.PlusAlloc(cfactors.size() + afactors.size());
if (cfactors.size() > 0) {
for (int i = 0; i < cfactors.size(); i++) {
BigRational cp = cfactors.get(i);
GenPolynomial<BigRational> p = cdenom.get(i);
plus.append(F.Times(F.fraction(cp.numerator(), cp.denominator()), F.Log(rationalPoly2Expr(p, false))));
}
}
// TODO implement this conversion for AlgebraicNumbers...
if (afactors.size() > 0) {
for (int i = 0; i < afactors.size(); i++) {
AlgebraicNumber<BigRational> ap = afactors.get(i);
AlgebraicNumberRing<BigRational> ar = ap.factory();
GenPolynomial<AlgebraicNumber<BigRational>> p = adenom.get(i);
if (p.degree(0) < ar.modul.degree(0) && ar.modul.degree(0) > 2) {
}
GenPolynomial<BigRational> v = ap.getVal();
IASTAppendable times = F.TimesAlloc(2);
if (p.degree(0) < ar.modul.degree(0) && ar.modul.degree(0) > 2) {
IASTAppendable rootOf = F.ast(S.RootOf);
rootOf.append(rationalPoly2Expr(ar.modul, false));
times.append(rootOf);
throw new UnsupportedOperationException("JASConvert#logIntegral2Expr()");
}
times.append(rationalPoly2Expr(v, false));
times.append(F.Log(polyAlgebraicNumber2Expr(p)));
plus.append(times);
}
}
return plus;
}
use of edu.jas.poly.AlgebraicNumber in project symja_android_library by axkr.
the class JASConvert method polyAlgebraicNumber2Expr.
public IAST polyAlgebraicNumber2Expr(final GenPolynomial<AlgebraicNumber<BigRational>> poly) throws ArithmeticException, JASConversionException {
if (poly.length() == 0) {
return F.Plus(F.C0);
}
SortedMap<ExpVector, AlgebraicNumber<BigRational>> val = poly.getMap();
if (val.size() == 0) {
return F.Plus(F.C0);
} else {
IASTAppendable result = F.PlusAlloc(val.size());
for (Map.Entry<ExpVector, AlgebraicNumber<BigRational>> m : val.entrySet()) {
AlgebraicNumber<BigRational> coeff = m.getValue();
ExpVector exp = m.getKey();
IASTAppendable monomTimes = F.TimesAlloc(exp.length() + 1);
monomialToExpr(coeff, exp, monomTimes);
result.append(monomTimes.oneIdentity1());
}
return result;
}
}
Aggregations