public class SuanShuUtils
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static void |
assertArgument(boolean condition,
java.lang.String errorMessage,
java.lang.Object... args)
Check if an argument condition is satisfied.
|
static void |
assertOrThrow(java.lang.RuntimeException error)
This is a wrapper method that throws a
RuntimeException if it is not null. |
static double |
autoEpsilon(double... inputs)
Guess a reasonable precision parameter.
|
static double |
autoEpsilon(double[]... inputs)
Guess a reasonable precision parameter.
|
static double |
autoEpsilon(MatrixTable A)
Guess a reasonable precision parameter.
|
public static void assertArgument(boolean condition,
java.lang.String errorMessage,
java.lang.Object... args)
IllegalArgumentException if not.condition - the argument condition to be checkederrorMessage - the error message if the condition is not satisfied (format string can be used with args, see format)args - the arguments for the error messagepublic static void assertOrThrow(java.lang.RuntimeException error)
RuntimeException if it is not null.
To use this method efficiently, we need to avoid the slow and expensive creation of an exception object on each checking.
For a sample usage,
assertOrThrow(cond ? null : new RuntimeException("msg"));
It is important that we use lazy evaluation of the if statement.error - the error thrown if the condition is not satisfiedpublic static double autoEpsilon(double... inputs)
auto ε = |max(inputs)| * sqrt(number of inputs) * machine ε * 10
inputs - doublespublic static double autoEpsilon(double[]... inputs)
auto ε = |max(inputs)| * sqrt(number of inputs) * machine ε * 10
inputs - arrays of double[]spublic static double autoEpsilon(MatrixTable A)
auto ε = |max(inputs)| * sqrt(number of inputs) * machine ε * 10
A - a matrix