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


Java ExpVector.compareTo方法代码示例

本文整理汇总了Java中edu.jas.poly.ExpVector.compareTo方法的典型用法代码示例。如果您正苦于以下问题:Java ExpVector.compareTo方法的具体用法?Java ExpVector.compareTo怎么用?Java ExpVector.compareTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在edu.jas.poly.ExpVector的用法示例。


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

示例1: isSigRedundant

import edu.jas.poly.ExpVector; //导入方法依赖的package包/类
/**
 * Is sigma redundant.
 * @param A polynomial.
 * @param G polynomial list.
 * @return true if A is sigma redundant with respect to G.
 */
public boolean isSigRedundant(List<SigPoly<C>> G, SigPoly<C> A) {
    if (G.isEmpty()) {
        return false;
    }
    ExpVector e = A.sigma.leadingExpVector();
    if (e == null) {
        e = A.poly.ring.evzero;
    }
    for (SigPoly<C> p : G) {
        if (p.sigma.isZERO()) {
            continue;
        }
        ExpVector f = p.sigma.leadingExpVector();
        if (f == null) { // does not happen
            f = p.poly.ring.evzero;
        }
        boolean mt = e.multipleOf(f);
        if (mt) {
            ExpVector g = e.subtract(f);
            ExpVector h = p.poly.leadingExpVector();
            h = h.sum(g);
            if (h.compareTo(A.poly.leadingExpVector()) == 0) {
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:kredel,项目名称:java-algebra-system,代码行数:35,代码来源:SigReductionSeq.java

示例2: criterion3

import edu.jas.poly.ExpVector; //导入方法依赖的package包/类
/**
 * GB criterium 3.
 * @return true if the S-polynomial(i,j) is required.
 */
public boolean criterion3(int i, int j, ExpVector eij) {  
    // assert i < j;
    boolean s;
    s = red.get( j ).get(i); 
    if ( ! s ) { 
        logger.warn("c3.s false for " + j + " " + i); 
        return s;
    }
    s = true;
    boolean m;
    GenPolynomial<C> A;
    ExpVector ek;
    for ( int k = 0; k < P.size(); k++ ) {
        A = P.get( k );
        ek = A.leadingExpVector();
        m = eij.multipleOf(ek) && eij.compareTo(ek) != 0;
        if ( m ) {
            if ( k < i ) {
                // System.out.println("k < i "+k+" "+i); 
                s =    red.get( i ).get(k) 
                    || red.get( j ).get(k); 
            }
            if ( i < k && k < j ) {
                // System.out.println("i < k < j "+i+" "+k+" "+j); 
                s =    red.get( k ).get(i) 
                    || red.get( j ).get(k); 
            }
            if ( j < k ) {
                //System.out.println("j < k "+j+" "+k); 
                s =    red.get( k ).get(i) 
                    || red.get( k ).get(j); 
            }
            //System.out.println("s."+k+" = " + s); 
            if ( ! s ) return s;
        }
    }
    return true;
}
 
开发者ID:kredel,项目名称:java-algebra-system,代码行数:43,代码来源:OrderedMinPairlist.java

示例3: recursiveDivide

import edu.jas.poly.ExpVector; //导入方法依赖的package包/类
/**
 * GenSolvablePolynomial left recursive quotient for recursive polynomials
 * and exact division by coefficient ring element.
 * @param <C> coefficient type.
 * @param P recursive GenSolvablePolynomial.
 * @param s GenSolvablePolynomial.
 * @return this/s.
 */
@SuppressWarnings({ "unchecked", "cast" })
public static <C extends GcdRingElem<C>> GenSolvablePolynomial<GenPolynomial<C>> recursiveDivide(
                GenSolvablePolynomial<GenPolynomial<C>> P, GenSolvablePolynomial<C> s) {
    if (s == null || s.isZERO()) {
        throw new ArithmeticException("division by zero " + P + ", " + s);
    }
    if (P.isZERO()) {
        return P;
    }
    if (s.isONE()) {
        return P;
    }
    GenSolvablePolynomialRing<GenPolynomial<C>> rfac = (GenSolvablePolynomialRing<GenPolynomial<C>>) P.ring;
    GenSolvablePolynomial<GenPolynomial<C>> onep = rfac.getONE();
    //ExpVector zero = rfac.evzero;
    GenSolvablePolynomial<GenPolynomial<C>> q = rfac.getZERO();
    GenSolvablePolynomial<GenPolynomial<C>> r;
    GenSolvablePolynomial<GenPolynomial<C>> p = P; //.ring.getZERO().copy();
    while (!p.isZERO()) {
        // for (Map.Entry<ExpVector, GenPolynomial<C>> m1 : P.getMap().entrySet()) {
        Map.Entry<ExpVector, GenPolynomial<C>> m1 = p.leadingMonomial();
        GenSolvablePolynomial<C> c1 = (GenSolvablePolynomial<C>) m1.getValue();
        ExpVector e1 = m1.getKey();
        GenSolvablePolynomial<C> c = c1.divide(s);
        if (c.isZERO()) {
            throw new RuntimeException("something is wrong: c is zero, c1 = " + c1 + ", s = " + s);
        }
        r = onep.multiplyLeft(c.multiply(s), e1); // right: (c e1) * 1 * (s zero)
        if (!c1.equals(r.leadingBaseCoefficient())) {
            System.out.println("recRightDivide: lc(r) = " + r.leadingBaseCoefficient() + ", c1 = " + c1);
            System.out.println("recRightDivide: lc(r) = " + c.multiply(s) + ", c = " + c + ", s = " + s);
            throw new RuntimeException("something is wrong: lc(r) != c*s");
        }
        p = (RecSolvablePolynomial<C>) p.subtract(r);
        if (!p.isZERO() && e1.compareTo(p.leadingExpVector()) == 0) {
            System.out.println("recRightDivide: c     = " + c);
            System.out.println("recRightDivide: lt(p) = " + p.leadingExpVector() + ", e1 = " + e1);
            System.out.println("recRightDivide: c1/s  = " + c1.divide(s));
            System.out.println("recRightDivide: s*c   = " + s.multiply(c));
            System.out.println("recRightDivide: c*s   = " + c.multiply(s));
            throw new RuntimeException("something is wrong: degree not descending");
        }
        q = (RecSolvablePolynomial<C>) q.sum(c, e1);
    }
    return q;
}
 
开发者ID:kredel,项目名称:java-algebra-system,代码行数:55,代码来源:FDUtil.java

示例4: recursiveRightDivide

import edu.jas.poly.ExpVector; //导入方法依赖的package包/类
/**
 * GenSolvablePolynomial recursive quotient for recursive polynomials and
 * partial right exact division by coefficient ring element.
 * @param <C> coefficient type.
 * @param P recursive GenSolvablePolynomial.
 * @param s GenSolvablePolynomial.
 * @return P/s.
 */
@SuppressWarnings({ "unchecked", "cast" })
public static <C extends GcdRingElem<C>> GenSolvablePolynomial<GenPolynomial<C>> recursiveRightDivide(
                GenSolvablePolynomial<GenPolynomial<C>> P, GenSolvablePolynomial<C> s) {
    if (s == null || s.isZERO()) {
        throw new ArithmeticException("division by zero " + P + ", " + s);
    }
    if (P.isZERO()) {
        return P;
    }
    if (s.isONE()) {
        return P;
    }
    if (!(P instanceof RecSolvablePolynomial)) {
        //return FDUtil.<C> recursiveDivide(P,s);
    }
    RecSolvablePolynomialRing<C> rfac = (RecSolvablePolynomialRing<C>) P.ring;
    if (rfac.coeffTable.isEmpty()) {
        //return FDUtil.<C> recursiveDivide(P,s);
    }
    RecSolvablePolynomial<C> onep = rfac.getONE();
    //ExpVector zero = rfac.evzero;
    RecSolvablePolynomial<C> q = rfac.getZERO();
    RecSolvablePolynomial<C> r;
    RecSolvablePolynomial<C> p = (RecSolvablePolynomial<C>) P;
    //System.out.println("recRightDivide: p = " + p + ", s = " + s);
    while (!p.isZERO()) {
        Map.Entry<ExpVector, GenPolynomial<C>> m1 = p.leadingMonomial();
        GenSolvablePolynomial<C> a = (GenSolvablePolynomial<C>) m1.getValue();
        ExpVector f = m1.getKey();
        GenSolvablePolynomial<C> c = (GenSolvablePolynomial<C>) a.rightDivide(s);
        if (c.isZERO()) {
            //logger.info("something is wrong: c is zero, a = " + a + ", s = " + s);
            throw new RuntimeException("something is wrong: c is zero, a = " + a + ", s = " + s);
        }
        //r = onep.multiply(c, f, s, zero); // right: (c f) * 1 * (s zero)
        ///r = onep.multiply(c.multiply(s), f); //, c, zero); // 
        r = onep.multiply(s.multiply(c), f); //, c, zero); // 
        if (!a.equals(r.leadingBaseCoefficient())) {
            System.out.println("recRightDivide: a   = " + a + ", lc(r) = " + r.leadingBaseCoefficient());
            System.out.println("recRightDivide: c*s = " + c.multiply(s) + ", s = " + s + ", c = " + c);
            System.out.println(
                            "recRightDivide: s*c = " + s.multiply(c) + ", a%s = " + a.rightRemainder(s));
            throw new RuntimeException("something is wrong: c*s != a: " + rfac.toScript());
        }
        p = (RecSolvablePolynomial<C>) p.subtract(r);
        if (!p.isZERO() && f.compareTo(p.leadingExpVector()) == 0) {
            System.out.println("recRightDivide: c     = " + c);
            System.out.println("recRightDivide: lt(p) = " + p.leadingExpVector() + ", f = " + f);
            System.out.println("recRightDivide: a/s   = " + a.divide(s));
            System.out.println("recRightDivide: s*c   = " + s.multiply(c));
            System.out.println("recRightDivide: c*s   = " + c.multiply(s));
            throw new RuntimeException("something is wrong: degree not descending");
        }
        q = (RecSolvablePolynomial<C>) q.sum(c, f);
    }
    return q;
}
 
开发者ID:kredel,项目名称:java-algebra-system,代码行数:66,代码来源:FDUtil.java

示例5: recursiveLeftDivide

import edu.jas.poly.ExpVector; //导入方法依赖的package包/类
/**
 * GenSolvablePolynomial recursive quotient for recursive polynomials and
 * partial left exact division by coefficient ring element.
 * @param <C> coefficient type.
 * @param P recursive GenSolvablePolynomial.
 * @param s GenSolvablePolynomial.
 * @return P/s.
 */
@SuppressWarnings({ "unchecked", "cast" })
public static <C extends GcdRingElem<C>> GenSolvablePolynomial<GenPolynomial<C>> recursiveLeftDivide(
                GenSolvablePolynomial<GenPolynomial<C>> P, GenSolvablePolynomial<C> s) {
    if (s == null || s.isZERO()) {
        throw new ArithmeticException("division by zero " + P + ", " + s);
    }
    if (P.isZERO()) {
        return P;
    }
    if (s.isONE()) {
        return P;
    }
    if (!(P instanceof RecSolvablePolynomial)) {
        //return FDUtil.<C> recursiveDivide(P,s);
    }
    RecSolvablePolynomialRing<C> rfac = (RecSolvablePolynomialRing<C>) P.ring;
    if (rfac.coeffTable.isEmpty()) {
        //return FDUtil.<C> recursiveDivide(P,s);
    }
    RecSolvablePolynomial<C> onep = rfac.getONE();
    //ExpVector zero = rfac.evzero;
    RecSolvablePolynomial<C> q = rfac.getZERO();
    RecSolvablePolynomial<C> r, Pp;
    //RecSolvablePolynomial<C> p = (RecSolvablePolynomial<C>) P;
    RecSolvablePolynomial<C> p = (RecSolvablePolynomial<C>) P.rightRecursivePolynomial();
    Pp = p;
    while (!p.isZERO()) {
        ExpVector f = p.leadingExpVector();
        GenSolvablePolynomial<C> a = (GenSolvablePolynomial<C>) p.leadingBaseCoefficient();
        GenSolvablePolynomial<C> c = (GenSolvablePolynomial<C>) a.divide(s);
        ///GenSolvablePolynomial<C> c = (GenSolvablePolynomial<C>) a.rightDivide(s);
        if (c.isZERO()) {
            throw new RuntimeException("something is wrong: c is zero, a = " + a + ", s = " + s);
        }
        //r = onep.multiply(c, f, s, zero); // right: (c f) * 1 * (s zero)
        r = onep.multiplyLeft(c.multiply(s), f); // right: (c*s f) * one
        ///r = onep.multiplyLeft(s.multiply(c), f); // left: (s*c f) * one
        if (!a.equals(r.leadingBaseCoefficient())) {
            System.out.println("recLeftDivide: a        = " + a);
            C ac = a.leadingBaseCoefficient();
            C rc = r.leadingBaseCoefficient().leadingBaseCoefficient();
            C cc = rc.inverse().multiply(ac);
            System.out.println("recLeftDivide: cc       = " + cc);
            c = c.multiply(cc);
            r = onep.multiplyLeft(c.multiply(s), f); // right: (c f) * 1 * (s zero)
            ///r = onep.multiplyLeft(s.multiply(c), f); // left: (s*c f) * 1
            System.out.println("recLeftDivide: lc(r)    = " + r.leadingBaseCoefficient());
            throw new RuntimeException("something is wrong: c*s != a: " + rfac.toScript());
        }
        p = (RecSolvablePolynomial<C>) p.subtract(r);
        if (!p.isZERO() && f.compareTo(p.leadingExpVector()) == 0) {
            System.out.println("recLeftDivide: P        = " + P + ", s = " + s);
            System.out.println("recLeftDivide: right(P) = " + Pp);
            System.out.println("recLeftDivide: c        = " + c);
            System.out.println("recLeftDivide: lt(p)    = " + p.leadingExpVector() + ", f = " + f);
            System.out.println("recLeftDivide: a/s      = " + a.divide(s));
            System.out.println("recLeftDivide: a\\s      = " + a.rightDivide(s));
            System.out.println("recLeftDivide: s*c      = " + s.multiply(c));
            System.out.println("recLeftDivide: c*s      = " + c.multiply(s));
            throw new RuntimeException("something is wrong: degree not descending");
        }
        q = (RecSolvablePolynomial<C>) q.sum(c, f);
    }
    q = (RecSolvablePolynomial<C>) q.evalAsRightRecursivePolynomial();
    return q;
}
 
开发者ID:kredel,项目名称:java-algebra-system,代码行数:75,代码来源:FDUtil.java

示例6: sigNormalform

import edu.jas.poly.ExpVector; //导入方法依赖的package包/类
/**
 * Top normalform.
 * @param A polynomial.
 * @param F polynomial list.
 * @param G polynomial list.
 * @return nf(A) with respect to F and G.
 */
public SigPoly<C> sigNormalform(List<GenPolynomial<C>> F, List<SigPoly<C>> G, SigPoly<C> A) {
    if (F.isEmpty() && G.isEmpty()) {
        return A;
    }
    if (A.poly.isZERO()) {
        return A;
    }
    List<GenPolynomial<C>> ff = F; //polys(F);
    GenPolynomial<C> a = A.poly;
    GenPolynomial<C> sigma = A.sigma;
    GenPolynomialRing<C> ring = a.ring;
    boolean reduced = true;
    while (!a.isZERO() && reduced) {
        reduced = false;
        a = red.normalform(ff, a);
        if (a.isZERO()) {
            continue;
        }
        ExpVector e = a.leadingExpVector();
        for (SigPoly<C> p : G) {
            if (p.poly.isZERO()) {
                continue;
            }
            ExpVector f = p.poly.leadingExpVector();
            boolean mt = e.multipleOf(f);
            if (mt) {
                ExpVector g = e.subtract(f);
                C sc = a.leadingBaseCoefficient().divide(p.poly.leadingBaseCoefficient());
                GenPolynomial<C> sigup = p.sigma.multiply(sc, g);
                ExpVector se = sigma.leadingExpVector();
                if (se == null) {
                    se = ring.evzero;
                }
                ExpVector sp = sigup.leadingExpVector();
                if (sp == null) {
                    sp = ring.evzero;
                }
                //logger.info("sigup, sigma  = " + sigup + ", " + sigma);
                boolean sigeq = (sigup.compareTo(sigma) < 0)
                                || ((sp.compareTo(se) == 0 && (sigup.leadingBaseCoefficient().compareTo(
                                                sigma.leadingBaseCoefficient()) != 0)));
                //logger.info("sigup < sigma = " + sigup.compareTo(sigma));
                if (sigeq) {
                    reduced = true;
                    a = a.subtractMultiple(sc, g, p.poly);
                    if (sp.invGradCompareTo(se) == 0) {
                        sigma = sigma.subtract(sigup);
                    }
                    if (a.isZERO()) {
                        break;
                    }
                    e = a.leadingExpVector();
                } else {
                    //logger.info("not reduced: a = " + a + ", p = " + p.poly);
                }
            }
        }
    }
    if (!a.isZERO()) {
        C ac = a.leadingBaseCoefficient();
        if (!ac.isONE()) {
            ac = ac.inverse();
            a = a.multiply(ac);
            sigma = sigma.multiply(ac);
        }
    }
    return new SigPoly<C>(sigma, a);
}
 
开发者ID:kredel,项目名称:java-algebra-system,代码行数:76,代码来源:SigReductionSeq.java

示例7: sigSemiNormalform

import edu.jas.poly.ExpVector; //导入方法依赖的package包/类
/**
 * Top semi-complete normalform.
 * @param A polynomial.
 * @param F polynomial list.
 * @param G polynomial list.
 * @return nf(A) with respect to F and G.
 */
public SigPoly<C> sigSemiNormalform(List<GenPolynomial<C>> F, List<SigPoly<C>> G, SigPoly<C> A) {
    if (F.isEmpty() && G.isEmpty()) {
        return A;
    }
    if (A.poly.isZERO()) {
        return A;
    }
    List<GenPolynomial<C>> ff = F; //polys(F);
    GenPolynomial<C> a = A.poly;
    GenPolynomial<C> sigma = A.sigma;
    ExpVector esig = sigma.leadingExpVector();
    if (esig == null) {
        logger.info("esig = null");
        //esig = a.ring.evzero;
    }
    //GenPolynomialRing<C> ring = a.ring;
    boolean reduced = true;
    while (!a.isZERO() && reduced) {
        reduced = false;
        a = red.normalform(ff, a);
        if (a.isZERO()) {
            continue;
        }
        ExpVector e = a.leadingExpVector();
        for (SigPoly<C> p : G) {
            if (p.poly.isZERO()) {
                continue;
            }
            ExpVector f = p.poly.leadingExpVector();
            boolean mt = e.multipleOf(f);
            if (mt) {
                ExpVector g = e.subtract(f);
                C sc = a.leadingBaseCoefficient().divide(p.poly.leadingBaseCoefficient());
                GenPolynomial<C> sigup = p.sigma.multiply(sc, g);
                ExpVector eup = sigup.leadingExpVector();
                if (eup == null) {
                    logger.info("eup = null");
                    //eup = a.ring.evzero;
                    throw new IllegalArgumentException("eup == null: " + sigup);
                }

                //wrong: boolean sigeq = (sigup.compareTo(sigma) < 0);
                boolean sigeq = (eup.compareTo(esig) < 0);
                if (sigeq) {
                    //logger.info("reduced: sigup = " + sigup + ", sigma = " + sigma);
                    reduced = true;
                    a = a.subtractMultiple(sc, g, p.poly);
                    if (a.isZERO()) {
                        break;
                    }
                    e = a.leadingExpVector();
                } else {
                    //logger.info("not reduced: a = " + a + ", p = " + p.poly);
                }
            }
        }
    }
    if (!a.isZERO()) {
        C ac = a.leadingBaseCoefficient();
        if (!ac.isONE()) {
            ac = ac.inverse();
            a = a.multiply(ac);
        }
    }
    return new SigPoly<C>(sigma, a);
}
 
开发者ID:kredel,项目名称:java-algebra-system,代码行数:74,代码来源:SigReductionSeq.java


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