|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--edu.stanford.nlp.math.SloppyMath
The class SloppyMath
contains methods for performing basic
numeric operations. In some cases, such as max and min, they cut a few
corners in
the implementation for the sake of efficiency. In particular, they may
not handle special notions like NaN and -0.0 correctly. This was the
origin of the class name, but some other operations are just useful
math additions, such as logSum.
Constructor Summary | |
SloppyMath()
|
Method Summary | |
static boolean |
isDangerous(double d)
Returns true if the argument is a "dangerous" double to have around, namely one that is infinite, NaN or zero. |
static boolean |
isVeryDangerous(double d)
Returns true if the argument is a "very dangerous" double to have around, namely one that is infinite or NaN. |
static double |
logAdd(double lx,
double ly)
Returns the log of the sum of two numbers, which are themselves input in log form. |
static double |
logSum(double[] logInputs)
Returns the log of the sum of an array of numbers, which are themselves input in log form. |
static double |
max(double a,
double b)
Returns the greater of two double values. |
static float |
max(float a,
float b)
Returns the greater of two float values. |
static double |
min(double a,
double b)
Returns the smaller of two double values. |
static float |
min(float a,
float b)
Returns the smaller of two float values. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public SloppyMath()
Method Detail |
public static float max(float a, float b)
float
values. That is,
the result is the argument closer to positive infinity. If the
arguments have the same value, the result is that same
value. Does none of the special checks for NaN or -0.0f that
Math.max
does.
a
- an argument.b
- another argument.
a
and b
.public static double max(double a, double b)
double
values. That
is, the result is the argument closer to positive infinity. If
the arguments have the same value, the result is that same
value. Does none of the special checks for NaN or -0.0f that
Math.max
does.
a
- an argument.b
- another argument.
a
and b
.public static float min(float a, float b)
float
values. That is,
the result is the value closer to negative infinity. If the
arguments have the same value, the result is that same
value. Does none of the special checks for NaN or -0.0f that
Math.max
does.
a
- an argument.b
- another argument.
a
and b.
public static double min(double a, double b)
double
values. That
is, the result is the value closer to negative infinity. If the
arguments have the same value, the result is that same
value. Does none of the special checks for NaN or -0.0f that
Math.max
does.
a
- an argument.b
- another argument.
a
and b
.public static boolean isDangerous(double d)
public static boolean isVeryDangerous(double d)
public static double logSum(double[] logInputs)
public static double logAdd(double lx, double ly)
lx
- First number, in log formly
- Second number, in log form
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |