public class Utils extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Utils.AtomicDoubleArray |
static class |
Utils.AtomicFloatArray |
static class |
Utils.AtomicIntArray |
static class |
Utils.AtomicLongArray |
static class |
Utils.ExpectedExceptionForDebug |
static class |
Utils.IcedArrayList<T extends Iced>
Simple wrapper around ArrayList with support for H2O serialization
|
static class |
Utils.IcedBitSet |
static class |
Utils.IcedDouble |
static class |
Utils.IcedHashMap<K extends Iced,V extends Iced>
Simple wrapper around HashMap with support for H2O serialization
|
static class |
Utils.IcedInt |
static class |
Utils.IcedLong |
static class |
Utils.IcedString |
| Modifier and Type | Field and Description |
|---|---|
static Pattern[] |
ILLEGAL_CHARACTERS
Java-string illegal characters which need to be escaped
|
static String[] |
REPLACEMENTS |
| Constructor and Description |
|---|
Utils() |
| Modifier and Type | Method and Description |
|---|---|
static byte[][][] |
add(byte[][][] a,
byte[][][] b) |
static byte[][] |
add(byte[][] a,
byte[][] b) |
static byte[] |
add(byte[] a,
byte[] b) |
static double[][][] |
add(double[][][] a,
double[][][] b) |
static double[][] |
add(double[][] a,
double[][] b) |
static double[] |
add(double[] a,
double[] b) |
static float[][][] |
add(float[][][] a,
float[][][] b) |
static float[][] |
add(float[][] a,
float[][] b) |
static float[] |
add(float[] a,
float[] b) |
static int[][][] |
add(int[][][] a,
int[][][] b) |
static int[][] |
add(int[][] a,
int[][] b) |
static int[] |
add(int[] a,
int[] b) |
static long[][][] |
add(long[][][] a,
long[][][] b) |
static long[][] |
add(long[][] a,
long[][] b) |
static long[] |
add(long[] a,
long[] b) |
static double[][] |
append(double[][] a,
double[][] b) |
static double[] |
append(double[] a,
double e) |
static double[] |
append(double[] a,
double[] e) |
static int[] |
append(int[] a,
int[] b) |
static long[][][] |
append(long[][][] a,
long[][] e) |
static String[] |
append(String[] a,
String[] b) |
static <T> T[] |
append(T[] a,
T... b) |
static double |
approxExp(double x)
Fast approximate exp
|
static double |
approxInvSqrt(double x)
Fast approximate 1./sqrt
|
static float |
approxInvSqrt(float x)
Fast approximate 1./sqrt
|
static double |
approxLog(double x)
Fast approximate log for values greater than 1, otherwise exact
|
static double |
approxSqrt(double x)
Fast approximate sqrt
|
static float |
approxSqrt(float x)
Fast approximate sqrt
|
static float |
approxSumSquares(float[] a,
int from,
int to)
Approximate sumSquares
|
static double[] |
asDoubles(Vec v) |
static int[] |
asInts(Vec v) |
static double |
avg(double[] nums) |
static double |
avg(long[] nums) |
static String |
className(String path) |
static void |
clearFolder(File folder) |
static void |
clearFolder(String folder) |
static void |
close(Closeable... closeable) |
static void |
close(Socket s) |
static boolean |
compareDoubles(double a,
double b) |
static int[][] |
compose(int[][] first,
int[][] second) |
static int[] |
compose(int[] first,
int[] transf) |
static boolean |
contains(int[] a,
int d) |
static boolean |
contains(String[] names,
String name) |
static boolean |
contains(String s,
CharSequence cs)
Returns true if given string contains at least on of character of
given sequence.
|
static String[] |
createConfusionMatrixHeader(long[] xs,
String[] ds) |
static int[] |
difference(int[] a,
int[] b) |
static double[] |
div(double[] nums,
double n) |
static float[] |
div(float[] nums,
float n) |
static float[] |
div(float[] nums,
int n) |
static String[] |
domainUnion(String[] a,
String[] b)
Clever union of String arrays.
|
static float |
entropy(byte[] f) |
static boolean |
equalsWithinOneSmallUlp(double a,
double b) |
static boolean |
equalsWithinOneSmallUlp(float a,
float b)
Compare two numbers to see if they are within one ulp of the smaller decade.
|
static String |
escapeJava(String s)
Escape all " and \ characters to provide a proper Java-like string
Does not escape unicode characters.
|
static int[] |
filter(int[] values,
boolean[] filter,
int fcnt) |
static String |
formatPct(double pct) |
static Key[] |
generateNumKeys(Key mk,
int num)
Generate given numbers of keys by suffixing key by given numbered suffix.
|
static Key[] |
generateNumKeys(Key mk,
int num,
String delim) |
static Key |
generateShuffledKey(Key mk) |
static int |
get4(byte[] buf,
int off) |
static double |
get8d(byte[] buf,
int off) |
static Random |
getDeterRNG(long seed) |
static byte[] |
getFirstUnzipedBytes(Key k) |
static byte[] |
getFirstUnzipedBytes(Value v) |
static int |
getPoisson(double lambda,
Random rng)
Poisson-distributed RNG
|
static Random |
getRNG(long... seed) |
static String |
getStackAsString(Throwable t) |
static H2ORandomRNG.RNGKind |
getUsedRNGKind() |
static H2ORandomRNG.RNGType |
getUsedRNGType() |
static ParseDataset2.Compression |
guessCompressionMethod(byte[] bits) |
static boolean |
hasNaNsOrInfs(double[] arr) |
static boolean |
isEmpty(int[] a) |
static boolean |
isInt(String s) |
static boolean |
isSorted(int[] ids) |
static String |
join(char sep,
Iterable it) |
static String |
join(char sep,
Object[] array) |
static double[] |
join(double[] a,
double[] b) |
static float[] |
join(float[] a,
float[] b) |
static <T> T[] |
join(T[] a,
T[] b) |
static double |
lnF(double what) |
static int[] |
mapping(int[] dom)
Returns a mapping of given domain to values (0, ...
|
static int |
maxIndex(float[] from) |
static int |
maxIndex(float[] from,
Random rand) |
static int |
maxIndex(int[] from) |
static int |
maxIndex(int[] from,
Random rand)
Returns the index of the largest value in the array.
|
static int |
maxIndex(long[] from) |
static int |
maxValue(byte[] from) |
static double |
maxValue(double[] from) |
static float |
maxValue(float[] from) |
static float |
maxValue(float[] from,
int start,
int end) |
static long |
maxValue(long[] from) |
static int |
minIndex(float[] from) |
static int |
minIndex(int[] from) |
static double |
minValue(double[] from) |
static float |
minValue(float[] from) |
static long |
minValue(long[] from) |
static double[] |
mult(double[] nums,
double n) |
static float[] |
mult(float[] nums,
float n) |
static long[] |
nfold(long nrows,
int nfolds,
int i)
Compute start row and length of
i-th fold from nfolds. |
static int |
numInts(String... a)
Returns number of strings which represents a number.
|
static byte[] |
or(byte[] a,
byte[] b) |
static int[] |
or(int[] a,
int[] b) |
static String |
p2d(double d) |
static String |
p5d(double d) |
static int[][] |
pack(int[] values,
boolean[] usemap) |
static int[] |
partitione(int len,
float[] ratio)
Divide given size into partitions based on given ratios.
|
static long[] |
partitione(long len,
float[] ratio) |
static String |
pprint(double[][] arr) |
static String |
pprint(double[][] arr,
DecimalFormat dformat) |
static void |
printConfusionMatrix(StringBuilder sb,
long[][] cm,
String[] domain,
boolean html) |
static String |
readConsole() |
static String |
readFile(File file) |
static void |
readFile(File file,
OutputStream out) |
static int[] |
remove(int[] a,
int i) |
static <T> T[] |
remove(T[] a,
int i) |
static StringBuilder |
replace(StringBuilder sb,
CharSequence from,
CharSequence to)
Replace given characters in a given string builder.
|
static String |
sampleToString(double[] val,
int max) |
static String |
sampleToString(int[] val,
int max) |
static int[] |
seq(int start,
int stop)
Generates sequence (start, stop) of integers: (start, start+1, ...., stop-1)
|
static int |
set4(byte[] buf,
int off,
int x) |
static int |
set8d(byte[] buf,
int off,
double d) |
static void |
setUsedRNGKind(H2ORandomRNG.RNGKind kind) |
static void |
setUsedRNGType(H2ORandomRNG.RNGType rngType) |
static int[] |
shuffleArray(int[] a,
int n,
int[] result,
long seed,
int startIndex)
Extract a shuffled array of integers
|
static void |
shuffleArray(long[] a,
long seed) |
static float[] |
sortAccording(float[] ary,
Integer[] sortOrder)
Create a new sorted array according to given sort order
|
static int[] |
sortAccording(int[] ary,
Integer[] sortOrder) |
static String[] |
sortAccording(String[] ary,
Integer[] sortOrder) |
static void |
sortAccording2(boolean[] ary,
Integer[] sortOrder)
Sort given array according given sort order.
|
static void |
sortAccording2(int[] ary,
Integer[] sortOrder)
Sort given array according given sort order.
|
static void |
sortWith(int[] ary,
int[] ary2)
Sort two arrays - the second one is sorted according the first one.
|
static <T> T[] |
subarray(T[] a,
int off,
int len) |
static double |
sum(double[] from) |
static float |
sum(float[] from) |
static int |
sum(int[] from) |
static long |
sum(long[] from) |
static float |
sumSquares(float[] a) |
static float |
sumSquares(float[] a,
int from,
int to) |
static File |
tmp()
Returns the system temporary folder, e.g.
|
static int[] |
toInt(String[] a,
int off,
int len) |
static String[] |
toString(int[] dom) |
static String[] |
toString(long[] dom) |
static String[] |
toStringMap(int first,
int last) |
static int[] |
union(int[] a,
int[] b)
Returns a union of given sorted arrays.
|
static String[] |
union(String[] a,
String[] b,
boolean lexo)
Union of given String arrays.
|
static String[] |
union(String[] a,
String[] b,
int aoff,
int alen,
int boff,
int blen,
boolean lexo) |
static int[] |
unpackInts(long... longs) |
static byte[] |
unzipBytes(byte[] bs,
ParseDataset2.Compression cmp) |
static File |
writeFile(File file,
String content) |
static File |
writeFile(String content) |
static void |
writeFileAndClose(File file,
InputStream in) |
public static final Pattern[] ILLEGAL_CHARACTERS
public static final String[] REPLACEMENTS
public static int maxIndex(int[] from,
Random rand)
public static int maxIndex(float[] from,
Random rand)
public static int maxIndex(int[] from)
public static int maxIndex(long[] from)
public static int maxIndex(float[] from)
public static int minIndex(int[] from)
public static int minIndex(float[] from)
public static double maxValue(double[] from)
public static float maxValue(float[] from)
public static float maxValue(float[] from,
int start,
int end)
public static double minValue(double[] from)
public static float minValue(float[] from)
public static long maxValue(long[] from)
public static long minValue(long[] from)
public static boolean equalsWithinOneSmallUlp(float a,
float b)
a - First numberb - Second numberpublic static boolean equalsWithinOneSmallUlp(double a,
double b)
public static boolean compareDoubles(double a,
double b)
public static double lnF(double what)
public static String p2d(double d)
public static String p5d(double d)
public static int set4(byte[] buf,
int off,
int x)
public static int get4(byte[] buf,
int off)
public static int set8d(byte[] buf,
int off,
double d)
public static double get8d(byte[] buf,
int off)
public static long sum(long[] from)
public static int sum(int[] from)
public static float sum(float[] from)
public static double sum(double[] from)
public static float sumSquares(float[] a)
public static float approxSumSquares(float[] a,
int from,
int to)
a - Array with numbersfrom - starting index (inclusive)to - ending index (exclusive)public static float sumSquares(float[] a,
int from,
int to)
public static String sampleToString(int[] val, int max)
public static String sampleToString(double[] val, int max)
public static Random getDeterRNG(long seed)
public static void setUsedRNGKind(H2ORandomRNG.RNGKind kind)
public static Random getRNG(long... seed)
public static void setUsedRNGType(H2ORandomRNG.RNGType rngType)
public static H2ORandomRNG.RNGType getUsedRNGType()
public static H2ORandomRNG.RNGKind getUsedRNGKind()
public static float entropy(byte[] f)
public static int[] unpackInts(long... longs)
public static void shuffleArray(long[] a,
long seed)
public static int[] shuffleArray(int[] a,
int n,
int[] result,
long seed,
int startIndex)
a - input arrayn - number of elements to extractresult - array to store the results into (will be of size n)seed - random number seedstartIndex - offset into apublic static void close(Closeable... closeable)
public static void close(Socket s)
public static String readConsole()
public static void writeFileAndClose(File file, InputStream in)
public static void readFile(File file, OutputStream out)
public static byte[] or(byte[] a,
byte[] b)
public static int[] or(int[] a,
int[] b)
public static byte[] add(byte[] a,
byte[] b)
public static byte[][] add(byte[][] a,
byte[][] b)
public static byte[][][] add(byte[][][] a,
byte[][][] b)
public static int[] add(int[] a,
int[] b)
public static int[][] add(int[][] a,
int[][] b)
public static int[][][] add(int[][][] a,
int[][][] b)
public static long[] add(long[] a,
long[] b)
public static long[][] add(long[][] a,
long[][] b)
public static long[][][] add(long[][][] a,
long[][][] b)
public static float[] add(float[] a,
float[] b)
public static float[][] add(float[][] a,
float[][] b)
public static float[][][] add(float[][][] a,
float[][][] b)
public static double[] add(double[] a,
double[] b)
public static double[][] add(double[][] a,
double[][] b)
public static double[][][] add(double[][][] a,
double[][][] b)
public static double[][] append(double[][] a,
double[][] b)
public static int[] append(int[] a,
int[] b)
public static double[] append(double[] a,
double e)
public static double[] append(double[] a,
double[] e)
public static long[][][] append(long[][][] a,
long[][] e)
public static <T> T[] append(T[] a,
T... b)
public static <T> T[] remove(T[] a,
int i)
public static int[] remove(int[] a,
int i)
public static <T> T[] subarray(T[] a,
int off,
int len)
public static void clearFolder(String folder)
public static void clearFolder(File folder)
public static File tmp()
public static byte[] getFirstUnzipedBytes(Key k)
public static byte[] getFirstUnzipedBytes(Value v)
public static ParseDataset2.Compression guessCompressionMethod(byte[] bits)
public static byte[] unzipBytes(byte[] bs,
ParseDataset2.Compression cmp)
public static String formatPct(double pct)
public static int maxValue(byte[] from)
public static final boolean hasNaNsOrInfs(double[] arr)
public static int[] mapping(int[] dom)
public static String[] toString(long[] dom)
public static String[] toString(int[] dom)
public static String[] toStringMap(int first, int last)
public static int[] compose(int[] first,
int[] transf)
public static int[][] compose(int[][] first,
int[][] second)
public static String pprint(double[][] arr)
public static String pprint(double[][] arr, DecimalFormat dformat)
public static boolean isEmpty(int[] a)
public static boolean contains(int[] a,
int d)
public static int[] difference(int[] a,
int[] b)
public static int[] seq(int start,
int stop)
public static double avg(double[] nums)
public static double avg(long[] nums)
public static float[] div(float[] nums,
int n)
public static float[] div(float[] nums,
float n)
public static double[] div(double[] nums,
double n)
public static float[] mult(float[] nums,
float n)
public static double[] mult(double[] nums,
double n)
public static final double approxSqrt(double x)
x - public static final float approxSqrt(float x)
x - public static final double approxInvSqrt(double x)
x - public static final float approxInvSqrt(float x)
x - public static final double approxExp(double x)
x - public static final double approxLog(double x)
x - public static StringBuilder replace(StringBuilder sb, CharSequence from, CharSequence to)
sb - string builder containing a string to be modifiedfrom - characters to replacedto - replacement characterspublic static boolean contains(String s, CharSequence cs)
s - stringcs - a sequence of characterpublic static String escapeJava(String s)
public static String[] domainUnion(String[] a, String[] b)
a - a set of stringsb - a set of stringspublic static String[] union(String[] a, String[] b, boolean lexo)
a - first arrayb - second arraylexo - - true if domains are sorted in lexicographical order or false for numeric domainspublic static String[] union(String[] a, String[] b, int aoff, int alen, int boff, int blen, boolean lexo)
public static int[] union(int[] a,
int[] b)
public static <T> T[] join(T[] a,
T[] b)
public static float[] join(float[] a,
float[] b)
public static double[] join(double[] a,
double[] b)
public static int numInts(String... a)
public static boolean isInt(String s)
public static int[] toInt(String[] a, int off, int len)
public static int[] filter(int[] values,
boolean[] filter,
int fcnt)
public static int[][] pack(int[] values,
boolean[] usemap)
public static int getPoisson(double lambda,
Random rng)
lambda - Lambda parameterpublic static float[] sortAccording(float[] ary,
Integer[] sortOrder)
public static int[] sortAccording(int[] ary,
Integer[] sortOrder)
public static void sortWith(int[] ary,
int[] ary2)
public static void sortAccording2(int[] ary,
Integer[] sortOrder)
public static void sortAccording2(boolean[] ary,
Integer[] sortOrder)
public static String[] createConfusionMatrixHeader(long[] xs, String[] ds)
public static void printConfusionMatrix(StringBuilder sb, long[][] cm, String[] domain, boolean html)
public static final int[] partitione(int len,
float[] ratio)
len - number to be split into partitionsratio - split ratio of each partitionpublic static final long[] partitione(long len,
float[] ratio)
public static final long[] nfold(long nrows,
int nfolds,
int i)
i-th fold from nfolds.nrows - number of rowsnfolds - number of foldsi - fold which is intended to be computedi-th fold.public static Key[] generateNumKeys(Key mk, int num)
public static boolean isSorted(int[] ids)
public static double[] asDoubles(Vec v)
public static int[] asInts(Vec v)
Copyright © 2013–2014 0xdata. All rights reserved.