at.tuwien.ifs.commons.util
Class MathUtils

java.lang.Object
  extended by at.tuwien.ifs.commons.util.MathUtils

public class MathUtils
extends Object

A collection of math-related utility methods.

Version:
$Id: MathUtils.java 3800 2010-09-13 14:03:43Z frank $
Author:
Rudolf Mayer, Jakob Frank

Constructor Summary
MathUtils()
           
 
Method Summary
static int cap(int i, int cap)
          Deprecated. use Math.min(int, int) instead.
static long cap(long i, long cap)
          Deprecated. use Math.min(long, long) instead.
static double capLower(double i, double lowerCap)
          caps a value by the given minimum value.
static int capLower(int i, int lowerCap)
          Deprecated. use Math.max(int, int) instead
static int constrainWithin(int i, int lower, double upper)
          contrains a value within the given lower and upper boundaries
static int constrainWithin(int i, int lower, int upper)
          contrains a value within the given lower and upper boundaries
static double getSumOf(double[] in)
          sums up the values in the array and returns the sum
static int getSumOf(int[] in)
          sums up the values in the array and returns the sum
static int min(int... arguments)
          finds the minimum value from a given array of integer values
static int numberOfDigits(int i)
           
static int numberOfDigits(long i)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MathUtils

public MathUtils()
Method Detail

min

public static int min(int... arguments)
finds the minimum value from a given array of integer values


constrainWithin

public static final int constrainWithin(int i,
                                        int lower,
                                        int upper)
contrains a value within the given lower and upper boundaries


constrainWithin

public static int constrainWithin(int i,
                                  int lower,
                                  double upper)
contrains a value within the given lower and upper boundaries


cap

@Deprecated
public static final int cap(int i,
                                       int cap)
Deprecated. use Math.min(int, int) instead.

caps a value by the given maximum value.


capLower

@Deprecated
public static final int capLower(int i,
                                            int lowerCap)
Deprecated. use Math.max(int, int) instead

caps a value by the given minimum value.


capLower

public static double capLower(double i,
                              double lowerCap)
caps a value by the given minimum value.


cap

@Deprecated
public static final long cap(long i,
                                        long cap)
Deprecated. use Math.min(long, long) instead.

caps a value by the given maximum value.


getSumOf

public static double getSumOf(double[] in)
sums up the values in the array and returns the sum

Parameters:
in - the array over which the sum shall be calculated
Returns:
the sum of all values in the array

getSumOf

public static int getSumOf(int[] in)
sums up the values in the array and returns the sum

Parameters:
in - the array over which the sum shall be calculated
Returns:
the sum of all values in the array

numberOfDigits

public static int numberOfDigits(int i)

numberOfDigits

public static int numberOfDigits(long i)