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


Java ExpVector.subtract方法代码示例

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


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

示例1: shift

import edu.jas.poly.ExpVector; //导入方法依赖的package包/类
/**
 * Shift coefficients. Multiply by exponent vector.
 * @param k shift ExpVector.
 * @return new power series with coefficient(i) = old.coefficient(i-k).
 */
public MultiVarPowerSeries<C> shift(final ExpVector k) {
    if (k == null) {
        throw new IllegalArgumentException("null ExpVector not allowed");
    }
    if (k.signum() == 0) {
        return this;
    }
    int nt = Math.min(truncate + (int) k.totalDeg(), ring.truncate);
    return new MultiVarPowerSeries<C>(ring, new MultiVarCoefficients<C>(ring) {


        @Override
        public C generate(ExpVector i) {
            ExpVector d = i.subtract(k);
            if (d.signum() < 0) {
                return ring.coFac.getZERO();
            }
            return coefficient(d);
        }
    }, nt);
}
 
开发者ID:kredel,项目名称:java-algebra-system,代码行数:27,代码来源:MultiVarPowerSeries.java

示例2: criterion4

import edu.jas.poly.ExpVector; //导入方法依赖的package包/类
/**
 * GB criterium 4. Use only for commutative polynomial rings. <b>Note:</b>
 * Experimental version for r-Groebner bases.
 * @param A polynomial.
 * @param B polynomial.
 * @return true if the S-polynomial(i,j) is required, else false.
 */
@Override
public boolean criterion4(GenPolynomial<C> A, GenPolynomial<C> B) {
    if (logger.isInfoEnabled()) {
        if (A instanceof GenSolvablePolynomial || B instanceof GenSolvablePolynomial) {
            logger.error("GBCriterion4 not applicabable to SolvablePolynomials");
            return true;
        }
    }
    ExpVector ei = A.leadingExpVector();
    ExpVector ej = B.leadingExpVector();
    ExpVector g = ei.sum(ej);
    ExpVector e = ei.lcm(ej);
    //        boolean t =  g == e ;
    ExpVector h = g.subtract(e);
    int s = h.signum();
    if (s == 0) { // disjoint ht
        C a = A.leadingBaseCoefficient();
        C b = B.leadingBaseCoefficient();
        C d = a.multiply(b);
        if (d.isZERO()) { // a guess
            return false; // can skip pair
        }
    }
    return true; //! ( s == 0 );
}
 
开发者ID:kredel,项目名称:java-algebra-system,代码行数:33,代码来源:RReductionSeq.java

示例3: criterion4

import edu.jas.poly.ExpVector; //导入方法依赖的package包/类
/**
 * GB criterium 4. Use only for commutative polynomial rings. This version
 * works also for d-Groebner bases.
 * @param A polynomial.
 * @param B polynomial.
 * @return true if the S-polynomial(i,j) is required, else false.
 */
@Override
public boolean criterion4(GenPolynomial<C> A, GenPolynomial<C> B) {
    if (logger.isInfoEnabled()) {
        if (A instanceof GenSolvablePolynomial || B instanceof GenSolvablePolynomial) {
            logger.error("GBCriterion4 not applicabable to SolvablePolynomials");
            return true;
        }
    }
    ExpVector ei = A.leadingExpVector();
    ExpVector ej = B.leadingExpVector();
    ExpVector g = ei.sum(ej);
    ExpVector e = ei.lcm(ej);
    //        boolean t =  g == e ;
    ExpVector h = g.subtract(e);
    int s = h.signum();
    if (s == 0) { // disjoint ht
        C a = A.leadingBaseCoefficient();
        C b = B.leadingBaseCoefficient();
        C d = a.gcd(b);
        if (d.isONE()) { // disjoint hc
            return false; // can skip pair
        }
    }
    return true; //! ( s == 0 );
}
 
开发者ID:kredel,项目名称:java-algebra-system,代码行数:33,代码来源:DReductionSeq.java

示例4: GPolynomial

import edu.jas.poly.ExpVector; //导入方法依赖的package包/类
/**
 * G-Polynomial.
 * @param Ap polynomial.
 * @param Bp polynomial.
 * @return gpol(Ap,Bp) the g-polynomial of Ap and Bp.
 */
public GenPolynomial<C> GPolynomial(GenPolynomial<C> Ap, GenPolynomial<C> Bp) {
    if (logger.isInfoEnabled()) {
        if (Bp == null || Bp.isZERO()) {
            return Ap.ring.getZERO();
        }
        if (Ap == null || Ap.isZERO()) {
            return Bp.ring.getZERO();
        }
        if (!Ap.ring.equals(Bp.ring)) {
            logger.error("rings not equal");
        }
    }
    Map.Entry<ExpVector, C> ma = Ap.leadingMonomial();
    Map.Entry<ExpVector, C> mb = Bp.leadingMonomial();

    ExpVector e = ma.getKey();
    ExpVector f = mb.getKey();

    ExpVector g = e.lcm(f);
    ExpVector e1 = g.subtract(e);
    ExpVector f1 = g.subtract(f);

    C a = ma.getValue();
    C b = mb.getValue();
    C[] c = a.egcd(b);

    //System.out.println("egcd[0] " + c[0]);

    GenPolynomial<C> App = Ap.multiply(c[1], e1);
    GenPolynomial<C> Bpp = Bp.multiply(c[2], f1);
    GenPolynomial<C> Cp = App.sum(Bpp);
    return Cp;
}
 
开发者ID:kredel,项目名称:java-algebra-system,代码行数:40,代码来源:DReductionSeq.java

示例5: leftSPolynomial

import edu.jas.poly.ExpVector; //导入方法依赖的package包/类
/**
 * Left S-Polynomial.
 * @param Ap solvable polynomial.
 * @param Bp solvable polynomial.
 * @return left-spol(Ap,Bp) the left S-polynomial of Ap and Bp.
 */
public GenSolvablePolynomial<C> leftSPolynomial(GenSolvablePolynomial<C> Ap, GenSolvablePolynomial<C> Bp) {
    if (logger.isInfoEnabled()) {
        if (Bp == null || Bp.isZERO()) {
            if (Ap != null) {
                return Ap.ring.getZERO();
            }
            return null;
        }
        if (Ap == null || Ap.isZERO()) {
            return Bp.ring.getZERO();
        }
        if (!Ap.ring.equals(Bp.ring)) {
            logger.error("rings not equal");
        }
    }
    Map.Entry<ExpVector, C> ma = Ap.leadingMonomial();
    Map.Entry<ExpVector, C> mb = Bp.leadingMonomial();

    ExpVector e = ma.getKey();
    ExpVector f = mb.getKey();

    ExpVector g = e.lcm(f);
    ExpVector e1 = g.subtract(e);
    ExpVector f1 = g.subtract(f);

    C a = ma.getValue();
    C b = mb.getValue();

    GenSolvablePolynomial<C> App = Ap.multiplyLeft(b, e1);
    GenSolvablePolynomial<C> Bpp = Bp.multiplyLeft(a, f1);
    GenSolvablePolynomial<C> Cp = (GenSolvablePolynomial<C>) App.subtract(Bpp);
    return Cp;
}
 
开发者ID:kredel,项目名称:java-algebra-system,代码行数:40,代码来源:SolvableReductionAbstract.java

示例6: SPolynomial

import edu.jas.poly.ExpVector; //导入方法依赖的package包/类
/**
 * S-Polynomial.
 * @param Ap polynomial.
 * @param Bp polynomial.
 * @return spol(Ap,Bp) the S-polynomial of Ap and Bp.
 */
@Override
public GenPolynomial<C> SPolynomial(GenPolynomial<C> Ap, GenPolynomial<C> Bp) {
    if (logger.isInfoEnabled()) {
        if (Bp == null || Bp.isZERO()) {
            return Ap.ring.getZERO();
        }
        if (Ap == null || Ap.isZERO()) {
            return Bp.ring.getZERO();
        }
        if (!Ap.ring.equals(Bp.ring)) {
            logger.error("rings not equal");
        }
    }
    Map.Entry<ExpVector, C> ma = Ap.leadingMonomial();
    Map.Entry<ExpVector, C> mb = Bp.leadingMonomial();

    ExpVector e = ma.getKey();
    ExpVector f = mb.getKey();

    ExpVector g = e.lcm(f);
    ExpVector e1 = g.subtract(e);
    ExpVector f1 = g.subtract(f);

    C a = ma.getValue();
    C b = mb.getValue();
    C c = a.gcd(b);
    C m = a.multiply(b);
    C l = m.divide(c); // = lcm(a,b)

    C a1 = l.divide(a);
    C b1 = l.divide(b);

    GenPolynomial<C> App = Ap.multiply(a1, e1);
    GenPolynomial<C> Bpp = Bp.multiply(b1, f1);
    GenPolynomial<C> Cp = App.subtract(Bpp);
    return Cp;
}
 
开发者ID:kredel,项目名称:java-algebra-system,代码行数:44,代码来源:DReductionSeq.java

示例7: SPolynomialExpVectorFactors

import edu.jas.poly.ExpVector; //导入方法依赖的package包/类
/**
 * S-Polynomial factors.
 * @param A monic polynomial.
 * @param B monic polynomial.
 * @return exponent vectors [e,f] such that spol(A,B) = e*a - f*B.
 */
public ExpVector[] SPolynomialExpVectorFactors(SigPoly<C> A, SigPoly<C> B) {
    Map.Entry<ExpVector, C> ma = A.poly.leadingMonomial();
    Map.Entry<ExpVector, C> mb = B.poly.leadingMonomial();
    ExpVector e = ma.getKey();
    ExpVector f = mb.getKey();
    ExpVector g = e.lcm(f);
    ExpVector e1 = g.subtract(e);
    ExpVector f1 = g.subtract(f);
    ExpVector[] F = new ExpVector[] { e1, f1 };
    return F;
}
 
开发者ID:kredel,项目名称:java-algebra-system,代码行数:18,代码来源:SigReductionSeq.java

示例8: SPolynomialHalf

import edu.jas.poly.ExpVector; //导入方法依赖的package包/类
/**
 * S-Polynomial half.
 * @param A monic polynomial.
 * @param B monic polynomial.
 * @return e*A "half" of an S-polynomial such that spol(A,B) = e*A - f*B.
 */
public GenPolynomial<C> SPolynomialHalf(SigPoly<C> A, SigPoly<C> B) {
    Map.Entry<ExpVector, C> ma = A.poly.leadingMonomial();
    Map.Entry<ExpVector, C> mb = B.poly.leadingMonomial();
    ExpVector e = ma.getKey();
    ExpVector f = mb.getKey();
    ExpVector g = e.lcm(f);
    ExpVector e1 = g.subtract(e);
    GenPolynomial<C> F = A.poly.multiply(e1);
    return F;
}
 
开发者ID:kredel,项目名称:java-algebra-system,代码行数:17,代码来源:SigReductionSeq.java

示例9: 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

示例10: SPolynomial

import edu.jas.poly.ExpVector; //导入方法依赖的package包/类
/**
 * S-Polynomial with recording.
 * @param S recording matrix, is modified. <b>Note</b> the negative
 *            S-polynomial is recorded as required by all applications.
 * @param i index of Ap in basis list.
 * @param A a polynomial.
 * @param j index of Bp in basis list.
 * @param B a polynomial.
 * @return Spol(A, B), the S-Polynomial for A and B.
 */
public GenPolynomial<C> SPolynomial(List<GenPolynomial<C>> S, int i, GenPolynomial<C> A, int j,
                GenPolynomial<C> B) {
    if (debug) {
        if (B == null || B.isZERO()) {
            throw new ArithmeticException("Spol B is zero");
        }
        if (A == null || A.isZERO()) {
            throw new ArithmeticException("Spol A is zero");
        }
        if (!A.ring.equals(B.ring)) {
            logger.error("rings not equal " + A.ring + ", " + B.ring);
        }
    }
    Map.Entry<ExpVector, C> ma = A.leadingMonomial();
    Map.Entry<ExpVector, C> mb = B.leadingMonomial();

    ExpVector e = ma.getKey();
    ExpVector f = mb.getKey();

    ExpVector g = e.lcm(f);
    ExpVector e1 = g.subtract(e);
    ExpVector f1 = g.subtract(f);

    C a = ma.getValue();
    C b = mb.getValue();

    //GenPolynomial<C> App = A.multiply(b, e1);
    //GenPolynomial<C> Bpp = B.multiply(a, f1);
    //GenPolynomial<C> Cp = App.subtract(Bpp);
    GenPolynomial<C> Cp = A.scaleSubtractMultiple(b, e1, a, f1, B);

    GenPolynomial<C> zero = A.ring.getZERO();
    GenPolynomial<C> As = zero.sum(b.negate(), e1);
    GenPolynomial<C> Bs = zero.sum(a /*correct .negate()*/, f1);
    S.set(i, As);
    S.set(j, Bs);
    return Cp;
}
 
开发者ID:kredel,项目名称:java-algebra-system,代码行数:49,代码来源:ReductionAbstract.java

示例11: coefficientPseudoRemainder

import edu.jas.poly.ExpVector; //导入方法依赖的package包/类
/**
 * Polynomial leading coefficient pseudo remainder.
 * @param P generic polynomial in n+1 variables.
 * @param A generic polynomial in n variables.
 * @return pseudo remainder of the leading coefficient of P wrt A, with
 *         ldcf(A)<sup>m'</sup> P = quotient * A + remainder.
 */
public static <C extends RingElem<C>> GenPolynomial<GenPolynomial<GenPolynomial<C>>> coefficientPseudoRemainder(
                GenPolynomial<GenPolynomial<GenPolynomial<C>>> P, GenPolynomial<GenPolynomial<C>> A) {
    if (A == null || A.isZERO()) { // findbugs
        throw new ArithmeticException(P + " division by zero " + A);
    }
    if (A.isONE()) {
        return P.ring.getZERO();
    }
    if (P.isZERO() || P.isONE()) {
        return P;
    }
    GenPolynomialRing<GenPolynomial<GenPolynomial<C>>> pfac = P.ring;
    GenPolynomialRing<GenPolynomial<C>> afac = A.ring; // == pfac.coFac
    GenPolynomial<GenPolynomial<GenPolynomial<C>>> r = P;
    GenPolynomial<GenPolynomial<C>> h;
    GenPolynomial<GenPolynomial<GenPolynomial<C>>> hr;
    GenPolynomial<GenPolynomial<C>> ldcf = P.leadingBaseCoefficient();
    long m = ldcf.degree(0);
    long n = A.degree(0);
    GenPolynomial<C> c = A.leadingBaseCoefficient();
    GenPolynomial<GenPolynomial<C>> cc = afac.getZERO().sum(c);
    //System.out.println("cc = " + cc);
    ExpVector e = A.leadingExpVector();
    for (long i = m; i >= n; i--) {
        if (r.isZERO()) {
            return r;
        }
        GenPolynomial<GenPolynomial<C>> p = r.leadingBaseCoefficient();
        ExpVector g = r.leadingExpVector();
        long k = p.degree(0);
        if (i == k) {
            GenPolynomial<C> pl = p.leadingBaseCoefficient();
            ExpVector f = p.leadingExpVector();
            f = f.subtract(e);
            r = r.multiply(cc); // coeff cc
            h = A.multiply(pl, f); // coeff ac
            hr = new GenPolynomial<GenPolynomial<GenPolynomial<C>>>(pfac, h, g);
            r = r.subtract(hr);
        } else {
            r = r.multiply(cc);
        }
        //System.out.println("r = " + r);
    }
    if (r.degree(0) < P.degree(0)) { // recursion for degree
        r = coefficientPseudoRemainder(r, A);
    }
    return r;
}
 
开发者ID:kredel,项目名称:java-algebra-system,代码行数:56,代码来源:PolyGBUtil.java

示例12: normalform

import edu.jas.poly.ExpVector; //导入方法依赖的package包/类
/**
 * Normalform. Allows concurrent modification of the DHT.
 * @param Ap polynomial.
 * @param mp a map from Integers to polynomials, e.g. a distributed hash
 *            table, concurrent modification allowed.
 * @return nf(Ap) with respect to Pp.
 */
@SuppressWarnings("cast")
public GenPolynomial<C> normalform(Map<Integer, GenPolynomial<C>> mp, GenPolynomial<C> Ap) {
    if (mp == null || mp.isEmpty()) {
        return Ap;
    }
    if (Ap == null || Ap.isZERO()) {
        return Ap;
    }
    int l;
    GenPolynomial<C>[] P;
    //synchronized ( mp ) { // no more required
    l = mp.size();
    P = (GenPolynomial<C>[]) new GenPolynomial[l];
    P = mp.values().toArray(P);
    l = P.length;
    //}

    Map.Entry<ExpVector, C> m;
    Map.Entry<ExpVector, C> m1;
    ExpVector e;
    ExpVector f = null;
    C a;
    boolean mt = false;
    GenPolynomial<C> Rz = Ap.ring.getZERO();
    GenPolynomial<C> R = Rz.copy();
    GenPolynomial<C> p = null;
    //GenPolynomial<C> Q = null;
    GenPolynomial<C> S = Ap.copy();
    while (S.length() > 0) {
        if (mp.size() != l) {
            //long t = System.currentTimeMillis();
            //synchronized ( mp ) { // no more required, ok in distributed
            P = mp.values().toArray(P);
            l = P.length;
            //}
            //t = System.currentTimeMillis()-t;
            //logger.info("Pp.toArray() = " + t + " ms, size() = " + l);
            //logger.info("Pp.toArray() size() = " + l);
            S = Ap.copy(); // S.add(R)? // restart reduction ?
            R = Rz.copy();
        }

        m = S.leadingMonomial();
        e = m.getKey();
        a = m.getValue();
        for (int i = 0; i < P.length; i++) {
            p = P[i];
            f = p.leadingExpVector();
            if (f != null) {
                mt = e.multipleOf(f);
                if (mt)
                    break;
            }
        }
        if (!mt) {
            //logger.debug("irred");
            //R = R.sum( a, e );
            //S = S.subtract( a, e ); 
            R.doPutToMap(e, a);
            S.doRemoveFromMap(e, a);
            // System.out.println(" S = " + S);
        } else {
            //logger.debug("red");
            m1 = p.leadingMonomial();
            e = e.subtract(f);
            a = a.divide(m1.getValue());
            //Q = p.multiply( a, e );
            //S = S.subtract( Q );
            S = S.subtractMultiple(a, e, p);
        }
    }
    return R;
}
 
开发者ID:kredel,项目名称:java-algebra-system,代码行数:81,代码来源:ReductionPar.java

示例13: leftBasePseudoQuotientRemainder

import edu.jas.poly.ExpVector; //导入方法依赖的package包/类
/**
 * GenSolvablePolynomial sparse pseudo quotient and remainder for univariate
 * polynomials or exact division.
 * @param <C> coefficient type.
 * @param P GenSolvablePolynomial.
 * @param S nonzero GenSolvablePolynomial.
 * @return [ quotient, remainder ] with ore(ldcf(S)<sup>m'</sup>) P =
 *         quotient * S + remainder. m' &le; deg(P)-deg(S)
 * @see edu.jas.poly.GenPolynomial#divide(edu.jas.poly.GenPolynomial).
 */
@SuppressWarnings("unchecked")
public static <C extends GcdRingElem<C>> GenSolvablePolynomial<C>[] leftBasePseudoQuotientRemainder(
                GenSolvablePolynomial<C> P, GenSolvablePolynomial<C> S) {
    if (S == null || S.isZERO()) {
        throw new ArithmeticException(P.toString() + " division by zero " + S);
    }
    //if (S.ring.nvar != 1) { // ok if exact division
    //    throw new RuntimeException("univariate polynomials only");
    //}
    GenSolvablePolynomial<C>[] ret = new GenSolvablePolynomial[2];
    ret[0] = null;
    ret[1] = null;
    if (P.isZERO() || S.isONE()) {
        ret[0] = P;
        ret[1] = S.ring.getZERO();
        return ret;
    }
    if (P instanceof RecSolvablePolynomial) {
        RecSolvablePolynomial<C> Pr = (RecSolvablePolynomial) P;
        if (!Pr.ring.coeffTable.isEmpty()) {
            throw new UnsupportedOperationException(
                            "RecSolvablePolynomial with twisted coeffs not supported");
        }
    }
    GreatestCommonDivisorAbstract<C> fd = new GreatestCommonDivisorFake<C>(P.ring.coFac);
    ExpVector e = S.leadingExpVector();
    GenSolvablePolynomial<C> h;
    GenSolvablePolynomial<C> r = P;
    GenSolvablePolynomial<C> q = S.ring.getZERO().copy();
    while (!r.isZERO()) {
        ExpVector f = r.leadingExpVector();
        if (f.multipleOf(e)) {
            C a = r.leadingBaseCoefficient();
            f = f.subtract(e);
            h = S.multiplyLeft(f); // coeff a
            C c = h.leadingBaseCoefficient();
            // need ga, gc: ga a = gc c
            C[] oc = fd.leftOreCond(a, c);
            C ga = oc[0];
            C gc = oc[1];
            r = r.multiplyLeft(ga); // coeff ga a, exp f
            h = h.multiplyLeft(gc); // coeff gc c, exp f
            q = q.multiplyLeft(ga); // c
            q = (GenSolvablePolynomial<C>) q.sum(gc, f); // a
            //System.out.println("q = " + q);
            r = (GenSolvablePolynomial<C>) r.subtract(h);
        } else {
            break;
        }
    }
    int sp = P.signum();
    int ss = S.signum();
    int sq = q.signum();
    // sp = ss * sq
    if (sp != ss * sq) {
        q = (GenSolvablePolynomial<C>) q.negate();
        r = (GenSolvablePolynomial<C>) r.negate();
    }
    ret[0] = q;
    ret[1] = r;
    return ret;
}
 
开发者ID:kredel,项目名称:java-algebra-system,代码行数:73,代码来源:FDUtil.java

示例14: rightBasePseudoQuotientRemainder

import edu.jas.poly.ExpVector; //导入方法依赖的package包/类
/**
 * GenSolvablePolynomial sparse pseudo quotient and remainder for univariate
 * polynomials or exact division.
 * @param <C> coefficient type.
 * @param P GenSolvablePolynomial.
 * @param S nonzero GenSolvablePolynomial.
 * @return [ quotient, remainder ] with P ore(ldcf(S)<sup>m'</sup>) = S *
 *         quotient + remainder. m' &le; deg(P)-deg(S)
 * @see edu.jas.poly.GenPolynomial#divide(edu.jas.poly.GenPolynomial).
 */
@SuppressWarnings("unchecked")
public static <C extends GcdRingElem<C>> GenSolvablePolynomial<C>[] rightBasePseudoQuotientRemainder(
                GenSolvablePolynomial<C> P, GenSolvablePolynomial<C> S) {
    if (S == null || S.isZERO()) {
        throw new ArithmeticException(P.toString() + " division by zero " + S);
    }
    //if (S.ring.nvar != 1) { // ok if exact division
    //    throw new RuntimeException("univariate polynomials only");
    //}
    GenSolvablePolynomial<C>[] ret = new GenSolvablePolynomial[2];
    ret[0] = null;
    ret[1] = null;
    if (P.isZERO() || S.isONE()) {
        ret[0] = P;
        ret[1] = S.ring.getZERO();
        return ret;
    }
    if (P instanceof RecSolvablePolynomial) {
        RecSolvablePolynomial<C> Pr = (RecSolvablePolynomial) P;
        if (!Pr.ring.coeffTable.isEmpty()) {
            throw new UnsupportedOperationException(
                            "RecSolvablePolynomial with twisted coeffs not supported");
        }
    }
    GreatestCommonDivisorAbstract<C> fd = new GreatestCommonDivisorFake<C>(P.ring.coFac);
    ExpVector e = S.leadingExpVector();
    GenSolvablePolynomial<C> h;
    GenSolvablePolynomial<C> r = P;
    GenSolvablePolynomial<C> q = S.ring.getZERO().copy();
    while (!r.isZERO()) {
        ExpVector f = r.leadingExpVector();
        if (f.multipleOf(e)) {
            C a = r.leadingBaseCoefficient();
            f = f.subtract(e);
            h = S.multiply(f); // coeff a
            C c = h.leadingBaseCoefficient();
            // need ga, gc: a ga = c gc
            C[] oc = fd.rightOreCond(a, c);
            C ga = oc[0];
            C gc = oc[1];
            r = r.multiply(ga); // coeff a ga, exp f
            h = h.multiply(gc); // coeff c gc, exp f wanted but is exp f * coeff c gc, okay for base
            q = q.multiply(ga); // c
            q = (GenSolvablePolynomial<C>) q.sum(gc, f); // a
            r = (GenSolvablePolynomial<C>) r.subtract(h);
        } else {
            break;
        }
    }
    int sp = P.signum();
    int ss = S.signum();
    int sq = q.signum();
    // sp = ss * sq
    if (sp != ss * sq) {
        q = (GenSolvablePolynomial<C>) q.negate();
        r = (GenSolvablePolynomial<C>) r.negate();
    }
    ret[0] = q;
    ret[1] = r;
    return ret;
}
 
开发者ID:kredel,项目名称:java-algebra-system,代码行数:72,代码来源:FDUtil.java

示例15: recursivePseudoQuotientRemainder

import edu.jas.poly.ExpVector; //导入方法依赖的package包/类
/**
 * GenSolvablePolynomial recursive pseudo quotient and remainder for
 * recursive polynomials.
 * @param <C> coefficient type.
 * @param P recursive GenSolvablePolynomial.
 * @param S nonzero recursive GenSolvablePolynomial.
 * @return [ quotient, remainder ] with ore(ldcf(S)<sup>m'</sup>) P =
 *         quotient * S + remainder.
 * @see edu.jas.poly.GenPolynomial#remainder(edu.jas.poly.GenPolynomial).
 */
@SuppressWarnings("unchecked")
public static <C extends GcdRingElem<C>> GenSolvablePolynomial<GenPolynomial<C>>[] recursivePseudoQuotientRemainder(
                GenSolvablePolynomial<GenPolynomial<C>> P, GenSolvablePolynomial<GenPolynomial<C>> S) {
    if (S == null || S.isZERO()) {
        throw new ArithmeticException(P + " division by zero " + S);
    }
    //if (S.ring.nvar != 1) { // ok if exact division
    //    throw new RuntimeException("univariate polynomials only");
    //}
    GenSolvablePolynomial<GenPolynomial<C>>[] ret = new GenSolvablePolynomial[2];
    if (P == null || P.isZERO()) {
        ret[0] = S.ring.getZERO();
        ret[1] = S.ring.getZERO();
        return ret;
    }
    if (S.isONE()) {
        ret[0] = P;
        ret[1] = S.ring.getZERO();
        return ret;
    }
    GenPolynomialRing<C> cofac = (GenPolynomialRing) P.ring.coFac;
    GreatestCommonDivisorAbstract<C> fd = new GreatestCommonDivisorSimple<C>(cofac.coFac);

    ExpVector e = S.leadingExpVector();
    GenSolvablePolynomial<GenPolynomial<C>> h;
    GenSolvablePolynomial<GenPolynomial<C>> r = P;
    GenSolvablePolynomial<GenPolynomial<C>> q = S.ring.getZERO().copy();
    while (!r.isZERO()) {
        ExpVector g = r.leadingExpVector();
        ExpVector f = g;
        if (f.multipleOf(e)) {
            f = f.subtract(e);
            h = S.multiplyLeft(f); // coeff c, exp (f/e) e
            GenSolvablePolynomial<C> a = (GenSolvablePolynomial<C>) r.leadingBaseCoefficient();
            GenSolvablePolynomial<C> d = (GenSolvablePolynomial<C>) h.leadingBaseCoefficient();
            GenSolvablePolynomial<C>[] oc = fd.leftOreCond(a, d);
            GenPolynomial<C> ga = oc[0]; // d
            GenPolynomial<C> gd = oc[1]; // a
            // ga a = gd d
            r = r.multiplyLeft(ga); // coeff ga a, exp f
            h = h.multiplyLeft(gd); // coeff gd d, exp f
            q = q.multiplyLeft(ga); // d
            q = (GenSolvablePolynomial<GenPolynomial<C>>) q.sum(gd, f); // a
            r = (GenSolvablePolynomial<GenPolynomial<C>>) r.subtract(h);
            if (!r.isZERO() && g.equals(r.leadingExpVector())) {
                throw new RuntimeException("degree not descending: r = " + r);
            }
        } else {
            break;
        }
    }
    int sp = P.signum();
    int ss = S.signum();
    int sq = q.signum();
    // sp = ss * sq
    if (sp != ss * sq) {
        q = (GenSolvablePolynomial<GenPolynomial<C>>) q.negate();
        r = (GenSolvablePolynomial<GenPolynomial<C>>) r.negate();
    }
    ret[0] = q;
    ret[1] = r;
    return ret;
}
 
开发者ID:kredel,项目名称:java-algebra-system,代码行数:74,代码来源:FDUtil.java


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