com.singularsys.aa.polynomial
Class PolynomialExpr

java.lang.Object
  extended by com.singularsys.aa.SimpleExpr
      extended by com.singularsys.aa.polynomial.PolynomialExpr
All Implemented Interfaces:
Expression

public class PolynomialExpr
extends SimpleExpr

This class represents a polynomial expression consisting of any number of terms of type

PolynomialTerm
.

Author:
nathan

Field Summary
 
Fields inherited from class com.singularsys.aa.SimpleExpr
variables
 
Constructor Summary
PolynomialExpr(java.util.Vector variables_in)
          Creates a new instance of Polynomial
 
Method Summary
 void addToExponent(java.lang.String name, double value)
          Adds
 java.util.Vector getTerms()
          Returns the Vector of PolynomialTerm objects.
 java.lang.Object getValue(java.util.Hashtable varValues)
          Returns the value of the expression given the variable values in
 void makeNewTerm()
          Starts a new PolynomialTerm to which the calls to multiplyCoefficientWith() and addToExponent() will be applied.
 void multiplyCoefficientWith(double value)
          Multiplies the coefficient of the current term with
 void simplify()
          Simplifies this polynomial with the PolySimplifier class.
 java.lang.String toString()
           
 
Methods inherited from class com.singularsys.aa.SimpleExpr
getValue, getVariables
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PolynomialExpr

public PolynomialExpr(java.util.Vector variables_in)
Creates a new instance of Polynomial

Method Detail

makeNewTerm

public void makeNewTerm()
Starts a new PolynomialTerm to which the calls to multiplyCoefficientWith() and addToExponent() will be applied.

According to the constructor of PolynomialTerm, the coefficient is set to 1, and all exponents to 0.


multiplyCoefficientWith

public void multiplyCoefficientWith(double value)
Multiplies the coefficient of the current term with
value
.
makeNewTerm()
must be called before using this method.

Parameters:
value - the value to multiply the coefficient with.

addToExponent

public void addToExponent(java.lang.String name,
                          double value)
Adds
value
to the exponents of the variable
name
for the current term.

makeNewTerm()
must be called before using this method.

Parameters:
name - the variable name as the base for the exponent.
value - the value to be added to the exponent.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getTerms

public java.util.Vector getTerms()
Returns the Vector of PolynomialTerm objects.

Returns:
the Vector of PolynomialTerm objects.

simplify

public void simplify()
Simplifies this polynomial with the PolySimplifier class.


getValue

public java.lang.Object getValue(java.util.Hashtable varValues)
Returns the value of the expression given the variable values in
varValues
.

Specified by:
getValue in interface Expression
Overrides:
getValue in class SimpleExpr
Parameters:
varValues - A hastable containing the variable names as keys, and the values as objects.
Returns:
The value of the expression.