001 002 /* 003 * $Id: Monomial.java 2209 2008-11-15 20:08:23Z kredel $ 004 */ 005 006 package edu.jas.poly; 007 008 import java.util.Map; 009 import java.util.SortedMap; 010 import java.util.Iterator; 011 012 import edu.jas.structure.RingElem; 013 014 import edu.jas.poly.ExpVector; 015 016 017 /** 018 * Monomial class. 019 * Represents pairs of exponent vectors and coefficients. 020 * Adaptor for Map.Entry. 021 * @author Heinz Kredel 022 */ 023 024 public final class Monomial<C extends RingElem<C> > { 025 026 /** 027 * Exponent of monomial. 028 */ 029 public final ExpVector e; 030 031 032 /** 033 * Coefficient of monomial. 034 */ 035 public final C c; 036 037 038 /** 039 * Constructor of monomial. 040 * @param me a MapEntry. 041 */ 042 public Monomial(Map.Entry<ExpVector,C> me){ 043 this( me.getKey(), me.getValue() ); 044 } 045 046 047 /** 048 * Constructor of monomial. 049 * @param e exponent. 050 * @param c coefficient. 051 */ 052 public Monomial(ExpVector e, C c) { 053 this.e = e; 054 this.c = c; 055 } 056 057 058 /** 059 * Getter for exponent. 060 * @return exponent. 061 */ 062 public ExpVector exponent() { 063 return e; 064 } 065 066 067 /** 068 * Getter for coefficient. 069 * @return coefficient. 070 */ 071 public C coefficient() { 072 return c; 073 } 074 075 /** 076 * String representation of Monomial. 077 * @see java.lang.Object#toString() 078 */ 079 @Override 080 public String toString() { 081 return c.toString() + " " + e.toString(); 082 } 083 084 }