public final class Arrays
extends java.lang.Object
All methods in this class are static.
Modifier and Type | Method and Description |
---|---|
static double |
calcAverage(double[] values)
Calculates the average of the values in an array.
|
static double |
calcMaximum(double[] values)
Calculates the maximum of the values in an array.
|
static int |
calcMaximum(int[] values)
Calculates the maximum of the values in an array.
|
static double |
calcMedian(double[] values)
Calculates the median of the values in an array.
|
static double |
calcMinimum(double[] values)
Calculates the minimum of the values in an array.
|
static int |
calcMinimum(int[] values)
Calculates the minimum of the values in an array.
|
static double |
calcSum(double[] values)
Calculates the sum of the values in an array.
|
static double |
calcSum(double[] values,
int beginIndex,
int endIndex)
Calculates the sum of the values in an array, considering only array
elements within a specified range.
|
static double[] |
createDoubleArrayOfOnes(int nElements)
Creates a double array of ones.
|
static double[] |
createDoubleArrayOfRandomNumbers(int nElements)
Creates a double array of random numbers.
|
static double[] |
createDoubleArrayOfRandomNumbers(int nElements,
java.util.Random random)
Creates a double array of random numbers.
|
static int[] |
generateRandomPermutation(int nElements)
Generates a random permutation.
|
static int[] |
generateRandomPermutation(int nElements,
java.util.Random random)
Generates a random permutation.
|
static void |
permuteRandomly(int[] elements,
java.util.Random random)
Randomly permutes the elements.
|
static double[] |
repeat(double value,
int nElements)
Creates an integer array of repeated elements.
|
static int[] |
repeat(int value,
int nElements)
Creates a double array of repeated elements.
|
public static double calcSum(double[] values)
values
- Valuespublic static double calcSum(double[] values, int beginIndex, int endIndex)
The sum is calculated over the elements
values[beginIndex], ..., values[endIndex - 1]
.
values
- ValuesbeginIndex
- Begin indexendIndex
- End indexpublic static double calcAverage(double[] values)
values
- Valuespublic static double calcMedian(double[] values)
values
- Valuespublic static double calcMinimum(double[] values)
values
- Valuespublic static double calcMaximum(double[] values)
values
- Valuespublic static int calcMinimum(int[] values)
values
- Valuespublic static int calcMaximum(int[] values)
values
- Valuespublic static double[] createDoubleArrayOfOnes(int nElements)
nElements
- Number of elementspublic static int[] repeat(int value, int nElements)
value
- Element to repeatnElements
- Number of elementspublic static double[] repeat(double value, int nElements)
value
- Element to repeatnElements
- Number of elementspublic static double[] createDoubleArrayOfRandomNumbers(int nElements)
nElements
- Number of elementspublic static double[] createDoubleArrayOfRandomNumbers(int nElements, java.util.Random random)
nElements
- Number of elementsrandom
- Random number generatorpublic static int[] generateRandomPermutation(int nElements)
A random permutation is generated of the integers
0, ..., nElements - 1
.
nElements
- Number of elementspublic static int[] generateRandomPermutation(int nElements, java.util.Random random)
A random permutation is generated of the integers
0, ..., nElements - 1
.
nElements
- Number of elementsrandom
- Random number generatorpublic static void permuteRandomly(int[] elements, java.util.Random random)
Randomly permutes the elements 0, ..., nElements - 1.
elements
- Elementsrandom
- Random number generator