当前位置: 首页>>代码示例>>Java>>正文


Java BigInteger类代码示例

本文整理汇总了Java中edu.jas.arith.BigInteger的典型用法代码示例。如果您正苦于以下问题:Java BigInteger类的具体用法?Java BigInteger怎么用?Java BigInteger使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BigInteger类属于edu.jas.arith包,在下文中一共展示了BigInteger类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: jasToPoly

import edu.jas.arith.BigInteger; //导入依赖的package包/类
/**
 * Transforms a JAS polynomial to a Polynomial object.
 * 
 * @param j JAS polynomial
 * @return polynomial of Polynomial class
 */
private Polynomial jasToPoly(GenPolynomial<BigInteger> j)
{
	int numVariables = j.numberOfVariables();
	Polynomial result = new Polynomial(numVariables, j.length());
	for (Monomial<BigInteger> jasMono : j) {
		java.math.BigInteger coeff = (jasMono.coefficient()).getVal();
		ExpVector jasExpo = jasMono.exponent();
		ArrayList<Integer> expo = new ArrayList<Integer>();
		for (int var = 0; var < numVariables; var++) {
			expo.add((int)jasExpo.getVal(var));
		}
		result.addTerm(coeff, expo);
	}
	
	return result;
}
 
开发者ID:musaeed,项目名称:Prism-gsoc16,代码行数:23,代码来源:JasFunction.java

示例2: JasFunctionFactory

import edu.jas.arith.BigInteger; //导入依赖的package包/类
/**
 * Creates a new function factory.
 * 
 * @param parameterNames names of parameters
 * @param lowerBounds lower bounds of parameters
 * @param upperBounds upper bounds of parameters
 */
JasFunctionFactory(String[] parameterNames, BigRational[] lowerBounds, BigRational[] upperBounds)
{
	super(parameterNames, lowerBounds, upperBounds);
	String[] pNameReversed = new String[parameterNames.length];
	System.arraycopy(parameterNames, 0, pNameReversed, 0, parameterNames.length);
	Collections.reverse(Arrays.asList(pNameReversed));
	this.parameterNames = parameterNames;
	
	BigInteger fac = new BigInteger();
	jasPolyRing = new GenPolynomialRing<BigInteger>(fac,pNameReversed.length,pNameReversed);
	jasQuotRing = new QuotientRing<BigInteger>(jasPolyRing);
	one = new JasFunction(this, jasQuotRing.getONE(), JasFunction.NORMAL);
	zero = new JasFunction(this, jasQuotRing.getZERO(), JasFunction.NORMAL);
	nan = new JasFunction(this, jasQuotRing.getZERO(), JasFunction.NAN);
	inf = new JasFunction(this, jasQuotRing.getZERO(), JasFunction.INF);
	minf = new JasFunction(this, jasQuotRing.getZERO(), JasFunction.MINF);
	parameters = new JasFunction[parameterNames.length];
	for (int param = 0; param < parameterNames.length; param++) {
		parameters[param] = new JasFunction(this, jasQuotRing.parse(parameterNames[param]), JasFunction.NORMAL);
	}
}
 
开发者ID:musaeed,项目名称:Prism-gsoc16,代码行数:29,代码来源:JasFunctionFactory.java

示例3: fromIntegerCoefficients

import edu.jas.arith.BigInteger; //导入依赖的package包/类
/**
 * From BigInteger coefficients. Represent as polynomial with type
 * GenPolynomial&lt;C&gt; coefficients, e.g. ModInteger or BigRational.
 * @param fac result polynomial factory.
 * @param A polynomial with GenPolynomial&lt;BigInteger&gt; coefficients to
 *            be converted.
 * @return polynomial with type GenPolynomial&lt;C&gt; coefficients.
 */
public static <C extends RingElem<C>> GenPolynomial<GenPolynomial<C>> fromIntegerCoefficients(
                GenPolynomialRing<GenPolynomial<C>> fac, GenPolynomial<GenPolynomial<BigInteger>> A) {
    GenPolynomial<GenPolynomial<C>> B = fac.getZERO().copy();
    if (A == null || A.isZERO()) {
        return B;
    }
    RingFactory<GenPolynomial<C>> cfac = fac.coFac;
    GenPolynomialRing<C> rfac = (GenPolynomialRing<C>) cfac;
    for (Map.Entry<ExpVector, GenPolynomial<BigInteger>> y : A.getMap().entrySet()) {
        ExpVector e = y.getKey();
        GenPolynomial<BigInteger> a = y.getValue();
        GenPolynomial<C> p = PolyUtil.<C> fromIntegerCoefficients(rfac, a);
        if (!p.isZERO()) {
            //B = B.sum( p, e ); // inefficient
            B.doPutToMap(e, p);
        }
    }
    return B;
}
 
开发者ID:kredel,项目名称:java-algebra-system,代码行数:28,代码来源:PolyUfdUtil.java

示例4: integerFromRationalCoefficients

import edu.jas.arith.BigInteger; //导入依赖的package包/类
/**
 * BigInteger from BigRational coefficients. Represent as polynomial with type
 * GenPolynomial&lt;BigInteger&gt; coefficients.
 * @param fac result polynomial factory.
 * @param L polynomial list with GenPolynomial&lt;BigRational&gt;
 *            coefficients to be converted.
 * @return polynomial list with polynomials with type GenPolynomial&lt;BigInteger&gt;
 *         coefficients.
 */
public static List<GenPolynomial<GenPolynomial<BigInteger>>> integerFromRationalCoefficients(
                  GenPolynomialRing<GenPolynomial<BigInteger>> fac, List<GenPolynomial<GenPolynomial<BigRational>>> L) {
    List<GenPolynomial<GenPolynomial<BigInteger>>> K = null;
    if (L == null) {
        return K;
    }
    K = new ArrayList<GenPolynomial<GenPolynomial<BigInteger>>>(L.size());
    if (L.isEmpty()) {
        return K;
    }
    for (GenPolynomial<GenPolynomial<BigRational>> a : L) {
        GenPolynomial<GenPolynomial<BigInteger>> b = integerFromRationalCoefficients(fac, a);
        K.add(b);
    }
    return K;
}
 
开发者ID:kredel,项目名称:java-algebra-system,代码行数:26,代码来源:PolyUfdUtil.java

示例5: integerFromRationalCoefficients

import edu.jas.arith.BigInteger; //导入依赖的package包/类
/**
 * BigInteger from BigRational coefficients. Represent as polynomial with
 * BigInteger coefficients by multiplication with the lcm of the numerators
 * of the BigRational coefficients.
 * @param fac result polynomial factory.
 * @param A polynomial with BigRational coefficients to be converted.
 * @return polynomial with BigInteger coefficients.
 */
public static GenPolynomial<BigInteger> integerFromRationalCoefficients(GenPolynomialRing<BigInteger> fac,
                GenPolynomial<BigRational> A) {
    if (A == null || A.isZERO()) {
        return fac.getZERO();
    }
    java.math.BigInteger c = null;
    int s = 0;
    // lcm of denominators
    for (BigRational y : A.val.values()) {
        java.math.BigInteger x = y.denominator();
        // c = lcm(c,x)
        if (c == null) {
            c = x;
            s = x.signum();
        } else {
            java.math.BigInteger d = c.gcd(x);
            c = c.multiply(x.divide(d));
        }
    }
    if (s < 0) {
        c = c.negate();
    }
    return PolyUtil.<BigRational, BigInteger> map(fac, A, new RatToInt(c));
}
 
开发者ID:kredel,项目名称:java-algebra-system,代码行数:33,代码来源:PolyUtil.java

示例6: testTermOrderDegreeReverseLexicographic

import edu.jas.arith.BigInteger; //导入依赖的package包/类
/**
 * Test order DegreeReverseLexicographic.
 */
public void testTermOrderDegreeReverseLexicographic() {
    // integers
    BigInteger rf = new BigInteger();
    String[] v = new String[] { "x", "y", "z" };

    String testPolynomial = "-10*x^5*y^4*z^2 + 7*x^2*y^5*z^3 - 10*x^2*y*z^5 - 7*x*y^5*z^4 + 6*x*y^4*z^3 + 6*x*y^3*z^3 + 3*x*y^2*z + y^4*z - 7*y^2*z + 2*z^5";

    // polynomials over integral numbers
    GenPolynomialRing<BigInteger> pf = new GenPolynomialRing<BigInteger>(rf,
                    TermOrderByName.DegreeReverseLexicographic, v);
    //System.out.println("pf = " + pf);
    // test order DegreeReverseLexicographic of polynomial:
    GenPolynomial<BigInteger> p = pf.parse(testPolynomial);

    // -10*x^5*y^4*z^2,7*x^2*y^5*z^3,-7*x*y^5*z^4,6*x*y^4*z^3,-10*x^2*y*z^5,6*x*y^3*z^3,y^4*z,2*z^5,3*x*y^2*z,-7*y^2*z
    //degrees       11,           10,          10,          8,            8,          7,    5,    5,        4,       3
    assertEquals("( -10 ) x^5 * y^4 * z^2 + 7 x^2 * y^5 * z^3 - 7 x * y^5 * z^4 + 6 x * y^4 * z^3 - 10 x^2 * y * z^5 + 6 x * y^3 * z^3 + y^4 * z + 2 z^5 + 3 x * y^2 * z - 7 y^2 * z",
                    p.toString());
}
 
开发者ID:kredel,项目名称:java-algebra-system,代码行数:23,代码来源:TermOrderByNameCompatTest.java

示例7: testSequentialGBase

import edu.jas.arith.BigInteger; //导入依赖的package包/类
/**
 * Test sequential GBase.
 */
public void testSequentialGBase() {
    L = new ArrayList<GenSolvablePolynomial<BigInteger>>();

    L.add(a);
    L = sbb.leftGB(L);
    assertTrue("isLeftGB( { a } )", sbb.isLeftGB(L));

    L.add(b);
    //System.out.println("L = " + L.size() );
    L = sbb.leftGB(L);
    assertTrue("isLeftGB( { a, b } )", sbb.isLeftGB(L));

    L.add(c);
    L = sbb.leftGB(L);
    assertTrue("isLeftGB( { a, b, c } )", sbb.isLeftGB(L));

    L.add(d);
    L = sbb.leftGB(L);
    assertTrue("isLeftGB( { a, b, c, d } )", sbb.isLeftGB(L));

    L.add(e);
    L = sbb.leftGB(L);
    assertTrue("isLeftGB( { a, b, c, d, e } )", sbb.isLeftGB(L));
}
 
开发者ID:kredel,项目名称:java-algebra-system,代码行数:28,代码来源:SolvableGroebnerBasePseudoSeqTest.java

示例8: getImplementation

import edu.jas.arith.BigInteger; //导入依赖的package包/类
/**
 * Determine suitable implementation of GB algorithms, case BigInteger.
 * @param fac BigInteger.
 * @param a algorithm, a = igb, egb, dgb.
 * @param pl pair selection strategy
 * @return GB algorithm implementation.
 */
public static GroebnerBaseAbstract<BigInteger> getImplementation(BigInteger fac, Algo a,
                PairList<BigInteger> pl) {
    GroebnerBaseAbstract<BigInteger> bba;
    switch (a) {
    case igb:
        bba = new GroebnerBasePseudoSeq<BigInteger>(fac, pl);
        break;
    case egb:
        bba = new EGroebnerBaseSeq<BigInteger>(); // pl not suitable
        break;
    case dgb:
        bba = new DGroebnerBaseSeq<BigInteger>(); // pl not suitable
        break;
    default:
        throw new IllegalArgumentException("algorithm not available for BigInteger " + a);
    }
    return bba;
}
 
开发者ID:kredel,项目名称:java-algebra-system,代码行数:26,代码来源:GBFactory.java

示例9: testRemoveUnusedLower

import edu.jas.arith.BigInteger; //导入依赖的package包/类
/**
 * Test remove unused lower varaibles.
 */
public void testRemoveUnusedLower() {
    //System.out.println("dfac = " + dfac);
    a = dfac.univariate(3, 2);
    b = a.subtract(dfac.univariate(1, 1));
    //System.out.println("a = " + a);
    //System.out.println("b = " + b);

    c = PolyUtil.<BigInteger> removeUnusedLowerVariables(b);
    //System.out.println("c = " + c + ", fac = " + c.ring);
    assertTrue("#var == 4: " + c.ring.nvar, c.ring.nvar == 4);

    a = dfac.univariate(3, 2);
    //System.out.println("a = " + a);

    c = PolyUtil.<BigInteger> removeUnusedLowerVariables(a);
    //System.out.println("c = " + c + ", fac = " + c.ring);
    assertTrue("#var == 4: " + c.ring.nvar, c.ring.nvar == 4);

    a = dfac.univariate(1, 2);
    //System.out.println("a = " + a);

    c = PolyUtil.<BigInteger> removeUnusedLowerVariables(a);
    //System.out.println("c = " + c + ", fac = " + c.ring);
    assertTrue("#var == 2: " + c.ring.nvar, c.ring.nvar == 2);
}
 
开发者ID:kredel,项目名称:java-algebra-system,代码行数:29,代码来源:PolyUtilTest.java

示例10: testPowerSet

import edu.jas.arith.BigInteger; //导入依赖的package包/类
/**
 * Test power set.
 * 
 */
public void testPowerSet() {
    BigInteger ai = new BigInteger();
    int s1 = 5;
    int s = 1;
    for (int i = 0; i < s1; i++) {
        s *= 2;
    }
    //System.out.println("s = " + s);
    List<BigInteger> tlist = new ArrayList<BigInteger>(s1);
    for (int j = 0; j < s1; j++) {
        tlist.add(ai.random(7));
    }
    //System.out.println("tlist = " + tlist);
    int t = 0;
    for (List<BigInteger> tuple : new PowerSet<BigInteger>(tlist)) {
        t++;
        //System.out.println("tuple = " + tuple);
        assertFalse("tuple != null", tuple == null);
    }
    assertTrue("#tuple == " + s + " == " + t + " ", t == s);
}
 
开发者ID:kredel,项目名称:java-algebra-system,代码行数:26,代码来源:IteratorsTest.java

示例11: testTermOrderNegativeLexicographic

import edu.jas.arith.BigInteger; //导入依赖的package包/类
/**
 * Test order NegativeLexicographic.
 */
public void testTermOrderNegativeLexicographic() {
    // integers
    BigInteger rf = new BigInteger();
    String[] v = new String[] { "x", "y", "z" };

    String testPolynomial = "-10*x^5*y^4*z^2 + 7*x^2*y^5*z^3 - 10*x^2*y*z^5 - 7*x*y^5*z^4 + 6*x*y^4*z^3 + 6*x*y^3*z^3 + 3*x*y^2*z + y^4*z - 7*y^2*z + 2*z^5";

    // polynomials over integral numbers
    GenPolynomialRing<BigInteger> pf = new GenPolynomialRing<BigInteger>(rf,
                    TermOrderByName.NegativeLexicographic, v);
    // test order NegativeLexicographic of polynomial:
    GenPolynomial<BigInteger> p = pf.parse(testPolynomial);

    // 2*z^5,-7*y^2*z,y^4*z,3*x*y^2*z,6*x*y^3*z^3,6*x*y^4*z^3,-7*x*y^5*z^4,-10*x^2*y*z^5,7*x^2*y^5*z^3,-10*x^5*y^4*z^2
    assertEquals("2 z^5 - 7 y^2 * z + y^4 * z + 3 x * y^2 * z + 6 x * y^3 * z^3 + 6 x * y^4 * z^3 - 7 x * y^5 * z^4 - 10 x^2 * y * z^5 + 7 x^2 * y^5 * z^3 - 10 x^5 * y^4 * z^2",
                    p.toString());

}
 
开发者ID:kredel,项目名称:java-algebra-system,代码行数:22,代码来源:TermOrderByNameCompatTest.java

示例12: testTermOrderLexicographic

import edu.jas.arith.BigInteger; //导入依赖的package包/类
/**
 * Test order Lexicographic.
 */
public void testTermOrderLexicographic() {
    // integers
    BigInteger rf = new BigInteger();
    String[] v = new String[] { "x", "y", "z" };

    String testPolynomial = "-10*x^5*y^4*z^2 + 7*x^2*y^5*z^3 - 10*x^2*y*z^5 - 7*x*y^5*z^4 + 6*x*y^4*z^3 + 6*x*y^3*z^3 + 3*x*y^2*z + y^4*z - 7*y^2*z + 2*z^5";

    // polynomials over integral numbers
    GenPolynomialRing<BigInteger> pf = new GenPolynomialRing<BigInteger>(rf,
                    TermOrderByName.Lexicographic, v);
    // test order Lexicographic of polynomial:
    GenPolynomial<BigInteger> p = pf.parse(testPolynomial);

    // -10*x^5*y^4*z^2,7*x^2*y^5*z^3,-10*x^2*y*z^5,-7*x*y^5*z^4,6*x*y^4*z^3,6*x*y^3*z^3,3*x*y^2*z,y^4*z,-7*y^2*z,2*z^5 
    assertEquals("( -10 ) x^5 * y^4 * z^2 + 7 x^2 * y^5 * z^3 - 10 x^2 * y * z^5 - 7 x * y^5 * z^4 + 6 x * y^4 * z^3 + 6 x * y^3 * z^3 + 3 x * y^2 * z + y^4 * z - 7 y^2 * z + 2 z^5",
                    p.toString());
}
 
开发者ID:kredel,项目名称:java-algebra-system,代码行数:21,代码来源:TermOrderByNameCompatTest.java

示例13: factorBound

import edu.jas.arith.BigInteger; //导入依赖的package包/类
/**
 * Factor coefficient bound. See SACIPOL.IPFCB: the product of all maxNorms
 * of potential factors is less than or equal to 2**b times the maxNorm of
 * A.
 * @param e degree vector of a GenPolynomial A.
 * @return 2**b.
 */
public static BigInteger factorBound(ExpVector e) {
    int n = 0;
    java.math.BigInteger p = java.math.BigInteger.ONE;
    java.math.BigInteger v;
    if (e == null || e.isZERO()) {
        return BigInteger.ONE;
    }
    for (int i = 0; i < e.length(); i++) {
        if (e.getVal(i) > 0) {
            n += (2 * e.getVal(i) - 1);
            v = new java.math.BigInteger("" + (e.getVal(i) - 1));
            p = p.multiply(v);
        }
    }
    n += (p.bitCount() + 1); // log2(p)
    n /= 2;
    v = new java.math.BigInteger("" + 2);
    v = v.shiftLeft(n);
    BigInteger N = new BigInteger(v);
    return N;
}
 
开发者ID:kredel,项目名称:java-algebra-system,代码行数:29,代码来源:PolyUtil.java

示例14: GB

import edu.jas.arith.BigInteger; //导入依赖的package包/类
/**
 * Groebner base using fraction free computation.
 * @param modv module variable number.
 * @param F polynomial list.
 * @return GB(F) a Groebner base of F.
 */
@Override
public List<GenPolynomial<BigRational>> GB(int modv, List<GenPolynomial<BigRational>> F) {
    List<GenPolynomial<BigRational>> G = F;
    if (F == null || F.isEmpty()) {
        return G;
    }
    GenPolynomialRing<BigRational> rring = F.get(0).ring;
    BigInteger cf = new BigInteger();
    GenPolynomialRing<BigInteger> iring = new GenPolynomialRing<BigInteger>(cf, rring);
    List<GenPolynomial<BigInteger>> Fi = PolyUtil.integerFromRationalCoefficients(iring, F);
    //System.out.println("Fi = " + Fi);
    logger.info("#Fi = " + Fi.size());

    List<GenPolynomial<BigInteger>> Gi = bba.GB(modv, Fi);
    //System.out.println("Gi = " + Gi);
    logger.info("#Gi = " + Gi.size());

    G = PolyUtil.<BigRational> fromIntegerCoefficients(rring, Gi);
    G = PolyUtil.<BigRational> monic(G);
    return G;
}
 
开发者ID:kredel,项目名称:java-algebra-system,代码行数:28,代码来源:GroebnerBaseRational.java

示例15: testTermOrderNegativeDegreeLexicographic

import edu.jas.arith.BigInteger; //导入依赖的package包/类
/**
 * Test order NegativeDegreeLexicographic.
 */
public void testTermOrderNegativeDegreeLexicographic() {
    // integers
    BigInteger rf = new BigInteger();
    String[] v = new String[] { "x", "y", "z" };

    String testPolynomial = "-10*x^5*y^4*z^2 + 7*x^2*y^5*z^3 - 10*x^2*y*z^5 - 7*x*y^5*z^4 + 6*x*y^4*z^3 + 6*x*y^3*z^3 + 3*x*y^2*z + y^4*z - 7*y^2*z + 2*z^5";

    // polynomials over integral numbers
    GenPolynomialRing<BigInteger> pf = new GenPolynomialRing<BigInteger>(rf,
                    TermOrderByName.NegativeDegreeLexicographic, v);
    //System.out.println("pf = " + pf);
    // test order NegativeDegreeLexicographic of polynomial:
    GenPolynomial<BigInteger> p = pf.parse(testPolynomial);

    // -7*y^2*z,3*x*y^2*z,y^4*z,2*z^5,6*x*y^3*z^3,-10*x^2*y*z^5,6*x*y^4*z^3,7*x^2*y^5*z^3,-7*x*y^5*z^4,-10*x^5*y^4*z^2
    //degrees 3,        4,    5,    5,          7,            8,          8,           10           10,             11  
    assertEquals("( -7 ) y^2 * z + 3 x * y^2 * z + y^4 * z + 2 z^5 + 6 x * y^3 * z^3 - 10 x^2 * y * z^5 + 6 x * y^4 * z^3 + 7 x^2 * y^5 * z^3 - 7 x * y^5 * z^4 - 10 x^5 * y^4 * z^2",
                    p.toString());
}
 
开发者ID:kredel,项目名称:java-algebra-system,代码行数:23,代码来源:TermOrderByNameCompatTest.java


注:本文中的edu.jas.arith.BigInteger类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。