Java Utililty Methods Array Subtract

List of utility methods to do Array Subtract

Description

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

Method

double[]subtractArray(double[] array1, double[] array2)
subtract Array
if (array1.length != array2.length) {
    throw new IllegalArgumentException("The dimensions have to be equal!");
double[] result = new double[array1.length];
assert array1.length == array2.length;
for (int i = 0; i < array1.length; i++) {
    result[i] = array1[i] - array2[i];
return result;
float[]subtractArray(float[] arr1, float[] arr2)
subtract Array
int l = arr1.length;
float[] res = new float[l];
for (int i = 0; i < l; i++) {
    res[i] = arr1[i] - arr2[i];
return res;
int[]subtractElementwise(int[] a, int[] b)
Subtracts the values in the two arrays of integers element-wise.
if (a.length != b.length) {
    throw new ArithmeticException();
} else {
    int[] result = new int[a.length];
    for (int i = 0; i < a.length; i++) {
        result[i] = a[i] - b[i];
    return result;
...
float[][]subtractImages(float[][] top, float[][] base)
Subtracts two images from each other
int row_count = top.length;
int column_count = top[0].length;
float[][] subtracted_image_mat = new float[row_count][column_count];
for (int row = 0; row < row_count; row++) {
    for (int column = 0; column < column_count; column++) {
        subtracted_image_mat[row][column] = top[row][column] - base[row][column];
return subtracted_image_mat;
voidsubtractInPlace(double[] a, double[] b)
Replace the contents of a with a[i] - b[i] for all i.
for (int i = 0; i < a.length; i++) {
    a[i] -= b[i];
voidsubtractInPlace(double[] first, double[] second)
Subtracts second array from the first, overwriting the values in first
if (first.length != second.length) {
    throw new Exception("Lengths of arrays are not equal");
for (int i = 0; i < first.length; i++) {
    first[i] = first[i] - second[i];
double[]subtractInPlace(final double[] a, final double[] b)
Subtract b to a in place
for (int i = 0; i < a.length; ++i)
    a[i] -= b[i];
return a;
float[]subtractKeepPositiveValues(float[] dividend, float divisor)
subtract Keep Positive Values
float[] difference = new float[dividend.length];
for (int i = 0; i < dividend.length; i++) {
    difference[i] = Math.max(dividend[i] - divisor, 0);
return difference;
Double[]subtractMin(Double[] array)
subtract Min
for (int i = 0; i < array.length; i++) {
    array[i] = array[i] - array[0];
return array;
double[]subtractRange(double[] accumulator, int offset, double[] values)
Subtracts the elements of one array of doubles from another.
assert (accumulator.length >= offset + values.length);
for (int i = offset, j = 0; j < values.length; i++, j++) {
    accumulator[i] -= values[j];
return accumulator;