Class defining basic arithmetic and statistic operations on 1D double arrays.
| 4 | * Class defining basic arithmetic and statistic operations on 1D double arrays. |
| 5 | */ |
| 6 | public class ArrayMath |
| 7 | { |
| 8 | /** |
| 9 | * Computes the absolute value of each value of the given double array |
| 10 | * |
| 11 | * @param overwrite |
| 12 | * true overwrites the input data, false returns the result in a new structure |
| 13 | */ |
| 14 | public static double[] abs(double[] input, boolean overwrite) |
| 15 | { |
| 16 | final double[] result = overwrite ? input : new double[input.length]; |
| 17 | |
| 18 | for (int i = 0; i < input.length; i++) |
| 19 | result[i] = Math.abs(input[i]); |
| 20 | |
| 21 | return result; |
| 22 | } |
| 23 | |
| 24 | /** |
| 25 | * Computes the absolute value of each value of the given float array |
| 26 | * |
| 27 | * @param overwrite |
| 28 | * true overwrites the input data, false returns the result in a new structure |
| 29 | */ |
| 30 | public static float[] abs(float[] input, boolean overwrite) |
| 31 | { |
| 32 | final float[] result = overwrite ? input : new float[input.length]; |
| 33 | |
| 34 | for (int i = 0; i < input.length; i++) |
| 35 | result[i] = Math.abs(input[i]); |
| 36 | |
| 37 | return result; |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Computes the absolute value of each value of the given long array |
| 42 | * |
| 43 | * @param overwrite |
| 44 | * true overwrites the input data, false returns the result in a new structure |
| 45 | */ |
| 46 | public static long[] abs(long[] input, boolean overwrite) |
| 47 | { |
| 48 | final long[] result = overwrite ? input : new long[input.length]; |
| 49 | |
| 50 | for (int i = 0; i < input.length; i++) |
| 51 | result[i] = Math.abs(input[i]); |
| 52 | |
| 53 | return result; |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Computes the absolute value of each value of the given int array |
| 58 | * |
| 59 | * @param overwrite |
| 60 | * true overwrites the input data, false returns the result in a new structure |
| 61 | */ |
| 62 | public static int[] abs(int[] input, boolean overwrite) |
| 63 | { |
nothing calls this directly
no outgoing calls
no test coverage detected