Java Utililty Methods Array Divide

List of utility methods to do Array Divide

Description

The list of methods to do Array Divide are organized into topic(s).

Method

double[]divide(long[] array, double value)
Divides all elements in an array by a scalar.
double[] out = new double[array.length];
for (int i = 0; i < out.length; i++) {
    out[i] = array[i] / value;
return out;
double[]divideAbsolute(double[] one, double[] two)
Divides two arrays of complex numbers.
double[] revan = null;
if (one.length == two.length) {
    revan = new double[one.length];
    for (int i = 0; i < one.length / 2; i++) {
        revan[2 * i] = (one[2 * i] / abs(i, two));
        revan[(2 * i) + 1] = (one[(2 * i) + 1] / abs(i, two));
return revan;
intdivideAndConquer(int[] array, int num)
divide And Conquer
return divideAndConquer(array, num, 0, array.length - 1);
float[]divideArray(float[] array, float num)
divide Array
float[] result = new float[array.length];
for (int i = 0; i < array.length; i++)
    result[i] = array[i] / num;
return result;
ListdivideArray(T[] arr, Integer... cuts)
Divides the given array using the boundaries in cuts.
Cuts are interpreted in an inclusive way, which means that a single cut at position i divides the given array in 0...i-1 + i...n
This method deals with both cut positions including and excluding start and end-indexes
Arrays.sort(cuts);
int c = cuts.length;
if (cuts[0] < 0 || cuts[c - 1] > arr.length - 1)
    throw new IllegalArgumentException("cut position out of bounds.");
int startIndex = cuts[0] == 0 ? 1 : 0;
if (cuts[c - 1] != arr.length - 1) {
    cuts = Arrays.copyOf(cuts, cuts.length + 1);
    cuts[cuts.length - 1] = arr.length - 1;
...
double[]divideArrayElements(final int[] array, final int divisor)
Average an int array elements with divisor.
final double[] averaged = new double[array.length];
for (int i = 0; i < averaged.length; i++) {
    averaged[i] = ((double) array[i]) / divisor;
return averaged;
byte[]divideBytearrays(byte[] ret, int headerLength, byte[] bArr)
divide Bytearrays
System.arraycopy(bArr, headerLength, ret, 0, bArr.length - headerLength);
return ret;
byte[][]divideByteArrayToChunks(byte data[], int chunkSize)

Breaks down a byte[] to several sub-arrays specified by the chunkSize.

int numChunks = (data.length + chunkSize - 1) / chunkSize;
byte chunks[][] = new byte[numChunks][];
for (int i = 0; i < numChunks; ++i) {
    int startByte = i * chunkSize;
    int endByte = startByte + chunkSize;
    if (endByte > data.length)
        endByte = data.length;
    int length = endByte - startByte;
...
double[]divideElements(double[] v1, double[] v2, double[] rs)
divide Elements
for (int i = 0; i < rs.length; i++) {
    if (v2[i] != 0) {
        rs[i] = v1[i] / v2[i];
return rs;
voiddivideElements(final int j, final int numRows, final double[] u, final int startU, final double realA, final double imagA)
Performs the following operation:
u[(startU+j):(startU+numRows)] /= A
were u and A are a complex
double mag2 = realA * realA + imagA * imagA;
int index = (j + startU) * 2;
for (int i = j; i < numRows; i++) {
    double realU = u[index];
    double imagU = u[index + 1];
    u[index++] = (realU * realA + imagU * imagA) / mag2;
    u[index++] = (imagU * realA - realU * imagA) / mag2;