|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectutils.Utils
public class Utils
| Field Summary | |
|---|---|
static boolean |
DEBUG
|
| Constructor Summary | |
|---|---|
Utils()
|
|
| Method Summary | ||
|---|---|---|
static double[] |
_column(double[][] source,
int column)
Returns the specified column from the given table. |
|
static double[] |
aabs(double[] src)
Returns an array of absolute values |
|
static double[] |
adiff(double[] src)
Given an array a, returns an array containing the differences between successive array elements (b[0] = a[1]-a[0], b[i] = a[i+1]-a[i]). |
|
static double[] |
alog10(double[] src)
Computes the log10 of the given array |
|
static double |
amax(double[] src)
Returns the largest element in the array |
|
static double |
amax(double[][] src,
int column)
Returns the largest element in table for the specified column |
|
static int |
amaxi(double[] src)
Returns the index of the largest item within the array. |
|
static int |
amaxi(double[][] src,
int col)
Returns the index of the largest item within the table for column col. |
|
static double |
amin(double[] src)
Returns the smallest item of the array |
|
static double |
amin(double[][] src,
int column)
Returns the smallest item of the table for the specified column |
|
static int |
amini(double[] src)
Returns the index of the smallest item within the array. |
|
static int |
amini(double[][] src,
int col)
Returns the index of the smallest item within the table for column col. |
|
static double[][] |
append_right(double[][] arr1,
double[] arr2)
|
|
static double[][] |
append(double[][] arr1,
double[] arr2)
|
|
static double[][] |
append(double[][] arr1,
double[][] arr2)
|
|
static double[] |
append(double[] arr1,
double[] arr2)
|
|
static java.lang.String[] |
append(java.lang.String[] arr,
java.lang.String el)
|
|
static double[] |
apply(double[] data,
java.lang.String operation)
|
|
static double[][] |
applySort(double[][] arr,
java.lang.Integer[] indices)
|
|
static double[] |
applySort(double[] arr,
java.lang.Integer[] indices)
|
|
static int[][] |
applySort(int[][] arr,
java.lang.Integer[] indices)
|
|
static java.lang.Object[] |
applySort(java.lang.Object[] arr,
java.lang.Integer[] indices)
|
|
static java.lang.String[] |
applySort(java.lang.String[] arr,
java.lang.Integer[] indices)
|
|
static double[] |
array(double v,
int length)
Creates a new array of the specified length and fills it with the specified double value. |
|
static double[][] |
bin_nn(double[] data,
java.lang.Double min,
java.lang.Double max,
int bins,
double[][] binv2,
double[] info)
|
|
static double[][] |
bin(double[] data,
java.lang.Double min,
java.lang.Double max,
int bins,
double[][] binv2,
double[] info)
Bins an array between the min and max values, for the given number of bins. |
|
static int[] |
booleanToIntArray(boolean[] source)
Converts a boolean array to an int array. |
|
static int[][] |
booleanToIntArray(boolean[][] source)
Converts a boolean table to an int table (true -> 1, false -> 0) |
|
static double[][] |
bootstrapCreateGaussianDeviates(double[][] data,
double dev)
|
|
static double[][] |
bootstrapDataSet(double[][] data)
|
|
static double[][] |
bootstrapDataSetAroundMean(double[][] data)
|
|
static double[][] |
bootstrapDataSetByScrambling(double[][] data)
|
|
static boolean |
checkOptions(java.lang.Object[] list,
java.lang.Object... tagsAndClasses)
|
|
static void |
column(boolean[][] dest,
boolean[] subst,
int column)
Substitutes the specified column in the dest table with the subst array. |
|
static void |
column(boolean[][] dest,
boolean subst,
int column)
Fills the specified column in the dest table with the subst value. |
|
static boolean[] |
column(boolean[][] source,
int column)
Returns the given column of the table. |
|
static void |
column(double[][] dest,
double[] subst,
int column)
Substitutes the specified column in the dest table with the subst array. |
|
static void |
column(double[][] dest,
double subst,
int column)
Fills the specified column in the dest table with the value subst. |
|
static double[] |
column(double[][] source,
int column)
Returns the specified column from the given table. |
|
static java.lang.String |
concat(java.util.List<java.lang.String> what,
java.lang.String sep)
|
|
static boolean[] |
copy(boolean[] vo)
Returns a copy of the specified array. |
|
static boolean[][] |
copy(boolean[][] source)
Returns a copy of the boolean table source. |
|
static void |
copy(boolean[][] source,
boolean[][] dest)
Copies the table source into the table dest. |
|
static javax.swing.table.DefaultTableModel |
copy(javax.swing.table.DefaultTableModel source)
|
|
static double[] |
copy(double[] source)
Returns a copy of the double array source. |
|
static double[][] |
copy(double[][] source)
Returns a copy of the table source. |
|
static void |
copy(double[][] source,
double[][] dest)
Copies a source array into the destination array. |
|
static void |
copy(double[][] source,
double[] dest,
int column)
Copies the specified column of the table source into the dest array. |
|
static void |
copy(double[] source,
double[] dest)
Copies a source array into the destination array. |
|
static int[] |
copy(int[] source)
Returns a copy of the specified array. |
|
static int[][] |
copy(int[][] source)
Returns a copy of the source table. |
|
static void |
copy(int[][] source,
int[][] dest)
Copies the table source into the table dest. |
|
static void |
copy(int[] source,
int[] dest)
Copies a source array into the destination array. |
|
static java.lang.String[] |
copy(java.lang.String[] source)
Returns a copy of the String array source. |
|
static void |
copy(java.lang.String[] source,
java.lang.String[] dest)
Copies a source array into the destination array. |
|
static GenericList |
copyGLAsDoubleArray(GenericList list)
|
|
static GenericList |
copyGLAsString(GenericList list)
|
|
static double[][] |
cumsum(double[][] data,
int col)
|
|
static double[] |
deleteIndex(double[] arr,
int index)
|
|
static
|
deleteIndex(T[] arr,
int index)
|
|
static void |
dprint(double str)
|
|
static void |
dprint(int str)
|
|
static void |
dprint(java.lang.String str)
|
|
static void |
dprintln()
|
|
static void |
dprintln(double str)
|
|
static void |
dprintln(int str)
|
|
static void |
dprintln(java.lang.String str)
|
|
static void |
eadd(double[] result,
double[] a,
double[] b)
|
|
static void |
ediv(double[] result,
double[] a,
double b)
|
|
static void |
ediv(double[] result,
double[] a,
double[] b)
Divides the two arrays. |
|
static void |
emul(double[][] result,
double[][] a,
int column,
double b)
|
|
static void |
emul(double[] result,
double[] a,
double b)
|
|
static void |
emul(double[] result,
double[] a,
double[] b)
Multiplies the two arrays. |
|
static boolean |
equals(double d1,
double d2,
double tolerance)
|
|
static double[] |
esub(double[] a,
double b)
|
|
static double[] |
esub(double[] a,
double[] b)
|
|
static void |
esub(double[] result,
double[] a,
double b)
|
|
static void |
esub(double[] result,
double[] a,
double[] b)
|
|
static void |
fill(boolean[][] m,
boolean v)
Fills a table with the value v. |
|
static void |
fill(boolean[][] m,
boolean v,
int column)
Fills the specified column of the table with the value v. |
|
static void |
fill(boolean[] m,
boolean v)
Fills an array with the value v (equivalent to Array.fill). |
|
static void |
fill(double[][] m,
double v)
Fills a table with the value v. |
|
static void |
fill(double[][] m,
double[] v,
int column)
Fills the specified column of the table with the given array. |
|
static void |
fill(double[][] m,
double v,
int column)
Fills the specified column of the table with the value v. |
|
static void |
fill(double[] m,
double v)
Fills an array with the value v (equivalent to Array.fill). |
|
static void |
fill(int[][] m,
int v)
Fills the table with the value v. |
|
static void |
fill(int[][] m,
int v,
int column)
Fills the table with the value v. |
|
static void |
fill(int[] m,
int v)
Fills an array with the value v (equivalent to Array.fill). |
|
static void |
fill(java.lang.Object[] m,
java.lang.Object v)
Fills an array with the value v (equivalent to Array.fill). |
|
static double[] |
findContainingEllipse(double[] data1,
double[] data2,
double perc,
boolean isAngle1,
boolean isAngle2,
int averageType)
|
|
static boolean[] |
flatten(boolean[][] source)
"Flattens" a table into an array (each row is appended to make an array). |
|
static double[] |
flatten(double[][] source)
"Flattens" a table into an array (each row is appended to make an array). |
|
static
|
indexOf(T[] array,
T item)
Searches the array for the specified item and returns its index within the array, or -1. |
|
static double[][] |
insert(double[][] arr1,
double[] arr2,
int idx)
|
|
static boolean[] |
intToBooleanArray(int[] source)
Converts an int array to a boolean array. |
|
static boolean[][] |
intToBooleanArray(int[][] source)
Converts an int table to a boolean table. |
|
static boolean |
isNumeric(java.lang.String num)
|
|
static double[] |
linspace(double a,
double b,
int len)
Returns an array of length len with elements equally spaced between a and b. |
|
static double[] |
numbers(java.lang.String line)
Returns an array containing all the numbers in the input string. |
|
static java.io.PrintStream |
openFile(java.lang.String fn,
boolean append)
|
|
static java.lang.Boolean |
parseOptions(java.lang.Object[] list,
java.lang.String tag,
boolean defaultValue)
|
|
static double |
parseOptions(java.lang.Object[] list,
java.lang.String tag,
double defaultValue)
|
|
static int |
parseOptions(java.lang.Object[] list,
java.lang.String tag,
int defaultValue)
|
|
static java.lang.Object |
parseOptions(java.lang.Object[] list,
java.lang.String tag,
java.lang.Object defaultValue)
|
|
static void |
printTable(java.io.PrintStream out,
double[][] table,
java.lang.String fmt)
|
|
static void |
printTable(java.io.PrintStream out,
double[] table,
java.lang.String fmt)
|
|
static void |
printTable(java.io.PrintStream out,
int[][] table,
java.lang.String fmt)
|
|
static void |
printTable(java.lang.String fn,
double[][] table,
java.lang.String fmt)
|
|
static void |
printTable(java.lang.String fn,
double[] table,
java.lang.String fmt)
|
|
static double[][] |
readTable(java.lang.String fn)
|
|
static double[][] |
reshape(double[] src,
int rows,
int columns)
Reshapes a table. |
|
static double[] |
resize(double[] source,
int size)
Resizes an array to a new size. |
|
static int |
rndIntRange(int r1,
int r2)
|
|
static double |
rndLogRange(double r1,
double r2)
Returns a number between r1 and r2, uniformly distributed in log. |
|
static double |
rndRange(double r1,
double r2)
Returns a number between r1 and r2, uniformly distributed. |
|
static double[][] |
sampleDataSet(double[][] dataset,
int length)
|
|
static void |
saveData(double[][] src,
java.lang.String fn)
Saves a table to a file, using the default format (%15.8f). |
|
static void |
saveData(double[] src,
java.lang.String fn)
Saves an array to a file, using the default format (%15.8f). |
|
static void |
saveData(java.util.List<double[]> src,
java.lang.String fn)
Saves a list of double arrays to a file, using the default format (%15.8f). |
|
static void |
shellSort(double[][] arr,
double[][] arrcp,
int col,
int startRow,
int endRow)
|
|
static void |
shellSort(double[][] arr,
int col)
|
|
static void |
shellSort(double[][] arr,
int col,
boolean descending)
|
|
static void |
shellSort(double[][] arr,
int col,
int startRow,
int endRow)
|
|
static void |
shellSort(double[][] arr,
int col,
int startRow,
int endRow,
boolean descending)
|
|
static void |
shellSort2(double[][] arr,
int col,
int startRow,
int endRow,
boolean descending)
|
|
static double[] |
shuffle(double[] array)
|
|
static double[][] |
shuffle(double[][] array)
|
|
static double[][] |
slice(double[][] array,
int from,
int count)
Returns a slice of the specified table (all rows between from and from + count) |
|
static double[] |
slice(double[] array,
int from,
int count)
Returns an array containing count elements from from (inclusive). |
|
static java.lang.Integer[] |
sort(double[][] arr,
int col,
boolean ascending)
|
|
static java.lang.Integer[] |
sort(double[] arr,
boolean ascending)
|
|
static double |
span(double[] array)
Returns the span of the array (max(array) - min(array)) |
|
static double |
span(double[][] table,
int column)
Returns the span of the table (max(array) - min(array)) for the given column |
|
static java.lang.Double |
stringToDouble(java.lang.String v,
java.lang.Double def)
Converts a string to a double number. |
|
static double |
sum(double[] data)
|
|
static double[][] |
table(java.lang.String source)
Attempts parsing a string into a numeric table. |
|
static double[] |
toArray(java.util.List<java.lang.Double> arr)
|
|
static double[][] |
toMatrix(java.util.List<double[]> arr)
|
|
static double |
valueOf(java.lang.String s,
double defaultn)
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static boolean DEBUG
| Constructor Detail |
|---|
public Utils()
| Method Detail |
|---|
public static <T> int indexOf(T[] array,
T item)
array - Array to searchitem - Item to search
public static void dprintln(java.lang.String str)
str - public static void dprintln(double str)
str - public static void dprintln(int str)
str - public static void dprintln()
public static void dprint(java.lang.String str)
str - public static void dprint(double str)
str - public static void dprint(int str)
str -
public static double[] resize(double[] source,
int size)
source - Arraysize - New length of the array
public static final void copy(int[] source,
int[] dest)
source - dest - public static final int[] copy(int[] source)
source -
public static final boolean[] copy(boolean[] vo)
vo -
public static final void copy(double[] source,
double[] dest)
source - dest -
public static final void copy(java.lang.String[] source,
java.lang.String[] dest)
source - dest -
public static final void copy(double[][] source,
double[][] dest)
source - dest - public static int amini(double[] src)
src -
public static int amaxi(double[] src)
src -
public static int amini(double[][] src,
int col)
src - col -
public static int amaxi(double[][] src,
int col)
src - col -
public static double[] linspace(double a,
double b,
int len)
a - b - len -
public static boolean checkOptions(java.lang.Object[] list,
java.lang.Object... tagsAndClasses)
list - tagsAndClasses -
public static java.lang.Object parseOptions(java.lang.Object[] list,
java.lang.String tag,
java.lang.Object defaultValue)
list - tag - defaultValue -
public static double parseOptions(java.lang.Object[] list,
java.lang.String tag,
double defaultValue)
list - tag - defaultValue -
public static int parseOptions(java.lang.Object[] list,
java.lang.String tag,
int defaultValue)
list - tag - defaultValue -
public static java.lang.Boolean parseOptions(java.lang.Object[] list,
java.lang.String tag,
boolean defaultValue)
list - tag - defaultValue -
public static double[] slice(double[] array,
int from,
int count)
array - Array to slicefrom - First indexcount - Slice size
public static double[][] slice(double[][] array,
int from,
int count)
array - from - count -
public static double span(double[] array)
array -
public static double span(double[][] table,
int column)
table - column -
public static double amin(double[] src)
src -
public static double amin(double[][] src,
int column)
src - column -
public static double[] adiff(double[] src)
src - The input array
public static double amax(double[] src)
src -
public static double amax(double[][] src,
int column)
src - column -
public static double[] aabs(double[] src)
src -
public static double[] alog10(double[] src)
src -
public static javax.swing.table.DefaultTableModel copy(javax.swing.table.DefaultTableModel source)
source -
public static GenericList copyGLAsDoubleArray(GenericList list)
list -
public static GenericList copyGLAsString(GenericList list)
list -
public static boolean[][] intToBooleanArray(int[][] source)
source -
public static java.lang.Double stringToDouble(java.lang.String v,
java.lang.Double def)
v - def -
public static int[][] booleanToIntArray(boolean[][] source)
source -
public static boolean[] intToBooleanArray(int[] source)
source -
public static int[] booleanToIntArray(boolean[] source)
source -
public static void saveData(double[][] src,
java.lang.String fn)
throws java.io.FileNotFoundException
src - Numeric tablefn - File name
java.io.FileNotFoundException
public static void saveData(java.util.List<double[]> src,
java.lang.String fn)
throws java.io.FileNotFoundException
src - fn -
java.io.FileNotFoundException
public static void saveData(double[] src,
java.lang.String fn)
throws java.io.FileNotFoundException
src - fn -
java.io.FileNotFoundException
public static final double[] array(double v,
int length)
v - Default value for array elementslength - Length of the array
public static final double[] findContainingEllipse(double[] data1,
double[] data2,
double perc,
boolean isAngle1,
boolean isAngle2,
int averageType)
data1 - data2 - perc - isAngle1 - isAngle2 - averageType -
public static final void copy(int[][] source,
int[][] dest)
source - dest - public static final int[][] copy(int[][] source)
source -
public static final void copy(boolean[][] source,
boolean[][] dest)
source - dest -
public static final void copy(double[][] source,
double[] dest,
int column)
source - dest - column - public static final double[][] copy(double[][] source)
source -
public static final double[] copy(double[] source)
source -
public static final java.lang.String[] copy(java.lang.String[] source)
source -
public static final boolean[][] copy(boolean[][] source)
source -
public static double[][] table(java.lang.String source)
source -
public static double[] numbers(java.lang.String line)
line -
public static double[] column(double[][] source,
int column)
source - column -
public static double[] _column(double[][] source,
int column)
source - column -
public static void column(double[][] dest,
double[] subst,
int column)
dest - subst - column -
public static void column(double[][] dest,
double subst,
int column)
dest - subst - column -
public static boolean[] column(boolean[][] source,
int column)
source - column -
public static void column(boolean[][] dest,
boolean[] subst,
int column)
dest - subst - column -
public static void column(boolean[][] dest,
boolean subst,
int column)
dest - subst - column -
public static double[][] reshape(double[] src,
int rows,
int columns)
src - rows - columns -
public static void emul(double[] result,
double[] a,
double[] b)
result - a - b -
public static void ediv(double[] result,
double[] a,
double[] b)
result - a - b -
public static void emul(double[] result,
double[] a,
double b)
result - a - b -
public static void emul(double[][] result,
double[][] a,
int column,
double b)
result - a - column - b -
public static void ediv(double[] result,
double[] a,
double b)
result - a - b -
public static void eadd(double[] result,
double[] a,
double[] b)
result - a - b -
public static final void esub(double[] result,
double[] a,
double[] b)
result - a - b -
public static final void esub(double[] result,
double[] a,
double b)
result - a - b -
public static final double[] esub(double[] a,
double[] b)
a - b -
public static final double[] esub(double[] a,
double b)
a - b -
public static final double[] flatten(double[][] source)
source -
public static boolean[] flatten(boolean[][] source)
source -
public static void fill(double[][] m,
double v)
m - v -
public static void fill(double[] m,
double v)
m - v -
public static void fill(boolean[] m,
boolean v)
m - v -
public static void fill(int[] m,
int v)
m - v -
public static void fill(java.lang.Object[] m,
java.lang.Object v)
m - v -
public static void fill(boolean[][] m,
boolean v)
m - v -
public static void fill(double[][] m,
double v,
int column)
m - v - column -
public static void fill(boolean[][] m,
boolean v,
int column)
m - v - column -
public static void fill(double[][] m,
double[] v,
int column)
m - v - column -
public static double rndRange(double r1,
double r2)
r1 - r2 -
public static int rndIntRange(int r1,
int r2)
public static double rndLogRange(double r1,
double r2)
r1 - r2 -
public static double[] apply(double[] data,
java.lang.String operation)
data - operation -
public static void fill(int[][] m,
int v)
m - v -
public static void fill(int[][] m,
int v,
int column)
m - v - column -
public static double[][] bin(double[] data,
java.lang.Double min,
java.lang.Double max,
int bins,
double[][] binv2,
double[] info)
data - Input data.min - Minimum value of the bin (can be null to use the minimum value of the data)max - Maximum value of the bin (can be null to use the maximum value of the data)bins - Number of binsbinv2 - info -
public static double[][] cumsum(double[][] data,
int col)
data - col -
public static double sum(double[] data)
data -
public static boolean isNumeric(java.lang.String num)
num -
public static double[][] bin_nn(double[] data,
java.lang.Double min,
java.lang.Double max,
int bins,
double[][] binv2,
double[] info)
data - min - max - bins - binv2 - info -
public static java.lang.String[] append(java.lang.String[] arr,
java.lang.String el)
arr - el -
public static <T> T[] deleteIndex(T[] arr,
int index)
public static double[] deleteIndex(double[] arr,
int index)
public static double valueOf(java.lang.String s,
double defaultn)
s - defaultn -
public static double[][] append(double[][] arr1,
double[][] arr2)
arr1 - arr2 -
public static double[][] append(double[][] arr1,
double[] arr2)
arr1 - arr2 -
public static double[][] append_right(double[][] arr1,
double[] arr2)
arr1 - arr2 -
public static double[] append(double[] arr1,
double[] arr2)
arr1 - arr2 -
public static final double[][] insert(double[][] arr1,
double[] arr2,
int idx)
arr1 - arr2 - idx -
public static double[][] toMatrix(java.util.List<double[]> arr)
arr -
public static double[] toArray(java.util.List<java.lang.Double> arr)
arr -
public static java.lang.String concat(java.util.List<java.lang.String> what,
java.lang.String sep)
what - sep -
public static final void shellSort(double[][] arr,
double[][] arrcp,
int col,
int startRow,
int endRow)
arr - arrcp - col - startRow - endRow -
public static void shellSort(double[][] arr,
int col,
int startRow,
int endRow)
arr - col - startRow - endRow -
public static void shellSort(double[][] arr,
int col)
arr - col - startRow - endRow -
public static void shellSort(double[][] arr,
int col,
boolean descending)
public static void shellSort2(double[][] arr,
int col,
int startRow,
int endRow,
boolean descending)
arr - col - startRow - endRow - descending -
public static final void shellSort(double[][] arr,
int col,
int startRow,
int endRow,
boolean descending)
arr - col - startRow - endRow - descending -
public static java.lang.Integer[] sort(double[][] arr,
int col,
boolean ascending)
arr - col - ascending -
public static java.lang.Integer[] sort(double[] arr,
boolean ascending)
arr - col - ascending -
public static double[][] applySort(double[][] arr,
java.lang.Integer[] indices)
arr - indices -
public static double[] applySort(double[] arr,
java.lang.Integer[] indices)
arr - indices -
public static int[][] applySort(int[][] arr,
java.lang.Integer[] indices)
arr - indices -
public static java.lang.String[] applySort(java.lang.String[] arr,
java.lang.Integer[] indices)
arr - indices -
public static java.lang.Object[] applySort(java.lang.Object[] arr,
java.lang.Integer[] indices)
arr - indices -
public static void printTable(java.io.PrintStream out,
int[][] table,
java.lang.String fmt)
out - table - fmt -
public static void printTable(java.io.PrintStream out,
double[][] table,
java.lang.String fmt)
out - table - fmt -
public static void printTable(java.lang.String fn,
double[][] table,
java.lang.String fmt)
public static void printTable(java.lang.String fn,
double[] table,
java.lang.String fmt)
public static void printTable(java.io.PrintStream out,
double[] table,
java.lang.String fmt)
out - table - fmt -
public static java.io.PrintStream openFile(java.lang.String fn,
boolean append)
public static boolean equals(double d1,
double d2,
double tolerance)
d1 - d2 - tolerance -
public static double[][] bootstrapDataSet(double[][] data)
data -
public static double[][] bootstrapDataSetAroundMean(double[][] data)
data -
public static double[][] bootstrapDataSetByScrambling(double[][] data)
data -
public static double[][] bootstrapCreateGaussianDeviates(double[][] data,
double dev)
data - dev -
public static double[] shuffle(double[] array)
public static double[][] shuffle(double[][] array)
public static double[][] sampleDataSet(double[][] dataset,
int length)
public static double[][] readTable(java.lang.String fn)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||