public class Utils
extends Object
Constructor and Description |
---|
Utils() |
Modifier and Type | Method and Description |
---|---|
static double |
EPSILON() |
static int |
indexUpperTriangular(int n,
int i,
int j)
Indexing in an array representing the upper triangular part of a matrix
into an n * n array representing the full symmetric matrix (column major).
|
static double |
log1pExp(double x)
When
x is positive and large, computing math.log(1 + math.exp(x)) will lead to arithmetic
overflow. |
static double[] |
unpackUpperTriangular(int n,
double[] triangularValues)
Convert an n * (n + 1) / 2 dimension array representing the upper triangular part of a matrix
into an n * n array representing the full symmetric matrix (column major).
|
public static double EPSILON()
public static double[] unpackUpperTriangular(int n, double[] triangularValues)
n
- The order of the n by n matrix.triangularValues
- The upper triangular part of the matrix packed in an array
(column major).public static int indexUpperTriangular(int n, int i, int j)
n
- The order of the n by n matrix.i
- (undocumented)j
- (undocumented)public static double log1pExp(double x)
x
is positive and large, computing math.log(1 + math.exp(x))
will lead to arithmetic
overflow. This will happen when x > 709.78
which is not a very large number.
It can be addressed by rewriting the formula into x + math.log1p(math.exp(-x))
when x
is positive.x
- a floating-point value as input.math.log(1 + math.exp(x))
.