com.hedgehog.math.functions
Class XYVectorPolynomialFunction

java.lang.Object
  extended by com.hedgehog.HObject
      extended by com.hedgehog.math.functions.Function
          extended by com.hedgehog.math.functions.XYVectorPolynomialFunction
All Implemented Interfaces:
java.lang.Comparable, java.util.Comparator
Direct Known Subclasses:
LagrangianPolynomialFunction

public class XYVectorPolynomialFunction
extends Function

Title: XYVectorPolynomialFunction - represents two FloatingPointVector vectors typically used in (x,y) data fitting

Description: Represents two FloatingPointVector vectors typically used in (x,y) data fitting.

Copyright: Copyright (c) Hedgehog Software 2007-2009.

Company: Hedgehog Software

Since:
1.0
Version:
1.1

Field Summary
protected  FloatingPointVector mxi
          Vector of x values.
protected  FloatingPointVector myi
          Vector of y values.
 
Fields inherited from class com.hedgehog.math.functions.Function
method
 
Fields inherited from class com.hedgehog.HObject
mID, mName
 
Constructor Summary
XYVectorPolynomialFunction(FloatingPointVector xi, FloatingPointVector yi)
          Constructor.
XYVectorPolynomialFunction(XYVectorPolynomialFunction object)
          Copy constructor.
 
Method Summary
 Interval findXInterval(double x, HInteger xminIndex, HInteger xmaxIndex)
          Assumes the x values [x0,x1,x2,....,xn-1] are increasing; ie x[i+1]>x[i].
 FloatingPointVector getXI()
          Returns the xi vector.
 FloatingPointVector getYI()
          Returns the yi vector.
 double interpolateY(double x)
          Interpolates the yi values for the specified x value.
 boolean isValid()
          Tests the validity of this object.
 void setXI(FloatingPointVector xi)
          Sets the xi vector.
 void setYI(FloatingPointVector yi)
          Sets the yi vector.
 double taylorsSeriesFirstDerivative(int xpoint)
          Computes the first derivative using Taylor's differentiation.
 double taylorsSeriesSecondDerivative(int xpoint)
          Computes the second derivative using Taylor's differentiation.
 java.lang.String toString()
          Returns a String representation of a XYVectorPolynomialFunction object.
 
Methods inherited from class com.hedgehog.math.functions.Function
getMethod, setMethod
 
Methods inherited from class com.hedgehog.HObject
clone, compare, compareTo, copy, equals, getID, getName, hashCode, hasID, hasName, setID, setName
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

mxi

protected FloatingPointVector mxi
Vector of x values.


myi

protected FloatingPointVector myi
Vector of y values.

Constructor Detail

XYVectorPolynomialFunction

public XYVectorPolynomialFunction(FloatingPointVector xi,
                                  FloatingPointVector yi)
                           throws java.lang.IllegalArgumentException
Constructor.

Parameters:
xi - Vector of x values.
yi - Vector of y values.
Throws:
java.lang.IllegalArgumentException - Thrown if xi and yi not of te same size.

XYVectorPolynomialFunction

public XYVectorPolynomialFunction(XYVectorPolynomialFunction object)
Copy constructor.

Parameters:
object - Object to copy.
Method Detail

getXI

public FloatingPointVector getXI()
Returns the xi vector.

Returns:
The xi vector.
Since:
1.1

getYI

public FloatingPointVector getYI()
Returns the yi vector.

Returns:
The yi vector.
Since:
1.1

setXI

public void setXI(FloatingPointVector xi)
Sets the xi vector.

Parameters:
xi - New xi vector.
Since:
1.1

setYI

public void setYI(FloatingPointVector yi)
Sets the yi vector.

Parameters:
yi - New yi vector.
Since:
1.1

findXInterval

public Interval findXInterval(double x,
                              HInteger xminIndex,
                              HInteger xmaxIndex)
Assumes the x values [x0,x1,x2,....,xn-1] are increasing; ie x[i+1]>x[i]. If xx[n-1] then the interval is set to [x[n-1]:POSITIVE_INFINITY].

Parameters:
x - Value in which to find enclosing interval.
xminIndex - Set upon return to the xi index of the interval minimum.
xmaxIndex - Set upon return to the xi index of the interval maximum.
Returns:
Enclosing interval.
Since:
1.1

interpolateY

public double interpolateY(double x)
Interpolates the yi values for the specified x value. If x < x[0] then x[0] is returned. If x > x[n-1] then x[n-1] is returned. If x[i]<=x<=x[i+1] then linear interpolation is used to calculate y.

Parameters:
x - The x value at which to interpolate y.
Returns:
The interpolated y value at the specified x.
Since:
1.1

taylorsSeriesFirstDerivative

public double taylorsSeriesFirstDerivative(int xpoint)
                                    throws InvalidObjectException,
                                           java.lang.IllegalArgumentException
Computes the first derivative using Taylor's differentiation.

Parameters:
xpoint - Point at which derivative is evaluated.
Returns:
First derivative.
Throws:
InvalidObjectException - Thrown if less than 3 points.
java.lang.IllegalArgumentException - Thrown if xpoint is out of range.

taylorsSeriesSecondDerivative

public double taylorsSeriesSecondDerivative(int xpoint)
                                     throws InvalidObjectException,
                                            java.lang.IllegalArgumentException
Computes the second derivative using Taylor's differentiation.

Parameters:
xpoint - Point at which derivative is evaluated.
Returns:
Second derivative.
Throws:
InvalidObjectException - Thrown if less than 3 points.
java.lang.IllegalArgumentException - Thrown if xpoint is out of range.

isValid

public boolean isValid()
Tests the validity of this object. Confirms that xi and yi have the same number of elements.

Specified by:
isValid in class Function
Returns:
Logical-true if a valid object, else logical-false.

toString

public java.lang.String toString()
Returns a String representation of a XYVectorPolynomialFunction object.

Overrides:
toString in class Function
Returns:
A String representation of a XYVectorPolynomialFunction object.