|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgov.sandia.cognition.math.LogMath
public class LogMath
A utility class for doing math with numbers represented as logarithms. Thus, the number x is instead represented as log(x). This can be useful when doing computation involving many products, such as with probabilities.
Field Summary | |
---|---|
static double |
LOG_0
The natural logarithm of 0 (log(0)), which is negative infinity. |
static double |
LOG_1
The natural logarithm of 1 (log(1)), which is 0. |
static double |
LOG_10
The natural logarithm of 10 (log(10)). |
static double |
LOG_2
The natural logarithm of 2 (log(2)). |
static double |
LOG_E
The natural logarithm of e (log(e)), which is 1. |
Constructor Summary | |
---|---|
LogMath()
|
Method Summary | |
---|---|
static double |
add(double logX,
double logY)
Adds two log-domain values. |
static double |
divide(double logX,
double logY)
Divides two log-domain values. |
static double |
fromLog(double logX)
Converts a number from log-domain representation (x = exp(logX)). |
static double |
inverse(double logX)
Takes the inverse of a log-domain value. |
static double |
multiply(double logX,
double logY)
Multiplies two log-domain values. |
static double |
subtract(double logX,
double logY)
Subtracts two log-domain values. |
static double |
toLog(double x)
Converts a number to its log-domain representation (log(x)). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final double LOG_0
public static final double LOG_1
public static final double LOG_2
public static final double LOG_E
public static final double LOG_10
Constructor Detail |
---|
public LogMath()
Method Detail |
---|
public static double toLog(double x)
x
- The number. Should not be negative.
public static double fromLog(double logX)
logX
- The log-domain representation of the number x (log(x)).
public static double add(double logX, double logY)
logX
- The first log-domain value (log(x)).
Must be the same basis as logY.logY
- The second log-domain value (log(y)).
Must be the same basis as logX.
public static double subtract(double logX, double logY)
logX
- The first log-domain value (log(x)).
Must be the same basis as logY.logY
- The second log-domain value (log(y)).
Must be the same basis as logX.
public static double multiply(double logX, double logY)
logX
- The first log-domain value (log(x)).
Must be the same basis as logY.logY
- The second log-domain value (log(y)).
Must be the same basis as logX.
public static double divide(double logX, double logY)
logX
- The first log-domain value (log(x)) used in the numerator.
Must be the same basis as logY.logY
- The second log-domain value (log(y)) used in the denominator.
Must be the same basis as logX.
public static double inverse(double logX)
logX
- The log-domain value (log(x)) to invert.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |