public class Arrays2 extends Object
Modifier and Type | Method and Description |
---|---|
static void |
abs(byte[] data)
turns all values of the array to their absolute values
|
static void |
abs(double[] data)
turns all values of the array to their absolute values
|
static void |
abs(float[] data)
turns all values of the array to their absolute values
|
static void |
abs(int[] data)
turns all values of the array to their absolute values
|
static void |
abs(short[] data)
turns all values of the array to their absolute values
|
static void |
add(byte[] a,
byte b)
adds b to a: a[i] += b
|
static void |
add(byte[] a,
byte[] b)
adds b to a: a[i] += b[i]
Values of b won't be changed.
|
static void |
add(double[] a,
double b)
adds b to a: a[i] += b
|
static void |
add(double[] a,
double[] b)
adds b to a: a[i] += b[i]
Values of b won't be changed
|
static void |
add(float[] a,
double b)
adds b to a: a[i] += b
|
static void |
add(float[] a,
float[] b)
adds b to a: a[i] += b[i]
Values of b won't be changed
|
static void |
add(int[] a,
double b)
adds b to a: a[i] += b
|
static void |
add(int[] a,
int[] b)
adds b to a: a[i] += b[i]
Values of b won't be changed
|
static double[] |
append(byte[] a,
byte... b)
appends two arrays and returns the concatenation
|
static double[] |
append(double[] a,
double... b)
appends two arrays and returns the concatenation
|
static float[] |
append(float[] a,
float... b)
appends two arrays and returns the concatenation
|
static int[] |
append(int[] a,
int... b)
appends two arrays and returns the concatenation
|
static boolean |
contains(Object[] arr,
Object o)
checks whether an object o is contained in arr
|
static double[] |
convertToDouble(byte[] in) |
static double[] |
convertToDouble(float[] in) |
static double[] |
convertToDouble(int[] in) |
static double[] |
convertToDouble(short[] in) |
static double[] |
convertToDouble(String[] src)
Convert string array to doubles - replaces all non numerics with a NaN and throws a warning message to
the logger
|
static double[] |
convertToDouble(String[] src,
double[] dst) |
static float[] |
convertToFloat(byte[] in) |
static float[] |
convertToFloat(double[] in) |
static float[] |
convertToFloat(int[] in) |
static float[] |
convertToFloat(String[] src)
Convert string array to doubles - replaces all non numerics with a NaN and throws a warning message to
the logger
|
static float[] |
convertToFloat(String[] src,
float[] dst) |
static int[] |
convertToInt(byte[] in) |
static int[] |
convertToInt(double[] in) |
static int[] |
convertToInt(float[] in) |
static int[] |
convertToInt(String[] src)
Convert string array to doubles - replaces all non numerics with a 0 and throws a warning message to
the logger
|
static int[] |
convertToInt(String[] src,
int[] dst) |
static double[] |
convolve(double[] in,
double[] out,
double[] kernel)
convolve an array with the specified kernel and write output into out
|
static float[] |
convolve(float[] in,
float[] out,
double[] kernel)
convolve n array with the specified kernel and write output into out
|
static int[] |
convolve(int[] in,
int[] out,
double[] kernel)
convolve an array with the specified kernel and write output into out
|
static void |
div(double[] data,
double factor)
divide array by a given value: data[i] /= factor
|
static void |
div(double[] data,
double[] factors)
divide array with values from other array: data[i] /= factors[i]
|
static void |
div(float[] data,
float factor)
divide array by a given value: data[i] /= factor
|
static void |
div(float[] data,
float[] factors)
divide array with values from other array: data[i] /= factors[i]
|
static double[] |
div(int[] data,
double factor,
double[] target)
divide an int array by a given value and write the result into a double array: target[i] = 1d * data[i]
/ factor;
|
static int |
findNaN(double[] in)
Finds the first NaN value in the given array.
|
static int |
indexOf(int[] src,
int o)
return first index of integer o in array a or -1 if the integer was not found
|
static int |
indexOf(Object[] src,
Object o)
return first index of Object o in array a or -1 if the object was not found
|
static String |
join(byte[] data,
String glue) |
static String |
join(double[] data,
String glue) |
static String |
join(double[] data,
String glue,
String formatString)
Join array of objects by using a glue string and the Object's toString methods.
|
static String |
join(double[] data,
String glue,
String formatString,
Locale locale)
Join array of objects by using a glue string and the Object's toString methods.
|
static String |
join(float[] data,
String glue) |
static String |
join(float[] data,
String glue,
int dec) |
static String |
join(int[] data,
Character glue) |
static String |
join(int[] data,
String glue) |
static String |
join(long[] arr,
Character glue)
join array of objects by using a glue string and a formatter object
|
static String |
join(long[] arr,
String glue)
join array of objects by using a glue string and a formatter object
|
static String |
join(long[] arr,
String glue,
Format f)
join array of objects by using a glue string and a formatter object
|
static String |
join(Object[] arr,
Character glue)
join array of objects by using a glue string and the Object's toString methods.
|
static String |
join(Object[] arr,
String glue)
join array of objects by using a glue string and the Object's toString methods.
|
static String |
join(Object[] arr,
String glue,
Format f)
join array of objects by using a glue string and a formatter object
|
static int |
max(byte[] a)
Deprecated.
since 2.5.0 due to danger of confusion with maxValue()
|
static int |
max(double[] a)
Deprecated.
since 2.5.0 due to danger of confusion with maxValue()
|
static int |
max(float[] a)
Deprecated.
since 2.5.0 due to danger of confusion with maxValue()
|
static int |
max(int[] a)
Deprecated.
since 2.5.0 due to danger of confusion with maxValue()
|
static int |
maxIndex(byte[] a)
Find and return the INDEX with the greatest value.
|
static int |
maxIndex(double[] a)
Find and return the index with the greatest value.
|
static int |
maxIndex(float[] a)
Find and return the index with the greatest value.
|
static int |
maxIndex(int[] a)
Find and return the INDEX with the greatest value.
|
static double |
maxValue(byte... a)
returns the largest value
|
static double |
maxValue(double... a)
returns the greatest value
|
static double |
maxValue(float... a)
returns the largest value
|
static double |
maxValue(int... a)
returns the largest value
|
static int |
min(byte[] a)
Deprecated.
since 2.5.0
|
static int |
min(double[] a)
Deprecated.
since 2.5.0
|
static int |
min(float[] a)
Deprecated.
since 2.5.0
|
static int |
min(int[] a)
Deprecated.
since 2.5.0
|
static int |
minIndex(byte[] a)
Finds and returns the INDEX with the least value.
|
static int |
minIndex(double[] a)
Finds and returns the INDEX with the least value.
|
static int |
minIndex(float[] a)
Finds and returns the index with the least value.
|
static int |
minIndex(int[] a)
Finds and returns the index with the least value.
|
static double |
minValue(byte... a)
returns the smallest value
|
static double |
minValue(double... a)
returns the smallest value
|
static double |
minValue(float... a)
returns the smallest value
|
static double |
minValue(int... a)
returns the smallest value
|
static void |
mul(double[] data,
double factor)
multiply array with factor
|
static void |
mul(double[] data,
double[] factors)
multiply array with factors from other array: data[i] *= factors[i]
|
static void |
mul(float[] data,
float factor)
multiply array with factors from other array: data[i] *= factors[i]
|
static void |
mul(float[] data,
float[] factors)
multiply array with factors from other array: data[i] *= factors[i]
|
static void |
replaceNaN(double[] arr,
double r)
replaces all NaNs and Infs with r
|
static void |
reverse(byte[] o) |
static void |
reverse(double[] o) |
static void |
reverse(float[] o) |
static void |
reverse(int[] o) |
static void |
reverse(Object[] o) |
static void |
sub(byte[] a,
byte[] b)
Performs a[i] = (byte)(a[i]-b[i])
|
static void |
sub(double[] a,
double b)
subtracts b from each element in a: a[i] -= b
|
static void |
sub(double[] a,
double[] b)
Performs a[i] = a[i]-b[i]
|
static double[] |
sub(double[] a,
double[] b,
double[] out)
Performs out[i] = a[i]-b[i]
|
static void |
sub(float[] a,
float b)
subtracts b from each element in a: a[i] -= b
|
static void |
sub(float[] a,
float[] b)
Performs a[i] = a[i]-b[i]
|
static float[] |
sub(float[] a,
float[] b,
float[] out)
Performs out[i] = a[i]-b[i]
|
static void |
sub(int[] a,
double b)
subtracts b from each element in a: a[i] -= b
|
static int |
sum(byte[] a)
Returns the sum of all elements in this array
|
static double |
sum(double[] a)
Returns the sum of all elements in this array
|
static double |
sum(double[] arr,
int a,
int b)
Returns the sum of a subarray
|
static float |
sum(float[] a)
Returns the sum of all elements in this array
|
static double |
sum(float[] arr,
int a,
int b)
Returns the sum of a subarray
|
static double |
sum(int[] a)
Returns the sum of all elements in this array
|
static double |
sum(int[] arr,
int a,
int b)
Returns the sum of a subarray
|
static double[] |
unique(double[] arr)
Deprecated.
since 2.4.0, use Arrays2#unique(double[] arr, double accuracy instead)
|
static double[] |
unique(double[] arr,
double accuracy)
Returns a new Array with unique elements from the source array.
|
static int[] |
unique(int[] arr)
Returns a new array with unique elements from the source array.
|
static Object[] |
unique(Object[] arr)
Returns a new Array with unique elements from the source array.
|
public static void abs(byte[] data)
data
- input byte arraypublic static void abs(int[] data)
data
- input int arraypublic static void abs(float[] data)
data
- input float arraypublic static void abs(short[] data)
data
- input short arraypublic static void abs(double[] data)
data
- input double arraypublic static void reverse(Object[] o)
o
- array to be reversedpublic static void reverse(double[] o)
o
- array to be reversedpublic static void reverse(byte[] o)
o
- array to be reversedpublic static void reverse(int[] o)
o
- array to be reversedpublic static void reverse(float[] o)
o
- array to be reversedpublic static Object[] unique(Object[] arr)
arr
- array from which distinct elments will be removed@Deprecated public static double[] unique(double[] arr)
arr
- array from which distinct elments will be removedpublic static int[] unique(int[] arr)
arr
- array from which distinct elments will be removedpublic static double[] unique(double[] arr, double accuracy)
arr
- array from which distinct elments will be removedaccuracy
- defines the allowed distance up to which 2 doubles are equalpublic static String join(Object[] arr, String glue)
arr
- elements to be joinedglue
- separator which is put between elementspublic static String join(Object[] arr, String glue, Format f)
arr
- elements to be joinedglue
- separator which is put between elementsf
- String.format(java.lang.String, java.lang.Object...)
public static String join(Object[] arr, Character glue)
arr
- elements to be joinedglue
- separator which is put between elementsjoin(java.lang.Object[], java.lang.Character)
public static String join(long[] arr, String glue, Format f)
arr
- elements to be joinedglue
- separator which is put between elementsf
- String.format(java.lang.String, java.lang.Object...)
public static String join(long[] arr, String glue)
arr
- elements to be joinedglue
- separator which is put between elementspublic static String join(long[] arr, Character glue)
arr
- elements to be joinedglue
- separator which is put between elementspublic static int indexOf(Object[] src, Object o)
src
- source arrayo
- object to searchpublic static int indexOf(int[] src, int o)
src
- source arrayo
- object to searchpublic static String join(byte[] data, String glue)
data
- elements to be joinedglue
- separator which is put between elementsdata
separated by glue
join(java.lang.Object[], java.lang.String)
public static String join(int[] data, String glue)
data
- elements to be joinedglue
- separator which is put between elementsdata
separated by glue
join(java.lang.Object[], java.lang.String)
public static String join(float[] data, String glue, int dec)
data
- elements to be joinedglue
- separator which is put between elementsdec
- amount of decimals used in the output formatdata
separated by glue
, rounded to
the dec
th decimale placejoin(java.lang.Object[], java.lang.String)
public static String join(float[] data, String glue)
data
- elements to be joinedglue
- separator which is put between elementsdata
separated by glue
, rounded to
the dec
th decimale placejoin(java.lang.Object[], java.lang.String)
public static String join(double[] data, String glue)
data
- elements to be joinedglue
- separator which is put between elementsdata
separated by glue
join(java.lang.Object[], java.lang.String)
public static String join(double[] data, String glue, String formatString, Locale locale)
data
- elements to be joinedglue
- separator which is put between elementsformatString
- which formats a single element of the arraylocale
- Locale setting, may be null (defaults to US then)public static String join(double[] data, String glue, String formatString)
data
- elements to be joinedglue
- separator which is put between elementsformatString
- which formats a single element of the arraypublic static void mul(double[] data, double factor)
data
- source arrayfactor
- each elem will be multiplied withpublic static void mul(double[] data, double[] factors)
data
- source arrayfactors
- array of factors each data element will be multiplied withpublic static void mul(float[] data, float factor)
data
- source arrayfactor
- each elem will be multiplied withpublic static void mul(float[] data, float[] factors)
data
- source arrayfactors
- array of factors each data element will be multiplied withpublic static double[] div(int[] data, double factor, double[] target)
data
- source arrayfactor
- array of factors each data element will be multiplied withtarget
- the target array (may be null)public static void div(float[] data, float factor)
data
- source arrayfactor
- the divisor which is applied to all elements of the arraypublic static void div(float[] data, float[] factors)
data
- source arrayfactors
- array of divisorspublic static void div(double[] data, double factor)
data
- source arrayfactor
- the divisor which is applied to all elements of the arraypublic static void div(double[] data, double[] factors)
data
- source arrayfactors
- array of divisorspublic static void add(byte[] a, byte[] b)
a
- mutable array of summandsb
- immutable array of summands (added to a[i])public static void add(int[] a, int[] b)
a
- mutable array of summandsb
- immutable array of summands (added to a[i])public static void add(float[] a, float[] b)
a
- mutable array of summandsb
- immutable array of summands (added to a[i])public static void add(double[] a, double[] b)
a
- mutable array of summandsb
- immutable array of summands (added to a[i])public static void add(double[] a, double b)
a
- mutable array of summandsb
- value which is added to all elements of apublic static void add(byte[] a, byte b)
a
- mutable array of summandsb
- value which is added to all elements of apublic static void add(int[] a, double b)
a
- mutable array of summandsb
- value which is added to all elements of apublic static void add(float[] a, double b)
a
- mutable array of summandsb
- value which is added to all elements of apublic static double sum(double[] a)
a
- input arraypublic static double sum(int[] a)
a
- input arraypublic static float sum(float[] a)
a
- input arraypublic static int sum(byte[] a)
a
- input arraypublic static double sum(double[] arr, int a, int b)
arr
- the input arraya
- start index inclusiveb
- end index inclusivepublic static double sum(int[] arr, int a, int b)
arr
- the input arraya
- start index inclusiveb
- end index inclusivepublic static double sum(float[] arr, int a, int b)
arr
- the input arraya
- start index inclusiveb
- end index inclusivepublic static void sub(int[] a, double b)
a
- input arrayb
- term that is subtrackted from apublic static void sub(double[] a, double b)
a
- input arrayb
- term that is subtrackted from apublic static void sub(float[] a, float b)
a
- input arrayb
- term that is subtrackted from apublic static void sub(byte[] a, byte[] b)
a
- input array which is modifiedb
- array of elements that is not modifiedpublic static void sub(double[] a, double[] b)
a
- input array which is modifiedb
- array of elements that is not modifiedpublic static void sub(float[] a, float[] b)
a
- input array which is modifiedb
- array of elements that is not modifiedpublic static double[] sub(double[] a, double[] b, double[] out)
a
- immutable input arrayb
- immutable input arrayout
- array that will contain the outputpublic static float[] sub(float[] a, float[] b, float[] out)
a
- immutable input arrayb
- immutable input arrayout
- array that will contain the outputpublic static int[] convolve(int[] in, int[] out, double[] kernel)
in
- input array which will NOT be changedout
- output array with convolved valueskernel
- mask (odd size!)public static double[] convolve(double[] in, double[] out, double[] kernel)
in
- input array which will NOT be changedout
- output array with convolved values (may be null)kernel
- mask (odd size!)public static float[] convolve(float[] in, float[] out, double[] kernel)
in
- input array which will NOT be changedout
- output array with convolved valueskernel
- mask (odd size!)public static double[] append(byte[] a, byte... b)
a
- first array (may be null, defaults to empty array)b
- second array (may be null, defaults to empty array)public static double[] append(double[] a, double... b)
a
- first array (may be null, defaults to empty array)b
- second array (may be null, defaults to empty array)public static int[] append(int[] a, int... b)
a
- first array (may be null, defaults to empty array)b
- second array (may be null, defaults to empty array)public static float[] append(float[] a, float... b)
a
- first array (may be null, defaults to empty array)b
- second array (may be null, defaults to empty array)@Deprecated public static int max(double[] a)
a
- input arraymaxIndex(double[])
public static int maxIndex(double[] a)
a
- input arraypublic static double maxValue(double... a)
a
- input arrayIllegalArgumentException
- if array length is zeropublic static double maxValue(int... a)
a
- input arrayIllegalArgumentException
- if array length is zeropublic static double maxValue(byte... a)
a
- input arrayIllegalArgumentException
- if array length is zeropublic static double maxValue(float... a)
a
- input arrayIllegalArgumentException
- if array length is zeropublic static int max(int[] a)
a
- input arraymaxIndex(int[])
public static int maxIndex(int[] a)
a
- input arraypublic static int max(byte[] a)
a
- input arraymaxIndex(byte[])
public static int maxIndex(byte[] a)
a
- input arraypublic static int max(float[] a)
a
- input arraymaxIndex(float[])
public static int maxIndex(float[] a)
a
- input arraypublic static int min(byte[] a)
a
- input arraypublic static int min(double[] a)
a
- input arraypublic static int min(int[] a)
a
- input arraypublic static int min(float[] a)
a
- input arraypublic static int minIndex(byte[] a)
a
- input arraypublic static int minIndex(double[] a)
a
- input arraypublic static int minIndex(int[] a)
a
- input arraypublic static int minIndex(float[] a)
a
- input arraypublic static double minValue(double... a)
a
- input arraypublic static double minValue(int... a)
a
- input arraypublic static double minValue(byte... a)
a
- input arraypublic static double minValue(float... a)
a
- input arraypublic static void replaceNaN(double[] arr, double r)
arr
- input arrayr
- replacement value for NaNspublic static boolean contains(Object[] arr, Object o)
arr
- haystacko
- needlyindexOf(java.lang.Object[], java.lang.Object)
public static int findNaN(double[] in)
in
- the array to be checkedpublic static double[] convertToDouble(byte[] in)
public static double[] convertToDouble(float[] in)
public static double[] convertToDouble(int[] in)
public static double[] convertToDouble(short[] in)
public static double[] convertToDouble(String[] src)
src
- input arraydouble[]
for each entry in src
public static double[] convertToDouble(String[] src, double[] dst)
public static float[] convertToFloat(byte[] in)
public static float[] convertToFloat(double[] in)
public static float[] convertToFloat(int[] in)
public static float[] convertToFloat(String[] src)
src
- input arraydouble[]
for each entry in src
public static float[] convertToFloat(String[] src, float[] dst)
public static int[] convertToInt(byte[] in)
public static int[] convertToInt(double[] in)
public static int[] convertToInt(float[] in)
public static int[] convertToInt(String[] src)
src
- input arraydouble[]
for each entry in src
public static int[] convertToInt(String[] src, int[] dst)
Copyright © 2015. All Rights Reserved.