gov.sns.tools.math.poly
Class UnivariateRealPolynomial

java.lang.Object
  |
  +--gov.sns.tools.math.poly.UnivariateRealPolynomial

public class UnivariateRealPolynomial
extends java.lang.Object

Represents a polynomial object with real coefficients over one real variable. This class is meant more as an encapsulation of a polynomial function rather than an algebraic object, as is implemented in the JSci mathematical/science package.


Constructor Summary
UnivariateRealPolynomial()
          Creates an empty polynomial object, the zero polynomial.
UnivariateRealPolynomial(double[] arrCoef)
          Creates and initializes a polynomial to the specified coefficients.
 
Method Summary
 double evaluateAt(double dblVal)
          Evaluate the polynomial for the specifed value of the indeterminate.
 double getCoef(int iOrder)
          Get the specified coefficient value.
 double[] getCoefs()
          Return the entire array of polynomial coefficients.
 int getDegree()
          Return the degree of the polynomial.
static void main(java.lang.String[] args)
          Testing driver
 UnivariateRealPolynomial plus(UnivariateRealPolynomial polyAddend)
          Nondestructively add two polynomials.
 void setCoefArray(double[] arrCoef)
          Set the entire coefficient array.
 UnivariateRealPolynomial times(UnivariateRealPolynomial polyFac)
          Nondestructive multiply two polynomials.
 java.lang.String toString()
          Construct and return a textual representation of the contents of this polynomial as a String object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UnivariateRealPolynomial

public UnivariateRealPolynomial()
Creates an empty polynomial object, the zero polynomial.


UnivariateRealPolynomial

public UnivariateRealPolynomial(double[] arrCoef)
Creates and initializes a polynomial to the specified coefficients.

Method Detail

setCoefArray

public void setCoefArray(double[] arrCoef)
Set the entire coefficient array. The coefficient array is arranged in order of ascending indeterminate order.

Parameters:
arrCoef - double array of coefficients.

getDegree

public int getDegree()
Return the degree of the polynomial. That is, the highest indeterminant order for all the nonzero coefficients.


getCoef

public double getCoef(int iOrder)
Get the specified coefficient value. The value of parameter iOrder specifies order of the indeterminate. For example, calling getCoef(2) would return the coefficient for the intdeterminate of second order. If the value of iOrder is larger than the size of the coefficient array then the coefficient is assumed to have value zero.

Parameters:
iOrder - order of the indeterminate
Returns:
coefficient of the specified indeterminate order

getCoefs

public double[] getCoefs()
Return the entire array of polynomial coefficients. The coefficient array is arranged in order of ascending indeterminate order.

Returns:
the entire coefficient array

evaluateAt

public double evaluateAt(double dblVal)
Evaluate the polynomial for the specifed value of the indeterminate. If the coefficient vector has not been specified this

Parameters:
dblVal - indeterminate value to evaluate the polynomial

plus

public UnivariateRealPolynomial plus(UnivariateRealPolynomial polyAddend)
Nondestructively add two polynomials. The current polynomial and the argument are added according to standard definitions (i.e., the coefficient array is added vectorily).

Parameters:
polyAddend - polynomial to be added to this
Returns:
a new polynomial object representing the sum

times

public UnivariateRealPolynomial times(UnivariateRealPolynomial polyFac)
Nondestructive multiply two polynomials. The current polynomial and the argument are multiplied according to standard definitions.

Parameters:
polyFac - polynomial to be multiplied by this
Returns:
a new polynomial object representing the product

toString

public java.lang.String toString()
Construct and return a textual representation of the contents of this polynomial as a String object.

Overrides:
toString in class java.lang.Object
Returns:
a String representation of the polynomial contents
See Also:
Object.toString()

main

public static void main(java.lang.String[] args)
Testing driver