vec_math
Class Extremum

java.lang.Object
  extended by vec_math.Extremum
All Implemented Interfaces:
Comparable<Extremum>

public class Extremum
extends Object
implements Comparable<Extremum>

Helper class to hold some type of (local) extremum in an indexed data set. Saddle points are not considered as extrema. It holds the index of the extremum, its value and the type, minima or maxima. They are comparable, which does sorting on the value of the extremum. In the very unlikely event of two extrema having the same value, their inidices are compared. Two extrema are equal, if their index, type and value agree. The hash code is the extrema index.


Nested Class Summary
static class Extremum.File
          Finds all maxima and minima in the quasi-conitinuous function, tabluated as an ascii-file in the first command line argument.
static class Extremum.Test1
          Classes that test the extrema finding method in smooth parabola.
static class Extremum.Test2
          Classes that test the extrema finding method in smooth parabola.
static class Extremum.Test3
          Classes that test the extrema finding method in smooth parabola.
static class Extremum.Test4
          Classes that test the extrema finding method in smooth parabola.
static class Extremum.Test5
          Classes that test the extrema finding method in smooth parabola.
static class Extremum.Test6
          Classes that test the extrema finding method in smooth parabola.
static class Extremum.Test7
          Classes that test the extrema finding method in smooth parabola.
static class Extremum.Test8
          Classes that test the extrema finding method in smooth parabola.
 
Field Summary
private  int index
          Index of the extremum, specified at construct.
private  boolean ismax
          If true, this extremum is a maximum, otherwise its a minimum.
private  double value
          Value of the extremum, specified at construct.
 
Constructor Summary
Extremum(int ind, double val, boolean max)
          Constructs a new extremum, specifying all information.
 
Method Summary
 int compareTo(Extremum that)
          Compares two extrem, consitent with equals.
 boolean equals(Object that)
          Two extrema are equal, if their type, value and index are identical.
 int getIndex()
          Returns the index in the array at which the extremum was encountered.
 double getValue()
          Returns the value of the extremum.
 int hashCode()
          Returns the index.
 boolean isMaximum()
          Returns true, if this extremum is a maximum.
 boolean isMinimum()
          Returns true, if this extremum is a minimum.
 String toString()
          Easy-readable sting.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

index

private int index
Index of the extremum, specified at construct.


value

private double value
Value of the extremum, specified at construct.


ismax

private boolean ismax
If true, this extremum is a maximum, otherwise its a minimum.

Constructor Detail

Extremum

public Extremum(int ind,
                double val,
                boolean max)
Constructs a new extremum, specifying all information.

Method Detail

isMaximum

public boolean isMaximum()
Returns true, if this extremum is a maximum. Otherwise it is a minimum.


isMinimum

public boolean isMinimum()
Returns true, if this extremum is a minimum. Otherwise it is a maximum.


getIndex

public int getIndex()
Returns the index in the array at which the extremum was encountered.


getValue

public double getValue()
Returns the value of the extremum.


hashCode

public int hashCode()
Returns the index.

Overrides:
hashCode in class Object

equals

public boolean equals(Object that)
Two extrema are equal, if their type, value and index are identical.

Overrides:
equals in class Object

compareTo

public int compareTo(Extremum that)
Compares two extrem, consitent with equals. First the values of the extremum are compared, followed by a comparison if their indices. If both are identical, -1 is returned if this is a minimum and that is a maximum.

This is faster than first checking for different types.

Specified by:
compareTo in interface Comparable<Extremum>

toString

public String toString()
Easy-readable sting.

Overrides:
toString in class Object