Package org.esa.snap.core.util.math
Class FXYSum
java.lang.Object
org.esa.snap.core.util.math.FXYSum
- Direct Known Subclasses:
FXYSum.BiCubic,FXYSum.BiLinear,FXYSum.BiQuadric,FXYSum.Cubic,FXYSum.Linear,FXYSum.Quadric
The class
FXYSum represents a sum of function terms sum(c[i] * f[i](x,y), i=0, n-1)
where the vector c is a double array of constant coefficients and the vector f
is an array of functions of type FXY in x and y.
The vector c of constants is set by the approximate(double[][], int[]) method.
After vector c is set, the actual function values z(x,y) are retrieved using the
computeZ(double, double) method.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classProvides an optimizedcomputeZmethod for bi-cubic polynomials (order = 3+3).static final classProvides an optimizedcomputeZmethod for bi-linear polynomials (order = 1+1).static final classProvides an optimizedcomputeZmethod for bi-quadric polynomials (order = 2+2).static final classProvides an optimizedcomputeZmethod for cubic polynomials (order = 3).static final classProvides an optimizedcomputeZmethod for linear polynomials (order = 1).static final classProvides an optimizedcomputeZmethod for quadric polynomials (order = 2). -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new sum of terms sum(c[i] * f[i](x,y), i=0, n-1) for the given vector of functions.Constructs a new sum of terms sum(c[i] * f[i](x,y), i=0, n-1) for the given vector of functions and a polynomial order.Constructs a new sum of terms sum(c[i] * f[i](x,y), i=0, n-1) for the given vector of functions and a polynomial order. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidappendCFunctionCodeBody(String fname, String x, String y, StringBuffer sb) protected voidappendCFunctionCodeEnd(String fname, String x, String y, StringBuffer sb) protected voidappendCFunctionCodePart(StringBuffer sb, String part, String x, String y) protected voidappendCFunctionCodeStart(String fname, String x, String y, StringBuffer sb) voidapproximate(double[][] data, int[] indices) Approximates the given data points x,y,z by this sum of function terms so that z ~ sum(c[i] * f[i](x,y), i=0, n-1).doublecomputeZ(double x, double y) Computes this sum of function terms z(x,y) = sum(c[i] * f[i](x,y), i=0, n-1).static doubleComputes z(x,y) = sum(c[i] * f[i](x,y), i = 0, n - 1).createCFunctionCode(String fname, String x, String y) Returns this sum of function terms as human-readable C-code.static FXYSumcreateCopy(FXYSum fxySum) Creates a copy of the givenfxySum.static FXYSumcreateFXYSum(int order, double[] coefficients) Creates aFXYSumby the given order and coefficients.final double[]Gets the vector c of coefficient elements c[i].final FXY[]Gets the vector f of functions elements f[i](x,y).doubleGets the maximum, absolute error of the approximation.final intGets the number n of terms c[i] * f[i](x,y).intgetOrder()Gets the polynomial order, if any.doubleGets the root mean square error.
-
Field Details
-
FXY_LINEAR
-
FXY_BI_LINEAR
-
FXY_QUADRATIC
-
FXY_BI_QUADRATIC
-
FXY_CUBIC
-
FXY_BI_CUBIC
-
FXY_4TH
-
FXY_BI_4TH
-
-
Constructor Details
-
FXYSum
Constructs a new sum of terms sum(c[i] * f[i](x,y), i=0, n-1) for the given vector of functions. The vector c is initally set to zero and will remeain zero until the methodapproximate(double[][], int[])is performed with given data on this function sum.- Parameters:
functions- the vector F of functions
-
FXYSum
Constructs a new sum of terms sum(c[i] * f[i](x,y), i=0, n-1) for the given vector of functions and a polynomial order. The vector c is initally set to zero and will remeain zero until the methodapproximate(double[][], int[])is performed with given data on this function sum.- Parameters:
functions- the vector F of functionsorder- the polynomial order (for descriptive purpose only), -1 if unknown
-
FXYSum
Constructs a new sum of terms sum(c[i] * f[i](x,y), i=0, n-1) for the given vector of functions and a polynomial order. The vector c is set by thecoefficientsparameter. The coefficients will be recalculated if the methodapproximate(double[][], int[])is called.- Parameters:
functions- the vector F of functionsorder- the polynomial order (for descriptive purpose only), -1 if unknowncoefficients- the vector c
-
-
Method Details
-
createFXYSum
Creates aFXYSumby the given order and coefficients.Note: This factory method supprots only the creation of instances of the following FXYSum classes:
FXYSum.Linear- order = 1 ; number of coefficients = 3FXYSum.BiLinear- order = 2 ; number of coefficients = 4FXYSum.Quadric- order = 2 ; number of coefficients = 6FXYSum.BiQuadric- order = 4 ; number of coefficients = 9FXYSum.Cubic- order = 3 ; number of coefficients = 10FXYSum.BiCubic- order = 6 ; number of coefficients = 16
- Parameters:
order- the order of the sumcoefficients- the coefficients- Returns:
- returns a FXYSum instance, or
nullif the resulting instance is one of the supported.
-
createCopy
Creates a copy of the givenfxySum. -
getNumTerms
public final int getNumTerms()Gets the number n of terms c[i] * f[i](x,y).- Returns:
- the number of function terms
-
getFunctions
Gets the vector f of functions elements f[i](x,y).- Returns:
- the vector F of functions
-
getCoefficients
public final double[] getCoefficients()Gets the vector c of coefficient elements c[i].- Returns:
- the vector F of functions
-
getOrder
public int getOrder()Gets the polynomial order, if any.- Returns:
- the polynomial order or -1 if unknown
-
getRootMeanSquareError
public double getRootMeanSquareError()Gets the root mean square error.- Returns:
- the root mean square error
-
getMaxError
public double getMaxError()Gets the maximum, absolute error of the approximation.- Returns:
- the maximum, absolute error
-
computeZ
public double computeZ(double x, double y) Computes this sum of function terms z(x,y) = sum(c[i] * f[i](x,y), i=0, n-1). The method will return zero unless theapproximate(double[][], int[])is called in order to set the coefficient vector c.- Parameters:
x- the x valuey- the y value- Returns:
- the z value
- See Also:
-
computeZ
Computes z(x,y) = sum(c[i] * f[i](x,y), i = 0, n - 1).- Parameters:
f- the function vectorc- the coeffcient vectorx- the x valuey- the y value- Returns:
- the z value
-
approximate
public void approximate(double[][] data, int[] indices) Approximates the given data points x,y,z by this sum of function terms so that z ~ sum(c[i] * f[i](x,y), i=0, n-1). The method also sets the error statistics which can then be retrieved by thegetRootMeanSquareError()andgetMaxError()methods.- Parameters:
data- an array of values of the form {{x1,y1,z1}, {x2,y2,z2}, {x3,y3,z3}, ...}indices- an array of coordinate indices, determining the indices of x, y and z within adataelement. Ifnullthenindicesdefaults to the array{0, 1, 2}.- See Also:
-
createCFunctionCode
Returns this sum of function terms as human-readable C-code.- Parameters:
fname- the name of the function z(x,y) = sum(C[i]*F[i](x,y), i, n)x- the name of the x variabley- the name of the y variable- Returns:
- the C-code
-
appendCFunctionCodeStart
-
appendCFunctionCodeBody
-
appendCFunctionCodeEnd
-
appendCFunctionCodePart
-