Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

de.lmu.ifi.dbs.elki.math
Class DoubleMinMax

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.utilities.pairs.DoubleDoublePair
      extended by de.lmu.ifi.dbs.elki.math.DoubleMinMax
All Implemented Interfaces:
Comparable<DoubleDoublePair>

public class DoubleMinMax
extends DoubleDoublePair

Class to find the minimum and maximum double values in data.

Author:
Erich Schubert

Field Summary
 
Fields inherited from class de.lmu.ifi.dbs.elki.utilities.pairs.DoubleDoublePair
first, second
 
Constructor Summary
DoubleMinMax()
          Constructor without starting values.
DoubleMinMax(double min, double max)
          Constructor with predefined minimum and maximum values.
 
Method Summary
 double[] asArray()
          Return minimum and maximum as array.
 double getDiff()
          Return the difference between minimum and maximum.
 double getMax()
          Get the current maximum.
 double getMin()
          Get the current minimum.
 boolean isValid()
          Test if we have seen any data (and thus have a useful minimum and maximum).
static DoubleMinMax[] newArray(int size)
          Generate a new array of initialized DoubleMinMax objects (with default constructor)
 void put(double data)
          Process a single double value.
 void put(double[] data)
          Process a whole array of double values.
 void put(Double[] data)
          Process a whole array of double values.
 void put(Iterable<Double> data)
          Process a whole collection of double values.
 void put(SortedSet<Double> data)
          Process a whole collection of double values.
 
Methods inherited from class de.lmu.ifi.dbs.elki.utilities.pairs.DoubleDoublePair
compareSwappedTo, compareTo, equals, getFirst, getSecond, hashCode, setFirst, setSecond
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DoubleMinMax

public DoubleMinMax()
Constructor without starting values. The minimum will be initialized to Double.POSITIVE_INFINITY. The maximum will be initialized to Double.NEGATIVE_INFINITY. So that the first data added will replace both.


DoubleMinMax

public DoubleMinMax(double min,
                    double max)
Constructor with predefined minimum and maximum values.

Parameters:
min - Minimum value
max - Maximum value
Method Detail

put

public void put(double data)
Process a single double value. If the new value is smaller than the current minimum, it will become the new minimum. If the new value is larger than the current maximum, it will become the new maximum.

Parameters:
data - New value

put

public void put(double[] data)
Process a whole array of double values. If any of the values is smaller than the current minimum, it will become the new minimum. If any of the values is larger than the current maximum, it will become the new maximum.

Parameters:
data - Data to process

put

public void put(Double[] data)
Process a whole array of double values. If any of the values is smaller than the current minimum, it will become the new minimum. If any of the values is larger than the current maximum, it will become the new maximum.

Parameters:
data - Data to process

put

public void put(Iterable<Double> data)
Process a whole collection of double values. If any of the values is smaller than the current minimum, it will become the new minimum. If any of the values is larger than the current maximum, it will become the new maximum.

Parameters:
data - Data to process

put

public void put(SortedSet<Double> data)
Process a whole collection of double values. If any of the values is smaller than the current minimum, it will become the new minimum. If any of the values is larger than the current maximum, it will become the new maximum.

Parameters:
data - Data to process

getMin

public double getMin()
Get the current minimum.

Returns:
current minimum.

getMax

public double getMax()
Get the current maximum.

Returns:
current maximum.

getDiff

public double getDiff()
Return the difference between minimum and maximum.

Returns:
Difference of current Minimum and Maximum.

isValid

public boolean isValid()
Test if we have seen any data (and thus have a useful minimum and maximum). by convention, the values are initialized such that min > max when there was no data yet, ideally min = Datatype.MAX_VALUE and max = Datatype.MIN_VALUE.

Returns:
true iff min <= max.

asArray

public double[] asArray()
Return minimum and maximum as array.

Returns:
Minimum, Maximum

newArray

public static DoubleMinMax[] newArray(int size)
Generate a new array of initialized DoubleMinMax objects (with default constructor)

Parameters:
size - Array size
Returns:
initialized array

Release 0.2.1 (2009-07-13_1605)