001/*
002 * $Id$
003 */
004
005package edu.jas.gb;
006
007
008import java.util.List;
009
010import edu.jas.poly.GenPolynomial;
011import edu.jas.poly.GenPolynomialRing;
012import edu.jas.poly.ModuleList;
013import edu.jas.poly.PolynomialList;
014import edu.jas.structure.RingElem;
015
016
017/**
018 * Container for a GB and transformation matrices. A container for F, G, calG
019 * and calF. Immutable objects.
020 * @typeparam C coefficient type
021 */
022public class ExtendedGB<C extends RingElem<C>> {
023
024
025    public final List<GenPolynomial<C>> F;
026
027
028    public final List<GenPolynomial<C>> G;
029
030
031    public final List<List<GenPolynomial<C>>> F2G;
032
033
034    public final List<List<GenPolynomial<C>>> G2F;
035
036
037    public final GenPolynomialRing<C> ring;
038
039
040    /**
041     * Container for a GB and transformation matrices.
042     * @param F an ideal base.
043     * @param G a Groebner base of F.
044     * @param F2G a transformation matrix from F to G.
045     * @param G2F a transformation matrix from G to F.
046     */
047    public ExtendedGB(List<GenPolynomial<C>> F, List<GenPolynomial<C>> G, List<List<GenPolynomial<C>>> F2G,
048                      List<List<GenPolynomial<C>>> G2F) {
049        this.F = F;
050        this.G = G;
051        this.F2G = F2G;
052        this.G2F = G2F;
053        GenPolynomialRing<C> r = null;
054        if (G != null) {
055            for (GenPolynomial<C> p : G) {
056                if (p != null) {
057                    r = p.ring;
058                    break;
059                }
060            }
061            if (r != null && r.getVars() == null) {
062                r.setVars(r.newVars("y"));
063            }
064        }
065        this.ring = r;
066    }
067
068
069    /**
070     * Get the String representation.
071     * @see java.lang.Object#toString()
072     */
073    @Override
074    public String toString() {
075        PolynomialList<C> P;
076        ModuleList<C> M;
077        StringBuffer s = new StringBuffer("ExtendedGB: \n\n");
078        P = null;
079        if (F != null) {
080            P = new PolynomialList<C>(ring, F);
081        }
082        s.append("F = " + P + "\n\n");
083        P = new PolynomialList<C>(ring, G);
084        s.append("G = " + P + "\n\n");
085        M = null;
086        if (F2G != null) {
087            M = new ModuleList<C>(ring, F2G);
088        }
089        s.append("F2G = " + M + "\n\n");
090        M = new ModuleList<C>(ring, G2F);
091        s.append("G2F = " + M + "\n");
092        return s.toString();
093    }
094
095}