Examples of BigRational


Examples of cc.redberry.core.transformations.factor.jasfactor.edu.jas.arith.BigRational

        GenPolynomialRing<BigRational> pfac = P.ring;
        if (pfac.nvar > 1) {
            throw new IllegalArgumentException(this.getClass().getName() + " only for univariate polynomials");
        }
        GenPolynomial<BigRational> Pr = P;
        BigRational ldcf = P.leadingBaseCoefficient();
        if (!ldcf.isONE()) {
            Pr = Pr.monic();
        }
        BigInteger bi = BigInteger.ONE;
        GenPolynomialRing<BigInteger> ifac = new GenPolynomialRing<>(bi, pfac);
        GenPolynomial<BigInteger> Pi = PolyUtil.integerFromRationalCoefficients(ifac, Pr);
        List<GenPolynomial<BigInteger>> ifacts = iengine.baseFactorsSquarefree(Pi);
        if (ifacts.size() <= 1) {
            factors.add(P);
            return factors;
        }
        List<GenPolynomial<BigRational>> rfacts = PolyUtil.fromIntegerCoefficients(pfac, ifacts);
        rfacts = PolyUtil.monic(rfacts);
        if (!ldcf.isONE()) {
            GenPolynomial<BigRational> r = rfacts.get(0);
            rfacts.remove(r);
            r = r.multiply(ldcf);
            rfacts.set(0, r);
        }
View Full Code Here

Examples of cc.redberry.core.transformations.factor.jasfactor.edu.jas.arith.BigRational

        GenPolynomialRing<BigRational> pfac = P.ring;
        if (pfac.nvar == 1) {
            return baseFactorsSquarefree(P);
        }
        GenPolynomial<BigRational> Pr = P;
        BigRational ldcf = P.leadingBaseCoefficient();
        if (!ldcf.isONE()) {
            Pr = Pr.monic();
        }
        BigInteger bi = BigInteger.ONE;
        GenPolynomialRing<BigInteger> ifac = new GenPolynomialRing<>(bi, pfac);
        GenPolynomial<BigInteger> Pi = PolyUtil.integerFromRationalCoefficients(ifac, Pr);
        List<GenPolynomial<BigInteger>> ifacts = iengine.factorsSquarefree(Pi);
        if (ifacts.size() <= 1) {
            factors.add(P);
            return factors;
        }
        List<GenPolynomial<BigRational>> rfacts = PolyUtil.fromIntegerCoefficients(pfac, ifacts);
        rfacts = PolyUtil.monic(rfacts);
        if (!ldcf.isONE()) {
            GenPolynomial<BigRational> r = rfacts.get(0);
            rfacts.remove(r);
            r = r.multiply(ldcf);
            rfacts.set(0, r);
        }
View Full Code Here

Examples of cc.redberry.core.transformations.factor.jasfactor.edu.jas.arith.BigRational

        GenPolynomialRing<BigRational> pfac = P.ring;
        if (pfac.nvar > 1) {
            throw new IllegalArgumentException(this.getClass().getName() + " only for univariate polynomials");
        }
        GenPolynomial<BigRational> Pr = P;
        BigRational ldcf = P.leadingBaseCoefficient();
        if (!ldcf.isONE()) {
            Pr = Pr.monic();
        }
        BigInteger bi = BigInteger.ONE;
        GenPolynomialRing<BigInteger> ifac = new GenPolynomialRing<>(bi, pfac);
        GenPolynomial<BigInteger> Pi = PolyUtil.integerFromRationalCoefficients(ifac, Pr);
        List<GenPolynomial<BigInteger>> ifacts = iengine.baseFactorsSquarefree(Pi);
        if (ifacts.size() <= 1) {
            factors.add(P);
            return factors;
        }
        List<GenPolynomial<BigRational>> rfacts = PolyUtil.fromIntegerCoefficients(pfac, ifacts);
        rfacts = PolyUtil.monic(rfacts);
        if (!ldcf.isONE()) {
            GenPolynomial<BigRational> r = rfacts.get(0);
            rfacts.remove(r);
            r = r.multiply(ldcf);
            rfacts.set(0, r);
        }
View Full Code Here

Examples of cc.redberry.core.transformations.factor.jasfactor.edu.jas.arith.BigRational

        GenPolynomialRing<BigRational> pfac = P.ring;
        if (pfac.nvar == 1) {
            return baseFactorsSquarefree(P);
        }
        GenPolynomial<BigRational> Pr = P;
        BigRational ldcf = P.leadingBaseCoefficient();
        if (!ldcf.isONE()) {
            Pr = Pr.monic();
        }
        BigInteger bi = BigInteger.ONE;
        GenPolynomialRing<BigInteger> ifac = new GenPolynomialRing<>(bi, pfac);
        GenPolynomial<BigInteger> Pi = PolyUtil.integerFromRationalCoefficients(ifac, Pr);
        List<GenPolynomial<BigInteger>> ifacts = iengine.factorsSquarefree(Pi);
        if (ifacts.size() <= 1) {
            factors.add(P);
            return factors;
        }
        List<GenPolynomial<BigRational>> rfacts = PolyUtil.fromIntegerCoefficients(pfac, ifacts);
        rfacts = PolyUtil.monic(rfacts);
        if (!ldcf.isONE()) {
            GenPolynomial<BigRational> r = rfacts.get(0);
            rfacts.remove(r);
            r = r.multiply(ldcf);
            rfacts.set(0, r);
        }
View Full Code Here

Examples of wyautl.util.BigRational

    Automaton.Bag terms = (Automaton.Bag) automaton.get(args.get(1));

    // Must use abs() here, otherwise can end up with negative gcd.
    // This is problematic for inequalities as it necessitate
    // changing their sign.
    BigRational gcd = constant.value.abs();

    if(gcd.equals(BigRational.ZERO)) {
      // Basically, if there is no coefficient, then ignore it.
      gcd = null;
    }

    // Now, iterate through each term examining its coefficient and
    // determining the GreatestCommonDivisor of the whole lot.
    for(int i=0;i!=terms.size();++i) {
      int child = terms.get(i);
      Automaton.Term mul = (Automaton.Term) automaton.get(child);
      Automaton.List ls = (Automaton.List) automaton.get(mul.contents);
      Automaton.Real coefficient = (Automaton.Real) automaton.get(ls.get(0));
      BigRational val = coefficient.value;
      if(gcd == null) {
        // Must use abs() here, otherwise can end up with negative gcd.
        // This is problematic for inequalities as it necessitate
        // changing their sign.
        gcd = val.abs();
      } else {
        // Note, gcd of two numbers (either of which may be negative) is
        // always positive.
        gcd = gcd.gcd(val);
      }
View Full Code Here

Examples of wyautl.util.BigRational

          index - 1));
    } else if (token instanceof Int) {
      BigInteger val = match(Int.class).value;
      return new Expr.Constant(val, sourceAttr(start, index - 1));
    } else if (token instanceof Real) {
      BigRational val = match(Real.class).value;
      return new Expr.Constant(val, sourceAttr(start,
          index - 1));
    } else if (token instanceof Strung) {
      return parseString();
    } else if (token instanceof Minus) {
View Full Code Here

Examples of wyautl.util.BigRational

    } else if (value instanceof Value.Integer) {
      Value.Integer v = (Value.Integer) value;
      return Num(automaton , BigRational.valueOf(v.value));
    } else if (value instanceof Value.Decimal) {
      Value.Decimal v = (Value.Decimal) value;
      return Num(automaton, new BigRational(v.value));
    } else if (value instanceof Value.String) {
      Value.String v = (Value.String) value;
      return Solver.String(automaton,v.value);
    } else if (value instanceof Value.Set) {
      Value.Set vs = (Value.Set) value;
View Full Code Here

Examples of wyautl.util.BigRational

        return new Int(r,input.substring(start,pos),start);
      }
      while (pos < input.length() && Character.isDigit(input.charAt(pos))) {
        pos = pos + 1;
      }
      BigRational r = new BigRational(input.substring(start, pos));
      return new Real(r,input.substring(start,pos),start);
    } else {
      BigInteger r = new BigInteger(input.substring(start, pos));
      return new Int(r,input.substring(start,pos),start);
    }
View Full Code Here

Examples of wyautl.util.BigRational

    public Real(long value) {
      super(K_REAL, BigRational.valueOf(value));
    }

    public Real(String str) {
      super(K_REAL, new BigRational(str));
    }
View Full Code Here

Examples of wyautl.util.BigRational

      } else {
        rhs = "new Automaton.Int(\"" + bi.toString() + "\")";
      }

    } else if (v instanceof BigRational) {
      BigRational br = (BigRational) v;
      rhs = "new Automaton.Real(\"" + br.toString() + "\")";
      if (br.isInteger()) {
        long lv = br.longValue();
        if (BigRational.valueOf(lv).equals(br)) {
          // Yes, this will fit in a long value. Therefore, inline a
          // long constant as this is faster.
          rhs = "new Automaton.Real(" + lv + ")";
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.