de.cau.cs.kieler.core.util
Class KielerMath

java.lang.Object
  extended by de.cau.cs.kieler.core.util.KielerMath

public final class KielerMath
extends Object

Mathematics utility class for the KIELER projects.

Rating proposed yellow
(2009-12-11) msp

Nested Class Summary
static class KielerMath.Point
          Data class to store two coordinate values.
 
Method Summary
static double binomiald(int n, int k)
          The binomial coefficient of integers n and k as double value.
static long binomiall(int n, int k)
          The binomial coefficient of integers n and k as long value.
static KielerMath.Point[] calcBezierPoints(List<KielerMath.Point> controlPoints, int resultSize)
          Calculates a number of points on the Bezier curve defined by the given control points.
static double factd(int x)
          The factorial of an integer x as double value.
static long factl(int x)
          The factorial of an integer x as long value.
static double maxd(double... values)
          Determines the maximum for an arbitrary number of doubles.
static float maxf(float... values)
          Determines the maximum for an arbitrary number of floats.
static int maxi(int... values)
          Determines the maximum for an arbitrary number of integers.
static double mind(double... values)
          Determines the minimum for an arbitrary number of doubles.
static float minf(float... values)
          Determines the minimum for an arbitrary number of floats.
static int mini(int... values)
          Determines the minimum for an arbitrary number of integers.
static double pow(double a, int b)
          The first argument raised to the power of the second argument.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

factl

public static long factl(int x)
The factorial of an integer x as long value. If x is negative the result is 1. This method always returns the exact value, but may lead to overflow for large input values.

Parameters:
x - an integer
Returns:
the factorial of x

factd

public static double factd(int x)
The factorial of an integer x as double value. If x is negative the result is 1. This method returns the exact value for small input values, and uses Stirling's approximation for large input values.

Parameters:
x - an integer
Returns:
the factorial of x

binomiall

public static long binomiall(int n,
                             int k)
The binomial coefficient of integers n and k as long value. If n is not positive or k is not between 0 and n the result is 1. This method always returns the exact value, but may take very long for large input values.

Parameters:
n - the upper integer
k - the lower integer
Returns:
n choose k

binomiald

public static double binomiald(int n,
                               int k)
The binomial coefficient of integers n and k as double value. If n is not positive or k is not between 0 and n the result is 1. This method returns the exact value for small input values, and uses an approximation for large input values.

Parameters:
n - the upper integer
k - the lower integer
Returns:
n choose k

pow

public static double pow(double a,
                         int b)
The first argument raised to the power of the second argument.

Parameters:
a - the base
b - the exponent
Returns:
a to the power of b

calcBezierPoints

public static KielerMath.Point[] calcBezierPoints(List<KielerMath.Point> controlPoints,
                                                  int resultSize)
Calculates a number of points on the Bezier curve defined by the given control points. The degree of the curve is derived from the number of control points. The array of resulting curve points includes the target point, but does not include the source point of the curve.

Parameters:
controlPoints - list of control points
resultSize - number of returned curve points
Returns:
points on the curve defined by the given control points

maxi

public static int maxi(int... values)
Determines the maximum for an arbitrary number of integers.

Parameters:
values - integer values
Returns:
the maximum of the given values, or MIN_VALUE if no values are given

mini

public static int mini(int... values)
Determines the minimum for an arbitrary number of integers.

Parameters:
values - integer values
Returns:
the minimum of the given values, or MAX_VALUE if no values are given

maxf

public static float maxf(float... values)
Determines the maximum for an arbitrary number of floats.

Parameters:
values - float values
Returns:
the maximum of the given values, or -MAX_VALUE if no values are given

minf

public static float minf(float... values)
Determines the minimum for an arbitrary number of floats.

Parameters:
values - float values
Returns:
the minimum of the given values, or MAX_VALUE if no values are given

maxd

public static double maxd(double... values)
Determines the maximum for an arbitrary number of doubles.

Parameters:
values - double values
Returns:
the maximum of the given values, or -MAX_VALUE if no values are given

mind

public static double mind(double... values)
Determines the minimum for an arbitrary number of doubles.

Parameters:
values - double values
Returns:
the minimum of the given values, or MAX_VALUE if no values are given