Search in sources :

Example 1 with AlgebraicNumber

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;
}
Also used : GenPolynomial(edu.jas.poly.GenPolynomial) BigRational(edu.jas.arith.BigRational) AlgebraicNumber(edu.jas.poly.AlgebraicNumber) IASTAppendable(org.matheclipse.core.interfaces.IASTAppendable)

Example 2 with AlgebraicNumber

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;
    }
}
Also used : IASTAppendable(org.matheclipse.core.interfaces.IASTAppendable) BigRational(edu.jas.arith.BigRational) ExpVector(edu.jas.poly.ExpVector) Map(java.util.Map) SortedMap(java.util.SortedMap) AlgebraicNumber(edu.jas.poly.AlgebraicNumber)

Aggregations

BigRational (edu.jas.arith.BigRational)2 AlgebraicNumber (edu.jas.poly.AlgebraicNumber)2 IASTAppendable (org.matheclipse.core.interfaces.IASTAppendable)2 ExpVector (edu.jas.poly.ExpVector)1 GenPolynomial (edu.jas.poly.GenPolynomial)1 Map (java.util.Map)1 SortedMap (java.util.SortedMap)1