@Deprecated
public class FuzzyFloat
extends java.lang.Object
Floating point numbers are compared for equality by dividing them by one another and comparing the ratio. By default they must be within 0.0001 (0.01%) to be considered equal; supply this value to the FuzzyFloat constructor, or set the value with the set_rel_diff method. Note that zero is never equal to a non-zero number using this method.
Two NaN floats are not considered equal (consistent with the == operator).
Modifier and Type | Class and Description |
---|---|
class |
FuzzyFloat.DoubleArrayComparatorLexical
Deprecated.
Lexically compares two double arrays.
|
Constructor and Description |
---|
FuzzyFloat()
Deprecated.
Creates a FuzzyFloat with the default rel_diff value of .0001.
|
FuzzyFloat(double rel_diff)
Deprecated.
Creates a FuzzyFloat.
|
Modifier and Type | Method and Description |
---|---|
boolean |
eq(double d1,
double d2)
Deprecated.
Test d1 and d2 for equality using the current ratio.
|
boolean |
gt(double d1,
double d2)
Deprecated.
test d1 and d2 for
d1 > d2 . |
boolean |
gte(double d1,
double d2)
Deprecated.
test d1 and d2 for d1 ≥ d2.
|
int |
indexOf(double[] a,
double elt)
Deprecated.
Searches for the first occurrence of elt in a.
|
int |
indexOf(double[] a,
double[] sub)
Deprecated.
Searches for the first subsequence of a that matches sub elementwise.
|
boolean |
isElemMatch(double[] a1,
double[] a2)
Deprecated.
Determines whether or not a1 and a2 are set equivalent (contain only the same elements).
|
boolean |
isSubset(double[] smaller,
double[] bigger)
Deprecated.
Determines whether smaller is a subset of bigger.
|
boolean |
lt(double d1,
double d2)
Deprecated.
Test d1 and d2 for
d1 < d2 . |
boolean |
lte(double d1,
double d2)
Deprecated.
Test d1 and d2 for
d1 ≤ d2 . |
boolean |
ne(double d1,
double d2)
Deprecated.
Test d1 and d2 for non-equality using the current ratio.
|
void |
set_rel_diff(double rel_diff)
Deprecated.
Set all the fields of this class.
|
public FuzzyFloat()
public FuzzyFloat(double rel_diff)
rel_diff
- the relative diff to usepublic void set_rel_diff(double rel_diff)
rel_diff
- the new relative diff to useFuzzyFloat(double)
public boolean eq(double d1, double d2)
Note that if one of the numbers if 0.0, then the other number must be less than the square of the fuzzy ratio. This policy accommodates round off errors in floating point values.
d1
- the first value to compared2
- the second value to comparepublic boolean ne(double d1, double d2)
d1
- the first value to compared2
- the second value to compareeq(double, double)
public boolean lt(double d1, double d2)
d1 < d2
. If d1 is equal to d2 using the current ratio this returns
false.d1
- the first value to compared2
- the second value to compareeq(double, double)
public boolean lte(double d1, double d2)
d1 ≤ d2
. If d1 is equal to d2 using the current ratio, this
returns true.d1
- the first value to compared2
- the second value to compareeq(double, double)
public boolean gt(double d1, double d2)
d1 > d2
. IF d1 is equal to d2 using the current ratio, this returns
false.d1
- the first value to compared2
- the second value to compareeq(double, double)
public boolean gte(double d1, double d2)
d1
- the first value to compared2
- the second value to compareeq(double, double)
public int indexOf(double[] a, double elt)
eq(double, double)
test.a
- the array to searchelt
- the element to search forArrayList.indexOf(java.lang.Object)
public int indexOf(double[] a, double[] sub)
eq(double, double)
test.a
- the sequence to search insub
- the sequence to search forArrayList.indexOf(java.lang.Object)
,
String.indexOf(java.lang.String)
public boolean isElemMatch(double[] a1, double[] a2)
eq(double, double)
.
Note that this implementation is optimized for cases where the elements are actually the same, since it does a sort of both arrays before starting the comparisons.
a1
- the first set to comparea2
- the second set to comparepublic boolean isSubset(double[] smaller, double[] bigger)
eq(double, double)
.
Note that this implementation is optimized for cases where the elements are actually the same, since it does a sort of both arrays before starting the comparisons.
smaller
- the possibly-smaller subsetbigger
- the possibly-larger set