com.hedgehog.math.interpolation
Class TripleFunctionCurveFit

java.lang.Object
  extended by com.hedgehog.HObject
      extended by com.hedgehog.math.interpolation.TripleFunctionCurveFit
All Implemented Interfaces:
java.lang.Comparable, java.util.Comparator

public class TripleFunctionCurveFit
extends HObject

Title: TripleFunctionCurveFit - performs a fit of the function y=af0(x)+bf1(x)+cf2(x) through (x[],y[]) data.

Description: Performs a fit of the linear sum y=af0(x)+bf1(x)+cf2(x) through (x[],y[]) data.

Fits the linear sum y=af0(x)+bf1(x)+cf2(x) through the specified data using the least squares method described in J Meeus's book "Astronomical Algorithms", p44. The fit is a linear combination of the three functions f0(x), f1(x) and f2(x).

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

Company: Hedgehog Software

Since:
1.0
Version:
1.1

Field Summary
protected  OneVariableFunction mf0
          Function f0(x).
protected  OneVariableFunction mf1
          Function f1(x).
protected  OneVariableFunction mf2
          Function f2(x).
protected  double[] mx
          1D Java array of x values.
protected  double[] my
          1D Java array of y values.
 
Fields inherited from class com.hedgehog.HObject
mID, mName
 
Constructor Summary
TripleFunctionCurveFit(double[] x, double[] y, OneVariableFunction f0, OneVariableFunction f1, OneVariableFunction f2)
          Constructor.
TripleFunctionCurveFit(TripleFunctionCurveFit object)
          Copy constructor.
 
Method Summary
 double[] fit(java.lang.Object f0InvokingObject, java.lang.Object f1InvokingObject, java.lang.Object f2InvokingObject)
          Fits the linear sum y=af0(x)+bf1(x)+cf2(x) through the (x[],y[]) data.
 OneVariableFunction getF0()
          Returns mf0.
 OneVariableFunction getF1()
          Returns mf1.
 OneVariableFunction getF2()
          Returns mf2.
 double[] getX()
          Returns the x values array.
 double[] getY()
          Returns the y values array.
 void setF0(OneVariableFunction f0)
          Sets f0(x).
 void setF1(OneVariableFunction f1)
          Sets f1(x).
 void setF2(OneVariableFunction f2)
          Sets f2(x).
 void setXY(double[] x, double[] y)
          Sets the x and y data arrays.
 
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, toString, wait, wait, wait
 

Field Detail

mx

protected double[] mx
1D Java array of x values.


my

protected double[] my
1D Java array of y values.


mf0

protected OneVariableFunction mf0
Function f0(x).


mf1

protected OneVariableFunction mf1
Function f1(x).


mf2

protected OneVariableFunction mf2
Function f2(x).

Constructor Detail

TripleFunctionCurveFit

public TripleFunctionCurveFit(double[] x,
                              double[] y,
                              OneVariableFunction f0,
                              OneVariableFunction f1,
                              OneVariableFunction f2)
                       throws java.lang.IllegalArgumentException
Constructor.

Parameters:
x - x values.
y - y values.
f0 - Function f0(x).
f1 - Function f1(x).
f2 - Function f2(x).
Throws:
java.lang.IllegalArgumentException - Thrown if x or y is null or x.length!=y.length. Thrown if f0, f1 or f2 are null.

TripleFunctionCurveFit

public TripleFunctionCurveFit(TripleFunctionCurveFit object)
Copy constructor.

Parameters:
object - Object to copy.
Method Detail

getX

public double[] getX()
Returns the x values array.

Returns:
x values array.

getY

public double[] getY()
Returns the y values array.

Returns:
y values array.

setXY

public void setXY(double[] x,
                  double[] y)
           throws java.lang.IllegalArgumentException
Sets the x and y data arrays.

Parameters:
x - x values.
y - y values.
Throws:
java.lang.IllegalArgumentException - Thrown if x or y is null or x.length!=y.length.

getF0

public OneVariableFunction getF0()
Returns mf0.

Returns:
The OneVariableFunction object mf0.

getF1

public OneVariableFunction getF1()
Returns mf1.

Returns:
The OneVariableFunction object mf1.

getF2

public OneVariableFunction getF2()
Returns mf2.

Returns:
The OneVariableFunction object mf2.

setF0

public void setF0(OneVariableFunction f0)
           throws java.lang.IllegalArgumentException
Sets f0(x).

Parameters:
f0 - New OneVariableFunction object mf0.
Throws:
java.lang.IllegalArgumentException - Thrown if f0 is null.

setF1

public void setF1(OneVariableFunction f1)
           throws java.lang.IllegalArgumentException
Sets f1(x).

Parameters:
f1 - New OneVariableFunction object mf1.
Throws:
java.lang.IllegalArgumentException - Thrown if f1 is null.

setF2

public void setF2(OneVariableFunction f2)
           throws java.lang.IllegalArgumentException
Sets f2(x).

Parameters:
f2 - New OneVariableFunction object mf2.
Throws:
java.lang.IllegalArgumentException - Thrown if f2 is null.

fit

public double[] fit(java.lang.Object f0InvokingObject,
                    java.lang.Object f1InvokingObject,
                    java.lang.Object f2InvokingObject)
Fits the linear sum y=af0(x)+bf1(x)+cf2(x) through the (x[],y[]) data.

Parameters:
f0InvokingObject - Invoking object for mf0.
f1InvokingObject - Invoking object for mf1.
f2InvokingObject - Invoking object for mf2.
Returns:
1D Java array of length 3 containing the polynomial coefficients [a,b,c]. A null object is returned if an internal error occurred generating the coefficients.