visad.data.in
Class ArithProg
- java.lang.Object
-
- visad.data.in.ArithProg
-
- Direct Known Subclasses:
- LonArithProg
public class ArithProg extends java.lang.ObjectProvides support for determining if a sequence of numeric values corresponds to an arithmetic progression and, if so, the progression parameters.
-
-
Constructor Summary
Constructors Constructor and Description ArithProg()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description booleanaccumulate(double value)Accumulates a value.booleanaccumulate(double[] values)Accumulates a set of doubles.booleanaccumulate(float value)Accumulates a value.booleanaccumulate(float[] values)Accumulates a set of floats.doublegetCommonDifference()Gets the current common difference.doublegetFirst()Gets the first value.doublegetLast()Returns the "last" value accumulated.longgetNumber()Gets the number of values.booleanisConsistent()Indicates whether or not the sequence so far is consistent with an arithmetic progression.static voidmain(java.lang.String[] args)
-
-
-
Method Detail
-
accumulate
public boolean accumulate(float[] values) throws VisADExceptionAccumulates a set of floats. Indicates whether or not the sequence is consistent with the arithmetic progression so far.- Parameters:
values- The values to accumulate.- Returns:
- False if the difference between any current and previous value normalized by the current increment differs from unity by more than the nearness threshold; otherwise, true.
- Throws:
VisADException-isConsistent()was false before this method was invoked.
-
accumulate
public boolean accumulate(double[] values) throws VisADExceptionAccumulates a set of doubles. Indicates whether or not the sequence is consistent with the arithmetic progression so far.- Parameters:
values- The values to accumulate.- Returns:
- False if the difference between any current and previous value normalized by the current increment differs from unity by more than the nearness threshold; otherwise, true.
- Throws:
VisADException-isConsistent()was false before this method was invoked.
-
accumulate
public final boolean accumulate(float value) throws VisADExceptionAccumulates a value. Indicate whether or not the value is consistent with the arithmetic progression so far.- Parameters:
value- The value to accumulate.- Returns:
- False if the difference between any current and previous value normalized by the current increment differs from unity by more than the nearness threshold; otherwise, true.
- Throws:
VisADException- The sequence isn't an arithmetic progression.
-
accumulate
public final boolean accumulate(double value) throws VisADExceptionAccumulates a value. Indicate whether or not the value is consistent with the arithmetic progression so far.- Parameters:
value- The value to accumulate.- Returns:
- False if the difference between any current and previous value normalized by the current increment differs from unity by more than the nearness threshold; otherwise, true.
- Throws:
VisADException- The sequence isn't an arithmetic progression.
-
isConsistent
public final boolean isConsistent()
Indicates whether or not the sequence so far is consistent with an arithmetic progression.- Returns:
trueif and only if the sequence of values seen so far is consistent with an arithmetic progression.
-
getNumber
public final long getNumber() throws VisADExceptionGets the number of values. Only meaningfull ifisConsistent()is true.- Returns:
- The number of values accumulated so far.
- Throws:
VisADException- The sequence isn't an arithmetic progression.
-
getFirst
public final double getFirst() throws VisADExceptionGets the first value.- Returns:
- The first accumulated value.
- Throws:
VisADException- The sequence isn't an arithmetic progression.
-
getLast
public final double getLast() throws VisADExceptionReturns the "last" value accumulated. It is only meaningfull ifisConsistentis true.- Returns:
- The last accumulated value.
- Throws:
VisADException- The sequence isn't an arithmetic progression.
-
getCommonDifference
public final double getCommonDifference() throws VisADExceptionGets the current common difference. Only meaningfull ifisConsistent()is true.- Returns:
- The computed common difference so far.
- Throws:
VisADException- The sequence isn't an arithmetic progression.
-
main
public static void main(java.lang.String[] args) throws java.lang.Exception- Throws:
java.lang.Exception
-
-
DMelt 3.0 © DataMelt by jWork.ORG