org.lsmp.djep.groupJep.values
Class Polynomial

java.lang.Object
  extended by java.lang.Number
      extended by org.lsmp.djep.groupJep.values.Polynomial
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
FreeGroupElement

public class Polynomial
extends java.lang.Number

The ring of polynomials over a ring R.

Author:
Rich Morris Created on 09-Mar-2004
See Also:
Serialized Form

Constructor Summary
Polynomial(RingI baseRing, java.lang.String symbol, java.lang.Number[] coeffs)
          Construct a polynomial over a ring.
 
Method Summary
 Polynomial add(Polynomial poly)
           
 Complex calculateComplexValue(Complex rootVal)
          returns the complex value of this polynomial.
 java.lang.Number calculateValue(java.lang.Number rootVal)
           
 Polynomial div(Polynomial poly)
           
 double doubleValue()
          value of constant coeff.
 boolean equals(Polynomial n)
           
 float floatValue()
          value of constant coeff.
 RingI getBaseRing()
           
 java.lang.Number getCoeff(int i)
           
 java.lang.Number[] getCoeffs()
          Returns the coefficients of polynomial.
 int getDegree()
           
 java.lang.String getSymbol()
           
 int intValue()
          value of constant coeff.
 boolean isConstantPoly()
          Is this a constant polynomial?
 long longValue()
          value of constant coeff.
 Polynomial mul(Polynomial poly)
           
 Polynomial pow(int exp)
           
protected  void setCoeffs(java.lang.Number[] coeffs)
          Sub classes can change the coefficients.
 Polynomial sub(Polynomial poly)
           
 java.lang.String toString()
           
protected  Polynomial valueOf(java.lang.Number[] lcoeffs)
          Factory method to create a polynomial with the given coefficients.
 
Methods inherited from class java.lang.Number
byteValue, shortValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Polynomial

public Polynomial(RingI baseRing,
                  java.lang.String symbol,
                  java.lang.Number[] coeffs)
Construct a polynomial over a ring. In general the valueOf method should be used to construct a new polynomial.

Parameters:
baseRing - the underlying ring of the polynomial.
symbol - the symbol used to display the polynomial
coeffs - an array of coeficients in the base ring coeff[0] is constant, coeff[1] is coefficient of t etc.
Method Detail

setCoeffs

protected void setCoeffs(java.lang.Number[] coeffs)
Sub classes can change the coefficients. Other methods should treat polynomials as imutable.


valueOf

protected Polynomial valueOf(java.lang.Number[] lcoeffs)
Factory method to create a polynomial with the given coefficients. Sub classes should overwrite this method to costruct objects of the correct type.


add

public Polynomial add(Polynomial poly)

sub

public Polynomial sub(Polynomial poly)

mul

public Polynomial mul(Polynomial poly)

div

public Polynomial div(Polynomial poly)

pow

public Polynomial pow(int exp)

toString

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

getDegree

public int getDegree()

getSymbol

public java.lang.String getSymbol()

getCoeffs

public java.lang.Number[] getCoeffs()
Returns the coefficients of polynomial. TODO use defensive copying

Returns:
the array of coefficients, constant coefficient is element 0.

getCoeff

public java.lang.Number getCoeff(int i)

getBaseRing

public RingI getBaseRing()

intValue

public int intValue()
value of constant coeff.

Specified by:
intValue in class java.lang.Number

longValue

public long longValue()
value of constant coeff.

Specified by:
longValue in class java.lang.Number

floatValue

public float floatValue()
value of constant coeff.

Specified by:
floatValue in class java.lang.Number

doubleValue

public double doubleValue()
value of constant coeff.

Specified by:
doubleValue in class java.lang.Number

isConstantPoly

public boolean isConstantPoly()
Is this a constant polynomial?


equals

public boolean equals(Polynomial n)

calculateComplexValue

public Complex calculateComplexValue(Complex rootVal)
returns the complex value of this polynomial. Where the value of the symbol is replaced by rootVal.


calculateValue

public java.lang.Number calculateValue(java.lang.Number rootVal)


http://www.singularsys.com/jep Copyright © 2007 Singular Systems