public class LogMath
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
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 and Description |
---|
LogMath() |
Modifier and Type | Method and Description |
---|---|
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)).
|
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
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.