Search in sources :

Example 11 with ExpVector

use of edu.jas.poly.ExpVector in project symja_android_library by axkr.

the class JASModInteger method modLongPoly2Expr.

public IExpr modLongPoly2Expr(final GenPolynomial<ModLong> poly) throws ArithmeticException, ClassCastException {
    if (poly.length() == 0) {
        return F.Plus(F.C0);
    }
    IAST result = F.Plus();
    for (Monomial<ModLong> monomial : poly) {
        ModLong coeff = monomial.coefficient();
        ExpVector exp = monomial.exponent();
        IInteger coeffValue = F.integer(coeff.getVal());
        IAST monomTimes = F.Times();
        monomialToExpr(coeffValue, exp, monomTimes);
        result.append(monomTimes.getOneIdentity(F.C1));
    }
    return result.getOneIdentity(F.C0);
}
Also used : ModLong(edu.jas.arith.ModLong) IInteger(org.matheclipse.core.interfaces.IInteger) ExpVector(edu.jas.poly.ExpVector) IAST(org.matheclipse.core.interfaces.IAST)

Example 12 with ExpVector

use of edu.jas.poly.ExpVector in project symja_android_library by axkr.

the class PartialFractionIntegrateGenerator method isQuadratic.

/**
	 * Check if the polynomial has maximum degree 2 in 1 variable and return the
	 * coefficients.
	 * 
	 * @param poly
	 * @return <code>null</code> if the polynomials degree > 2 and number of
	 *         variables <> 1
	 */
public static boolean isQuadratic(GenPolynomial<BigRational> poly, BigRational[] result) {
    if (poly.degree() <= 2 && poly.numberOfVariables() == 1) {
        result[0] = BigRational.ZERO;
        result[1] = BigRational.ZERO;
        result[2] = BigRational.ZERO;
        for (Monomial<BigRational> monomial : poly) {
            BigRational coeff = monomial.coefficient();
            ExpVector exp = monomial.exponent();
            for (int i = 0; i < exp.length(); i++) {
                result[(int) exp.getVal(i)] = coeff;
            }
        }
        return true;
    }
    return false;
}
Also used : BigRational(edu.jas.arith.BigRational) ExpVector(edu.jas.poly.ExpVector)

Example 13 with ExpVector

use of edu.jas.poly.ExpVector in project symja_android_library by axkr.

the class PartialFractionIntegrateGenerator method isQuadratic.

/**
	 * Check if the polynomial has maximum degree 2 in 1 variable and return the
	 * coefficients.
	 * 
	 * @param poly
	 * @return <code>null</code> if the polynomials degree > 2 and number of
	 *         variables <> 1
	 */
public static boolean isQuadratic(GenPolynomial<BigInteger> poly, BigInteger[] result) {
    if (poly.degree() <= 2 && poly.numberOfVariables() == 1) {
        result[0] = BigInteger.ZERO;
        result[1] = BigInteger.ZERO;
        result[2] = BigInteger.ZERO;
        for (Monomial<BigInteger> monomial : poly) {
            BigInteger coeff = monomial.coefficient();
            ExpVector exp = monomial.exponent();
            for (int i = 0; i < exp.length(); i++) {
                result[(int) exp.getVal(i)] = coeff;
            }
        }
        return true;
    }
    return false;
}
Also used : ExpVector(edu.jas.poly.ExpVector) BigInteger(edu.jas.arith.BigInteger)

Example 14 with ExpVector

use of edu.jas.poly.ExpVector in project symja_android_library by axkr.

the class MonomialList method monomialList.

/**
	 * Get the monomial list of a univariate polynomial.
	 * 
	 * @param polynomial
	 * @param variable
	 * @param termOrder
	 *            the JAS term ordering
	 * @return the list of monomials of the univariate polynomial.
	 */
private static IAST monomialList(IExpr polynomial, final List<IExpr> variablesList, final TermOrder termOrder) throws JASConversionException {
    JASIExpr jas = new JASIExpr(variablesList, ExprRingFactory.CONST, termOrder, false);
    GenPolynomial<IExpr> polyExpr = jas.expr2IExprJAS(polynomial);
    IAST list = F.List();
    for (Map.Entry<ExpVector, IExpr> monomial : polyExpr.getMap().entrySet()) {
        IExpr coeff = monomial.getValue();
        ExpVector exp = monomial.getKey();
        IAST monomTimes = F.Times();
        jas.monomialToExpr(coeff, exp, monomTimes);
        list.append(monomTimes);
    }
    return list;
}
Also used : JASIExpr(org.matheclipse.core.convert.JASIExpr) ExpVector(edu.jas.poly.ExpVector) JASIExpr(org.matheclipse.core.convert.JASIExpr) IExpr(org.matheclipse.core.interfaces.IExpr) IAST(org.matheclipse.core.interfaces.IAST) Map(java.util.Map)

Example 15 with ExpVector

use of edu.jas.poly.ExpVector in project symja_android_library by axkr.

the class Integrate method isQuadratic.

/**
	 * Check if the polynomial has maximum degree 2 in 1 variable and return the
	 * coefficients.
	 * 
	 * @param poly
	 * @return <code>false</code> if the polynomials degree > 2 and number of
	 *         variables <> 1
	 */
public static boolean isQuadratic(GenPolynomial<BigInteger> poly, BigInteger[] result) {
    if (poly.degree() <= 2 && poly.numberOfVariables() == 1) {
        result[0] = BigInteger.ZERO;
        result[1] = BigInteger.ZERO;
        result[2] = BigInteger.ZERO;
        for (Monomial<BigInteger> monomial : poly) {
            BigInteger coeff = monomial.coefficient();
            ExpVector exp = monomial.exponent();
            for (int i = 0; i < exp.length(); i++) {
                result[(int) exp.getVal(i)] = coeff;
            }
        }
        return true;
    }
    return false;
}
Also used : ExpVector(edu.jas.poly.ExpVector) BigInteger(edu.jas.arith.BigInteger)

Aggregations

ExpVector (edu.jas.poly.ExpVector)22 IAST (org.matheclipse.core.interfaces.IAST)15 BigRational (edu.jas.arith.BigRational)6 IExpr (org.matheclipse.core.interfaces.IExpr)6 ModLong (edu.jas.arith.ModLong)5 IInteger (org.matheclipse.core.interfaces.IInteger)5 WrongArgumentType (org.matheclipse.core.eval.exception.WrongArgumentType)3 ISymbol (org.matheclipse.core.interfaces.ISymbol)3 BigInteger (edu.jas.arith.BigInteger)2 ModLongRing (edu.jas.arith.ModLongRing)2 Complex (edu.jas.poly.Complex)2 GenPolynomial (edu.jas.poly.GenPolynomial)2 Map (java.util.Map)2 JASIExpr (org.matheclipse.core.convert.JASIExpr)2 JASModInteger (org.matheclipse.core.convert.JASModInteger)2 IFraction (org.matheclipse.core.interfaces.IFraction)2 AlgebraicNumber (edu.jas.poly.AlgebraicNumber)1 BigInteger (java.math.BigInteger)1 SortedMap (java.util.SortedMap)1 IComplex (org.matheclipse.core.interfaces.IComplex)1