ArrayUtils¶
-
public class
ArrayUtils
¶ Utils for quick manipulation with (numeric) arrays. Warning: most methods work only on rectangular arrays.
Author: pipek
Methods¶
add¶
-
public static double[]
add
(double[] array, double offset)¶ Add a constant to all elements of an array.
Returns: a new array
asDoubleArray¶
asDoubleArray¶
-
public static double[]
asDoubleArray
(long[] array)¶ Cast all values of an array to double.
asDoubleArray¶
-
public static double[]
asDoubleArray
(int[] array)¶ Cast all values of an array to double.
asDoubleArray¶
-
public static double[]
asDoubleArray
(short[] array)¶ Cast all values of an array to double.
asDoubleArray¶
-
public static double[]
asDoubleArray
(float[] array)¶ Cast all values of an array to double.
dimensions¶
get¶
linearTransform¶
-
public static double[]
linearTransform
(double[] array, double multiplyBy, double add)¶ Apply a linear transformation y = ax + b on an array.
Parameters: - multiplyBy – Multiplication constant
- add – Addition constant
Returns: a new array
linearTransform¶
-
public static Object
linearTransform
(Object array, double multiplyBy, double add)¶ A general linear transformation of multidimensional array.
Parameters: - array –
- N-dimensional rectangular array of double/long/int/short/float
- multiplyBy –
- multiplicative factor
- add –
- additive factor
Returns: - N-dimensional array of the same shape as input
- array –
multiply¶
-
public static double[]
multiply
(double[] array, double coefficient)¶ Multiply all elements of an array by a constant.
Returns: a new array
rank¶
reshape¶
-
public static Object
reshape
(Object array, int[] newDimensions)¶ Reshape array. Create a new array with the same total size but with different dimensions. Last index is moving fastest, while the elements are copied one after another. Works only on rectangular arrays.
Parameters: - array –
- newDimensions –
Returns: new array