001/*
002 * $Id: IdealWithUniv.java 4058 2012-07-26 21:03:53Z kredel $
003 */
004
005package edu.jas.application;
006
007
008import java.io.Serializable;
009import java.util.List;
010
011import edu.jas.poly.GenPolynomial;
012import edu.jas.structure.GcdRingElem;
013
014
015/**
016 * Container for Ideals together with univariate polynomials.
017 * @author Heinz Kredel
018 */
019public class IdealWithUniv<C extends GcdRingElem<C>> implements Serializable {
020
021
022    /**
023     * The ideal.
024     */
025    public final Ideal<C> ideal;
026
027
028    /**
029     * The list of univariate polynomials. Contains polynomials from serveral
030     * rings, depending on the stage of the decomposition. 1) polynomials in a
031     * ring of one variable, 2) polynomials depending on only one variable but
032     * in a ring with multiple variables, 3) after contraction to a non-zero
033     * dimensional ring multivariate polynomials depending on one significant
034     * variable and multiple variables from the quotient coefficients.
035     */
036    public final List<GenPolynomial<C>> upolys;
037
038
039    /**
040     * A list of other useful polynomials. 1) field extension polynomials, 2)
041     * generators for infinite quotients.
042     */
043    public final List<GenPolynomial<C>> others;
044
045
046    /**
047     * Constructor not for use.
048     */
049    protected IdealWithUniv() {
050        throw new IllegalArgumentException("do not use this constructor");
051    }
052
053
054    /**
055     * Constructor.
056     * @param id the ideal
057     * @param up the list of univariate polynomials
058     */
059    protected IdealWithUniv(Ideal<C> id, List<GenPolynomial<C>> up) {
060        this(id, up, null);
061    }
062
063
064    /**
065     * Constructor.
066     * @param id the ideal
067     * @param up the list of univariate polynomials
068     * @param og the list of other polynomials
069     */
070    protected IdealWithUniv(Ideal<C> id, List<GenPolynomial<C>> up, List<GenPolynomial<C>> og) {
071        ideal = id;
072        upolys = up;
073        others = og;
074    }
075
076
077    /**
078     * String representation of the ideal.
079     * @see java.lang.Object#toString()
080     */
081    @Override
082    public String toString() {
083        String s = ideal.toString();
084        if (upolys != null) {
085            s += "\nunivariate polynomials:\n" + upolys.toString();
086        }
087        if (others == null) {
088            return s;
089        }
090        return s + "\nother polynomials:\n" + others.toString();
091    }
092
093
094    /**
095     * Get a scripting compatible string representation.
096     * @return script compatible representation for this Element.
097     * @see edu.jas.structure.Element#toScript()
098     */
099    public String toScript() {
100        // Python case
101        String s = ideal.toScript();
102        if (upolys != null) {
103            s += ", upolys=" + upolys.toString();
104        }
105        if (others == null) {
106            return s;
107        }
108        return s + ", others=" + others.toString();
109    }
110
111}