math.numerics
Class Util

java.lang.Object
  extended by math.numerics.Util

public final class Util
extends java.lang.Object

A utility class for numerical analysis. This class cannot be subclassed or instantiated because all methods are static.

Version:
1.0
Author:
Wolfgang Christian

Field Summary
static double defaultNumericalPrecision
          The default precision for numerical analysis.
 
Method Summary
static int checkSorting(double[] array)
          Checks if an array is sorted.
static double computeAverage(double[] array, int start, int num)
          Computes the average value of a subset of an array.
static Function constantFunction(double _c)
          Creates a function having a constant value.
static double evalMath(java.lang.String str)
          Evalautes a mathematical expression without variables.
static double[][] functionFill(Function f, double start, double stop, double[][] data)
          Fills an array with f(x) values.
static double[][] functionFill(Function f, double start, double stop, int n)
          Fills an array with f(x) values.
static double[] getDomain(Function f, double a, double b, int n)
           
static double relativePrecision(double epsilon, double result)
          Method relativePrecision
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defaultNumericalPrecision

public static final double defaultNumericalPrecision
The default precision for numerical analysis.

Method Detail

relativePrecision

public static double relativePrecision(double epsilon,
                                       double result)
Method relativePrecision

Parameters:
epsilon - the absolute error
result - the result
Returns:
the relative error

checkSorting

public static int checkSorting(double[] array)
Checks if an array is sorted. Returns: Positive integer if array is sorted in increasing value. Negative integer if array is sorted in decreasing value. Zero if array is not sorted.

Parameters:
array - double[]
Returns:
int 1,0,-1 based on sorting

getDomain

public static double[] getDomain(Function f,
                                 double a,
                                 double b,
                                 int n)

functionFill

public static double[][] functionFill(Function f,
                                      double start,
                                      double stop,
                                      int n)
Fills an array with f(x) values.

Parameters:
f - Function
start - double
stop - double
n - int
Returns:
double[][]

functionFill

public static double[][] functionFill(Function f,
                                      double start,
                                      double stop,
                                      double[][] data)
Fills an array with f(x) values.

Parameters:
f - Function
start - double
stop - double
data - double[][]
Returns:
double[][]

computeAverage

public static double computeAverage(double[] array,
                                    int start,
                                    int num)
Computes the average value of a subset of an array.

Parameters:
array - the data to be averaged
start - the index of the first point to be averaged
num - the total number of points to be averaged
Returns:

constantFunction

public static Function constantFunction(double _c)
Creates a function having a constant value.

Parameters:
_c -
Returns:

evalMath

public static double evalMath(java.lang.String str)
Evalautes a mathematical expression without variables.

Parameters:
str - String
Returns:
double