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